【问题标题】:how to create bar chart with group and sam color for each group using chart.js?如何使用chart.js为每个组创建带有组和sam颜色的条形图?
【发布时间】:2020-07-28 08:51:50
【问题描述】:

我想使用 chart.js 创建一个条形图,但我需要一个这样的图表,这意味着每个组使用一种颜色。请帮忙

【问题讨论】:

    标签: javascript jquery charts chart.js bar-chart


    【解决方案1】:

    完成

    datasets: [{
            label: '',
            data: [...Array(160)].map(e => ~~(Math.random() * 160)),
            backgroundColor: ['#E07A5F','#81B29A','#3D405B'],
            borderWidth: 1
          },
          {
            label: '',
            fontSize: 40,
            data: [...Array(160)].map(e => ~~(Math.random() * 160)),
            backgroundColor: ['#E07A5F', '#81B29A', '#3D405B'],
            borderWidth: 1
          },
          {
            label: '',
            fontSize: 40,
            data: [...Array(160)].map(e => ~~(Math.random() * 160)),
            backgroundColor: ['#E07A5F', '#81B29A', '#3D405B'],
            borderWidth: 1
          },
          {
              label: '',
              fontSize: 40,
              data: [...Array(160)].map(e => ~~(Math.random() * 160)),
              backgroundColor: ['#E07A5F', '#81B29A', '#3D405B'],
              borderWidth: 1
            },
            {
              label: '',
              fontSize: 40,
              data: [...Array(160)].map(e => ~~(Math.random() * 160)),
              backgroundColor: ['#E07A5F', '#81B29A', '#3D405B'],
              borderWidth: 1
            }
    
          ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-16
      • 2020-12-07
      • 1970-01-01
      • 2021-09-24
      • 2017-07-12
      • 1970-01-01
      相关资源
      最近更新 更多