score:1
Accepted answer
i finally got it to work with version 2.x. i basically flattened the heirarchical data structure and padded the multiple dataset arrays with zeros. below is the code that will give you two layer doughnut chart with the second layer showing the split of the first layer section.
public summarytreechartlabels: label[] = ['asdf', 'sdgf', 'dfhg', 'asdf_1', 'asdf_2', 'sdgf_1', 'sdgf_2', 'dfgh_1', 'dfgh_2'];
public summarytreechartdata = [[34, 50, 26, 0,0,0,0,0,0], [0,0,0, 14, 20, 30, 20, 10, 16]];
public summarytreecharttype: charttype = 'doughnut';
score:0
you can use object notation for this together with a custom tooltip label callback:
var options = {
type: 'doughnut',
data: {
datasets: [{
label: '# of votes',
data: [{
id: 'parent1',
key: 55
}, {
id: 'parent2',
key: 55
}, {
id: 'parent3',
key: 30
}],
borderwidth: 1,
},
{
label: '# of points',
data: [{
id: 'child1',
key: 55
}, {
id: 'child2',
key: 55
}, {
id: 'child3',
key: 30
}, {
id: 'child4',
key: 55
}, {
id: 'child5',
key: 55
}, {
id: 'child6',
key: 30
}],
borderwidth: 1
}
]
},
options: {
plugins: {
tooltip: {
callbacks: {
label: (ttitem) => (`${ttitem.raw.id}: ${ttitem.raw.key}`)
}
}
},
parsing: {
key: 'key'
}
}
}
var ctx = document.getelementbyid('chartjscontainer').getcontext('2d');
new chart(ctx, options);
<body>
<canvas id="chartjscontainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/3.6.0/chart.js"></script>
</body>
Source: stackoverflow.com
Related Query
- ng2-charts doughnut chart with different data per series
- 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?
- Doughnut Chart not displaying data with Chart Js and Backbone js
- Doughnut chart updates with twice the data
- How to reuse a Chartjs Chart component in with different Data and get past the **Canvas is already in use** error?
- Charts JS: Doughnut chart and hiding tooltip for specific data index within each dataset
- ng2 charts bar chart need spacing between 2 bars in series Angular
- Want to multiple charts on same page with different data
- How write the labels of the data inside a Doughnut Chart made with Chart.js?
- Two data sets with different time instances on the same ChartJs chart
- Chart.js - creating time series freqency chart with JSON data
- Having different colors per bar with angular charts chart.js v2
- getting additional value fields from data source for dx.chartjs doughnut chart
- Chart changes different on zoom when using multiple charts with chart.js and flask
- Grouped bar chart having each group with different data using chart.js
- Charts with previous data appear when hovering the cursor over the chart in Chart.js
- multiple chartjs charts with the same configuration but different data
- chart.js mixed chart with different data points
- How can I build some chart with Chart.js and ng2-charts using an array of revenus & budgets per month date as Data source?
- Drawing chart with Chart.js filled with data gotten per JsonRPC
- ChartJS - Different color per data point
- Chartjs random colors for each part of pie chart with data dynamically from database
- ChartJS - Draw chart with label by month, data by day
- line chart with {x, y} point data displays only 2 values
- Chart.js Mixed Bar and Line chart with different scales
- chart.js Line chart with different background colors for each section
- Chart.js - Line charts with different colors for each border lines
- ChartJS - Line Chart with different size datasets
- How to display data labels outside in pie chart with lines in ionic
More Query from same tag
- Make pie chart smaller Chart JS
- Calling MouseLeave chartJs Angular
- How to force animation on chartjs?
- Django admin/ Chart js error - super() takes at least 1 argument (0 given)
- update chart data called through ajax via PHP, MySQL
- js devexpress PieChart Series color runtime
- Chartjs line chart gets all scrambled up when an x value coincides with a label
- Chart js always show labels on a doughnut chart
- pie chart label undefined ionic 3
- chartjs add dots to bars in grouped bar chart
- undefined labels piechart - chartjs
- Chart.js v3 - beginAtZero does nothing to my chart
- chart.js responsive bar chart label sizing
- How to install Chart.js in Laravel? ("Uncaught ReferenceError: Chart is not defined")
- How to remove strikethrough from label once click on legend
- Charts js only showing 2 data points on sparkline
- How to render data using chartjs in expressJS
- Create chart using one of the given javascript libraries
- Using ticks 'major' with Chart.js is overlapping with an unknown text
- Chart.js scale which increases by x (arbitary number) for each tick
- ChartJS not showing data for time series bar chart
- Gradient line chart with ChartJS
- Chart Js Show the old data on mouse hover
- Show values in Chart.js Pie chart parts
- chart js tooltip how to control the data that show
- how to show speedometer on Doughnut chart in chart.js using reactjs
- How to display data from database into line graph using php and mysql?
- How to convert (convas chart) to either (Chart , or system.drawing.image , or stream , or []byte ) where I can use it in c# to generate pdf
- Array value is not being passed to the plugin
- How to use chartjs-plugin-datalabels for specific charts using vue-chart.js