score:2
Accepted answer
plugins.datalabels.formatter
should be set to a function. You are setting it to an object. Change your definition so it doesn't include the leading {
and trailing }
:
var datalabels_format_sanssymb = function (value) {
if (value >= 1000000000 || value <= -1000000000) {
return (value / 1000000000).toFixed(1).replace(/\.0$/, '');
}
if (value >= 1000000 || value <= -1000000) {
return (value / 1000000).toFixed(1).replace(/\.0$/, '');
}
if (value >= 1000 || value <= -1000) {
return (value / 1000).toFixed(1).replace(/\.0$/, '');
}
return value;
}
See the plugin documentation for examples.
Source: stackoverflow.com
Related Query
- How to create a variable for chart js datalabel plugin formatter
- How to create a chart that uses strings for both the X and Y axes?
- How to create dynamically chart for Ionic App with Firebase data?
- How to create an array of objects dynamically in javascript for a pie chart
- How do you get the width of a datalabel from the Chartjs plugin after the chart animates?
- Chart.js how to create chart wirhout y-axis for two data sets
- how can i use inline plugin inner title for chart js?
- How to mapping variable data for pie chart (react.js)
- how to create bar chart with group and sam color for each group using chart.js?
- How can labels/legends be added for all chart types in chart.js (chartjs.org)?
- How can I create a horizontal scrolling Chart.js line chart with a locked y axis?
- How to create rounded bars for Bar Chart.js v2?
- Chart.js how to show cursor pointer for labels & legends in line chart
- How to create datasets dynamically for chart.js Line chart?
- How to add second Y-axis for Bar and Line chart in Chart.js?
- How to create stacked bar chart using react-chartjs-2?
- Chart js. How to change font styles for "labels" array?
- How to access labels array using chart plugin (Chart.pluginService.register) in Chartjs 2.x?
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How to create a gradient fill line chart in latest Chart JS version (3.3.2)?
- How to create single value Doughnut or Pie chart using Chart.js?
- how to create multiple chart on one component vue
- How to use 'time' (data from database, data type: timestamp ) for plotting graph in Chart JS
- (Vue, ChartJS) Create gradient background for chart from child component canvas context
- How do I obtain a Chart instance for Chart.js
- how to set chart.js grid color for line chart
- PrimeNg bar chart how to show a label for the y-axis
- How can I create custom tooltips for each data point in a graph?
- How to create a gantt chart using Chart.js and populate dates?
- How to add label in chart.js for polar chart area
More Query from same tag
- Chart.js - draw horizontal line
- Change List<Object> into List<List<int>> using LINQ
- How to Integrate Chart.Funnel.js in Chart.js
- In chartjs, add link text on tooltip
- Bar animations in 2.0.0-beta/dev are not working for me
- Bar chart with two sets of labels in Quickchart
- How to group and count missing values using linq
- Convert/transpose one array into another in JavaScript?
- How to inject "Chart.js" in my module?
- Chart.js always visible labels
- How to fix page layout with embedded frame
- change white cell border color in chart.js
- How to add image to chart.js tooltip?
- want to provide a space between the maximum value and the graph
- chartjs not following height when parent's height is 200px
- Angular-Chart.js chart doesn't shown, if data added automatically
- chart.js: Show labels outside pie chart
- Multiples values in yAxes with same xAxes
- Time scale with single object - bar isn't centered (chart.js)
- Chart JS in React doesn't fetch data
- Chart.js hiding lable
- Resizing chart issue with CSS Grid
- Chart.js add icon at the top of bar
- How do I change the grid line style on the Y axis in Chart.js?
- How to display pie slice data and tooltip together using chart.js
- How to change the display of an axis Chart.js
- Chart Js - Limit points on graph without limiting data
- Scatter plot not showing anything chartjs needs some debugging
- Pie Charts JS: How to set units?
- Update of options for PrimeNG Chart needs two calls instead of one