score:2
Accepted answer
You can handle this in the legendItemClick
event:
legendItemClick: function () {
var thisSeries = this;
var tot = 0, num = 0;
var aveSeries = null;
this.chart.series.forEach(function(d,i){
if (d.name == "Average"){
aveSeries = d;
return;
}
if (thisSeries == d && d.visible){
return;
}
if (thisSeries != d && !d.visible){
return;
}
tot += d.data[0].y;
num += 1.0;
});
var ave = tot/num;
aveSeries.setData([ave]);
}
Updated fiddle here.
score:0
Thanks! Just before your post I saw the legendItemClick, and from there I almost got it by myself, but your code helped me to the final result.
However, my original plan was to make it work with multiply series so I had some problem until I finally got to a working result.
This is the finished result:
legendItemClick: function(){
var tot=0,num=0,avg=0;
thisSeries=this;
if(this.name=="Average"){
return false;
}
this.data.forEach(function(ser,serI){
ser.series.chart.series.forEach(function(col,colI){
if(col.name=="Average"){
avgCol=col;
return;
}
if(thisSeries==col && col.visible){
return;
}
if(thisSeries!=col && !col.visible){
return;
}
tot+=col.data[serI].y;
num++;
});
avg=tot/num;
tot=0;
num=0;
avgCol.data[serI].update(avg);
});
}
updated fiddle here: http://jsfiddle.net/skorpion/L5chyc3e/
/Niclas
Source: stackoverflow.com
Related Query
- highcharts - make one column dynamic average?
- One Average Spline for each Column in Highcharts Combination Chart
- highcharts jquery dynamic change chart type column to bar
- Make Highcharts border color match background color on column chart
- Make stack label disabled for a column in stacked column graph in Highcharts
- Highcharts one value per series column
- Make highcharts bar-chart threshold line visible & labels not to overlap on one another
- Use of DotNet HighCharts dll to make charts in code behind
- Dynamic position of tooltip in highcharts column charts
- pushing dynamic data to stacked percentage column in highcharts
- Highcharts values in one column
- highcharts datalabel dynamic rotation as column height
- Highcharts Column Chart Not Displaying Dynamic Values
- Highcharts column only show one category
- Building dynamic HighCharts and image Highcharts with (mostly) one codebase?
- How to make highcharts with dynamic datetime range with monthly interval
- How to make split grouped column bar chart in highcharts with percentage?
- HighCharts - Make labels appear dynamically based on column size
- Highcharts Dynamic Column color based on data comparison
- Dynamic values above column + jQuery Highcharts
- Highcharts make percentage column chart
- Show average in highcharts graph as column
- Multiple dynamic Highcharts on one page with json
- Dynamic column based highcharts feeding data with jquery and php
- Highcharts Chart Bar - How can I display in the chart, only one column from my HTML table?
- Make only one legend active in HighCharts at the start
- highcharts graph with one regular column and one stacked column
- Highstock: how to make series name of first column to be dynamic on tooltip, year wise
- How to make the selection of individual series dynamic in highcharts even after setting max and min?
- how to enable only 1 out of 2 column column graph by default when page loads in highcharts and the 2nd one gets visible when toggled in the legend
More Query from same tag
- Highcharts not updating series stops
- Making a node_module global using Webpack 2
- HIGHCHARTS Treemap update is not working with animation
- HighCharts reading from CSV basic example
- How to get chart data in tabular form same as 'view data table' on click a button
- Adjust the org chart line to be from/to the side of the node versus top or bottom for organization chart?
- Highcharts Datetime axis issue
- Highcharts column width on a time series axis
- How to remove ONLY zoom buttons in Highcharts?
- Highcharts Chrome 71 leak
- Highcharts tooltip image
- Scraping data from an interactive highchart.js graph
- Background columns in linechart highchart
- Highstock Flags Series with stacked data
- Add text to generated quadrant area by x and y plot lines , highcharts
- Highstock: Remove the word "Zoom" from the rangeSelector
- react-highcharts how to call reflow?
- How to set interval points on the x-axis in HighCharts?
- Render a list of highcharts in Rmarkdown
- highcharts timestamp convert to human readable datetime
- Vue js + HighChart - how can I make a synchronous axios call before the component get rendered?
- highcharts multi curved for different x value
- Programmatically change legends in highstock or highchart
- having trouble with AlphaVanatage API, which return a Json timeseries, and I am not able to work with in python, since I need to graph with Highgraph
- Highcharts width exceeds container div on first load
- Scatter chart plot on border if values are outside the bounderies
- HighCharts adding a multi-select dropdown for each column of a series
- Parsing to milliseconds changes date
- Changing a pie chart into an arrow ring chart
- Highcharts Maps labels don't all show