Created
March 30, 2017 15:54
-
-
Save DaseinUXD/84b13e4009d565ac4edf87141fc1990f to your computer and use it in GitHub Desktop.
JavaScript function to hide the yAxis label when the legend is clicked to hide a data series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echartb.on('legendselectchanged', function(params) { | |
var legendObject = params.selected; // create variable from the selected: { object } | |
// console.log(legendObject) // {name: boolean-value, name: boolean-value} | |
// console.log(Object.values(legendObject)); // log to the console boolean values out of the key: value pair | |
var value1 = (Object.values(legendObject)[0]); // assign the boolean value in index[0] to value1 | |
var value2 = (Object.values(legendObject)[1]); // assign the boolean value in index[1] to value2 | |
// create a new option object to pass into myChart.setOption() | |
var option2 = { | |
yAxis: [{ | |
//show: value1, | |
axisLabel: { | |
show: value1 // set axisLabel[0] visability to true | false base on value1 | |
} | |
}, { | |
//show: value2, | |
axisLabel: { | |
show: value2 // set axisLabel[1] visability to true | false base on value2 | |
} | |
}] | |
}; | |
echartb.setOption(option2); // pass new option object into myCharts | |
// console.log(params.name) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works with the JavaScript library echarts 3