score:6
Accepted answer
You can switch out the colors array with a doubly-linked list.
Or just use an anonymous function on the object creation,
datasets: [{backgroundColor: (() => {
let bgcolors = [];
for (let i=0; i < tickers.length; ++i) bgcolors.push(colors[i % colors.length]);
return bgcolors;
})()
}]
Source: stackoverflow.com
Related Query
- Cycle through finite set of colours for indefinite set of data in Javascript
- Set custom colours for tooltip squares Chart.js
- How to set min max for x axis depend on data with Chartjs and Spring Boot?
- How to set prop data for chart.js in React?
- How can I set different colours for each bar in angular-chart.js v1.0.0?
- Two chart for the same set of data - Chart.js
- javascript chart library for every minutes data
- getting additional value fields from data source for dx.chartjs doughnut chart
- How to set php data to chart.js for creating graph?
- Use Google Spreadsheet as data source for Chart.js
- How to set max and min value for Y axis
- JavaScript Chart.js - Custom data formatting to display on tooltip
- Chartjs random colors for each part of pie chart with data dynamically from database
- How to change colours for Angular-Chart.js
- Chart.js - Hover labels to display data for all data points on x-axis
- Chartjs v2 - format tooltip for multiple data sets (bar and line)
- How to set default colour for bars in Chart.js
- Chart.js: only show labels on x-axis for data points
- ng2-charts: How to set fixed range for y axis
- Chart JS - set start of week for x axis time series
- Chart JS show multiple data points for the same label
- Move tooltip further from data point for Chart.js?
- dump missing date in data for chartjs
- Chartjs - data format for bar chart with multi-level x-axes
- Dashed line for missing data in Chart.JS (spanGaps style)
- Is it possible to set up 0 as a minimum number for bar chart? react-chart.js-2
- ChartJS bar not showing up for simple data points
- Chartjs 2.7.3: Set Y data at the correct X position axis
- How to use 'time' (data from database, data type: timestamp ) for plotting graph in Chart JS
- How to set a full length background color for each bar in chartjs bar
More Query from same tag
- Different labels in tooltip with chartjs
- Boxplot chartjs make min and max dynamic by leaving some space on both side
- Vuechart js not rendering on a component
- Chartjs v2.8 showAllTooltips does not exist
- Adding data to Chart.js line graph from array
- How to pass a array from node to .js file (pugJs)
- Chart.JS Time Axis Not Parsing
- How to display value after the bar using chart.js
- Dynamically Setting Height of Chart
- Chart.js 3.x custom positioners: cannot use them in TypeScript
- NuxtJS ChartJS Gradient Color doesnt apply
- Chart.JS Global Options
- how to use alpha vantage api in Instead list in chartjs?
- Custom label from using separate array in Chart JS
- Charts.js line chart: Show the most recent date on x-axis when setting ticks.maxTicksLimit
- chartJSRadar downloadhandler creating empty png
- How to avoid detached HTMLCanvasElements when updating canvas with JavaScript?
- yAxis control for stacked bar chart
- Chart.js get array of currently visible points on graph
- How can I change the color of certain lines in chartjs / vue-chartjs?
- React Js and Chart Js (Line Chart)
- Chart.JS how to change order of y-axis
- Charts not being displayed in django app when using Chart.js 3.6 version
- how to hide tick labels on chartjs/vue-chartjs
- Using vue-charts.js, I cannot get hoverOffset to work with doughnut
- How to manipulate data in react-chartjs-2
- Chart.js 2.2.1 - Chart doesn't render correctly before resizing
- ChartJS Line chart causes browser crash
- Chart Data Not Updating for Both Graphs?
- How to put indicator between yAxis values on yAxis chartJs?