heatmap-bmap初始化时报错 Cannot read property 'type' of null
option = {
animation: false,
bmap: {
center: point,
zoom: 14,
roam: true
},
visualMap: {
show: false,
top: 'top',
min: 0,
max: 5,
seriesIndex: 0,
calculable: true,
inRange: {
color: ['blue', 'blue', 'green', 'yellow', 'red']
}
},
series: [{
type: 'heatmap',
coordinateSystem: 'bmap',
data: points,
pointSize: 5,
blurSize: 6
}]
}
angular.js:10467TypeError: Cannot read property 'type' of null
at ExtendedClass.render (http://localhost:8080/entry/1.bundle.js:47297:26)
at ECharts.<anonymous> (http://localhost:8080/entry/1.bundle.js:1037:24)
at ExtendedClass.<anonymous> (http://localhost:8080/entry/1.bundle.js:2274:21)
at Array.forEach (native)
at each (http://localhost:8080/entry/1.bundle.js:2807:18)
at ExtendedClass.eachSeries (http://localhost:8080/entry/1.bundle.js:2272:14)
at ECharts.doRender (http://localhost:8080/entry/1.bundle.js:1034:18)
at ECharts.update (http://localhost:8080/entry/1.bundle.js:521:23)
at ECharts.prepareAndUpdate (http://localhost:8080/entry/1.bundle.js:654:35)
at ECharts.echartsProto.setOption (http://localhost:8080/entry/1.bundle.js:309:45)
module.exports = require('../../echarts').extendChartView({
type: 'heatmap',
render: function (seriesModel, ecModel, api) {
var visualMapOfThisSeries;
ecModel.eachComponent('visualMap', function (visualMap) {
visualMap.eachTargetSeries(function (targetSeries) {
if (targetSeries === seriesModel) {
visualMapOfThisSeries = visualMap;
}
});
});
if (__DEV__) {
if (!visualMapOfThisSeries) {
throw new Error('Heatmap must use with visualMap');
}
}
this.group.removeAll();
var coordSys = seriesModel.coordinateSystem;
// 这里报错了 seriesModel中没有coordinateSystem属性导致取不到type
if (coordSys.type === 'cartesian2d') {
this._renderOnCartesian(coordSys, seriesModel, api);
}
else if (isGeoCoordSys(coordSys)) {
this._renderOnGeo(
coordSys, seriesModel, visualMapOfThisSeries, api
);
}
},
..............
............
通过调试我发现是在赋值coordinateSystem出了问题,导致seriesModel没有seriesModel属性。
如果看到问题,烦请抽时间看一下,期待您的解答或者提供解决思路,谢谢。
设置 coordinateSystem 为 calendar 也会报这个错误。
const options = {
tooltip: {
position: 'top'
},
visualMap: {
min: 0,
max: 1000,
calculable: true,
orient: 'horizontal',
left: 'center',
top: 'bottom'
},
calendar: {
range: '2017',
cellSize: ['auto', 20]
},
series: [{
name: 'test',
type: 'heatmap',
coordinateSystem: 'calendar',
data: this.chartData
}]
}
【写给后来人】
没有引入 calendar 组件
我在 Vue 项目中遇到了同样问题,这里引入后可以了
Most helpful comment
没引入 bmap 组件?https://github.com/ecomfe/echarts/tree/master/extension/bmap