score:13
Accepted answer
in the chart options, you can use the tooltips callback to customize the tooltip.
here, the % sign is added to the standard tooltip text...
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
return data['labels'][tooltipItem['index']] + ': ' + data['datasets'][0]['data'][tooltipItem['index']] + '%';
}
}
}
see following working snippet...
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: ['confirmed', 'pending'],
datasets: [{
data: [67, 33],
backgroundColor: [
'rgba(41, 121, 255, 1)',
'rgba(38, 198, 218, 1)',
'rgba(138, 178, 248, 1)',
'rgba(255, 100, 200, 1)',
'rgba(116, 96, 238, 1)',
'rgba(215, 119, 74, 1)',
'rgba(173, 92, 210, 1)',
'rgba(255, 159, 64, 1)',
'rgba(247, 247, 247, 1)',
'rgba(227, 247, 227, 1)',
],
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
cutoutPercentage: 80,
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
return data['labels'][tooltipItem['index']] + ': ' + data['datasets'][0]['data'][tooltipItem['index']] + '%';
}
}
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
<canvas id="myChart"></canvas>
Source: stackoverflow.com
Related Query
- How to show percentage (%) in chart js
- How to show percentage (%) using chartjs-plugin-labels ( Pie chart ) in angular 2/8
- Chart.js how to show cursor pointer for labels & legends in line chart
- chart js tooltip how to control the data that show
- PrimeNg bar chart how to show a label for the y-axis
- How to show data values in top of bar chart and line chart in chart.js 3
- Chart.js - How to show loading animation before plotting chart
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- Angular chart how to show the legend data value by default along with legend name
- ChartJS version 3 how to add percentage to pie chart tooltip
- How to show gradient vertically on chart js grouped bar chart?
- How to show different product name for every bar in chart js
- angular-chart.js : how to show numbers in each bar of stacked bar chart
- Chart.js: How to get x-axis labels to show on top of bars in bar chart
- how to add percentage value to legend field in pie chart using chart.js
- How to show slice value inside of slice in pie chart using chart.js
- How to plot chart from external JSON and format X-AXIS to show time using Chart.JS?
- How to show multiple datasets in line chart js
- How to show tooltip value of all data falling on the same axis in chart js?
- How to show the chartjs bar chart data values labels as text?
- how to reduce list chart to one and use select dropdown to show selection without refresh page?
- How to show Nested charts Radar chart within Doughnut Chart?
- how to show speedometer on Doughnut chart in chart.js using reactjs
- ChartJS Pie Chart How default just show 2 legend datas
- how can i show labels and value in both on bar chart
- How to show tooltip only when data available in chart js?
- How to print a chart rendered by code
- Chart Piechart in only show percentage on hover but it shows data and label with percentage both i just want to show percentage only percentage
- How to show text as a series on a chart in Javascript?
- Char.js - How to show labels by default in pie chart
More Query from same tag
- How to change axis font in PrimeFaces and Chart.js
- Multiple charts in one page with chart.js
- ChartJs Scatter with Bars
- PrimeNg bar chart how to show a label for the y-axis
- Dropdown component not having effect in Chromium browser
- Creating a Normal Distribution graph with Chart.js
- Chart.js line chart is not displaying
- How to remove transparency from images downloaded in Chart.js
- How can I make small grid lines above ChartJS labels?
- How do I place 2 <div>s side by side
- How to display data by current month and display no data message if data not exists
- ChartJS vector maps
- Getting nice chart.js animation when adding data with unshift()?
- Chart.js barchart custom on hover method
- Custom empty screen for ng2-charts
- ChartJS: how to change data in hover box?
- React - How can I pass API data from one component to another in a different js file?
- make chartjs legend labels tabbable
- Why prettier put a comma ',' at the last element of the object
- Chart.js label on bar
- How to remove numbering on PolarArea circles?
- Chart.js legend position error
- How to pass data in Laravel with Chart.js
- How to select and pass array object to data setting of chart.js config?
- Chartjs disable legend click does not work when condition is not evaluated
- chart.js mix chart (bar + line): get lines to start at x = 0
- Bar chart not starting at 0
- How does one represent multiple threads in a structure/flowchart
- How can I pass my sqlite data to django, and make chart?
- Weird time formating with chart.js and moment.js