Skip to content

Instantly share code, notes, and snippets.

@JenniferFuBook
Last active December 9, 2022 05:57
Show Gist options
  • Save JenniferFuBook/1ad88abf9288943fca3b39e7a5575269 to your computer and use it in GitHub Desktop.
Save JenniferFuBook/1ad88abf9288943fca3b39e7a5575269 to your computer and use it in GitHub Desktop.
import Highcharts from 'highcharts';
import HighchartsReact from 'highcharts-react-official';
import _ from 'lodash';
import './App.css';
import HighchartsExporting from 'highcharts/modules/exporting';
HighchartsExporting(Highcharts);
const getOptions = (type) => ({
chart: {
type,
width: 500,
height: 300,
},
title: {
text: _.startCase(`${type} chart`),
},
yAxis: {
title: {
text: 'Values',
},
},
series: [
{
data: [1, 2, 1, 4, 3, 6],
},
{
data: [2, 7, 0, 4, 6, 2],
},
],
credits: {
enabled: false,
},
});
function App() {
return (
<div>
<HighchartsReact highcharts={Highcharts} options={getOptions('line')} />
<HighchartsReact highcharts={Highcharts} options={getOptions('spline')} />
<HighchartsReact highcharts={Highcharts} options={getOptions('area')} />
<HighchartsReact highcharts={Highcharts} options={getOptions('areaspline')} />
<HighchartsReact highcharts={Highcharts} options={getOptions('column')} />
<HighchartsReact highcharts={Highcharts} options={getOptions('bar')} />
<HighchartsReact highcharts={Highcharts} options={getOptions('pie')} />
<HighchartsReact highcharts={Highcharts} options={getOptions('scatter')} />
</div>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment