How to hide/show a column in a basic column graph of highcharts?

前端 未结 2 874
梦如初夏
梦如初夏 2020-12-04 03:25

I\'m trying to show/hide a column (with all the associated points) in a graph of highcharts.

For instance, consider following graph: jsfiddle.

I want the use

2条回答
  •  鱼传尺愫
    2020-12-04 04:03

    To do this with a grouped bar chart, you will need to create a custom function that will

    1) remove the data series from the chart

    2) rebuild the data series with the clicked data points removed

    3) re-add the series to the chart

    and,

    4) you will need to build some form of external control mimicking a legend, so that the user still has something to click in order to re-show the removed data. Otherwise, when you rescale the axis, you remove the label and the user can't get the data back.

    It is not a trivial exercise, unfortunately.

    the setData() function will handle 1 and 3: http://api.highcharts.com/highcharts#Series.setData%28%29

    OTOH, if you want to do this with a standard (non-grouped, non-stacked) bar chart, you can simply make each bar a separate data series, and the built in Legend functionality will handle everything for you.

提交回复
热议问题