score:0
Inside the options.animation.onComplete
callback function, you draw the text using ctx.fillText(...)
. Simply don't draw the text in case the value is zero.
To do so, you should add an if
statement as follows:
if (dataset.data[i] > 0) {
ctx.fillText(dataset.data[i], model.x, model.y + (dataset.data[i] / max * ((chartHeight / 2) - 50)));
}
In case the values are defined as strings as your question could suggest, the
if
statement may have to be changed slightly (i.eif (dataset.data[i] != '0') {
).
Source: stackoverflow.com
Related Query
- Chart.Js how to hide datapoints with "0" value in Stacked Bar Chart
- How to display inline values in a stacked bar chart with Chart.js?
- How to hide value in Chart JS bar
- How do I create a stacked horizontal bar chart with Chart.js in React?
- How can I create a stacked bar chart with Charts.JS that displays relative rather than absolute values?
- ChartJs - stacked bar chart with groups - how to create second x-axis with stack id
- How to sort stacked bar chart on certain value of bar in charts.js
- Horizontal stacked bar chart with chart.js
- Vertical stacked bar chart with chart.js
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- How to create stacked bar chart using react-chartjs-2?
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- Hide empty bars in Grouped Stacked Bar Chart - chart.js
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- Stacked horizontal bar chart along total count with chart.js
- Chart.js: Minimum value for x-axis at horizontal stacked bar chart
- how to hide 0 value on Yaxis in Chart.js with negative values
- How to remove bars for those bars with zero value in Chartjs bar chart?
- In Stacked horizontal bar chart how to remove the vertical line in Chart.js?
- Angular chart how to show the legend data value by default along with legend name
- Stacked bar chart with rounded corner of bar using Chart.js
- PrimeNg bar chart how do I hide the bar labels?
- Chart.js stacked bar chart - sorting values in bar by value
- ChartJS: how to make a bar chart with a horizontal guideline:
- Chartjs 3.x - How to duplicate X axis on both sides of horizontal bar chart with only 1 dataset?
- How to create Bar chart that gets updated from new ajax requests with ChartJS?
- angular-chart.js : how to show numbers in each bar of stacked bar chart
- How do I create stacked chart with Chart.js version 2.0.0-beta
- Create stacked bar chart with a single dataset per stack
- How to set X coordinate for each bar with react chart js 2?
More Query from same tag
- Chartjs - Donut Chart label for small values not visible
- "Process is not defined" with react-chartjs-2 CDN
- annotation line not visible in scatter chart in chartjs
- Line chart using Chart.js
- chart.js random weird problems
- How do I force Chart.js axes min and max with react-chartjs-2?
- Chart.js hours scale show day switch
- chartjs chart.update() function not rendering lines in foreground
- Chart js 2.8 - How to make bars grow at the same speed?
- ng2-charts not showing charts in Angular 10
- Remove/Hide (display:none) the graphical chart in small-mobile view - JS chart
- React-chartjs-2 update height dynamically
- How to pass values to a chart (chart.js / morris.js)
- Set Tooltip over line Chartjs
- Issue with HTML2Canvas - Green overlay while exporting
- Javascript : ""Uncaught TypeError: Cannot read property 'x' of undefined"" in canvasjs.min.js
- Add shadow Chart.js
- Hiden Gridline in chart JS
- Sending data to ChartJsLineChart in ChartJs.Blazor
- Can't change the default color and font size of labels in react-chartjs-2
- Chart.js in Angular 10: Specified colors not shown in multi-series bar chart (instead random colors)
- I want to bind the legend option with checkbox(show legend or not)
- Chart.js two y axes line chart tooltip value incorrect for 2nd y axis
- Chart.js - Setting x-axis based on user input
- Data-labeling ChartJS, Removing Duplicates?
- Reference external JS method in Chart.js callback using Chartjs.ror
- Loading an external JSON into ChartJs
- how can we use function of one component into another js file
- ChartJs events in Angular
- Chartjs v7.0 with plugin zoom, strange effect when use "drag" mode.