使用dataset数据集实现:

 option = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  legend: {},
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: {
          "type": "category",
       
  },
  yAxis:{
       "type": "value",
  },
  dataset: {
    source: [
     ['product', '2015', '2016', '2017'],
        ['Apples', 50, 80, 120],
        ['Oranges', 70, 100, 140],
        ['Bananas', 40, 60, 90],
    ],
    // 用 dimensions 指定了维度的顺序。直角坐标系中,如果 x轴 type 为 category
    //  默认把第一个维度映射到 X 轴上(第一列),后面维度映射到 Y 轴上。
    dimensions: [
        'product',//
        '2015',
        '2016',
        '2017'
    ],
  series: [
        {
            "type": "bar",
            // 给一个系列的 stack 值设置一个字符串类型的值
            // 拥有同样 stack 值的系列将堆叠在一组
            "stack": "fruit",
        },
        {
            "type": "bar",
            "stack": "fruit",
        },
        {
            "type": "bar",
            "stack": "fruit",
        }
    ]
};

在这里插入图片描述

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐