I am trying to create a heatmap in my React application using FusionCharts but I'm running into some issues.
Here is my code:
import React from 'react';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';
import ReactFC from 'react-fusioncharts';
ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);
const dataSource = {
"chart": {
"caption": "Sales of Liquor",
"subCaption": "Top 5 stores in last month by state",
"entityFillHoverColor": "#cccccc",
"numberScaleValue": "1,1000,1000",
"numberScaleUnit": "K,M,B",
"numberPrefix": "$",
"showLabels": "1",
"theme": "fusion"
},
"colorrange": {
"gradient": "1",
"minvalue": "0",
"code": "#e44a00",
"startlabel": "Poor",
"endlabel": "Good",
"color": [{
"maxvalue": "56580",
"code": "#f8bd19"
}, {
"maxvalue": "100000",
"code": "#6baa01"
}]
},
"data": [{
"id": "HI",
"value": "3189"
}, {
"id": "DC",
"value": "2879"
}, {
"id": "MD",
"value": "920"
}, {
"id": "DE",
"value": "4607"
}, {
"id": "RI",
"value": "4890"
}]
}
const HeatmapComponent = () => (
<div>
<ReactFC
type="heatmap"
width="100%"
height="400"
dataFormat="JSON"
dataSource={dataSource}
/>
</div>
);
export default HeatmapComponent;
I get the following error:
Uncaught (in promise) Error: ChunkLoadError: Loading chunk 4 failed.
(error: http://localhost:3000/main/fusioncharts.powercharts.js)
at a.e (fusioncharts.js:13:2215)
at h (fusioncharts.js:13:62601)
at Function.<anonymous> (fusioncharts.js:13:63900)
at i (fusioncharts.js:13:182570)
at o (fusioncharts.js:13:182814)
at d (fusioncharts.js:13:184030)
at t2.chartType (fusioncharts.js:13:89022)
at new e2 (fusioncharts.js:13:81081)
at new f (fusioncharts.js:13:65848)
at ReactFC2.renderChart (ReactFC.js:319:23)
at fusioncharts.js:13:76816
I can't seem to figure out what's wrong. I have made sure to import all necessary FusionCharts components and libraries. Any ideas on what could be causing this and how to resolve it?
Here are the package versions I am using:
"react": "^18.2.0",
"fusioncharts": "^3.20.0",
"react-fusioncharts": "^4.0.0",
Thanks in advance!
- I've tried using the boiler plate heatmap from the Fusion Charts website
- Also tried using a simpler heatmap to implement
- I've looked at this article and still no luck: fusioncharts react error loading chunks failed