How to have actual values in matplotlib Pie Chart displayed

Using the autopct keyword As we know that the percentage shown times the sum of all actual values must be the actual value, we can define this as a function and supply this function to plt.pie using the autopct keyword. import matplotlib.pyplot as plt import numpy labels=”Frogs”, ‘Hogs’, ‘Dogs’ sizes = numpy.array([5860, 677, 3200]) colors … Read more

Chart.js v2: How to make tooltips always appear on pie chart?

Solution for ChartJs Version > 2.1.5: Chart.pluginService.register({ beforeRender: function (chart) { if (chart.config.options.showAllTooltips) { // create an array of tooltips // we can’t use the chart tooltip because there is only one tooltip per chart chart.pluginTooltips = []; chart.config.data.datasets.forEach(function (dataset, i) { chart.getDatasetMeta(i).data.forEach(function (sector, j) { chart.pluginTooltips.push(new Chart.Tooltip({ _chart: chart.chart, _chartInstance: chart, _data: chart.data, _options: … Read more

jfreechart customize piechart to show absolute values and percentages

Use the MessageFormat symbol {1} for the absolute section value. See StandardPieSectionLabelGenerator for details. public class MyMinimalPieChartExample { private static final String KEY1 = “Datum 1”; public static final String KEY2 = “Datum 2”; public static void main(String[] args) { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue(KEY1, 99); dataset.setValue(KEY2, 77); JFreeChart someChart = ChartFactory.createPieChart( “Header”, dataset, … Read more