score:1
Accepted answer
Here you go. The problem was that when you set one of your data array, it passes by reference so both data sets are pointing at the same thing. So first make a copy of the data you want to set. Then set an empty array as your data to clear highcharts data then set it with the copy array.
var chart = Highcharts.chart('container', {
chart: {
type: 'pie'
},
title: {
text: 'Swap Pie Data'
},
series: [
{
id: 'relative',
name: 'Immediate',
type: 'pie',
size: '100%',
innerSize: '30%',
colorByPoint: true,
data: immediate
},
{
type: 'pie',
size: '30%',
name: 'Original',
colorByPoint: true,
data: original
}
]
});
$('#immediate').click(function() {
var temp = immediate.slice(0);
chart.series[0].setData([]);
chart.series[0].setData(temp);
});
$('#distant').click(function() {
var temp = distant.slice(0);
chart.series[0].setData([]);
chart.series[0].setData(temp);
});
Source: stackoverflow.com
Related Query
- How do I dynamically change a data point in Highcharts using JavaScript
- How can i change highcharts data values by selecting from a dropdown list
- Highcharts - Global configuration with common code and unique data & Headings
- highcharts change rendered image source on click
- Change color code on colum, depending on data value (highchartJS)
- highcharts change series color when data is dynamically inserted
- Highcharts - change seconds to time (H:M:S) in data labels
- Highcharts display label for pie chart using html table as data source
- Include additional highcharts source data in angular2 app
- Highcharts series data not persisting through angular route change
- How to change highcharts radius according to data
- Change data by download as pdf in Highcharts
- Highcharts series visibility with csv data source
- Update highcharts data dynamically on HTML form value change
- HTML table as data source for highstock charts using highcharts
- How to change line color when loading static csv data into Highcharts Highstock graph?
- How to update data table on data change highcharts
- Change highcharts data label position
- How can I change data series dynamically in HighCharts without overwriting initial series?
- How to have multiple highcharts with different series data in vuejs without repeating code
- Highcharts - change border of a single data point in series
- change data point value inside load event in HighCharts
- Using a flask variable as data source for highcharts
- Highcharts How to change align of data labels based on value
- Error: Data source must be a URL for refresh | console error | javascript | Highcharts
- How to change color of single column in Highcharts column graph when data is in CSV form?
- Highcharts cloud issue with data source when duplicating chart
- HighCharts Bubble graph JSON as data source
- Highcharts - How to change display data and remove mouseover?
- Use HTML class as Highcharts table data source
More Query from same tag
- Changing Directive that renders HighChart using AngularJS
- how to draw a directed path on a map in highcharts?
- Showing multiple data with same x and y in highchart
- Highcharts: create a stacked columnrange chart
- Highcharts in Angular - accessing the API
- setData is not a function + Angular2-Highcharts
- Showing only one tooltip for all. Highstock highcharts
- Rendering json results to a pie chart in a div - highmaps
- Highcharts rangeSelector: is there a formatter function callback for the inputData fields?
- HighCharts/Javascript: Resample Monthly Data Series to Quarterly/Yearly?
- Adjust pane position in solid gauge
- Highcharts Datetime axis issue
- Highcharts stock chart time selector
- Fixing/discounting a data series when changing chart-type in Highcharts
- How do I preload or install static files into Highchart's export server?
- Turning off animation in HighCharts globally
- How to remove Series name on bottom and we are not getting bar value on top of each bar and also each bar description is aligned cross in Columnchart
- How to enable mouse hover on subtitle or title of pie chart using highchart
- Animate stroke-width with Highcharts renderer
- Highcharts: saving canvas image as local file in IE
- how to give click event in directive using angular js?
- Highstock - Soft Min and Max is not working
- Undefined property in array of arrays
- highcharts: resize exporting dropdown
- Only one highcharts using react-grid-layout can resize
- Highcharts - advanced tooltip functionality needed
- Content must fill available space down to footer and highchart must be reponsive (no scrolling allowed)
- highcharts - disable fading series on marker hover
- High Charts Line Chart with missing data
- Highcharts - how to show/hide multiple data labels on mouseOver and mouseOut