score:-1
this is from github:
You could add a personalized callback to the tooltip labels, where you round the values e.g.
1 - tooltipItem.yLabel.toFixed(2) would return a value with 2 decimal places.
2.123.toFixed(2)
>> "2.12"
2.0001.toFixed(2)
>> "2.00"
2- Math.round(tooltipItem.yLabel * 100) / 100 would return a value rounded to the nearest 2nd decimal place.
Math.round(2.123 * 100) / 100
>> 2.12
Math.round(2.00001 * 100) / 100
>> 2
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
var label = data.datasets[tooltipItem.datasetIndex].label || '';
if (label) {
label += ': ';
}
label += tooltipItem.yLabel.toFixed(2);
return label;
}
}
}
Source: stackoverflow.com
Related Query
- Editing Chart.js legend template
- chart js legend template
- Chart.js - Increase spacing between legend and chart
- Pie Chart Legend - Chart.js
- Chartjs Bar Chart Legend
- chart js how to fill legend box with colour
- ChartJS bar chart with legend which corresponds to each bar
- Chart.js HTML custom legend issues with doughnut chart
- Chart js: how can I align the legend and the title
- Increase padding between legend and chart with react-chartjs-2
- Chart,js Pie Chart can the gap between a pie chart and the legend be adjusted
- Chart.js Radar chart legend label font size doesn't work
- Using Chart.js - Creating Legend for Doughnut Chart
- Chart.js . ASP . Legend Template
- Angular chart how to show the legend data value by default along with legend name
- Chart.js: Pie chart legend "onclick" gets overwritten by "options.onclick" if both are present
- Chart JS Legend Styling
- Chart.js chart onclick disables legend onclick
- chartjs Adding percentages to Pie Chart Legend
- Chart Js update legend boxes of graph with graph line style
- ChartJS horizontal chart display legend on each bar
- How do I change axis, title, legend formatting on chartjs template
- React chartjs-2 - Increase spacing between legend and chart
- how to add percentage value to legend field in pie chart using chart.js
- how to add legend in pie chart
- Legend not displaying on Line or Bar chart - React-Chartjs-2
- Removing legend from chart.js Radar chart
- Increase space between legend and chart
- Highlight chart element when hovering over its corresponding legend Item
- Chart.js - Pie chart calculate sum of visible values after legend click
More Query from same tag
- (Lifecycle problem?) React Chart js-2 not updating data from componentDidMount
- Put sum of values in center of doughnut chart?
- How to add a vertical line on the end of the chart.js scatter graph
- ChartJS rotate 90' but keep text straight
- ChartJS New Lines '\n' in X axis Labels or Displaying More Information Around Chart or Tooltip with ChartJS V2
- Set minimum number of steps in line chart
- Why is borderColor function in chartjs running multiple times, and how to reduce it?
- Responsive Chart.js Doughnut Chart with minimum height
- How to improve PDF rasterization quality in PhantomJS?
- Minimum value for x Axis doesn't work for horizontal bar chart | ChartJS
- Graph is not displayed
- how to set title in legend of chart.js?
- Chat.js, Codeigniter and MySQL. Something wrong on recover data
- ChartJS and Flask, how to pass data?
- Chart disappears, when pressing the submit button
- undefined labels piechart - chartjs
- ChartJs how to get from mulitiple dateset which dataset bar is clicked
- How to pass a nested function to an HTML button and Dropdown menu
- ChartJS 3+ x-axis only showing full moment object instead of just month
- Vuejs - Chartjs doesn't render my own options with api request
- Chartjs tick color different at zero
- How to Find the Sum of items Per Year Using Chart Js
- Barchart reducing space between bars
- Parsing JSON data into specific format for chart.js
- Horizontal bar with two yaxes chart js
- How to increase space between label and chart area in chart.js
- In react hooks, how can i pass the filtered values to the chart?
- ChartJS not displaying time data using Moment.js
- chart.js - Pie Chart doesn't display all data
- How to display that data was unavaible during some time in a Chart.js (or any other library's) timeline graph