Skip to content

martov1/chart.js-color-bars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

chart.js-color-bars

This plugin allows you to pass an array of background colors for your bar chart. This repostory has 2 files: chart.js-color-bars.ts, for TYPESCRIPT chartjs-color-bars.JS for JAVASCRIPT

the difference is minimal, the whole plugin is like 20 lines

How to use

for typescript


import {barColors} from 'chart.js-color-bars' //import it
Chart.pluginService.register(barcolors)// register it as a plugin

for javascripr

require("path-to-chartjs-color-bars.js")

on your dataset, add an array of colors of the same length as your array of data.

  datasets: [{
            label: ' % de venta',
            data: [10,5,4],
            borderWidth: 3,
            borderColor: '#ffa596',
            backgroundColor: 'rgba(0, 0, 0, 0)',
            pointBackgroundColor: 'rgba(0, 0, 0, 1)',
            colors: ["red","green","blue"],
          }]

Result:

screenshot

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published