提示
图例不显示,提示echarts.js:49037 2016-11-13 series not exists. Legend data should be same with series name or data name.
但是我series的data里name是有值的
option = {
"backgroundColor": "#fff",
"title": {
"text": "横向柱状图",
"left": "center",
"top": 20,
"textStyle": {
"color": "#636363",
"fontSize": 14,
"fontFamily": "Microsoft YaHei,Arial",
"fontWeight": "normal"
}
},
"color": [
"#bcdc73",
"#8fc966",
"#4bdddb",
"#169ccd",
"#4e6182"
],
"grid": {
"left": "3%",
"right": "3%",
"bottom": 40,
"containLabel": true
},
"tooltip": {},
"series": [
{
"name": "测试DEMO",
"type": "bar",
"data": [
{
"name": "2016-11-11",
"value": 100,
"itemStyle": {
"normal": {
"color": "#bcdc73"
},
"emphasis": {
"color": "#bcdc73"
}
}
},
{
"name": "2016-11-12",
"value": 200,
"itemStyle": {
"normal": {
"color": "#8fc966"
},
"emphasis": {
"color": "#8fc966"
}
}
},
{
"name": "2016-11-13",
"value": 300,
"itemStyle": {
"normal": {
"color": "#4bdddb"
},
"emphasis": {
"color": "#4bdddb"
}
}
}
]
}
],
"yAxis": {
"type": "category",
"data": [
"2016-11-11",
"2016-11-12",
"2016-11-13"
],
"splitLine": {
"show": true,
"lineStyle": {
"color": [
"#edeef1"
]
}
},
"axisLine": {
"lineStyle": {
"color": [
"#edeef1"
]
}
},
"axisLabel": {
"textStyle": {
"color": "#b0b0b0",
"fontSize": 12,
"fontFamily": "Microsoft YaHei,Arial"
}
}
},
"xAxis": {
"type": "value",
"splitLine": {
"show": true,
"lineStyle": {
"color": [
"#edeef1"
]
}
},
"axisLine": {
"lineStyle": {
"color": [
"#edeef1"
]
}
},
"axisLabel": {
"textStyle": {
"color": "#b0b0b0",
"fontSize": 12,
"fontFamily": "Microsoft YaHei,Arial"
}
},
"max": 300,
"min": 50
},
"legend": {
"data": [
"2016-11-11",
"2016-11-12",
"2016-11-13"
],
"bottom": 10,
"left": "center",
"itemWidth": 8,
"itemHeight": 8
}
};
柱状图的 legend 取的是系列的 name
legend data和series.name 保持一致 legend 不显示
{
"grid": {
"top": "80",
"left": "35",
"right": "38",
"containLabel": true
},
"legend": {
"data": [
2017,
2016
],
"textStyle": {
"color": "red"
},
"selectedMode": "single"
},
"tooltip": {
"trigger": "axis"
},
"xAxis": {
"name": "分数",
"type": "value",
"splitLine": {
"show": false
},
"boundaryGap": false
},
"yAxis": {
"name": "人数",
"type": "value",
"splitLine": {
"show": false
},
"boundaryGap": [
0,
"20%"
]
},
"dataZoom": [
{
"type": "inside",
"disabled": true,
"start": 10,
"end": 100
},
{
"start": 200,
"end": 100,
"handleIcon": "M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z",
"handleSize": "80%",
"handleStyle": {
"color": "#fff",
"shadowBlur": 3,
"shadowColor": "rgba(0, 0, 0, 0.6)",
"shadowOffsetX": 2,
"shadowOffsetY": 2
}
}
],
"series": [
{
"name": 2017,
"type": "line",
"smooth": true,
"maxScore": 669,
"minScore": 201,
"symbol": "none",
"sampling": "average",
"itemStyle": {
"normal": {
"color": "#0071bd"
}
},
"areaStyle": {
"normal": {
"color": {
"x": 0,
"y": 0,
"x2": 0,
"y2": 1,
"type": "linear",
"global": false,
"colorStops": [
{
"offset": 0,
"color": "#489ae4"
},
{
"offset": 1,
"color": "#489ae4"
}
]
}
}
},
"markLine": {
"silent": false,
"symbol": "arrow",
"symbolSize": 5,
"precision": 30,
"label": {
"normal": {
"position": "end",
"formatter": "{b}"
}
},
"data": [
{
"name": "本科一批 : 566",
"xAxis": "566",
"lineStyle": {
"normal": {
"color": "#37c1ff"
}
}
}
]
},
"data": [
[
669,
105
],
[
668,
15
]
]
},
{
"name": 2016,
"type": "line",
"smooth": true,
"maxScore": 698,
"minScore": 201,
"symbol": "none",
"sampling": "average",
"itemStyle": {
"normal": {
"color": "#0071bd"
}
},
"areaStyle": {
"normal": {
"color": {
"x": 0,
"y": 0,
"x2": 0,
"y2": 1,
"type": "linear",
"global": false,
"colorStops": [
{
"offset": 0,
"color": "#489ae4"
},
{
"offset": 1,
"color": "#489ae4"
}
]
}
}
},
"markLine": {
"silent": false,
"symbol": "arrow",
"symbolSize": 5,
"precision": 30,
"label": {
"normal": {
"position": "end",
"formatter": "{b}"
}
},
"data": [
{
"name": "本科一批 :584",
"xAxis": "584",
"lineStyle": {
"normal": {
"color": "#37c1ff"
}
}
}
]
},
"data": [
[
698,
11
],
[
697,
1
]
]
}
]
}
echarts 版本 4.1.0
legend.data 值类型必须为字符串才显示了, 在series明明是number类型啊... 在legend里必须是字符串... number类型不显示legend 好坑啊
Most helpful comment
柱状图的 legend 取的是系列的 name