1、错误描写叙述

echarts中的option.legend.data has not been defined._数据

echarts中的option.legend.data has not been defined._数据_02


2、错误原因

var map = function(mapData){
require(
[
'echarts',
'echarts/chart/map'
],
function (ec) {
var mapChart = ec.init(document.getElementById('mapDataChart'));

var option = {
title : {
text: '',
x : 'center',
y : 'top'
},
tooltip : {
trigger: 'item',
formatter: '{a}<br/>{b}:{c}个'
},
legend : {
show:true
},
dataRange: {
min: 0,
max: 1000,
calculable : true
},
series : [
{
name: '',
type: 'map',
mapType: 'china',
data:mapData,
showLegendSymbol:true
}
],
animation: true
};

// 为echarts对象载入数据
mapChart .setOption(option);

});
}

    因为echarts中的map没有legend属性,导致报错


3、解决的方法

var map = function(mapData){
require(
[
'echarts',
'echarts/chart/map'
],
function (ec) {
var mapChart = ec.init(document.getElementById('mapDataChart'));

var option = {
title : {
text: '',
x : 'center',
y : 'top'
},
tooltip : {
trigger: 'item',
formatter: '{a}<br/>{b}:{c}个'
},

dataRange: {
min: 0,
max: 1000,
calculable : true
},
series : [
{
name: '',
type: 'map',
mapType: 'china',
data:mapData,
showLegendSymbol:true
}
],
animation: true
};

// 为echarts对象载入数据
mapChart .setOption(option);

});
}

    去掉 

legend : {

                show:true

               },