echarts上加横线标线_echarts 添加标线,设置颜色

本文档介绍了如何在ECharts图表中添加横线标线,并详细展示了如何设置标线颜色,以及根据数据动态调整颜色的方法。通过示例代码,展示了在条形图上针对不同数据段设置不同颜色的效果。
摘要由CSDN通过智能技术生成

//

var myChart1 = echarts.init(document.getElementById('main1'));

var data1=['10.2','8.6','9.3','7.5']; //预警值 数组

var seriesData = [12, 7.8, 14.2, 6.2]; //总能耗数值数组

option1 = {

title: {

text: '分车型能耗预警'

},

color: ['#e7505a'],

tooltip: {

trigger: 'axis',

axisPointer: { // 坐标轴指示器,坐标轴触发有效

type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'

}

},

grid: {

right: '4%',

bottom: '3%',

containLabel: true

},

xAxis: [{

type: 'category',

data: ['伊兰特汽油', '伊兰特CNG', 'B50汽油', '凯美瑞混合动力'],

axisTick: {

alignWithLabel: true

}

}],

yAxis: [{

type: 'value',

name: '百公里能耗L/100KM',

min: 0,

max: 15,

interval: 3,

axisLabel: {

formatter: '{value}'

}

}],

series: [{

name: '',

type: 'bar',

barWidth: '45%',

data:seriesData,

markLine: {

itemStyle: {

normal: {

borderWidth: 1,

lineStyle: {

type: 'dash',

color: '#333 ',

width: 2,

},

label: {

formatter: '',

textStyle: {

fontSize: 16,

fontWeight: "bolder",

},

}

},

},

data: [

[{

coord: ['伊兰特汽油', 0]

}, {

coord: ['伊兰特汽油', 10.2]

}],

[{

coord: ['伊兰特CNG', 0]

}, {

coord: ['伊兰特CNG', 8.6]

}],

[{

coord: ['B50汽油', 0]

}, {

coord: ['B50汽油', 9.3]</

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值