score:1
Accepted answer
the reason of this not working is merely related to the chartjs version you are using. since you are using chartjs version 1.x, the current scales option will not be applicable for the chart.
you should rather use the following scale options ...
scaleoverride: true,
scalesteps: 10,
scalestepwidth: 10,
ᴡᴏʀᴋɪɴɢ ᴇxᴀᴍᴘʟᴇ
var ctx = document.getelementbyid("canvas").getcontext("2d");
var data = {
labels: ['jan', 'feb', 'mar'],
datasets: [{
label: "# of votes",
fillcolor: "#07c",
data: [50, 80, 200]
}]
};
var mybarchart = new chart(ctx).bar(data, {
scaleoverride: true,
scalesteps: 10, // number of ticks
scalestepwidth: 10, // tick interval
scalebeginatzero: true
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/1.0.2/chart.min.js"></script>
<canvas id="canvas" width="350" height="200"></canvas>
score:0
for chart.js v3.x.x, use the below (tested using v3.3.2):
var options = {
scales: {
y: {
suggestedmin: 0,
suggestedmax: 100
},
x: {
suggestedmin: 0,
suggestedmax: 100
}
}
}
read: https://www.chartjs.org/docs/3.3.2/axes/#axis-range-settings
Source: stackoverflow.com
Related Query
- Set max value of chart.js bar chart
- Chartjs - Set start and end value into a Bar Chart
- Chart Js - Globally set bar chart color based on value
- How to set minimal value for bar chart in Chart.js? (ver. 2.0.2)
- Chartjs Bar Chart Y Axis set base starting value to not be 0
- Chart.js with line chart and bar chart - bar chart not rendered although the max value of it is shown
- How to set percentage value by default on each bars in horizontal bar chart js
- How to set max and min value for Y axis
- chart js 2 how to set bar width
- chartjs : how to set custom scale in bar chart
- Obtain max value of y axis of line chart rendered with Chart.js
- Remove the label and show only value in tooltips of a bar chart
- set y-axis scale manually in a bar chart using angular-chart.js
- Chart.js: Minimum value for x-axis at horizontal stacked bar chart
- chart.js bar chart color change based on value
- Chart JS display Data Value on the top of the Bar
- How to set single color on each bar in angular chart js
- How to hide value in Chart JS bar
- Chart.js stacked bar chart - sorting values in bar by value
- Minimum value for x Axis doesn't work for horizontal bar chart | ChartJS
- How do I set a bar chart to default to a suggested maximum in chart.js v1.01?
- Chart.Js how to hide datapoints with "0" value in Stacked Bar Chart
- How to use set the color for each bar in a bar chart using chartjs?
- Click on interactive chart.js bar chart and get value for labels and groups in JS
- How to set the chartjs bar graph scale to the highest value in the result data
- How to set the xAxes min and max values of time cartesian chart in Chart.js
- How to set custom Y Axis Values (Chart.js v2.8.0) in Chart Bar JS
- Chartjs stacked bar single max value
- How to set y axis to the max dataset value in Chartjs?
- Set fixed label size for grouped bar chart in angular Chartjs
More Query from same tag
- Using chart js version 3, how to add custom data to external tooltip?
- Generate an indefinite number of charts as images (chart.js)
- How to edit style of negative x grid lines on Chart.js?
- how to display datetime list in graph using chart.js
- I can't import ChartsModule
- Why does chart update fail when its container has ng-show on it?
- ng2-charts - bar chart, showing only one color
- what is wrong with my code ? java script chart position
- chart.js value is two but only one display tooltip
- ChartJS: Percentage labels
- Chart.js not displaying on Android Webview if animation is set to false
- Show dynamic data with dynamic colours in chartjs
- Chart.js two y axes line chart tooltip value incorrect for 2nd y axis
- Chartjs initial animation want to change from left to right (default it is bottom to top)
- Chartjs - custom y axis range
- Chart.js bar chart bars and labels do not align
- Django Multiple chartJs chats in a page
- ChartJS color specific Grid Lines
- Is Chartjs compatible with PhoneGap?
- Chart.js StackedBar doesn't show labels on bar and maximum y-value
- Creating a Normal Distribution graph with Chart.js
- Chart.js line graph change x axis seperation
- How to get ChartJs object from dynamically created chart
- Chart disappears, when pressing the submit button
- Chart.js canvas rendered by ng-repeat does not show charts
- Use react-icons for pointStyles in Chart.js graph on Next.js app
- Chart Click Event - Clicking label of doughnut chart, doesn't return label ng2-charts
- Javascript instead of mapping to an array, returning one value at a time instead of a list of data?
- How to custom index label on each bar chart using chartjs?
- Is there a way to display a chart label that has no data behind it in Chart.js