排查ECharts折线图动画脚本数据替换时的Uncaught Error原因
ECharts自定义数据更新报错求助
替换自定义数据nu_data更新ECharts后,出现无法解读的模糊Uncaught Error,无法定位调试。报错信息如下:
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)
新旧数据结构相似,但新数据是3项数组,原数据为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'] } }); });
已尝试的操作:
- 将原数据变量替换为
nu_data - 更新
countries数组匹配新数据的分类项 - 将代码中涉及
Country的字段替换为Quartile
期望实现数据正常渲染动画,或获得明确的错误提示以定位问题,寻求解决指导。
内容的提问来源于stack exchange,提问作者datavizard
相关产品推荐
相关产品推荐

