echarts
echarts copied to clipboard
用markLine 设置预警线时能否设置自定义值
问题简述 (One-line summary)
用markLine 设置预警线时能否设置自定义值 目前看了配置项手册只有 http://echarts.baidu.com/option.html#series-bar.markLine.data.0.type min max avg 的选项。
版本及环境 (Version & Environment)
- ECharts 版本 3
- 浏览器类型和版本 ie8
- 操作系统类型和版本win 7
重现步骤 (Steps to reproduce)
期望结果 (Expected behaviour)
要求自定义的值能与bar的数据关联。即设置60 就能显示在 y轴值为60的位置上的警戒线。而不是通过设置markline 数组起点终点x,y轴的坐标来划线。
可能哪里有问题 (What went wrong)
ECharts配置项 (ECharts option)
option = {
title: {
text: '未来一周气温变化',
subtext: '纯属虚构'
},
tooltip: {
trigger: 'axis'
},
legend: {
data:['最高气温','最低气温']
},
toolbox: {
show: true,
feature: {
dataZoom: {},
dataView: {readOnly: false},
magicType: {type: ['line', 'bar']},
restore: {},
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['周一','周二','周三','周四','周五','周六','周日']
},
yAxis: {
type: 'value',
axisLabel: {
formatter: '{value} °C'
}
},
series: [
{
name:'最高气温',
type:'line',
data:[11, 11, 15, 13, 12, 13, 10],
markPoint: {
data: [
{type: 'max', name: '最大值'},
{type: 'min', name: '最小值'}
]
},
markLine: {
data: [
{type: 'average', name: '平均值'}
]
}
},
{
name:'最低气温',
type:'line',
data:[1, -2, 2, 5, 3, 2, 0],
markPoint: {
data: [
{name: '周最低', value: -2, xAxis: 1, yAxis: -1.5}
]
},
markLine: {
data: [
{type: 'average', name: '平均值'},
[{
symbol: 'arrow',
label: {
normal: {
formatter: '最大值'
}
},
type: 'max',
name: '最大值'
}, {
symbol: 'circle',
x: '60%',
y: '50%'
}]
]
}
}
]
};
其他信息 (Other comments)
line 不是bar
可以直接设置 yAxis: xxx,参考 http://echarts.baidu.com/demo.html#scatter-weight
@pissang
var option = {
title : {
text : ''
},
tooltip : {},
legend : {
data : [ '累计', '恢复' ],
textStyle:{fontSize:18}
},
xAxis : {
scale:true,
data : [ "倒杆", "断杆","断线" ],
nameTextStyle:{fontSize:18} ,
axisLabel:{textStyle:{fontSize:18}}
},
yAxis :{ scale:true,nameTextStyle:{fontSize:18}},
series : [{"markLine":{"data":[{"type":"average",name:"平均值"},{"yAxis":"60",name:"平均值"}]},"data":["233","22","2"],"itemStyle":{"normal":{"label":{"show":"true","position":"top"}}},"label":{"normal":{"show":"true","position":"top","textStyle":{"fontSize":"18"}}},"name":"累计","stack":"","type":"bar"},{"data":["0","0","0"],"itemStyle":{"normal":{"label":{"show":"true","position":"top"}}},"label":{"normal":{"show":"true","position":"top","textStyle":{"fontSize":"18"}}},"name":"恢复","stack":"","type":"bar"}]
};
这样貌似不能用,avg能出来 yAxis的值出不来
脚本会报错
- 确保最新版本
- 不要用字符串,
yAxis: 60
@pissang 谢谢字符串的问题