score:1
Accepted answer
the issue you are currently facing is causing because, you are passing the unitstepsize
value as a string.
it should be a number, with no quotes (''
) around it.
var ctx = document.queryselector('#canvas').getcontext('2d');
var mychart = new chart(ctx, {
type: 'line',
data: {
labels: ['12:00', '12:10', '12:20', '13:20', '13:30'],
datasets: [{
label: 'temperatures',
data: [20, 21, 22, 21, 23],
backgroundcolor: 'rgba(75,192,192, 0.4)',
bordercolor: '#4bc0c0',
pointbackgroundcolor: 'black',
tension: 0,
fill: false
}]
},
options: {
scales: {
xaxes: [{
type: 'time',
scalelabel: {
display: true,
labelstring: 'time'
},
time: {
unit: 'minute',
unitstepsize: 10,
format: "hh:mm",
displayformats: {
minute: 'hh:mm',
hour: 'hh:mm'
}
}
}],
yaxes: [{
scalelabel: {
display: true,
labelstring: 'temp'
},
ticks: {
max: 25,
min: 15,
stepsize: 1
}
}]
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.5.0/chart.min.js"></script>
<canvas id="canvas"></canvas>
Source: stackoverflow.com
Related Query
- Chart with Time axis only displaying first grid line and tick label (unitStepSize)
- How to show tick marks and labels with grid line for the specific one on the X axis with Chart.js?
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- Show X axis on top and bottom in line chart rendered with Chart.js 2.4.0
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How to change the label and grid line position on a timeseries chart in Chart.js 3?
- chart js - bar chart with time scale on Y axis in Hours and Minutes
- How to use chart.js to plot line chart with x axis as time stamp in seconds
- X and Y axis labels not displaying on line chart (Chart.js)
- Chart Piechart in only show percentage on hover but it shows data and label with percentage both i just want to show percentage only percentage
- Chart.js bar chart with time on X axis and category on Y axis is not rendered
- hereChartJS Line Chart with Time Axis
- 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
- ChartJs line chart time cartesian axis number of ticks and wierd offset
- chart.js - how to draw and manage line when only one label present in chart js Linechart
- How to configure chart.js line chart with very low minimum height, and only 0 and 1 (no decimals) as ticks on the y-axis
- Multiple axis line chart with Chart.js and JSON data from Google Sheet
- ChartJS New Lines '\n' in X axis Labels or Displaying More Information Around Chart or Tooltip with ChartJS V2
- line chart with {x, y} point data displays only 2 values
- Chart.js: bar chart first bar and last bar not displaying in full
- show label in tooltip but not in x axis for chartjs line chart
- Chart.js Mixed Bar and Line chart with different scales
- Chart.js bar chart : Grid color and hide label
- Chart.js Dynamically Updating Chart with X Axis Time
- Obtain max value of y axis of line chart rendered with Chart.js
- Line chart with large number of labels on X axis
- Remove the label and show only value in tooltips of a bar chart
- ChartJS - Line chart issue with only 1 point
- Chart.js with dual axis on bar and line graph
- Can we draw a Line Chart with both solid and dotted line in it?
More Query from same tag
- chartjs dataset attribute hidden from function
- I can't change the legend position in Laravel Charts & ChartJS
- How do you revert xAxes with Chart.js?
- ChartJS: Show all tooltips with Total for Multi Pie chart
- Chart.js dynamically upating data using variable
- Query with empty results laravel eloquent
- ChartJS executes a function multiple times
- Prevent the wiping of an Array after routing Angular.js
- Chart.js showing nothing on canvas
- How to display currency in Chart js
- Chartjs Polar Area Chart - Data labels shown don't rotate with startAngle
- Reactive charts with Meteor : d3charts , Hightcharts , ChartJS , other?
- How to print multiple items with the same charts? any directions?
- Chart.js with TypeScript
- How to change points/line based on value?
- Chartjs chart with only one axis
- Adding Vertical lines to charts
- skipping and merging similar data ecto elixir
- Chartjs dynamic chart return both x & y axis undefined
- Is it possible to create just header tip visible bar chart with chart js just like in image
- How do I change the bar colors in chart.js barcharts?
- How to use two Y axes in Chart.js v2?
- How can I add an event to chart.js legend?
- React-Chart-JS-2 ^3.0.5 | TypeError: Cannot read properties of undefined (reading 'visible') at Chart._getSortedDatasetMetas
- Dropdown component not having effect in Chromium browser
- How can i get my chartjs to show up graphically?
- Bar charts flickering issue in charts js
- Pass numeric matrix of rgb color values to chartJSRadar() in R
- Dynamically create dataset objects for multi-line graphing, using pre-defined dataset object arrays (JavaScript / Chart.js)
- Chart JS title passed from Django - issue with apostrophe '