Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-highcharts

kirjs55.4k16.1.0TypeScript support: definitely-typed

React wrapper for highcharts

chart, react, highcharts, graph

readme

react-highcharts

Build Status

Highcharts 6.x.x component for react. For highcharts 5.x.x use v. 13.0.0

Demos

react-highcharts | react-highcharts/more | react-highcharts/highstock | react-highcharts/highmaps

You can also see Code for the demo and run demo locally

Installation

npm install react-highcharts --save

Usage

Webpack/Browserify

npm install react-highcharts highcharts react --save
const React = require('react');
const ReactDOM = require('react-dom');

const ReactHighcharts = require('react-highcharts'); // Expects that Highcharts was loaded in the code.

const config = {
  /* HighchartsConfig */
};

ReactDOM.render(<ReactHighcharts config = {config}></ReactHighcharts>, document.body);

Optional after-render callback

const afterRender = (chart) => { /* do stuff with the chart  */ };
<ReactHighcharts config = {config} callback = {afterRender}></ReactHighcharts>

Passing properties to the wrapping DOM element

<ReactHighcharts config = {config} domProps = {{id: 'chartId'}}></ReactHighcharts>

Accessing Highcharts API After Render

For access to methods & properties from the Highcharts library you can use ReactHighcharts.Highcharts. For example, the Highcharts options are available via ReactHighcharts.Highcharts.getOptions().

Highcharts provides an API for manipulating a chart after the initial render. See the Methods and Properties in the documentation. Here's how you access it:

class MyComponent extends React.Component {
  componentDidMount() {
    let chart = this.refs.chart.getChart();
    chart.series[0].addPoint({x: 10, y: 12});
  }

  render() {
    return <ReactHighcharts config={config} ref="chart"></ReactHighcharts>;
  }
}

Limiting Highchart Rerenders

Rerendering a highcharts graph is expensive. You can pass in a isPureConfig option to the ReactHighcharts component, which will keep the highcharts graph from being updated so long as the provided config is referentially equal to its previous value. There is also neverReflow property.

Rendering on the server with node

See this recipe

Using highmaps (demo)

const ReactHighmaps = require('react-highcharts/ReactHighmaps');

Using highstock (demo)

const ReactHighstock = require('react-highcharts/ReactHighstock')

Using highcharts modules/add-ons like exporting, data, etc. (demo)

Use highcharts-more npm package.

const ReactHighcharts = require('react-highcharts')
require('highcharts-more')(ReactHighcharts.Highcharts)

You can find the full list here

Passing Highcharts instance manually

const ReactHighcharts = require('react-highcharts').withHighcharts(ReactHighstock)

For Contributors

Running tests

Run npm test

Running demo

git clone https://github.com/kirjs/react-highcharts.git
cd react-highcharts && npm install
npm run demo

Point your browser at http://localhost:8080

changelog

React-highcharts Change Log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning. From http://keepachangelog.com

[16.0.0] - 2018-01-14

  • Clean up the prod version: minify, get rid of prop types. Overall reduce the size from 70 to 4kb, thanks @ilyjs

[15.0.0] - 2017-10-11

  • Update Highcharts to 6.0.0

[14.0.0] - 2017-10-11

  • This release never happened

[13.0.0] - 2017-10-11

  • Support React 16

[12.0.0] - 2017-04-27

  • Use create-react-class
  • Add prop-types as a dependency

[11.5.0] - 2017-01-04

  • [Fix] Throwing an error when rendering on the server

[11.0.0] - 2016-10-22

  • Update Highcharts to 5.0.0

[10.0.0] - 2016-07-06

  • Introduce new domProps property to explicitly specifying DOM properties.

[9.0.0] - 2016-07-06

  • Get rid of custom property warnings in react 15.2

[6.0.0] - 2015-11-26

Changed

  • Update Highcharts Highmaps and Highstock to 4.2.0

[5.0.6] - 2015-11-26

  • No changes

[5.0.5] - 2015-11-26

Added

  • Minify all js files by default. Keep source files as file.src.js.

[5.0.4] - 2015-11-17

Fixed

  • reverted changed in 5.0.3

[5.0.3] - 2015-11-17

Changed

  • bundles copied to top level

Added

  • documentation : recipes.md

[5.0.2] - 2015-11-14

Added

  • some examples using ReactHighcharts
  • fakeHighcharts module for node.js env

[5.0.1] - 2015-11-09

Added

  • npm version hooks