score:404
For Chart.js 2.*, the option for the scale to begin at zero is listed under the configuration options of the linear scale. This is used for numerical data, which should most probably be the case for your y-axis. So, you need to use this:
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
A sample line chart is also available here where the option is used for the y-axis. If your numerical data is on the x-axis, use xAxes
instead of yAxes
. Note that an array (and plural) is used for yAxes
(or xAxes
), because you may as well have multiple axes.
score:4
Please add this option:
//Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
scaleBeginAtZero : true,
(Reference: Chart.js)
N.B: The original solution I posted was for Highcharts, if you are not using Highcharts then please remove the tag to avoid confusion
score:10
If you need use it as a default configuration, just place min: 0
inside the node defaults.scale.ticks
, as follows:
defaults: {
global: {...},
scale: {
...
ticks: { min: 0 },
}
},
Reference: https://www.chartjs.org/docs/latest/axes/
score:34
It's now (5 years later and version 3.x) a bit different
options: {
scales: {
y: {
beginAtZero: true
}
}
}
Source: stackoverflow.com
Related Query
- how to set start value as "0" in chartjs?
- Chartjs - Set start and end value into a Bar Chart
- How to set the chartjs bar graph scale to the highest value in the result data
- How to set start value as “0” in Chart.js Laravel
- How to set min Value a step down of min value received from database in Y Axis in ChartJS
- How to set up an initial Zoom value for a chart (ChartJS + ChartJS Zoom plugin)?
- How to set specific height for chartJs background color in terms of yAxis value
- How to set max and min value for Y axis
- How to set ChartJS Y axis title?
- chartjs : how to set custom scale in bar chart
- How to set static value in y-axis in chart.js?
- How do I fix over limit y axis value in ChartJS
- How to set a full length background color for each bar in chartjs bar
- how to change Y axis value dynamically based on user input in Chartjs for Line chart?
- How to dynamically set ChartJs line chart width based on dataset size?
- How to add ChartJS code in Html2Pdf to view image
- How to remove bars for those bars with zero value in Chartjs bar chart?
- ChartJS How to set max labels for X axis?
- How to set lower limit for the highest value being displayed on Y Axis?
- How to set ChartJS x-axis title
- how to set color for each item in tooltip with ChartJS
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- chartjs - how to set the order in which the different charts are displayed
- How to set max smaller than min in ChartJS
- How to set a borderWidth on ChartJS - AngularJS?
- How to set dynamic value for horizontal line in annotation plugin for Chart.js
- How to set vertical lines for new day on x-axis in ChartJS v3.x
- How to set y axis to the max dataset value in Chartjs?
- How to set a time scale to a ChartJS chart from JSON?
- How to set ChartJS Axis label with PrimeFaces
More Query from same tag
- Chart.js draw mathematical function
- Showing 'undefined%' in the graph if data does not exist
- Chart.js Box Annotations Fill Entire Chart
- How to position yAxes labels in chartJS
- Chart.js v3.60 - Add % symbol to the end of the tooltip label on a doughnut chart?
- How to make gap in chart.js graph?
- iframes without sandbox attribute is a Vulnerability
- Chart js 2.8 - How to make bars grow at the same speed?
- Problem extending data series in Chart.js
- Chart.js - Styling Legend - ONE legend entry per line
- Creating charts dynamically using ChartJS and AngularJS
- Real time colored bar chart
- Label not showing in Chart.js with Grails
- To display data from mock server into chartjs using ember
- Charts js showing only when positives data
- Pie Chart using chart.js not showing up but bar charts are?
- Chart.js in a Vue page throws error: do not mutate vuex store state outside mutation handlers
- Load JSON to display data, using ng-repeat {ANGULAR.JS}
- 'filter' function for chart.js legend labels never being called
- Assigning data structures to chartjs properties, NOT individually
- How can I draw dotted line using chartjs?
- Add custom data scale to Chart.js
- Unable to get chartjs to draw a chart with dynamic data (variable not hardcoded)
- Dynamically update the options of a chart in chartjs using Javascript
- Chart.js tooltip at any point on the chart
- How can I customize p:polarAreaChart tooltips?
- chartjs radar glowing edges effect
- Chart.js time scale graph - xAxis labelling
- ng2-charts access chartjs object to apply chartjs functions
- My chart won`t live update - done in Chart.js and Java Script