Automatic colors assignment in chart.js 2.x doesn't work anymore, used to work in v. 1.x

后端 未结 2 1307
北恋
北恋 2021-01-30 17:12

Using Chart.js 1.x I could create a pie chart and get the colors automatically assigned:



        
2条回答
  •  醉梦人生
    2021-01-30 17:38

    I would actually recommend ChartsJS-Plugin-ColorSchemes. Simply importing it after chartjs will be enough for you to have automatic coloring but adding options will allow you to make custom palettes, for example.

    ...
    
      options: {
    
        plugins: {
    
          colorschemes: {
    
            scheme: 'tableau.Tableau20'
    
          }
    
        }
    
      }
    

提交回复
热议问题