score:18
Also include scaleStartValue
and scaleStepWidth
as stated in docs.
Example
This example creates a bar chart with Y-axis starting at 0 and ending at 900. To do that, step width is set to 100 and number of steps are set to 9.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<canvas id="income" width="600" height="400"></canvas>
</body>
</html>
JS
var barData = {
labels : ["January","February","March","April","May","June"],
datasets : [
{
fillColor : "#48A497",
strokeColor : "#48A4D1",
data : [456,479,324,569,702,600]
},
{
fillColor : "rgba(73,188,170,0.4)",
strokeColor : "rgba(72,174,209,0.4)",
data : [364,504,605,400,345,320]
}
]
};
var income = document.getElementById("income").getContext("2d");
new Chart(income).Bar(barData, {
animation:false,
scaleOverride:true,
scaleSteps:9,
scaleStartValue:0,
scaleStepWidth:100
});
score:0
For those who struggle with react-chartjs-2:
Example that starts from 0, makes 2 steps
each of size
20 and goes up to max
let options = {
scales: {
y: {
ticks: {
beginAtZero: true,
steps: 2,
stepSize: 20,
max: 40
}
}
}
}
Usage:
// ... your component structure
return <Line options={options} />
score:1
@2.8.0 custom y-axis setup. You only need range min/max and with stepSize you control the axis.
...
yAxes: [{
ticks: {
stepSize: 0.1,
min: 2,
max: 2.5
},
gridLines: {
display: false
},
stacked: false
}]
...
score:12
var myChart = new Chart(ctx, {
type: 'bar',
data:data,
options: {
responsive: true,
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
steps: 10,
stepValue: 6,
max: 60 //max value for the chart is 60
}
}
}]
}
}
});
Source: stackoverflow.com
Related Query
- chartjs : how to set custom scale in bar chart
- How to set the chartjs bar graph scale to the highest value in the result data
- How to set custom Y Axis Values (Chart.js v2.8.0) in Chart Bar JS
- How to set a time scale to a ChartJS chart from JSON?
- How to access custom property in dataset object in Bar Chart in React ChartJS 2?
- chart js 2 how to set bar width
- How to set a full length background color for each bar in chartjs bar
- set y-axis scale manually in a bar chart using angular-chart.js
- How to draw Horizontal line on Bar Chart Chartjs
- How to dynamically set ChartJs line chart width based on dataset size?
- How to set single color on each bar in angular chart js
- Chartjs - Set start and end value into a Bar Chart
- Chartjs 3.x - How to duplicate X axis on both sides of horizontal bar chart with only 1 dataset?
- How do I set a bar chart to default to a suggested maximum in chart.js v1.01?
- How to use set the color for each bar in a bar chart using chartjs?
- How to highlight single bar in bar chart using Chartjs
- How to select context or scale on chart in chartjs quickchart io to run getValueForPixel?
- Set fixed label size for grouped bar chart in angular Chartjs
- How to set X coordinate for each bar with react chart js 2?
- How to set the gap between data items in a chartjs chart
- How to show the chartjs bar chart data values labels as text?
- ChartJS add custom tooltip to a stacked bar chart
- How to remove a label in top of bar in chartjs chart
- ChartJs - stacked bar chart with groups - how to create second x-axis with stack id
- set scroll on bar chart in chartjs
- How to set Custom tooltip event with Chartjs version 2.X
- How to set up a simple pie chart using React in ChartJS on codesandbox
- chartjs - How to access chart instance in a custom tooltip callback
- How to make custom text appear underneath each bar in chartjs bar chart?
- How to set Solid label in bar chart using Chart JS
More Query from same tag
- Chart.js - Hover labels to display data for all data points on x-axis
- chartjs-plugin-streaming + chartjs-plugin-zoom
- Force two Chart.js doughnut charts with legends to same size in Bootstrap columns
- How to colorize individual rings in polar chart background in chart.js/ng2-charts?
- How to vary the thickness of doughnut chart, using ChartJs.?
- Create a pie chart using an array from a data table in chart.js
- Can't find the chart.js v2 docs
- Width and Height in Chart.js
- create Chart.js after getting data from api
- Chart.js chart not displaying until I open the browser's console
- How to set the gap between data items in a chartjs chart
- Multiple data sets not working when using ChartJS
- React ChartJS 2 : Get data on clicking the chart
- Chart.js loading data colors from PHP
- ChartJS ReactJS Object of Objects
- 2 or more charts on same page?
- ChartJs events in Angular
- How to add a second set of labels to a Chart.js doughnut chart?
- How to dynamically use chartjs-plugin-annotation with ng2-charts?
- How can I build a vertical line without going through my dots on my line graph? (charts.js)
- How to add dataset legend in chartjs tooltip
- Download Chart.js graph from view
- Chartjs graphs are not respecting height of container
- Set Start Value as '0' With Dynamic Data In Chart.js
- Access data arrays from c# method inside JavaScript inside .cshtml file
- How to make the whole <canvas> element in Chart.js V3.7.0 display cursor as pointer on hover?
- Chart.js Line chart Option does not disable gridlines
- Canvas JS using ajax call
- How to change text colour of specific labels of axis in Chart JS?
- Chart.Js pie chart click