score:0
you can use the position
option in the scale config and set it to 'center'
like so:
const options = {
type: 'line',
data: {
labels: ["red", "blue", "yellow", "green", "purple", "orange"],
datasets: [{
label: '# of votes',
data: [12, 19, 3, 5, 2, 3],
bordercolor: 'pink'
},
{
label: '# of points',
data: [7, 11, 5, 8, 3, 7],
bordercolor: 'orange'
}
]
},
options: {
scales: {
y: {
position: 'center'
}
}
}
}
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.6.0/chart.js"></script>
</body>
Source: stackoverflow.com
Related Query
- Are we able to position the y axis in the center of the x axis?
- Using Chart.js - The X axis labels are not all showing
- Chartjs 2.7.3: Set Y data at the correct X position axis
- Ng2-charts + How to customize the position of X axis labels?
- Why are changing the time value of my axis (moment.js)?
- Chartjs - how to make line position to vertical center and how to display dotted sharp in the backround?
- 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
- Why the bar are not aligned the y axis
- Are you able to offset a secondary y-axis in ChartJS, by a decimal value, whilst keeping the same scale for both y-axes?
- How to remove the line/rule of an axis in Chart.js?
- Chart js. How to align text by the center of the tooltip?
- How to change the color of legend in chartjs and be able to add one more legend?
- What is the order in which the hooks (plugins) of Chart.js are executed?
- How do I change the 'months' language displayed on the date axis in Chart JS?
- Can't figure out why the values in my objects are changing
- Chartjs change the specific label color in x axis in callback function
- How to align Chart.JS line chart labels to the center
- How to show Y axis ticks for every point in the graph
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- Map event position to y axis value in chartjs line chart
- chart.js v2: Align time scale labels with the center of the bars
- How to remove the Chart.js x Axis bottom line?
- Changing the Y axis unit in Chartjs
- Position Label under the Horizontal Bar
- Chart Js, Style some ticks on the axis differently
- Maintain Y axis scale in graph with scroll in the X axis when the dataset grows bigger. Aspect-ratio problem
- Chart.js How to change y axis title position
- How to start the line graph from the left Y axis in a line/bar mixed chart (Chart.js)?
- ChartJs - Pie Chart - how to remove labels that are on the pie chart
- Custom data position on the doughnut chart in chart.js
More Query from same tag
- chart.js php live update
- I cannot update my chart ( in react-chartjs-2 )
- I want to bind the legend option with checkbox(show legend or not)
- Chart JS - Horizontal Bar Chart Not Filling Canvas
- Ng2-charts / chart.js - how to refresh/update chart - angular 4
- How do I stop chart js from auto rescaling the y axis upon calling chart.update()?
- How to get any y value for specified x in chart.js?
- Default font size doesn't change ChartJS
- How can I create custom tooltips for each data point in a graph?
- How to remove automatically applied background color to the body?
- How to set the xAxes min and max values of time cartesian chart in Chart.js
- graph (chartjs.org) does not stretch properly when sidebar(menu) is collapsed
- Chart.JS: How to add Data to a specific dataset
- Chart.js : How I change the x axes ticks labels alignment in any sizes?
- Is there a way to display a chart label that has no data behind it in Chart.js
- Can i use crosshairs with OHLC/candlestick charts using ChartJS
- Realtime data from a service in ionic / angular
- How do i use chartjs in react project properly?
- Multiple stacked bar chart using ChartJs
- Construct a bar chart using chart.js
- React.js made a Custom Line Chart
- Angular4 ng2-charts TypeError: Cannot read property 'length' of undefined
- Chart.js chart.update() method is not doing anything
- Array of objects condensed into array of unique objects with nested array
- How to stack time charts vertically
- customized Doughnut char using charjs
- Cannot find centroid of path
- Chart.js tooltip hover customization for mixed chart
- Custom text in tooltip and legend: ChartJs
- chartjs dataset attribute hidden from function