score:1
Accepted answer
You tried to place the beginAtZero
in the V2 place, in V3 you have to put it in the root of the scale object like so:
const options = {
type: 'line',
data: {
labels: [1, 2, 3],
datasets: [{
label: '# of Votes',
data: [0, 0, 0],
borderColor: 'pink'
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
}
const ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.js"></script>
</body>
For all changes between V2 and V3 you can read the migration guide
Source: stackoverflow.com
Related Query
- Chart JS tick options not working for y axis
- show label in tooltip but not in x axis for chartjs line chart
- ChartJS - radar chart options not working
- Charts.js - Colors for stacked bar on multi-series line/bar chart are not working
- Charts.js - Bar chart different colors for value intervals not working
- chart.js legend not working for pie chart
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- Chart JS - set start of week for x axis time series
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- Chart js different background for y axis
- Adding options to vue-chartjs seems not working
- Time Series Line chart js in react not working
- Click event of stacked line chart not working
- Bubble Chart in Chartjs not working
- Android: WebView with JavaScript for Chart.js not working properly
- Chartjs - Donut Chart label for small values not visible
- Minimum value for x Axis doesn't work for horizontal bar chart | ChartJS
- Css style not working well when resizing chart height in angular application
- Chart js options not changing chart
- code works fine on jsfiddle but one function is not working on website
- Chartjs not working with d3 from csv source
- zeroLineColor and zeroLineWidth not working for the x-axis in Chartjs
- in chart js tooltip font size is not working
- Chart JS not working with date
- Chart Js reduce text size for label on X axis
- 'barradius' for Barchart in ChartJS is not working
- Background color of the chart area in chartjs not working
- Chartjs with Vue, Bar Chart Border Radius not working
- Trouble setting options for radar chart on Quickchart.io
- Chart.js - changing tick / label positions for x axis time series
More Query from same tag
- How to change width of the chart using Chart.js
- Chart.js – how to remove data entries from the tooltip?
- How do I change the grid line style on the Y axis in Chart.js?
- React + ChartJS V3: Annoations don't work
- How to make Chart.js with dynamic months on x-axis
- Exporting dynamic chartjs to jspdf
- Chart JS Logarithmic x-axis
- build dynamic array for charts.js
- Add shadow Chart.js
- Chart.js group data by month\year
- Chart.js / Google Charts and JSON
- How do i find area under the graph
- How to move a chart.js to the center
- How to draw the circular progress bar in Chart.js Or any other JavaScript library in Angular 2
- chart.js Doughnut anticlockwise animation
- How to set a responsive chart.js chart to not fill screen?
- how to make a chart linked to the C# database?
- Return 0 when some information DOESN'T EXIST (not when exists and return null)
- Using chartjs v2 to show categorical values on axis instead of numeric
- How do I get the current step size of a chartjs chart whose stepSize I have not defined?
- Chart.elements.Rectangle.prototype.draw inpacting on other charts in the same page(Angular)
- Chart JS Crosshair - Linked Charts without linked Legends
- Chart.Mvc colliding with System.Web.Helpers.Chart
- Replace a Canvas Pie Chart Onclick
- Hide Legend in Chart.js V3.7.1
- ChartJs: X Axis labels cutting at bottom
- Chart.js, change color of specific ticks
- How can we type a variable which is a method in TypeScript ? (Using Chart.js)
- Chart.js v3 - beginAtZero does nothing to my chart
- How to create Chart with 2 variables (x,,y)