score:11
Accepted answer
so, i have found a workaround. it is working perfectly. i am getting the chart by ref
and then set a new data using setdata
. this only updates the data rather than re-rendering the whole chart component. and i am using component lifecycle method shouldcomponentupdate
to stop the re-rendering of the component. here is the related code:
class contributionriskgraph extends react.purecomponent {
constructor() {
super();
this.state = {
riskvalue: 8.161736
};
this.handlechange = this.handlechange.bind(this);
}
shouldcomponentupdate(nextprops, nextstate) {
if(this.state.riskvalue !== nextstate.riskvalue) {
return false;
}
}
handlechange(value) {
this.setstate({
riskvalue: value
});
let riskvalue = this.state.riskvalue / 100;
let chart = this.crg.getchart();
chart.series[0].setdata(getgraphplotdata(riskvalue, 'lowerbound'), true);
chart.series[1].setdata(getgraphplotdata(riskvalue, 'expectedvalue'), true);
chart.series[2].setdata(getgraphplotdata(riskvalue, 'upperbound'), true);
}
render() {
// other code
return(
<div>
<reacthighcharts config={config} ref={a => this.crg = a} />
<div style={{ display: 'flex', justifycontent: 'center', margintop: 30 }}>
<rangeslider
label="risk value"
defaultvalue={8}
min={1}
max={62}
handlechange={this.handlechange}
/>
</div>
</div>
)
}
}
Source: stackoverflow.com
Related Query
- Change series data dynamically in react-highcharts without re-render of the chart
- change datalabels color in a HighCharts chart when hovering without updating the series
- Highcharts series doesnt show data and render the chart
- How can I change data series dynamically in HighCharts without overwriting initial series?
- highcharts change series color when data is dynamically inserted
- How to change the chart title dynamically on tooltip hover in the points Highcharts.. React JS
- How to change the background series colour of Highcharts Radar chart
- How to have multiple highcharts with different series data in vuejs without repeating code
- change particular line chart series colour dynamically in highcharts
- Get the exact highcharts data which was used to render a chart
- Highcharts - Sankey chart not displaying all the data when series font increased
- How to add series to an empty chart without breaking the plot border in highcharts
- Add series to highcharts dynamically without initial data
- Get SVG Data from Highcharts without displaying the chart
- Can not access Highcharts chart from container, so I can't change data in a chart dynamically
- Highcharts Column chart Series data formatting change
- Hiding a Highcharts series without using the legend
- Changing data dynamically for a series in Highcharts
- How do I dynamically change a data point in Highcharts using JavaScript
- Changing Highcharts data series type dynamically
- Dynamically update Highcharts chart in react
- HighCharts Dynamically Change Chart Type
- Using Highcharts and displaying a message over or on the chart when there is no data
- Highcharts - Scatter chart with a line connecting the dots in the series
- Sort the series data for every X-Axis in Highcharts
- Dynamically add data to series in Highcharts
- Highcharts hide series without change legend color
- Highcharts Bubble Chart - How to move an individual point's data label (dataLabel) to the front/top
- Highcharts will not render if element in series data is empty
- Setting Highcharts Series and Category data dynamically
More Query from same tag
- Highcharts in Power BI
- Setting options.rangeSelector.selected to 0 does not set zoom to correct level in highstock
- Line not show properly while exporting HTML to PDF using wkhtmltopdf
- Highcharts custom tooltip
- Highcharts columnrange tooltip issue
- How to show full date to my labels and each x axis in different colour in highcharts?
- Display Percentage Values on (highcharts) bubble chart
- R Highcharter: Formatting tooltip
- How to change the interval of negative values? using Highcharts
- Jquery Highcharts is not loading when using with common function?
- Highcharts export module: Multiple Phantom JS instance in jBoss
- Highcharts - Legend Positioning outside the chart
- Highcharts-react not rendering on initial page load
- Highcharts angular.js custom tooltip
- Highcharts spline and columnrange inverted
- Highmaps logo string rendering invalid copyright character
- Updating Points
- Change Fontsize and boxsize in highchart R
- Highcharts Pie Chart Slice Errors
- HighCharts Not Displaying Correctly
- Highcharts not displaying json data in php
- Highcharts Dynamic candlestick
- highchart bar using json with series and xAxis data
- Trigger mousedown and include e.which in the event
- Setting additional data to Highchart series via <%= #{} %> works for integers but not Strings
- highchart network network-graph
- load data in highcharts from 2 different csv files
- Rails 4 - Sprockets::FileNotFound in Welcome#index
- How to show data between two date range in spline chart of Highcharts?
- Highcharts - use same chart on multiple places