score:1
I think what you are after is a way to make only the clicked legend series show. If that is the case you can do it with the plotOptions.series.events.legendItemClick
. To have only one series show up initially on the chart (but still show in the legend) you need to set that series' visible
property to true
and the others to false
. If you want to have all series show on initial load that step can be ignored.
To get the toggle working you need to get the index of the legend item you clicked. You then loop through all the series in your chart to find the one that matches that clicked index. When it matches you set series\[i\].show()
for the ones that don't you set series.hide()
.
Here is the basic toggling code:
series: {
events: {
legendItemClick: function (event) {
var seriesIndex = this.index;
var serie = this.chart.series;
console.log(seriesIndex);
for (i = 0; i < serie.length; i++) {
if (serie[i].index == seriesIndex) {
serie[i].show();
console.log(serie[i].index);
} else {
serie[i].hide();
}
}
return false;
}
}
}
And here is a live fiddle.
score:1
When creating chart, just set series.visible = false
for series which should be hidden by default.
See docs.
Source: stackoverflow.com
Related Articles
- How to set the enable property to a highcharts line in page load
- How to visible tool tip in highcharts while page load
- how to render multiple line charts - highcharts on same page using highcharts react wrapper - highcharts-react-offical
- Load JSON file into highcharts to draw a Line Chart
- R Shiny: setExtremes in Highcharts (rCharts) on page load
- 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
- Load mysql data to Highcharts line chart using JSON
- Create visualforce page to show time line using highcharts in salesforce
- highcharts not given the right xAxis labels on page load
- HighCharts turn animation false for line chart
- Hide line in default state in Highcharts
- Highcharts width exceeds container div on first load
- Render Highcharts canvas as a PNG on the page
- Highcharts => Getting the id of a point when clicking on a line chart
- missing value in highcharts line graph results in no line, just points
- SyntaxError: JSON.parse: expected property name or '}' while using highcharts
- Get Highcharts Series Data after Load
- Highcharts Error #16: charts not showing on the same page
- Can I add an "average" line to Highcharts Chart?
- HighCharts load data via ajax
- Highcharts vertical line (crosshair) logic
- How to export the whole page or html content with Highcharts not just the chart?
- Improve performance of Highcharts line chart
- Highcharts highlight single point on line
- Load data into Highcharts with Ajax
- How to enable Highcharts scrollbar?
- Custom Highcharts Context Menu Button Appearing in Every Chart on Page
- Highcharts - How to remove connecting line between fixed tooltip and point
- Enable or disable data labels shown in pie charts in Highcharts on click of a button
- Highcharts - best way to handle and display zero (or negative) values in a line chart series with logarithmic Y axis
- data not getting displayed/plotted in highchart
- Aligning the xAxis of highcharts
- Highchart JS Set data not updating Export: ShowTable on Dropdown Event but chart updates fine
- Arrange the html text inside flag ( HighStock)
- Send variables from Symfony2 PHP file to js file
- how to parse json into highcharts
- Highcharts.js: Possible to map paths/text to tick marks?
- how to reduce padding when embedding highcharts?
- Drilldown on label in spiderweb graph
- Highcharts Bar Chart - How to set the minimum bar width/length
- How can we display daily visits using Highcharts?
- Border on selected series in Stacked Bar charts + High Charts
- Angular 4 - how to use data from Http Post Response to .js file or highchart?
- How to use HighChart's column-stacked-and-grouped graph dynamic date range in x-axis?
- Draw multiple series in Highchart from single JSON data container
- How to set background image on 3d highcharts?
- Highcharts value bars with full height background bars
- How to fix this error Type 'number' has no properties in common with type 'XrangePointOptionsObject'
- Need to precisely set Highcharts axis min/max after chart creation
- Highchart error with date values on xaxis