Search code examples
javascriptecharts

Apache eCharts: show/hide toolbox on event


How to show/hide the toolbox of a chart, where the zoom tool etc. is located, on a certain event?

Toolbox is in the upper right corner

I tried changing the "show" property, which didn't work:

chart.getOption().toolbox[0].show = false;

Solution

  • getOption() only returns the value of your chart configuration. What you actually need to use is setOption() to change your chart's options :

    myChart.setOption({
        toolbox: { show: false }
    })
    

    Here is a simple example I created where the toolbox is shown/hidden each time you click the chart.