Note that there are some explanatory texts on larger screens.

plurals
  1. POHighcharts - Issue with showing and hiding plot lines and bands on legendItemClick
    primarykey
    data
    text
    <p>I have a chart on which I have several x axis plotLines and plotBands. I have a function, which on legendItemClick, will show/hide the plotLines and Bands. (it is a histogram with normal curve overlaid and stdev levels marked)</p> <p>The chart and code can be seen here: <a href="http://jsfiddle.net/jlbriggs/FnhRV/" rel="nofollow">http://jsfiddle.net/jlbriggs/FnhRV/</a></p> <pre><code>function toggleBands(chart) { $.each(chart.xAxis[0].plotLinesAndBands, function(index,el){ if(el.svgElem != undefined) { el.svgElem[ el.visible ? 'show' : 'hide' ](); el.visible = !el.visible; } }); } </code></pre> <p>The problem: when other series are shown or hidden, and the x axis scales accordingly, if any of the plot lines or bands fall off the scale, the behavior starts getting hinky.</p> <p>In the example posted, if you hide the normal curve series, the outermost plotlines will be outside the bounds of the x axis. Once that happens, those two lines will reappear every time you hide them, and clicking on the various legend items will cause various states of hidden/visible that shouldn't be.</p> <p>IF the series are such that the axis always remains wide enough for the plotlines, this error DOES NOT happen, and the showing and hiding will happily occur as intended.</p> <p>Can anyone tell me why this is happening, and/or provide a solution? thanks in advance</p> <p>Jamie</p> <p>{{edit: setting a min and max to match the curve value will not help the situation in this case, as the desired usability is that the user can hide the curve and see the chart scaled to the histogram data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload