score:3
You can control labels alignment by using crossAlignment option on the tick configuration. There are three possible values: "near
", "center
", and "far
".
In your case, you will just use near
options: {
...
scales: {
y: {
ticks: {
crossAlign: "far",
},
},
},
}
score:8
The yAxis.ticks
labels can be left aligned by defining mirror: true
combined with adding some padding
.
yAxes: [{
ticks: {
mirror: true,
padding: 220
},
To make the labels visible on the chart area, the same padding needs to be defined left of the chart layout.
layout: {
padding: {
left: 220
}
},
Please have a look at your changed code below.
new Chart('myChart', {
type: 'horizontalBar',
data: {
labels: ["Total", "301 Redirect", "Broken Pages (4xx Errors)", "Uncategorised HTTP Response Codes", "5xx Errors", "Unauthorised Pages", "Non-301 Redirects"],
datasets: [{
data: [16, 14, 1, 1, 0, 0, 0],
backgroundColor: ['rgba(237, 56, 98, 1.0)', 'rgba(237, 56, 98, 1.0)', 'rgba(237, 56, 98, 1.0)', 'rgba(237, 56, 98, 1.0)', 'rgba(237, 56, 98, 1.0)', 'rgba(237, 56, 98, 1.0)','rgba(237, 56, 98, 1.0)']
}]
},
options: {
responsive: false,
layout: {
padding: {
left: 220
}
},
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
mirror: true,
padding: 220
},
gridLines: {
display: false
},
}],
xAxes: [{
ticks: {
display: false
},
gridLines: {
drawBorder: false,
}
}],
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<canvas id="myChart" width="500" height="200"></canvas>
Source: stackoverflow.com
Related Query
- How to set labels align left in Horizontal Bar using chart.js?
- How to use set the color for each bar in a bar chart using chartjs?
- Labels (category type) on left and right of bar chart using chart.js?
- Chart, X and Y-Axis labels are blurred in horizontal bar chart using chart.js
- Using Chart.js version 3, How to left justify the y-axis labels on a stacked bar chart?
- How to draw multiple color bars in a bar chart along a Horizontal Line using chart.js
- How to set Solid label in bar chart using Chart JS
- How to show bar chart labels clearly using ChartJS?
- How to make labels on both side from horizontal bar chart js
- how to modify horizontal bar chart using chart js
- How to set percentage value by default on each bars in horizontal bar chart js
- chart js 2 how to set bar width
- chartjs : how to set custom scale in bar chart
- How to create stacked bar chart using react-chartjs-2?
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- How to align Chart.JS line chart labels to the center
- How to access labels array using chart plugin (Chart.pluginService.register) in Chartjs 2.x?
- How to display the labels in doughnut chart using ng2 charts?
- set y-axis scale manually in a bar chart using angular-chart.js
- How to draw Horizontal line on Bar Chart Chartjs
- How to set single color on each bar in angular chart js
- How to change Chart.js horizontal bar chart Width?
- Display labels on bar chart using Chart.js
- In Stacked horizontal bar chart how to remove the vertical line in Chart.js?
- Draw a horizontal bar chart from right to left
- How to draw outer labels for polar chart using ng2-charts and chart.js at fixed positions outside the rings?
- ChartJS: how to make a bar chart with a horizontal guideline:
- Chartjs 3.x - How to duplicate X axis on both sides of horizontal bar chart with only 1 dataset?
- How to set static labels for ng2-charts bar charts?
- How do I set a bar chart to default to a suggested maximum in chart.js v1.01?
More Query from same tag
- NPM module doesn't work with Webpack 3 but works with vue-cli3 which based on Webpack 4
- Split assoc array by keys
- ChartNew.js - Remove/Hide zero label from Pie Chart
- Chartjs - Dataset colors are getting overloaded with angular-chartjs
- How to display data values on Chart.js
- Angular chart js how to use formatter with Doughnut chart
- How to vary the thickness of doughnut chart, using ChartJs.?
- set y-axis scale manually in a bar chart using angular-chart.js
- Replace Chart.js Data during `onClick` causes _meta error
- Increase point radius when tootip shown for certain data on Charts.js
- how resetZoom() en multiple charts (ng2charts or chartjs)?
- CoreUI Chart type Bar- clickable bars to link to another page
- Chart.js not showing data when pass dynamic labels
- Set minimum number of steps in line chart
- chartjs with the plugin chartjs-plugin-dragdata can i set fix dropdown values
- Charting with chartjs, can't get it working correctly
- What is the correct format for time data in chartjs?
- How to align labels at same side chartjs React
- ChartJs DrawBorder() Configuration not working
- Why can I not see a data value when hovering over a point on the radar chart?
- Is it possible to create a canvas to extract image data without actually rendering the canvas?
- chartjs-plugin-zoom: get currently visible values when the page first loads
- Position tooltip based on mouse position
- How to add an extra legend item in chart.js?
- Chart.js not to be begin in Y-Axis
- Rotate 90 degrees clockwise the scaleLabel (no ticks or labels) on a Chart.js line chart
- How to pass a variable to the dataset for a graph in chart.js?
- Chartjs - first x-axis tick is not displayed
- Puppeteer with Chart.js
- How to set min max for x axis depend on data with Chartjs and Spring Boot?