echarts折线图之曲曲折折颜色渐变

效果: 

代码:

 option = {
     backgroundColor: 'b',
          tooltip : {
            trigger: 'axis',
            formatter: "{b}<br/>{c}分",
            axisPointer: {
              type: 'cross',
              label: {
                backgroundColor: '#6a7985'
              }
            }
          },
          xAxis: {
            name: '年份',
            boundaryGap: true,
            nameTextStyle: {
              color: '#71edff'
            },
            type: 'category',
            data: ['2017', '2018', '2019'],
            splitLine: {
              show: true,
              lineStyle:{
                color: 'rgba(224,224,224,0.2)'
              }
            },
            axisLabel: { /*坐标轴的刻度文字设置*/
              formatter: '{value}',
              textStyle: {
                color: "rgba(113,237,255,0.5)"
              }
            },
            axisLine: {/*坐标轴,轴线的设置*/
              lineStyle: {
                color: "rgba(224,224,224,0.5)",
              }
            }

          },
          grid: {
            top: '14%',
            left: '8%',
            right:'14%',
            bottom: '8%',
            containLabel: true,

          },
          yAxis: {
            name: '数值',
            nameTextStyle: {
              color: '#71edff'
            },
            type: 'value',
            splitLine: {
              show: true,
              lineStyle:{
                color: 'rgba(224,224,224,0.2)'
              }
            },
            axisLabel: { /*坐标轴的刻度文字设置*/
              formatter: '{value}',
              textStyle: {
                color: "rgba(113,237,255,0.5)"
              }
            },
            axisLine: {/*坐标轴,轴线的设置*/
              lineStyle: {
                color: "rgba(224,224,224,0.5)",
              }
            }
          },
          series: [{
            data: [30, 70, 60],
            type: 'line',

            itemStyle: {
              normal: {
                color: '#a18cd2',
                lineStyle: {
                  color: '#a18cd2'
                },
                areaStyle: {
                  color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                    {offset: 0, color: "#a18cd2"},
                    {offset: 0.5, color: "rgba(181,152,254,0.8)"},
                    {offset: 1, color: "rgba(181,152,254,0)"}
                  ])
                }
              }
            }
          }]
        };

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
echarts折线图中,可以通过设置itemStyle属性和emphasis属性来实现折线颜色渐变效果。在itemStyle属性中,可以设置normal属性来定义线条上点的颜色,可以使用color属性来指定颜色值。而在emphasis属性中,可以使用itemStyle属性来定义鼠标hover时拐点的颜色和样式。可以使用color属性来指定颜色值,borderColor属性来指定图形的描边颜色,borderWidth属性来指定描边的线宽。\[1\] 此外,还可以使用areaStyle属性来设置折线的渐变颜色。在areaStyle属性中,可以使用color属性来指定渐变颜色的类型为linear,然后通过colorStops属性来设置渐变颜色的起始和结束值。可以使用offset属性来指定渐变颜色的位置,color属性来指定颜色值。\[2\] 另外,还可以使用symbol属性和symbolSize属性来设置折线拐点的形状和大小。可以使用symbol属性来指定拐点的形状,可以使用symbolSize属性来指定拐点的大小。\[3\] 综上所述,可以通过设置itemStyle属性、emphasis属性、areaStyle属性、symbol属性和symbolSize属性来实现echarts折线图折线颜色渐变效果。 #### 引用[.reference_title] - *1* *2* *3* [Echarts-折线图-设置线条颜色及线条以下区域渐变颜色](https://blog.csdn.net/m0_55969466/article/details/130485523)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值