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
- ChartJS not work in .php loaded by jquery .load() (AJAX)
- How to create datasets for all labels for stacked bar in chart.js?
- JavaScript Error - Uncaught SyntaxError: Unexpected number
- Chart.js x-axes not working?
- Chart.js - draw an arbitrary point with tooltip
- How to achieve a mixed chart of 'horizontal' bars and line chart using Chart.js?
- Changing the background of a ChartJS on node js
- Updating Chartjs with new data
- Get the data from node.js for Chart.js
- Chart with tool tip values
- Laravel - production.ERROR: Undefined variable: department_chart_data in Chartjs barchart
- Dynamically update values of a chartjs chart
- How to get line x value from Label chart js
- Chart.js bezier curve discontinuity
- Can a service get access to component's template
- How to get data on chart based on selected date (Filtering data Chart JS with datepicker)
- chartjs data isn't passing to django webpage
- Angular Chartjs How to make it reactive to data change?
- How to add font family to Chart.js V3.7.0
- Hide all labels and tooltips in Chart.js and make it very small size
- Change time format in Chart.js date
- how to show labels in laravel charts when the name of the label is on another table?
- Get position in array element
- Is it possible to combine two Y axes into a single tooltip with ChartJS 2?
- Tooltip does not appear
- How to use chartjs-plugin-trendline with react-chartjs-2
- Disable Charts.js animations in Polymer?
- setInterval on myDoughnut animation
- How to dynamically link json data to chart.js
- Angular js pie chart styling