score:0
Accepted answer
you can add an empty label and to the start of the labels array and a null
value to the start of your dataarray to shift it a bit
example:
var options = {
type: 'line',
data: {
labels: ["", "red", "blue", "yellow", "green", "purple", "orange"],
datasets: [{
label: '# of votes',
data: [null, 12, 19, 3, 5, 2, 3],
borderwidth: 1,
fill: false,
bordercolor: 'red',
backgroundcolor: 'red'
}]
},
options: {
scales: {
yaxes: [{
ticks: {
reverse: false
}
}]
}
}
}
var 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/2.9.4/chart.js" integrity="sha512-hzf9qhp3rldjbvakvmig+goaakrza6lkuo35ok6esm0/kjpk32yw7urqrq3q+nvbbt8usss+iekl7crn83dymw==" crossorigin="anonymous"></script>
</body>
Source: stackoverflow.com
Related Query
- How does the chartjs line look start to be greater than 0
- How to start the line graph from the left Y axis in a line/bar mixed chart (Chart.js)?
- How do I hide line outside the min/max (scale area) in chartjs 2.0?
- How to reduce the number of points shown on line chartjs chart with a large dataset?
- How to shift the origin along y-axis direction in a chart.js3 line chart, so that x-axis pass through a different point other than (0,0)?
- How to plot a line chart which has both the start and points outside the canvas area using Chart.js
- How to start the chart from specific time and offest hour and then show the data on chart from target datetime in chartjs
- how can I show only 2 numbers on the xAxe in Chartjs having more than two numbers on the chart? (line chart)
- How do I make the Line in ChartJS not exceed the maximum of yAxes
- Chartjs - how to make line position to vertical center and how to display dotted sharp in the backround?
- How to shrink the height and increase the line width of a custom Chartjs horizontal line?
- How do I use ChartJS with a background color in the space between two line charts?
- How to sort color segments by value within the 100% stacked bars rather than by value across all the stacked bars in Highcharts or ChartJs
- How to properly use the chartjs datalabels plugin
- How to change the color of legend in chartjs and be able to add one more legend?
- How to render a vertical line on hover in chartjs
- How to change the cursor to a pointer when I hover over a bar in a ChartJS bar chart?
- How to align Chart.JS line chart labels to the center
- In ChartJS is it possible to change the line style between different points?
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How can I remove extra whitespace from the bottom of a line chart in chart.js?
- Chart.js How to set line height only to the points?
- how to change Y axis value dynamically based on user input in Chartjs for Line chart?
- How to draw Horizontal line on Bar Chart Chartjs
- Chart.js - IndexSizeError: Index or size is negative or greater than the allowed amount
- ChartJS Line chart cut off at the top and bottom
- How to dynamically set ChartJs line chart width based on dataset size?
- Line ChartJS empty / null values doesn't break the line
- How do I make line charts overlay over bar charts in chartjs
- how to reset the graph/chart after zoomin, pan using chartjs
More Query from same tag
- How to add a point to chart.js line chart?
- How to build dynamic charts with Chart.js
- Tooltip is not displayed when using annotation in ChartJs
- How scale sector in doughnut chartjs on hover?
- ChartJS - Injecting data from the server-side
- Hide all scale labels in chartjs
- Chartjs doughnut chart rounded corners for half doghnut
- How to install Chart.js in Laravel?
- Dynamically update values of a chartjs2.0 chart
- Get bar value when onClick Reactjs
- How to inject “Chart.js” to my module?
- Chart.js: trouble with resizing on window resize
- How to loop over Chart.js with Django list view
- php/laravel: Creating chartdata, return 0 if no data is being submitted to database
- Frontend and backend for chart using chartjs, mongodb, and controller
- Chart.js Bar Chart change width (not duplicated to bar width questions!)
- injecting chart.js sparkline to jqxGrid widget in Angular with typescript
- How could I implement chartjs-plugin-datalabels in chartjs-node-canvas?
- Chart js: I'm getting the labels crossed on my pieChart and doughnut. Not able to get the chart itself
- chart js how to fill legend box with colour
- How to make bars dashed in chart js?
- ng2-charts - bar chart, showing only one color
- Chart.js Show Dollar Amount On Left Y And Percent Amount On Right Y
- chart.js: segment true is not working in labels outside pie chart : chart.piecelabel.js
- React-Chartjs-2 and Chartjs v3:Option Property
- Y-Axis with different colors
- Can I make a horizontal bar chart with two category axes?
- Chart.JS - Polar area - Legend hover style and margin
- CHART.JS scriptable backgroupColor attribute
- Doughnut chart updates with twice the data