{"id":18017,"date":"2019-05-15T16:07:12","date_gmt":"2019-05-15T16:07:12","guid":{"rendered":"http:\/\/www.highcharts.com\/blog\/?p=18017"},"modified":"2026-01-12T11:30:15","modified_gmt":"2026-01-12T11:30:15","slug":"creating-mobile-charts-with-highcharts-react-native","status":"publish","type":"post","link":"https:\/\/www.highcharts.com\/blog\/integration\/creating-mobile-charts-with-highcharts-react-native\/","title":{"rendered":"Creating Mobile Charts with Highcharts &#038; React Native"},"content":{"rendered":"<p>&nbsp;<br \/>\n&nbsp;<\/p>\n<div class=\"alert alert-info\" style=\"margin-top: 20px;\">The React Native wrapper package is <b>no longer actively maintained<\/b>.<\/div>\n<p>&nbsp;<\/p>\n<p>In this tutorial, we will show you how to get started with the official <a href=\"https:\/\/github.com\/highcharts\/highcharts-react-native\">Highcharts wrapper for React Native<\/a>. We will begin with setting up the environment, then jump to create a simple demo of Highcharts.<\/p>\n<h4>Set up the environment<\/h4>\n<p>For this project, we will use <a href=\"http:\/\/expo.io\">Expo<\/a> App tool to create a simple app and focus only on the code.<\/p>\n<p><b>Installation<\/b><\/p>\n<p>Since the Expo App tool is used regularly, it is a good practice to install it globally. To do so, open the terminal and run the following command line with the option <code>-g<\/code> for global: <code>$npm install -g expo-cli<\/code><\/p>\n<p>To create our application \u201chcreact,\u201d run this command <code>$expo init hcreact<\/code><\/p>\n<p>The previous command line creates a folder with a default project.<br \/>\nLet\u2019s run the project, as is, to be sure that everything is correctly set up before making changes to the project.<br \/>\nReturn to the terminal and run these commands:<br \/>\n<code>$ cd hcreact\/<\/code><br \/>\n<code>$ npm start<\/code><\/p>\n<p>The npm start command will launch a server on port 19000, and you may test your app in a iOS \/ Android emulator or use your mobile phone.<\/p>\n<p>To learn more about expo, you go <a href=\"https:\/\/facebook.github.io\/react-native\/docs\/getting-started\">here<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-18022 aligncenter\" src=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15154033\/Screenshot-2019-05-15-at-15.39.40.jpg\" alt=\"\" width=\"638\" height=\"653\" srcset=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15154033\/Screenshot-2019-05-15-at-15.39.40.jpg 881w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15154033\/Screenshot-2019-05-15-at-15.39.40-430x440.jpg 430w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15154033\/Screenshot-2019-05-15-at-15.39.40-768x786.jpg 768w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15154033\/Screenshot-2019-05-15-at-15.39.40-576x590.jpg 576w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15154033\/Screenshot-2019-05-15-at-15.39.40-273x280.jpg 273w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15154033\/Screenshot-2019-05-15-at-15.39.40-879x900.jpg 879w\" sizes=\"auto, (max-width: 638px) 100vw, 638px\" \/><\/p>\n<p>Next step is to setup Highcharts React Wrapper. First, stop the running project on the terminal using <code>Ctrl+c<\/code>, then run this command line to install the Highcharts React Native wrapper:<\/p>\n<p><code>$ npm install @highcharts\/highcharts-react-native<\/code><\/p>\n<p>Now, we are ready to add our own code.<\/p>\n<h4>Highcharts chart<\/h4>\n<p>In the App.js file, import highcharts-react-native-official.<\/p>\n<p><code>import HighchartsReactNative from '@highcharts\/highcharts-react-native';<\/code><\/p>\n<p>A simple chart to start with is a line chart with the following <code>data:[1, 3, 2]<\/code>. To achieve that, we need to create an object (options) then pass the data:<\/p>\n<pre>this.state = {\r\n            chartOptions: {\r\n                series: [{\r\n                    data: [1, 3, 2]\r\n                }]\r\n            }\r\n        };<\/pre>\n<p>The last step is to initialize Highcharts.<\/p>\n<pre>&lt;HighchartsReactNative\r\n                    styles={styles.container}\r\n                    options={this.state.chartOptions}\r\n                    modules={modules}\r\n\/&gt;\r\n<\/pre>\n<p><b>Code of App.js<\/b><\/p>\n<pre>import React from 'react';\r\nimport {\r\n    StyleSheet,\r\n    View\r\n} from 'react-native';\r\nimport HighchartsReactNative from '@highcharts\/highcharts-react-native';\r\nexport default class App extends React.Component {\r\n    constructor(props) {\r\n        super(props);\r\n        this.state = {\r\n            chartOptions: {\r\n                series: [{\r\n                    data: [1, 3, 2]\r\n                }]\r\n            }\r\n        };\r\n    }\r\n    render() {\r\n        return (\r\n            &lt;View&gt;\r\n                &lt;HighchartsReactNative\r\n                    styles={styles.container}\r\n                    options={this.state.chartOptions}\r\n                    modules={modules}\r\n                \/ &gt;\r\n            &lt;\/View &gt;\r\n        );\r\n    }\r\n}\r\nconst styles = StyleSheet.create({\r\n    container: {\r\n        \/\/ height: 200,\r\n        \/\/ width: 200,\r\n        backgroundColor: '#fff',\r\n        justifyContent: 'center'\r\n    }\r\n});<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-18031 aligncenter\" src=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15155032\/Screenshot-2019-05-15-at-15.49.47.jpg\" alt=\"\" width=\"304\" height=\"523\" srcset=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15155032\/Screenshot-2019-05-15-at-15.49.47.jpg 496w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15155032\/Screenshot-2019-05-15-at-15.49.47-256x440.jpg 256w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15155032\/Screenshot-2019-05-15-at-15.49.47-343x590.jpg 343w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2019\/05\/15155032\/Screenshot-2019-05-15-at-15.49.47-163x280.jpg 163w\" sizes=\"auto, (max-width: 304px) 100vw, 304px\" \/><\/p>\n<p>That is it, now you know how to set up a project using Highchart wrapper React Native. Feel free to share your experience, questions and comments below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Step by step tutorial to learn how to create Mobile Charts with Highcharts &#038; React Native<\/p>\n","protected":false},"author":223,"featured_media":21421,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"meta_title":"","meta_description":"","hc_selected_options":[],"footnotes":""},"categories":[1105],"tags":[1094],"coauthors":[737],"class_list":["post-18017","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-integration","tag-highcharts-core"],"_links":{"self":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/18017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/users\/223"}],"replies":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/comments?post=18017"}],"version-history":[{"count":2,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/18017\/revisions"}],"predecessor-version":[{"id":29199,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/18017\/revisions\/29199"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/media\/21421"}],"wp:attachment":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/media?parent=18017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/categories?post=18017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/tags?post=18017"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/coauthors?post=18017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}