score:2
First at all, you should upgrade to the most stable version of Chart.js, which currently is v2.9.4.
The dataset
accepts number of properties, that can be defined for styling the border. Its color and width are controlled through the following ones.
borderColor
arc border colorborderWidth
arc border width (in pixels).
In order to see a shadow, you can use the Plugin Core API. The API offers a range of hooks that may be used for performing custom code. In the beforeDraw
for example, you can draw a circle with shadow through CanvasRenderingContext2D.arc()
.
Please take a look at your amended code below and see how it works.
new Chart('canvas', {
type: 'pie',
plugins: [{
beforeDraw: chart => {
var ctx = chart.chart.ctx;
ctx.save();
ctx.beginPath();
ctx.fillStyle = 'white';
ctx.shadowColor = 'black';
ctx.shadowBlur = 20;
ctx.shadowOffsetX = -10;
ctx.shadowOffsetY = 0;
const x = chart.chart.width / 2;
const y = chart.chart.height / 2 + 15;
ctx.arc(x, y, 95, 0, Math.PI*2, false);
ctx.fill();
ctx.restore();
}
}],
data: {
labels: ['Dr. John', 'Alex', 'Other'],
datasets: [{
data: [923864, 720988, 179539],
backgroundColor: ['#58508d', '#3292b0', 'orange'],
hoverBackgroundColor: ['#003f5c', '#6fefff', 'darkblue'],
borderWidth: 0
}],
},
options: {
responsive: false,
layout: {
padding: {
top: 15,
bottom: 20
}
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"></script>
<canvas id="canvas" height="260"></canvas>
Source: stackoverflow.com
Related Query
- How to style a pie chart in chart js? I want to change the border color, border width and give them shadow
- How to change color by clicking on the chart bar?
- How can I change the cursor on pie chart segment hover in ChartJS 3?
- Is there a way to give a pie chart in chart.js a different color outer border than the border color between segments?
- How can I remove the white border from Chart.js pie chart when all legends are hidden?
- Change the color of displayed values in pie chart
- How set color family to pie chart in chart.js
- chartjs datalabels change font and color of text displaying inside pie chart
- How to change the color of Chart.js points depending on the label
- How to change the color of legend in chartjs and be able to add one more legend?
- How do I change the 'months' language displayed on the date axis in Chart JS?
- How to change cursor style to pointer on hovering over points of the chart?
- Angular 8 & ChartJs change color in pie chart
- ChartJs - Pie Chart - how to remove labels that are on the pie chart
- How to change the label color in chart.js?
- How to use segment property to color line / border color based on value in chart js?
- How to change the label and grid line position on a timeseries chart in Chart.js 3?
- How to change color of column in chart js
- How to use set the color for each bar in a bar chart using chartjs?
- angular-chart.js doughnut chart : How do I change width of the arc of a doughnut?
- Change the background color of tooltip dynamically using chart color
- How to change the chart line or area colors according to the user need?
- How to change background color of labels in line chart from chart.js?
- Change the style of the border in ChartJS
- Chart JS, ng2-Charts - How to make the label to the right of pie chart instead on top?
- Chartjs - how to change the notation of doughnut chart
- How can I remove the white border from Chart.js V2.6.0 pie chart?
- In ChartJS how do I change the color of a label in the legend?
- How to change the color of the bar in barchart if the data is negative - Angular Charts
- Chart.Js : How to change the color of a point, based on a third data
More Query from same tag
- Avoid data resetting when toggling series
- Chart.js padding not working for ScaleLabel
- Chart.js pie chart in table shows weird behavior on page resize
- Chartjs not working with d3 from csv source
- Who knows why I can't plot my chart properly?
- Chartjs unexpected visual animation effect when adding data
- Chart.js pie chart not showing in Google Chrome canvas
- Data Visualization DataTables.js using chart.js
- Rendering charts using local Chart.js in overriding Django templates
- How to install Chart.js in Laravel?
- Chart.js data goes backwards when retroactively pushing datapoint from HTTP request using Angular
- Change the background color of tooltip dynamically using chart color
- Chart.js - Bar values showing on the middle of bar
- charts.js not loading in Django
- chartjs loading data from ajax doesn't work fine
- charts.js won't show legend and on chart descriptions
- How to Import Angular Chart in IONIC
- Why ChartJs is not working in IE
- Floating clone does not show in chrome if dragged element contains a chartjs component
- chart is not getting updated from the values it received from Jquery
- Chart.js letter spacing very awkward
- Prime NG Customise tool tip on Bar Chart
- Dynamic chart codeigniter
- React-chart does not render the legend for PIE chart
- ng2-charts: How to set fixed range for y axis
- Small value in doughnut chart is not visible - Chartjs
- How to realize a discontinuous section (jumps) in a continuous line plot with Chart.js?
- how to remove odd number from yaxes in chartjs using angular?
- Chart.js drawing only in the top of canvas
- How to hide the labels of graphs that are not toggled in ChartJS