Search code examples
javascriptjquerychartsdata-visualizationshieldui

how to disable the functionality to hide/show the chart when user click ChartLegend with ShieldUI?


Here we have an Example of a ShieldUI Chart, does someone if it's possible to disable the functionality to hide/show the chart when user click the CharLegent? I mean as you can see when user hits "Braking Distance" the yellow chart has been hidden. I want to disable that kind of functionality.


Solution

  • You should stop the event from being triggered in a legendSeriesClick event handler function, as shown here:

    $(document).ready(function () {
        $("#chart").shieldChart({
            ...
            events: {
                legendSeriesClick: function (e) {
                    // stop the series item click event, so that 
                    // user clicks do not toggle visibility of the series
                    e.preventDefault();
                }
            }
        });
    });
    

    A complete example is shown in this chart demo.