{"id":16329,"date":"2018-04-11T13:01:52","date_gmt":"2018-04-11T13:01:52","guid":{"rendered":"http:\/\/www.highcharts.com\/blog\/?p=16329"},"modified":"2026-01-12T09:49:42","modified_gmt":"2026-01-12T09:49:42","slug":"highcharts-react-wrapper","status":"publish","type":"post","link":"https:\/\/www.highcharts.com\/blog\/integration\/highcharts-react-wrapper\/","title":{"rendered":"Highcharts React Wrapper"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>I like <a href=\"https:\/\/en.wikipedia.org\/wiki\/React_(JavaScript_library)\">React<\/a>. It is a simple and powerful JavaScript library for building user interfaces. It offers many advantages such as fast dynamic web pages (thanks to the virtual DOM), reusable components, easy to write with JSX, etc.<\/p>\n<p>Given how many Highcharts users are also React users, we decided to create a <a href=\"https:\/\/github.com\/highcharts\/highcharts-react\">Highcharts React wrapper<\/a> to make developers\u2019 lives even easier.<\/p>\n<p>Here is a short tutorial on how it works!<\/p>\n<p>This tutorial has two sections. In the first section, I will set up the demo and run it, and then I will explain how the demo\u2019s code works.<\/p>\n<p><i><b>Remark<\/b><\/i><\/p>\n<p><em>Basic knowledge of <strong>NodeJS<\/strong> and <strong>ES6<\/strong> is recommended to follow along.<\/em><\/p>\n<p>&nbsp;<\/p>\n<h2>Part 1. Setting up the demo<\/h2>\n<p>The first thing to do is to create a folder to save the demo, e.g., I created <i>HighchartsReactDemo<\/i>, then clone or download the demo from this <a href=\"https:\/\/github.com\/highcharts\/highcharts-react\">Github link<\/a> and save it to the folder created earlier. Navigate to your folder (e.g., <i>HighchartsReactDemo<\/i>), and write the following command to install the dependencies:<\/p>\n<p><code>npm install<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-21517 aligncenter\" src=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114102\/picture-of-npm-install.png\" alt=\"picture of npm install\" width=\"808\" height=\"282\" srcset=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114102\/picture-of-npm-install.png 808w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114102\/picture-of-npm-install-560x195.png 560w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114102\/picture-of-npm-install-760x265.png 760w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114102\/picture-of-npm-install-768x268.png 768w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114102\/picture-of-npm-install-360x126.png 360w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/p>\n<p>Use this command to build the demo<\/p>\n<p><code>npm run build-demo<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21518 aligncenter\" src=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114202\/command-to-build-the-demo.png\" alt=\"command to build the demo\" width=\"698\" height=\"144\" srcset=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114202\/command-to-build-the-demo.png 698w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114202\/command-to-build-the-demo-560x116.png 560w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114202\/command-to-build-the-demo-360x74.png 360w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/p>\n<p>Now, it is time to see the result. Go to the demo folder, then click on the <code>index.html<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-21519 aligncenter\" src=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114259\/image3.png\" alt=\"Folder to show the position of the index\" width=\"767\" height=\"391\" srcset=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114259\/image3.png 767w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114259\/image3-560x285.png 560w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114259\/image3-760x387.png 760w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/19114259\/image3-360x184.png 360w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/p>\n<p>The result should be as shown in this GIF:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-19683 aligncenter\" src=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2018\/04\/30124239\/highchartsReactWrapper.gif\" alt=\"highcharts React Wrapper\" width=\"903\" height=\"508\" \/><\/p>\n<h2>Part 2. Explanations<\/h2>\n<p>The main file that you have to care about is the demo.jsx under the folder demo.<\/p>\n<p>The first section of the file is to import react and the highcharts library:<\/p>\n<pre>import React from 'react'\r\nimport { render } from 'react-dom'\r\nimport Highcharts from 'highcharts\/highstock'\r\nimport HighchartsReact from 'highcharts-react'<\/pre>\n<p>The second section holds the main options of the charts, such as the title, data set, etc.<\/p>\n<pre>const options = {\r\n  title: {\r\n    text: 'My stock chart'\r\n  },\r\n    \r\n  series: [{\r\n    data: [[Date.UTC(2013,5,2),0.7695],\r\n[Date.UTC(2013,5,3),0.7648],\r\n...\r\n[Date.UTC(2013,5,24),0.7623],]\r\n  }]\r\n}<\/pre>\n<p>And finally, I use a container and the API to wrap the chart:<\/p>\n<pre>const App = () =&gt; &lt;div&gt;\r\n   &lt;HighchartsReact\r\n    highcharts={Highcharts}\r\n    constructorType={'stockChart'}\r\n    options={options}\r\n  \/&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>That is it! Now you know how to use Highcharts React wrapper \ud83d\ude42<\/p>\n<p>If you have any questions or you want more details, feel free to share it in the comments below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use Highcharts React Wrapper to create interactive charts in this step by step tutorial.<\/p>\n","protected":false},"author":32,"featured_media":21952,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"meta_title":"","meta_description":"","hc_selected_options":[],"footnotes":""},"categories":[1105],"tags":[1094,1031,824],"coauthors":[699],"class_list":["post-16329","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-integration","tag-highcharts-core","tag-javascript","tag-react"],"_links":{"self":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/16329","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\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/comments?post=16329"}],"version-history":[{"count":1,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/16329\/revisions"}],"predecessor-version":[{"id":29126,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/16329\/revisions\/29126"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/media\/21952"}],"wp:attachment":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/media?parent=16329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/categories?post=16329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/tags?post=16329"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/coauthors?post=16329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}