echarts折线图

echarts 折线图加流动箭头

代码

  let list = [
    {name:'7',value:233},
    {name:'8',value:233},
    {name:'9',value:200},
    {name:'10',value:180},
    {name:'11',value:199},
    {name:'12',value:233},
    {name:'13',value:210},
    {name:'14',value:180},
    {name:'15',value:174},
    {name:'16',value:135,predict:true},
    {name:'17',value:399,predict:true},
    {name:'18',value:480,predict:true},
    ]
    
  let data1 = [];
  let data2 = [];
  list.forEach((item) => {
    if (item.predict) {
      data2.push([item.name, item.value]);
    } 
    else {
      data1.push([item.name, item.value]);
    }
  });
  
    data2.unshift(data1[data1.length - 1]);
    
    
    option = {
    tooltip: {
      trigger: 'axis',
    },
    xAxis: {
      type: 'category',
      data: list.map((m) => {
        return m.name;
      }),
    },
    yAxis: [
      {
        type: 'value',
        name: '(Gbps)',
      },
      {
        type: 'value',
      },
    ],
    series: [
     {
      name: 'test1',
      type: 'line',
      yAxisIndex: 1,
      data: data1,
      symbol: 'circle',
      symbolSize: 16,
      lineStyle: {
        width: 6,
        shadowColor: 'rgba(0, 0, 0, 0.5)',
        shadowOffsetY: 16,
        shadowBlur: 8,
        color:{
            type: 'linear',
            x: 1,
            y: 0,
            x2: 0,
            y2: 0,
            colorStops: [
              {
                offset: 0,
                color: '#2FACFF', // 0% 处的颜色
              },
              {
                offset: 1,
                color: '#1666FF', // 100% 处的颜色
              },
            ],
            global: false, // 缺省为 false
          },
      },
      itemStyle: {
        color: '#fff',
        borderWidth: 4,
        borderType: 'solid',
        borderColor: '#53BAFF',
      },
      },
     {
        name: 'test2',
        type: 'line',
        yAxisIndex: 1,
        data: data2,
        symbol: 'circle',
        symbolSize: 16,
        lineStyle: {
          width: 6,
          shadowColor: 'rgba(0, 0, 0, 0.5)',
          shadowOffsetY: 16,
          shadowBlur: 8,
          color:{
              type: 'linear',
              x: 1,
              y: 0,
              x2: 0,
              y2: 0,
              colorStops: [
   {
                  offset: 1,
                  color: '#F1D361', // 0% 处的颜色
                },
                {
                  offset: 0,
                  color: '#FF8D53', // 100% 处的颜色
                },
              ],
              global: false, // 缺省为 false
            },
        },
        itemStyle: {
          color: '#fff',
          borderWidth: 4,
          borderType: 'solid',
          borderColor: '#53BAFF',
        },
      },
     {
        name: 'test3',
        type:'line',
        itemStyle: {
            color:'none',
            lineStyle: {
              color: "none",
            },
        },
        areaStyle: {
              color:   {
                type: 'linear',
                x: 0,
                y: 1,
                x2: 0,
                y2: 0,
                colorStops: [{
                  offset: 0,
                  color: 'rgba(7,44,90,0.3)'
                }, {
                  offset: 1,
                  color: 'rgba(0,146,246,0.9)'
                }],
                global: false, // 缺省为 false
              }
            },
        data:list.map((m) => {
          return m.value;
        }),
      },
     {
        name: 'jiantou',
        type: 'lines',
        yAxisIndex: 1,
        coordinateSystem: 'cartesian2d',
        polyline: true,
        z: 10,
        lineStyle:{
          color:'#fff',
          opacity:0,
        }, 
        effect: {
          period:10,
          show: true,
          symbolSize: 24,
          symbol: 'pin',
           color: 'pink'
        },
        data: [
        {
            coords: list
                .map((d) => {
                  return [d.name, d.value]
                }),
        },
        ],
     }
    ]
    }

实例

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值