score:6
Accepted answer
In highcharts-react-official v2.0.0
has been added allowChartUpdate
option, which should work great in your case. By using this option you can block updating the chart with updating the component:
categoryClicked() {
this.allowChartUpdate = false;
this.setState({
...
});
}
...
<HighchartsReact
ref={"chartComponent"}
allowChartUpdate={this.allowChartUpdate}
highcharts={Highcharts}
options={...}
/>
Moreover, to get the chart instance use refs
:
componentDidMount(){
const chart = this.refs.chartComponent.chart;
}
Live demo: https://codesandbox.io/s/98nl4pp5r4
score:-1
// react native functional
import React, {useState, useRef,useLayoutEffect} from "react"
import HighchartsReactNative from '@highcharts/highcharts-react-native'
function chartcomponent(props){
const [options, setoptions] = useState({});
const chartRef = useRef(null);
useEffect(() => {
// create the options for your chart.
setoptions({chart:{}, yaxis:{}, xAxis:{},})// etc.
}, []);
useLayoutEffect(() => {
// new point to add, you can get new data via props, fetch, socket, etc.
var x = new Date(hr.timestamp).getTime();
var y = 10
// these are the important parts here:
var series = chartRef.current.props.options.series;
if (!Array.isArray(series)){return;}
var seriesdata = series[0].data;
seriesdata.push([x,y]);
// next line limits points in chart to 10, so new poitn replaces first point
if (seriesdata.length>10){seriesdata.splice(0,1);}
return () => {};
}, [props]);
return(
<View style={styles.charting}><HighchartsReactNative styles={{height:300, width:600}} options={options} ref={chartRef} ></HighchartsReactNative></View>
)
}
Source: stackoverflow.com
Related Query
- Dynamically update Highcharts chart in react
- Dynamically update subtitle on Highcharts chart?
- Highcharts pie chart dynamically changes size
- HighCharts Dynamically Change Chart Type
- Dynamically update gauge on highcharts
- Issue Dynamically Changing HighCharts Chart Title
- Update Chart Colors When Using Styled HighCharts Version
- Angular Highcharts - How to enable noData options and update it dynamically
- creating a bar chart using Highcharts with React - getting an error that rendering div isn't found
- How to center chart title position dynamically inside pie chart in highcharts
- Highcharts update x-axis categories dynamically
- How to dynamically update highcharts using jQuery UI sliders
- HighCharts Stock Chart error code 18
- How To Dynamically Truncate The Y-Axis Title On Chart Resize/Reflow In Highcharts
- How to Build a Column Chart in Highcharts with Data Entered Dynamically Within a CMS
- trying to dynamically update Highchart column chart but series undefined
- Highcharts - update chart using ajax
- How to use Highcharts React to create chart with multiple lines for same XAxis?
- Highcharts chart width to dispay size dynamically
- How to create a HighCharts chart in react
- Pie chart Slice color Change Dynamically in Highcharts
- Highcharts with react Error: "missingModule" with chart type of "timeline"
- Highcharts - Update column chart in real time
- How to dynamically set title in Pie Chart of Highcharts
- Highcharts - Dynamically change chart type with on radio buttons click
- Highcharts display label for pie chart using html table as data source
- Update chart with HighchartsReact is not working when a timer is used in React
- How to change the chart title dynamically on tooltip hover in the points Highcharts.. React JS
- Dynamically updating a highcharts object after data refresh in React
- Update series using Highcharts React wrapper
More Query from same tag
- How to process json object in highchart
- Hicharts data API for line graph using datatime and matching x-axis to y-axis
- Highcharts: Click to Highlight instead of Hide (= Always show non-selected)
- Trying to append arrays to highcharts ( jquery)
- how do you create a link on highcharts to open up pop up window with another chart
- Highcharts, influxdb and nodejs, how to display data of influxdb in highcharts using influxdb-nodejs?
- highcharts get dashstyle from existing series
- Highcharts sets default value for blank data
- Images/Icons in datalabel not getting exported - highchart treemap
- Is it possible to have multiple highcharts with one id?
- HighMaps select map from list - Highcharts.geojson and Highcharts.mapDataIndex issues
- style highmaps mapbubbles onclick
- highcharts override addEvent function
- Highmaps: Change periods to commas when setOptions wont work
- Line graph disappears after new line is added
- Highcharts with a thick line - at 0 values the line is half hidden
- HighStocks/HighCharts scrollbar not displaying with large datasets causing xAxis labels to disappear and making bars not show
- Highcharts - yAxis logarithmic scale and allowDecimals set to false not seeming to have any effect
- Highcharts export web war does not work on Weblogic server
- highstock.js chart plotting is a bit off
- Plot options don't work in Variable Radius Pie chart
- Different approach to generate PDF of a HTML page which contains 10 highcharts using mPDF in PHP
- Customise Highstock tooltip conditionally
- How to set pie chart wedge colors based on wedge values for highcharts?
- Rcharts hplot (Highcharts) colors attribute not working
- Can you pass a variable to the data property in HighCharts?
- How to Load HighChart dynamically within angular UI Accorion(uib-Accordion)?
- Radar Chart: Label outside the chart
- Django Chart using Highcharts
- highcharter hc_axis not working correctly