score:5
no, chartjs does not come with this option.
i guess you have two options:
if you know a maximum (ex: there won't be more than 10 values), then you can make an array with 10 colors and assign the first colors to the elements you have (ex: if you have 5 elements, assign the first 5 colors to them). you could easily randomize for example where in the array does the assignment start, to still get a different color set every time.
this method if good if you want to keep your colors to match a specific color theme.
if you do not care about a color theme, i think the easiest would be to generate the colors randomly. with this function, you can only hope to not get twice the same color (very very unlikely):
function getrandomcolor() {
var letters = '0123456789abcdef';
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[math.floor(math.random() * 16)];
}
return color;
}
console.log(getrandomcolor());
Source: stackoverflow.com
Related Query
- chart.js pie chart background colors: is there any way to generate them randomly?
- Legend color not working with randomly generated background colors in chartjs pie chart
- ChartJS – is there any way to remove blank space around pie charts?
- Is there any way to get Chiselled Effect in chart js?
- Is there a way to give a pie chart in chart.js a different color outer border than the border color between segments?
- Is there any way to remove extra space and Horizontal line from Bar chart of Chart.js?
- How to assign different background colors to chart.js pie chart data set?
- Is there any way to change the font size of labels in bar chart in Chart.js v3?
- Is there any way to show tooltip by default (without hover pie chart) on chartjs
- Is there any way to show a tooltip for points which are not visible on the chart in Chart.js?
- In ng 2 chart during the load an undefined legend gets created automatically ,Is there any way to remove it?
- Chartjs random colors for each part of pie chart with data dynamically from database
- chart.js Line chart with different background colors for each section
- Chart.js ng2-charts colors in pie chart not showing
- Chart.js v2 is there a way to draw bar chart horizontally?
- How do you set pie chart colors in angular-chart.js
- Configure Pie Chart Colors Using Chart.js and PHP
- Is there any way to use 2 different color for the same bar in a chart?
- Is there any way to change the font color and size of labels in Chartjs 3.0.0
- Is there a convenient way to print values to a JS chart from a CSV file without converting it?
- Is there any way to get y of specific x which not belongs to the dataset in Chart.js graph?
- How to style a pie chart in chart js? I want to change the border color, border width and give them shadow
- Is there any way to display float bar in chart.js?
- angular-chartJs change chart background and highlight colors
- Chart.js How to sum the values in a pie chart and display them in the header
- How to put dynamic colors for pie chart - chart js
- Is there a way to display a chart label that has no data behind it in Chart.js
- chart.js Is there way to color line chart ticks depending on value
- The colors of the bar chart in chart.js is not showing. I tried background color and fill color but none of it worked
- Chart JS - Is there a way to connect two datasets in a line chart?
More Query from same tag
- How to collect values of object properties into a list?
- Why scatter chart does not show axes?
- refresh chart data every second javascript
- React passing a variable object to setState vs. an anonymous object to setState
- Chart.js adding tooltip with cashflow
- JS Chart: do not merge duplicate x axis labels
- Is it possible in chartjs to hide certain dataset legends?
- In chart.js how can I change the x axis on my line \chart from January-December to October-September? Basically, fiscal year instead of calendar year
- Stepped Line with angular-chart.js
- chart.js version 2.4.0 does not display bars for me
- How to make dynamic chart js using JSON in Codeigniter?
- Chartjs error : time scale: "time.format" is deprecated. Please use "time.parser" instead
- Hide x-axis when it has no value on chart.js
- Define new position for tooltip in ng2-charts
- How to Add X axis Padding in chart js Line Graph
- chart.js substitute tooltipItems
- Map with pie chart and label
- How to hide labels by two ticks? chartjs
- Chart.js not displaying when including variable
- Stacked bar chart starting from 0 - ChartJS React
- ChartJS large data range
- Different color for each bar in a bar graph in ChartJS and VueJS
- Chart.js - creating time series freqency chart with JSON data
- Chart.js how to display % on tooltip
- ChartJS and Laravel5
- Chart.js ignoring canvas height & width
- Where are the default colors for charts in Chart.js defined?
- How to add chart js legends in ember?
- Chart js not display graph
- Chart.js page is zooming out everytime we change to a different graph while using a browser on with IOS El Capitan or latest iPad version