Comments (12)
For chartjs 2.0 I've found the solution. Put this in the options object.
Have fun!
scales: {
yAxes: [{
id: 'y-axis-0',
gridLines: {
display: true,
lineWidth: 1,
color: "rgba(0,0,0,0.30)"
},
ticks: {
beginAtZero:true,
mirror:false,
suggestedMin: 0,
suggestedMax: 500,
},
afterBuildTicks: function(chart) {
}
}],
xAxes: [{
id: 'x-axis-0',
gridLines: {
display: false
},
ticks: {
beginAtZero: true
}
}]
}
from chart.js.
@chesstrian the solution is not working for me, but i am able to find a solution from a site https://www.dyclassroom.com/chartjs/how-to-create-a-bar-graph-using-chartjs
where they are using min option for y axis, which can solve few of our requirements
yAxes: [{ ticks: { min: 0 } }]
from chart.js.
I've harcoded this in my fork:
from chart.js.
hi, I've tried your solution but it didn't work for me - I found on stack other answer (http://stackoverflow.com/questions/43040867/show-bar-with-zero-value-in-chartjs-v2/), but it's more hack than solution - can you show on jsfiddle how exactly you soultion works?
from chart.js.
@bartekmaciejewski @nickgrossman Not sure if you still need it, it works for me with:
var config = {
type: 'bar',
data: {
...
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
};
from chart.js.
I agree. On the list of todos for the next major release.
from chart.js.
Wow, can't believe this isn't available! I'll look elsewhere for bar charts. :-(
from chart.js.
This is a most flabbergasting flaw. Unbelievable that this beautiful plugin missed a fundamental business criteria like that. Both bars and lines need this option of course.
from chart.js.
Line charts need to start at 0 as well. Keep your original code though, Fox News will love it. xD
from chart.js.
I'm not sure if I agree that line charts should always start at zero, visual context at a small size is difficult when a scale a lot larger than the change itself.
Though there is a new option for doing this - pass scaleBeginAtZero: true
into your options for chart types.
For bar charts, this now defaults to true.
from chart.js.
This new feauter should be in http://www.chartjs.org/docs/#line-chart documentation.
from chart.js.
same here- doesn't work for me, and I would like my y axis to begin at zero!
from chart.js.
Related Issues (20)
- Timeline / Gantt Style Charts HOT 1
- Data-labels not rendering. Bar Element element coordinate properties 'y' and 'base' are assigned 'NaN' when all values for that dataset are zero. HOT 3
- Error on IPHONE 5s running 12.9.7 HOT 4
- Add more styles for legends
- Configuration "animation: false" doesn't load point icon images HOT 2
- Floating Stacked Bar Chart problem + Duplicate legend problem
- Allow setting constant width for bars and variable width for categories
- Setting Y-Min for bar chart messes with interactions/tooltips HOT 1
- ticks padding does not work as expected
- padding for the legend
- Clip option on scale doesn't do anything
- Cannot read properties of null (reading 'getContext')
- Radial Bar Chart Label Issue HOT 3
- Y-labels cropped way too early for vertically stacked axes
- Ticks callback function don't return initial value labels HOT 2
- floating point on y axis HOT 8
- Easy API for setting background color on each dataset's tooltip
- Hovering functionality for long labels
- Angular application reacting slow once multiple chart loaded into page. HOT 1
- Title padding does not appear to be scriptable (or type needs updating?)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chart.js.