score:0
try this
var myBarChart = new Chart(ctx).Bar(dataset, options);
var dataset = {
labels: ["a", "b", "c", "d", "e", "f", "g"], // Optional Labels
datasets: [ // array of data
{
label: "Bar - Set 1",
fillColor: "rgba(220,220,220,0.5)",
strokeColor: "rgba(220,220,220,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data: [65, 59, 80, 81, 56, 55, 40]
},
{
label: "Bar - Set 2",
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,0.8)",
highlightFill: "rgba(151,187,205,0.75)",
highlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
//ect..
};
score:0
You can access the datasets and their single bars using an indexer (like an array):
myBarChart.datasets[0].bars[0].fillColor = "#2ECC71";
myBarChart.datasets[0].bars[0].highlightFill = "#58D68D";
myBarChart.datasets[0].bars[1].fillColor = "#3498DB";
myBarChart.datasets[0].bars[1].highlightFill = "#5DADE2";
score:0
In ChartJS 2.4.0, you may assign a different color for each element in your dataset[idx].data array
i.e.
....
data: [65, 59, 80, 81, 56, 55, 40],
backgroundColor: ["#5e4fa2", "#745998", "#8a638d", "#a06d83", "#b57678", "#cb806e", "#e18a63"]
Link to reference: http://www.chartjs.org/docs/latest/charts/bar.html
Source: stackoverflow.com
Related Query
- How to use set the color for each bar in a bar chart using chartjs?
- How to set a full length background color for each bar in chartjs bar
- how to create bar chart with group and sam color for each group using chart.js?
- Gradient color for each bar in a bar graph using ChartJS
- How to set single color on each bar in angular chart js
- how to set color for each item in tooltip with ChartJS
- How to set X coordinate for each bar with react chart js 2?
- Issue with chartjs linear gradient for the mixed bar chart in ReactJS is not calculated for each individual Bars
- How to add additional label in the middle of each bar using ChartJS
- Set different color for each bars using ChartJS in Angular 4
- subcategories for each bar in multibar chart using chartjs
- Angular 4: Different color for bar in bar chart dynamically using ChartJS
- Different color for each bar in a bar chart; ChartJS
- chartjs : how to set custom scale in bar chart
- Different color for each column in angular-chartjs bar chart
- Border radius for the bar chart in ChartJS
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- how to set chart.js grid color for line chart
- Grouping the object by key for Chartjs bar chart
- PrimeNg bar chart how to show a label for the y-axis
- How to draw outer labels for polar chart using ng2-charts and chart.js at fixed positions outside the rings?
- Is there any way to use 2 different color for the same bar in a chart?
- how can i send a list of numbers from views.py to a chartjs file im using for the front?
- How to draw multiple color bar in a bar chart using chart.js
- How to set the chartjs bar graph scale to the highest value in the result data
- How to highlight single bar in bar chart using Chartjs
- how to set color for each datapoint in chartjs-chart-treemap
- Set fixed label size for grouped bar chart in angular Chartjs
- How to set the gap between data items in a chartjs chart
- How to take a set of Date objects and display the frequency based on time of day using ChartJS
More Query from same tag
- Adding a label to a doughnut chart in Chart.js shows all values in each chart
- Define backgroundColor from data in chartJS
- Chartjs + moment() not displaying on django
- Switching between Charts with chart.js using Buttons
- Vue.js Vue-chart.js linear gradient background fill
- How to add a coloured legend box to a pie chart with Chart.js v1?
- Javascript: Showing bedtimes in Chart.js
- how to use chart.js with angular-chart using requirejs
- Chartjs blocks jumping to a section in ASP.NET MVC 5
- Show highest value untop of a bars when dataset is stacked (chartjs)
- What is self.scale.endPoint chartJs v2.0?
- VueJS : How to group by based on response data columns
- chart.js-plugin-annotations multiple horizontal lines in one chart
- What's the most effective way to implement a radar plot with 50 points at arbitrary locations using chart.js
- How do I place 2 <div>s side by side
- Displaying line chart for multiple datasets using chart.js
- How to embed php code in min.js file
- How to create a multiline graph with differents labels
- How to fix a stacked logarithmic bar chart values to fit the grid
- HTML Input Form to a Javascript Variable
- Add line from point to x-axis and bold label of him
- Setting ChartJS plugin on vue-chartjs not working
- How to use Chart.js with Typescript without getting assignable errors?
- What is the correct format for time data in chartjs?
- Chart.js time series
- Create a weekly line chart (52 labels)
- Unable to Draw Chart using ChartJS
- ChartJS Arrays Acting as One Item
- Charts .js update when array changes
- ChartJS line chart drag and zoom