Echarts联动和共享数据集,多个数据集时的处理

5 篇文章 0 订阅
2 篇文章 0 订阅

在这里插入图片描述
echarts【联动和共享数据集】

☆多数据集的处理

setTimeout(function () {
  option = {
    legend: {},
    tooltip: {
      trigger: 'axis',
      showContent: false
    },
    dataset: [{
      source: [
        ['product', '2012', '2013', '2014', '2015', '2016', '2017'],
        ['Milk Tea', 56.5, 82.1, 88.7, 70.1, 53.4, 85.1],
        ['Matcha Latte', 51.1, 51.4, 55.1, 53.3, 73.8, 68.7],
        ['Cheese Cocoa', 40.1, 62.2, 69.5, 36.4, 45.2, 32.5],
        ['Walnut Brownie', 25.2, 37.1, 41.2, 18, 33.9, 49.1],
      ]
    },{
      source: [
        ['product', '2012', '2013', '2014', '2015', '2016', '2017'],
        ['多数据集', 10, 20, 30, 40, 50, 60],
      ]
    }],
    xAxis: { type: 'category' },
    yAxis: { gridIndex: 0 },
    grid: { top: '55%' },
    series: [

      {
        type: 'bar',
        smooth: true,
         stack: 'Ad',
        seriesLayoutBy: 'row',
        datasetIndex: 0
      
      },
      {
        type: 'bar',
        smooth: true,
         stack: 'Ad',
        seriesLayoutBy: 'row',
      datasetIndex: 0
      },
      {
        type: 'bar',
        smooth: true,
         stack: 'Ad',
        seriesLayoutBy: 'row',
      datasetIndex: 0
      },
      {
        type: 'bar',
        smooth: true,
         stack: 'Ad',
        seriesLayoutBy: 'row',
        datasetIndex: 0
       
      },
       {
        type: 'bar',
        smooth: true,
        seriesLayoutBy: 'row',
       datasetIndex: 1
      },
      {
        type: 'pie',
        id: 'pie',
        radius: '30%',
        center: ['50%', '25%'],
        label: {
          formatter: '{b}: {@2012} ({d}%)'
        },
        encode: {
          itemName: 'product',
          value: '2012',
          tooltip: '2012'
        }
      }
    ]
  };
  myChart.on('updateAxisPointer', function (event) {
    const xAxisInfo = event.axesInfo[0];
    if (xAxisInfo) {
      const dimension = xAxisInfo.value + 1;
      myChart.setOption({
        series: {
          id: 'pie',
          label: {
            formatter: '{b}: {@[' + dimension + ']} ({d}%)'
          },
          encode: {
            value: dimension,
            tooltip: dimension
          }
        }
      });
    }
  });
  myChart.setOption(option);
});
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值