I am trying to activate/deactivate a chart line using an HTML button in ECharts js. I do not want to use the ECharts legend to perform this action. I want this HTML button to have this functionality. How is that possible? Thank you!
This is my code:
<html>
<script src="https://cdn.jsdelivr.net/npm/echarts@4/dist/echarts.min.js?_v_=1607268016278"></script>
<link href="https://getbootstrap.com/docs/5.0/dist/css/bootstrap.min.css" rel="stylesheet">
<div class="form-check" style="margin-left: 100px;">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<label class="form-check-label" for="flexCheckDefault">
Activate & Deactivate line
</label>
</div>
<div id="benchmark" style="min-height:500px;"></div>
<script>
var myChart = echarts.init(document.getElementById('benchmark'));
option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line'
}]
};
myChart.setOption(option);
</script>
</html>