score:4
The API has a method to update the series (http://api.highcharts.com/highcharts#Series.update()). e.g.
chart.series[0].update({ type: 'spline' });
You should be able to use this API call to modify any of the series attributes.
For instance, you could have two series objects defined, and update the chart to use the one you want on a button click:
var seriesWeek = {
type: 'column',
name: title,
data: data,
dataGrouping: {
units: [ ['week', [1] ] ]
}
}
var seriesMonth = {
type: 'column',
name: title,
data: data,
dataGrouping: {
units: [ ['month', [1] ] ]
}
}
chart.series[0].update(seriesWeek);
score:0
We tried a Hack around this, where we used Highstock's (Splinechart) RangeSelector, Event and DataGrouping. On click of weekly rangeselectorButton we catch this event through setExtremes. Post catching the event approximate it to "sum". If you are using two series than iterate the object.
events: {
setExtremes: function (e) {
if (e.rangeSelectorButton != undefined) {
var triger = e.rangeSelectorButton;
if (triger.type == 'week') {
$.each(this.series, function (index, obj) {
obj.options.dataGrouping.units[0] = ['week', [1]];
});
} else if (triger.type == 'day') {
$.each(this.series, function (index, obj) {
obj.options.dataGrouping.units[0] = ['day', [1]];
});
}
}
}
},
score:1
I have always exactly one timeseries, so this approach works for me (no need to update each timeseries manually):
self.myChart = new window.Highcharts.stockChart(pChartDivContainer, {
title: {
text: 'My title'
},
rangeSelector: {
enabled: true
},
plotOptions: {
series: {
dataGrouping: {
approximation: 'ohlc',
units: [
["minute", [1]]
],
forced: true,
enabled: true,
groupAll: true
}
}
}
}, function (chart) {
self.onChartReady();
});
After that it's easy to change the unit:
self.setCandleInterval = function (pUnit, pInterval) {
self.myChart.update({
plotOptions: {
series: {
dataGrouping: {
units: [
[pUnit, [pInterval]]
]
}
}
}
});
}
Source: stackoverflow.com
Related Query
- How to set Highcharts chart maximum yAxis value
- how to set the interval of points on Y - Axis highcharts
- Highcharts How to Show Loading Animation At Set Data
- Highcharts - How to set custom colors for the series
- how to set dynamic data in highcharts
- How to set a static minimum value for axes in Highcharts
- Highcharts: How to set dataGrouping
- Highcharts Bar Chart - How to set the minimum bar width/length
- How do I set highcharts line graph point colors to an array of colors?
- How to set the z-index of points on a HighCharts scatter plot?
- how to set xAxis pointInterval(update: tickInterval) in highcharts
- Highcharts (Highstock) how to manually set the navigator selected range
- How do I set the background color of a Highcharts HTML label?
- How to color series legend in highcharts when colorbypoint is set to true
- How to set an fillArea offset in HighCharts
- highcharts pie monochrome: how to set the default color?
- Highcharts - how to set custom content in point tooltip (popup) on 3D scatter chart or how to customize point tooltip information?
- How to set 'lang' property in Highcharts using Angular JS?
- How to set Highcharts object configuration globaly with vue-highcharts?
- How do i add mouse wheel code in Angular2 highcharts in typescript
- how to display 2 same highcharts without duplicate the code
- How to edit tooltip in Highcharts C# code
- Highcharts server side image generation, how to set up legend labelFormatter in callback argument
- How to set datalabels as vertical in Highcharts
- Highcharts - how to set textShadow for data labels
- HighCharts - how to set labels font color for printing?
- How set options from HIGHCHARTS in a chart using vue chartkick
- how to use highcharts tooltip formatter in python code
- How do I set Highcharts categories dynamically?
- How to set Highcharts options in Angular 5
More Query from same tag
- Change chart size on print - Highcharts
- How to dynamically update highcharts using jQuery UI sliders
- HighCharts - HighStock - Show Date for Candlestick & Volume
- Loading Javascript Highcharts series data issues
- Long length string is not displaying correctly in the chart
- Load json-data into Highchart
- Highcharts in Angular - accessing the API
- IE 6 Script error when Highstock & Highcharts are loaded
- How to display custom or non-series data array on Highcharts tooltip on hover?
- Highcharts PieChart Legend paging faulty
- Highcharts: only display stack labels if there are multiple stacks?
- Change/Swap Highcharts Data
- set chart type property in devexpress chart control c#
- I am working on highcharts, and want to adjust tooltip with chart name ( chart title )
- Echarts how to highlight area between 2 line charts
- Highcharts x-axis label
- How to synchronize the Highchart Sunburst behavior
- HighCharts-Removing the padding for a bar chart
- highcharts download not working from html page with iframe in IE
- Angular highchart and ng-grid headers not respecting frame widths
- How to show plotlines on highstock when its set much higher than the data series?
- Highstocks / Highcharts API : how to add spline/line to already rendered chart?
- Image on pie graph with highcharts
- Highcharts 3d bar chart data labels position is wrong
- a better way to color many individual markers in a scatter chart?
- HighCharts uncaught exception
- How can I draw a plot in negative y direction in HighCharts?
- How to add series to an empty chart without breaking the plot border in highcharts
- how to place heat-map tick label at top of the y-axis instead of middle
- Using modified JS version in Highcharts to bring back the pre-3.0 export buttons