日常生活的交流与学习

首页 新随笔 联系 管理

折线图

option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [150, 230, 224, 218, 135, 147, 260],
      type: 'line'
    }
  ]
};

折线图百分比

import * as echarts from 'echarts';

type EChartsOption = echarts.EChartsOption;

var chartDom = document.getElementById('main')!;
var myChart = echarts.init(chartDom);
var option: EChartsOption;

option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [0.99, 0.98, 0.94, 0.96, 0.95, 0.88, 0.87],
      label: {
        show: true,
        position: 'top'
      },
      type: 'line'
    }
  ]
};

option.series[0].label.formatter = function (params) {
  return (params.value * 100).toFixed(2) + '%';
};

option && myChart.setOption(option);
posted on 2022-12-08 17:10  lazycookie  阅读(34)  评论(0编辑  收藏  举报