I'm trying to recreate a chart (the one below) using Highcharts. I'm using a basic bar chart, and I'm wondering if there is a way to get a vertical line showing the average of all the bars? I have the value calculated, I just need it to display as the picture shows. Can I do this using Highcharts?
Yes, you can. You could add more. If you get stack with implementing your project, please send us a minimal, verifiable demo in JSFiddle, so we could help you out with your code.
An array of lines stretching across the plot area, marking a specific value on one of the axes. In styled mode, the plot lines are styled by the . highcharts-plot-line class in addition to the className option.
Re: Change chart type dynamically? You can't change a series type like that, as they are entire different JavaScript classes. What you can do without regenerating the chart, is to get the data from the first series, destroy it, and add a new series of a different type with the same data.
But from what I see, it's only possible in Highcharts to either have all lines on one y-axis or each line has its own y-axis.
Yes. You can add it as a plotline, like this:
yAxis: {
// ...Options
plotLines: [{
color: 'red',
value: '15', // Insert your average here
width: '1',
zIndex: 4 // To not get stuck below the regular plot lines or series
}]
}
See this JSFiddle demonstration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With