score:1
Accepted answer
That's because there are different orders of action.
With React:
- Chart is created without data
- Data is received and the chart is updated
Without React:
- Data is received
- Chart is created
As a solution, you can call loadInitialData
in useEffect
hook and render HighchartsReact
component after the data has been received.
const ChartComponent = () => {
const [options, setOptions] = useState(null);
useEffect(() => {
loadInitialData();
}, []);
function loadInitialData() {
fetch(dataURL)
.then((res) => res.ok && res.json())
.then((data) => {
...
setOptions({
...chartOptions,
series: [
{
data
}
],
...
});
});
}
function afterSetExtremes(e) {
...
}
return (
options && (
<HighchartsReact
constructorType="stockChart"
highcharts={Highcharts}
options={options}
/>
)
);
};
Live demo: https://codesandbox.io/s/highcharts-react-3tcdw7?file=/demo.jsx
Source: stackoverflow.com
Related Query
- why is afterSetExtremes function being called twice highcharts using react
- Using PhantomJS to create HighCharts grahps server side for use in PDF creation (PHP) - results in exit code 11 from PHPs exec();
- Uncaught TypeError: undefined is not a function when using highcharts
- creating a bar chart using Highcharts with React - getting an error that rendering div isn't found
- Highcharts - Using a function to change the tooltip
- How to draw a bubble map with longitude and latitude using Highcharts in react
- How To Call A Function To Make A Graph Using HighCharts in PHP
- Calling function in component class from Highcharts component in React
- Why do I have the issue 'property assigment expected' when I want to display a chart on my web page using highcharts
- Why is Highchart loaded twice in my rails app ? (Uncaught Highcharts error #16)
- Highcharts display label for pie chart using html table as data source
- Error using Highcharts (>= 8.0.1) function stockChart() in Angular
- Update series using Highcharts React wrapper
- I am using click event to trigger a new page to generate the drill down data from highcharts however the entire chart is being generated
- how to render multiple line charts - highcharts on same page using highcharts react wrapper - highcharts-react-offical
- HTML table as data source for highstock charts using highcharts
- Old state is being shown despite updating in React Highcharts click event
- Uncaught Error: Highcharts error #17 while creating sunburst chart using react
- Using a flask variable as data source for highcharts
- Why code of Horizonal line(y-axis) on a single in Highcharts get applied to all other charts integrated with Webdatarocks
- chartOptions.redraw is not a function in highcharts using angular
- React highcharts unable to call function from data label onclick
- Decimals on yAxis are not being displayed, even if that same code works on highcharts jsfiddle
- using JS event function twice in shiny R to create a dropdown
- Parsing JSON for use with Highcharts using jquery .parseJSON or JSON.parse: how to remove quotes from function calls for formatters?
- Set file type dynamically when click on exporting menu in highcharts using chart.exportChart function
- javascript display multiple Highcharts using single function
- Why is my addPoint() not recognized as a function in my highcharts code?
- How to access function of buit-in button in highcharts using asp.net
- Highcharts Click Function Not Being Called?
More Query from same tag
- How do I remove left-hand numeric values in Bar Chartjs?
- Radial Gradient, for plot bands on a gauge?
- I want to update my series dynamically on highcharts with a click & also bring it to the original way by clicking on an other button (#previous)
- how to change the slice color in donut chart on click of slice?
- Unable to change row height in Bootstrap 4
- Angular 7 - Dynamic HighChart update
- High charts not displaying proper data timestamp
- Is Highmaps included in the .NET wrapper?
- How to plot the X axis data point for uneven tick interval at in Highcharts
- Get max value and label in series after zoom in JS HighCharts
- how to customize the tooltip in solid gauge in highchart
- Displaying additional text for Highcharts Bubble chart
- HighStock xAxis values separate from series "y" data
- js timeseries/waterfall graph within table
- X-axis alignment for Columnrange
- Multiple images for Highcharts X Axis Labels
- Highcharts add line-through to legend text when hidden (itemHiddenStyle)
- High chart spline chart is not plotting with single data
- Show message "Loading..." in Highcharts on loading data from array
- very simple highcharts column graph with two arrays
- How to bind data to line chart in highcharts in MVC3?
- Turning array of JSON objects into an array for HighCharts/GoogleCharts
- Highcharts series bars - multiple series, same xAxis
- drag and zoom scatter plot in highcharts shiny R
- ASP.NET MVC Angular 2 Failed to load resource: the server responded with a status of 404 (Not Found)
- DataLabels in Highcharts are outside the container / not showing
- Fullscreen functionality on saperate html button for highchart in angular
- How to show/hide labels customizely in highcharts
- Highcharts csv data loading
- Data exposure for HighCharts