Article From:

echarts Click on external elements to display / hide corresponding graphics.

 function onclick(){

                  url: "",//Please ignore this URLDataType:'jsonp',Jsonp:'callback',Data:{Start_time:start,End_time:end},Success: function (objdata) {/ * two timesThe number of days subtracted from each other * /Var day = (New Date (end) - New Date (start)) / (24*60*60*1000);Var len = 0;For (VaR I = 0; I < day; i++) {Var did[i].temp; / / inlet temperatureVar out1 =objdata.daTa.table_out[i].temp; / / tube temperatureVar scale = (did/out1).ToFixed (2)Var date = ([i].time)Data.push (scale)Time.push (date)}SetOption (DATA)}})}$("#btn1").Click (function () {)OnClick ()})

Label: echarts

Now click to show, but what I want is to hide it by clicking it. I don’t know how to do it.

Answer 0:

Put echart.init outside
Redeclare a flag to control display hiding

var xxx = echart.init;
var flag = false;
function onclick(){
    flag = true
        //Here, according to specific requirements, if it is only hidden, then $(chartDom).Hide (); below is destruction.Xxx.dispose ()}else{Onclick ()}})

Take a look at the features you’d like to add below, similar to the legend in the icon, but the grid is switched on the same graph
If you want to show the hidden line, you can consider binding the following events in the button.

let newop = chartDom.getOption();    
newop.series = [];    //Clear the series, so the chart is on, the wireless barChartDom.setOption (newop);

Look at the 3 switch in the upper left corner of your map (it should be the switch chart), and it is suggested to make a option so that you can use the echarts grid to switch the 3 diagrams (the grid mode is set to a single), which is much more efficient than the option method above.

Answer 1:

Thank you. If you hide the broken line instead of hiding the whole element, how do you write it?

Leave a Reply

Your email address will not be published. Required fields are marked *