Last active
December 21, 2022 04:41
-
-
Save JenniferFuBook/2e8c5f586be1c9e8112de547178ed026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Highcharts from 'highcharts'; | |
import HighchartsReact from 'highcharts-react-official'; | |
import _ from 'lodash'; | |
import HighchartsExporting from 'highcharts/modules/exporting'; | |
import HighchartsAccessibility from 'highcharts/modules/accessibility'; | |
import HighchartsSankey from 'highcharts/modules/sankey'; | |
HighchartsExporting(Highcharts); | |
HighchartsAccessibility(Highcharts); | |
HighchartsSankey(Highcharts); | |
const getOptions = (type) => ({ | |
chart: { | |
type, | |
width: 800, | |
height: 600, | |
}, | |
title: { | |
text: _.startCase(`${type} chart`), | |
}, | |
series: [ | |
{ | |
keys: ['from', 'to', 'weight'], | |
dataLabels: { | |
format: '{point.fromNode.name} → {point.toNode.name}: {point.weight}', | |
nodeFormat: '{point.name}', | |
color: 'black', | |
}, | |
data: [ | |
['A1', 'B1', 1], | |
['A1', 'B2', 3], | |
['A1', 'B3', 1], | |
['A2', 'B1', 1], | |
['A2', 'B3', 1], | |
['A3', 'B1', 2], | |
['A3', 'B2', 3], | |
['A3', 'B3', 1], | |
], | |
}, | |
], | |
credits: { | |
enabled: false, | |
}, | |
}); | |
function App() { | |
return ( | |
<HighchartsReact highcharts={Highcharts} options={getOptions('sankey')} /> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment