score:6
have 2 canvas elements and position them one over the other using css. the inner canvas has the inner doughnut and has rounded borders so that it covers up as little of the outer doughnut as possible.
preview
html
<div id="w">
<canvas id="d1" height="400" width="400"></canvas>
<canvas id="d2" height="320" width="320"></canvas>
</div>
css
#w {
position: relative;
height: 400px;
width: 400px;
}
#d1, #d2 {
position: absolute;
}
#d1 {
top: 0px;
left: 0px;
}
#d2 {
border-radius: 150px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
fiddle - https://jsfiddle.net/rhlxawt5/
at this point we have a reasonably decent looking pie chart with non overlapping doughnuts, however our tooltips will get clipped off because they are still part of their respective canvases.
we can work around this by writing a customtooltips function to use a div instead of drawing a rectangle within the canvas.
fiddle - https://jsfiddle.net/rca0ync3/
score:6
you can use multiple datasets, checkout the chart js demo page:
http://www.chartjs.org/samples/latest/charts/doughnut.html
also, here is an example with multiple datasets and multiple labels too:
https://jsfiddle.net/moe2ggrd/1/
the important part:
...
var mychart = new chart(ctx, {
type: 'doughnut',
data: {
labels: ["green", "yellow", "red", "purple", "blue"],
datasets: [{
data: [1, 2, 3, 4, 5],
backgroundcolor: [
'green',
'yellow',
'red',
'purple',
'blue',
],
labels: [
'green',
'yellow',
'red',
'purple',
'blue',
]
}, {
data: [6, 7, 8],
backgroundcolor: [
'black',
'grey',
'lightgrey'
],
labels: [
'black',
'grey',
'lightgrey'
],
}, ]
},
...
hope it helps someone who's trying to do the same thing.
Source: stackoverflow.com
Related Query
- Chart.js - Multiple Doughnut Charts on same Canvas
- Chart.js doughnut and pie chart at same canvas mixed
- Pie chart inside doughnut on same canvas
- how to not repeat code while creating multiple charts in chart js
- Chart.js multiple doughnut charts above pie chart
- Chart JS show multiple data points for the same label
- Multiple charts on same page not working - ng2-charts
- Vue Chart 3 - Doughnut Charts with Text in the Middle (Trouble registering a plugin)
- How can I load multiple Chartjs charts with different data on the same page?
- Chart.js creating multiple Charts in Angular in same Component
- ChartJs - Round borders on a doughnut chart with multiple datasets
- Chart.js -> line chart -> multiple points with the same X
- Multiple Charts of the Same Type in ChartJS2 ReactJS - Buggy Tooltips
- charts js, doughnut chart not rendering tooptips correctly
- Chart.js 3.5: linear gradient doesn't apply properly when multiple bars in the same chart
- Ionic using multiple chart.js canvas in the same page
- React with chart js, labelling problems in multiple datasets for doughnut chart
- show multiple responsive chart in the same page using chart.js
- Chart js pie or doughnut charts 3 inside instead of 1
- How to show Nested charts Radar chart within Doughnut Chart?
- Charts JS: Doughnut chart and hiding tooltip for specific data index within each dataset
- multiple charts js in page but with same tooltips (about last chart)
- Chart js update multiple charts
- Trying to get multiple chart.js charts to load on the same page
- Want to multiple charts on same page with different data
- generate multiple charts via loop for chart js
- Representing multiple subsections within a section of a doughnut chart Chart.js
- multiple horizontal bar charts to display in same row
- Chart.js canvas resize of pie / doughnut chart
- Is there a way to style multiple borders on Doughnut chart with Chart.js library?
More Query from same tag
- ChartJs Force scatter plot to be square shaped
- Chartjs: How to create padding between ticks and scale label
- Vertical align bar chart from chart.js not working
- Charts js. How to pass datasets use a select dropdown by angular instead jquery
- Displaying two values in tooltip using chart.js
- Chart Js Data transformation using Javascript
- Chart.js | Trouble refreshing line chart with "setInterval"
- How do I change the colour of a Chart.js line when drawn above/below an arbitary value?
- Angular2 ng2-chart customizations?
- CakePhp3 - Showing values on ChartJs
- Chartjs initial animation want to change from left to right (default it is bottom to top)
- Chartjs columns does not appear by value
- Adding responsive text inside chart in Charts Js
- Getting TypeError: (intermediate value).Bar is not a function with react and chart.js
- How can I display desired/particular chart in App.vue from Charts.vue which contains different charts in Vuejs
- New Chart.js Chart onclick
- how to dynamicly change the json data in chartjs
- Update ChartJS line chart from DynamoDB query
- Angular-Chart.js it doesn't display the chart
- How to change the Y-axis values from numbers to strings in Chart.js?
- Legend not displaying on Line or Bar chart - React-Chartjs-2
- Chart bundle js is not showing dynamic data
- Passing data from Python to JavaScript to plot Chart.js
- charts.js stacked bar with polymer's wrapper chart-elements
- ChartJS Horizontal Bar is displaying backwards
- Moving vertical line when hovering over the chart using chart.js
- Angular: How to change color of chartjs?
- display data on chart.s
- Testing Chart.js Plugin with React and Jest/Enzyme
- Chart.js Box Annotations Fill Entire Chart