score:0
The reason is that you define backgroundColor
at the wrong place. It's a dataset property, hence needs to be defined inside the dataset
.
var distinctFeeEarners = ['MEH', 'IHM'];
var totalHoursByFE = [0.8, 0.7];
var chartdata = {
labels: distinctFeeEarners,
datasets: [{
label: 'Fee Earner',
data: totalHoursByFE,
backgroundColor: ['rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)']
}]
};
var donutChart = new Chart(document.getElementById('hoursFEContainer'), {
type: 'doughnut',
data: chartdata
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<div id="chartContainer" style="height: 320px; width: 320px">
<canvas id="hoursFEContainer"></canvas>
</div>
score:0
Had exactly the same problem with ng2-charts
What did it for me was not pre-initializing dataset. Prevously i would declare empty array
public data: MultiDataSet = [];
then after backend request resolves i would assign new value
const dataset: Array<number> = new Array();
response.items.map(result => {
dataset.push(result);
});
this.data = [dataset];
This would print doughnut chart but without color. Everything was gray. Simply not preinitializing MultiDataSet like this fixes things
public data: MultiDataSet; //=[];
Source: stackoverflow.com
Related Query
- Chart.js donut chart remains grey - no color
- Chart area background color chartjs
- How set color family to pie chart in chart.js
- Chart.js line chart set background color
- chartjs datalabels change font and color of text displaying inside pie chart
- Chart.js bar chart : Grid color and hide label
- Unable to parse color in line chart (angular-chart.js)
- set background color to save canvas chart
- Different color for each column in angular-chartjs bar chart
- Chart looks only grey, does not show the color - Chartjs,discordjs
- angular-chart.js bar chart with 100% opacity color
- Angular 2 ng2-charts donut change segment color
- how to set chart.js grid color for line chart
- chart js - Apply different color for each x-axes label
- Chartjs doughnut chart with gradient color
- chart.js bar chart color change based on value
- Angular 8 & ChartJs change color in pie chart
- Chart.js - Color specific parts of the background in a line chart
- Chart.js different scaleLine color of radar chart (angular)
- How to set single color on each bar in angular chart js
- charts.js layered donut pie chart
- How to draw a needle on a custom donut chart and add datapoints to the needle?
- Use transparent stroke color with chartjs pie chart
- How to add an image to a slice of a donut chart in chart.js?
- Apply color only to lower part of Chart.js line chart
- How to add area with break on line chart with fill color
- Chartjs - Donut Chart label for small values not visible
- how to add FAHRENHEIT symbol in chart js donut chart
- Change Axis Line color in Chart created using chart.js
- How to use segment property to color line / border color based on value in chart js?
More Query from same tag
- Text in center of chartJS lead to infiniteloop
- Get data from SQLite as an array and generate charts with the data using Chart.js in an HTML
- How to add vertical line in bar chart using chartJs and ng2-charts?
- Is there any way I can customize my chartjs
- Ionic: Doughnut Chart's legend occupies complete card in mobile, while on big screen chart and legend looks fine
- Padding Between Pie Charts in chart js
- Combine multiple columns values to one label in chart.js
- How do I change the 'months' language displayed on the date axis in Chart JS?
- Chart js Backgroundimage Scaling
- line chart with {x, y} point data displays only 2 values
- React-Chart-JS-2 ^3.0.5 | TypeError: Cannot read properties of undefined (reading 'visible') at Chart._getSortedDatasetMetas
- Chart.js - How To Show Value of Label as Percent of X and Y Values - Currently Always 100%
- How can I force my ChartJS canvas legend to stay in a single column?
- Javascript - How to Transform MiB to GB
- ChartJS not working in Vue
- Chart.js only appears randomly, and disappears on page refresh
- chart.js onClick event function, access angular component
- ChartJS tooltip when having multiple lines on a time graph
- chart.js modify style from dataset label
- How to create float charts with chartjs?
- How do I remove CSS code arriving in my webpage?
- Chart.js zoom start at zoomed in
- While placing chart.js Doughnut Chart inside Primeng Carousel, the text inside the canvas seems blurred/distorted a little bit
- How to set the number of of rows in a line chart in chart.js?
- chart.js show time in series
- Chartjs + jsPDF = Blurry image
- How to draw lines between minimum and maximum value to average value in chartJS?
- Remove top horizontal line in a horizontal bar chart (Chart.js 2)
- ChartJS scatterplot multi-line tooltip, one box
- How to show a "total" sum label on the top of stacked bars