我试图用我自己的数据更新这个电子图表,遇到了一个模糊的错误,我无法破译调试。
echarts.min.js:45 Uncaught Error
at vo (echarts.min.js:45:7325)
at Object.prepareGetValue (echarts.min.js:45:901430)
at echarts.min.js:45:900501
at gG (echarts.min.js:45:900842)
at echarts.min.js:45:900983
at Array.map (<anonymous>)
at z (echarts.min.js:35:5289)
at yG (echarts.min.js:45:900959)
at gG (echarts.min.js:45:900327)
at new t (echarts.min.js:45:901100)
这是没有修改的工作代码:https://codepen.io/kml-projects/pen/poxzazM
这是我试图交换"json"nu_data": https://codepen.io/kml-projects/pen/bGmbaXQ
数据结构是相似的,但是我的新数据是一个3 vs. 4的数组
下面的代码正在读取和过滤列表,我尝试为"nu_data"更新它。示例可能是问题所在。
const countries = [
'Fourth',
'Third',
'Second',
'Top'
];
const datasetWithFilters = [];
const seriesList = [];
echarts.util.each(countries, function (country) {
var datasetId = 'dataset_' + country;
datasetWithFilters.push({
id: datasetId,
fromDatasetId: 'dataset_raw',
transform: {
type: 'filter',
config: {
and: [
{ dimension: 'Year', gte: 1950 },
{ dimension: 'Quartile', '=': country }
]
}
}
});
seriesList.push({
type: 'line',
datasetId: datasetId,
showSymbol: false,
name: country,
endLabel: {
show: true,
formatter: function (params) {
return params.value[1] + ': ' + params.value[0];
}
},
labelLayout: {
moveOverlap: 'shiftY'
},
emphasis: {
focus: 'series'
},
encode: {
x: 'Year',
y: 'Income',
label: ['Quartile', 'Income'],
itemName: 'Year',
tooltip: ['Income']
}
});
});
感谢您的指导,谢谢您的时间。
尝试:
更新"json"Var data w/"nu_data">
更新的const "countries"对于过滤器语句
交换"Country"为"Quartile"在代码中
期望:数据动画样例或错误,将描述与数据/格式的问题
数据集已更新到如下代码所示的位置,而不是仅在"运行"中更新。声明
只要数组的数据数组有"头"数组,它将工作
option = {
animationDuration: 10000,
dataset: [
{
id: 'dataset_raw',
source: **UPDATE HERE***
},
...datasetWithFilters
],
title: {
text: 'Income of Germany and France since 1950'
},
tooltip: {
order: 'valueDesc',
trigger: 'axis'
},
xAxis: {
type: 'category',
nameLocation: 'middle'
},
yAxis: {
name: 'Income'
},
grid: {
right: 140
},
series: seriesList
};
myChart.setOption(option);
}