使用 ECharts图表组件 导入 echarts 图表发生错误,请问有解决办法吗?
导入 echarts 代码片段 var option;
setTimeout(function () {
option = {
legend: {
top: 15,
data: ['甲类设备', '乙类设备', '丙类设备', '丁类设备'],
textStyle: {
fontSize: 16
}
},
tooltip: {
trigger: 'axis',
showContent: false
},
title: {
left: 'left',
text: '设备故障统计图'
},
dataset: {
source: [
['product', '7月', '8月', '9月', '10月', '11月', '12月'],
['甲类设备', 10, 8, 14, 21, 13, 9],
['乙类设备', 15, 16, 21, 18, 12, 17],
['丙类设备', 8, 6, 9, 7, 5, 10],
['丁类设备', 11, 13, 16, 18, 20, 19]
]
},
xAxis: {
type: 'category',
name: '日期',
nameGap: 16,
nameTextStyle: {
fontSize: 16
}
},
yAxis: {
name: '次数',
nameLocation: 'end',
nameGap: 20,
nameTextStyle: {
fontSize: 16
},
gridIndex: 0
},
grid: {
top: '55%',
bottom: '5%'
},
series: [
{
type: 'line',
smooth: true,
seriesLayoutBy: 'row',
emphasis: { focus: 'series' }
},
{
type: 'line',
smooth: true,
seriesLayoutBy: 'row',
emphasis: { focus: 'series' }
},
{
type: 'line',
smooth: true,
seriesLayoutBy: 'row',
emphasis: { focus: 'series' }
},
{
type: 'line',
smooth: true,
seriesLayoutBy: 'row',
emphasis: { focus: 'series' }
},
{
type: 'pie',
id: 'pie',
radius: '35%',
center: ['50%', '30%'],
emphasis: {
focus: 'self'
},
label: {
formatter: '{b}: {@2012} ({d}%)'
},
encode: {
itemName: 'product',
value: '2012',
tooltip: '2012'
}
}
]
};
myChart.on('updateAxisPointer', function (event) {
const xAxisInfo = event.axesInfo[0];
if (xAxisInfo) {
const dimension = xAxisInfo.value + 1;
myChart.setOption({
series: {
id: 'pie',
label: {
formatter: '{b}: {@[' + dimension + ']} ({d}%)'
},
encode: {
value: dimension,
tooltip: dimension
}
}
});
}
});
myChart.setOption(option);
});
option && myChart.setOption(option);
发现报错信息 [图片] 初步判断问题在 myChart.on('updateAxisPointer', function (event) {
里面,但是无法处理,将上面 echarts 代码复制到 https://echarts.apache.org/examples/zh/editor.html?c=line-simple 是可以正常显示的 请问各位有什么好的解决办法吗