score:2
Accepted answer
using chart.js, you can set the background color of a pie chart with the backgroundcolor
attribute:
{
type: 'pie',
data: {
labels: ['high', 'medium', 'low'],
datasets: [{
data: [50, 60, 70],
backgroundcolor: ['#4e73df', '#0f3dc4', '#9fb4f3']
}]
}
}
additionally, you may want to change the color of the labels using the datalabels
plugin:
{
type: 'pie',
data: {
labels: ['high', 'medium', 'low'],
datasets: [{
data: [50, 60, 70],
backgroundcolor: ['#4e73df', '#0f3dc4', '#9fb4f3']
}]
},
options: {
plugins: {
datalabels: {
color: '#fff'
}
}
}
}
pack it into the chart url:
and it will look like this:
Source: stackoverflow.com
Related Query
- setting QuickCharts color
- Chart.js tooltip background color setting
- Setting specific color per label in chart.js
- Setting Common labels and background color common for all the charts in ChartJs
- How to generate color code dynamically by swapping 2 characters within a string using PHP
- Trouble with setting background color for Line chart at Chartjs version 3.5.1
- How to run Chart.js samples using source code
- Setting width and height
- Different color for each bar in a bar chart; ChartJS
- ChartJS Line Charts - remove color underneath lines
- Chart.js label color
- Chartjs change grid line color
- Chart area background color chartjs
- ChartJS - Different color per data point
- Chart.js - add gradient instead of solid color - implementing solution
- Change X and Y axis font color
- Change color of X and Y axis values in Chart.js
- How set color family to pie chart in chart.js
- Can't change color line with chart.js
- Chart.js line chart set background color
- Chart.js Text color
- chartjs datalabels change font and color of text displaying inside pie chart
- Chart.js change color of Bar
- Chart.js Line, different fill color for negative point
- Chart.js setting maximum bar size of bar chart
- Can I set different fill color based on a given threshold in Chart.js?
- Change point size and color on hover in chartjs
- Chart.js bar chart : Grid color and hide label
- Change point color on click using ChartJS
- Unable to parse color in line chart (angular-chart.js)
More Query from same tag
- Blazor ChartJs: Expanding bar to the end of the canvas
- How do I fix over limit y axis value in ChartJS
- Unable to clone a Chart.js chart in a pop up
- Remove Angularjs-Chart border and reduce chart arc thickness
- chart.js and asynchronous loading
- How to apply to different bground color for each area in Chart.js
- how to group the chart
- Adding images/icons to specific coordinates in chart.js
- Bubbling mouse event to parent canvas that is of chart.js
- How should i apply date picker in my chart
- Can I color the first bar in "Bart Char" differently?
- How to create a chart that uses strings for both the X and Y axes?
- Chart.js modal window
- Canvas displays initially in Chrome but not in Firefox
- Convert this canvasjs chart to chart.js chart
- ChartJS Datalabels plugin and negative numbers
- Chart.js multicolored fill sections
- Chart.js reset zoom button
- Overlay Line on chart.js Graph
- Datalabels not showing on Chart.js
- Can't increase font size in google bar chart
- How to pass variable (list) to JavaScript in Django?
- Change data onclick with ChartJS
- Django ValueError The view todo_lists.views.visualisation didn't return an HttpResponse object. It returned None instead
- How to get access to Chart instance related to current tooltip callback in Chart.js
- Chartjs, plot data based with unequal time intervals
- In Chart.js >3.0, on axis of type time, how to show labels and ticks only for existing data points (make labels reflect data)?
- Why chart renders after second click - react-chartjs-2
- Change point size and color on hover in chartjs
- ChartJS 2.6 - Bar chart fixed height scrollable-X