echarts中graphic_Echarts实现折线图

本文介绍如何利用Echarts的graphic属性来实现一个质控月度评分的折线图,包括设置标题、图例、坐标轴、数据系列、颜色、线宽和区域填充。示例代码展示了如何创建具有不同颜色和样式的两条折线,以及添加提示框和网格。
摘要由CSDN通过智能技术生成

1.引用Echarts的js

var arr =[];

var rgs=[];

var jqs=[];

这里调用ajax把对应的值赋给定义的数组

function chartShow(arr,rgs,jqs) {

myChart.setOption({

title: {

text: ‘质控月度评分’ // 标题栏

},

tooltip: { // 提示框

trigger: ‘axis’, // 触发类型

axisPointer: { // 坐标轴指示器配置项

type: ‘cross’,

label: {

backgroundColor: ‘#6a7985’

}

}

},

legend: { // 图例组件

orient: ‘horizontal’, // 图例列表的布局朝向

right: 1, // 图例组件离容器右侧的距离

textStyle: {

color: ‘#6e6e6e’, // 字体颜色

fontWeight: ‘normal’,

fontSize: 12

},

data: [‘人工质控’, ‘机器质控’] // 和series 中的name对应

},

grid: { // 直角坐标系内绘图网格

left: ‘3%’,

top: ‘15%’,

containLabel: true

},

xAxis: [{

type: ‘category’,

name: ‘年/月’,

boundaryGap: false,

axisLabel: {

show: true,

textStyle: {

color: ‘#8a94a3’ // 坐标字体颜色

},

// rotate: 0 // 坐标倾斜角度

},

axisLine: {

lineStyle: {

color: ‘black’, // x坐标轴颜色

}

},

data: arr

}],

yAxis: {

type: ‘value’,

name: ‘平均分’,

axisLine: { //坐标轴线条相关设置(颜色等)

lineStyle: {

color: ‘black’ // y轴颜色

}

},

axisLabel: {

formatter: ‘{value}’,

textStyle: {

color: ‘#babced’

}

},

splitLine: {

lineStyle: {

color: ‘#57617B’ //分隔线颜色设置

}

}

},

series: [

{

name: ‘人工质控’,

type: ‘line’,

symbol: ‘circle’, //标记的图形

symbolSize: 8, // 拐点的大小

label: {

normal: {

show: true,

color: ‘#4a9eff’, // 数字颜色

position: ‘top’

}

},

itemStyle: {

normal: {

borderColor: ‘#3794FF’, // 边框颜色

color: ‘#3794FF’, // 折线上标记点的颜色 和 图例的颜色

lineStyle: {

width: 4, // 折线图的粗细

color: ‘#4a9eff’ // 折线的颜色

}

}

},

areaStyle: {

normal: {

type: ‘default’,

color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{

offset: 0,

color: ‘#4a9eff’ // 区域颜色

}, {

offset: 1,

color: ‘#4a9eff’ // 区域颜色

}], false)

}

},

data: rgs

},

{

name: ‘机器质控’,

type: ‘line’,

symbol: ‘circle’, //标记的图形

symbolSize: 10, // 拐点的大小

label: {

normal: {

show: true,

color: ‘#4a9eff’, // 数字颜色

position: ‘top’

}

},

itemStyle: {

normal: {

borderColor: ‘orange’, // 边框颜色

color: ‘orange’, // 折线上标记点的颜色 和 图例的颜色

lineStyle: {

width: 4, // 折线图的粗细

color: ‘orange’ // 折线的颜色

}

}

},

areaStyle: {

normal: {

type: ‘default’,

color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{

offset: 0,

color: ‘orange’ // 区域颜色

}, {

offset: 1,

color: ‘orange’ // 区域颜色

}], false)

}

},

data: jqs

}

]

});

// myChart.setOption(option);

// });

//}

}

标签:颜色,normal,实现,质控,color,图例,折线图,type,Echarts

来源: https://blog.csdn.net/wqwq093030/article/details/102752805

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值