score:1
the scatter chart uses a line chart internally but changes it so the showline
property becomes false and both axis are set to linear.
so you can just set the showline
property to false in your dataset and use a line chart.
score:2
you can define your x-axis as follows
x: {
type: 'time',
time: {
parser: 'yyyy-m-d',
unit: 'day',
displayformats: {
day: 'd mmm yyyy'
},
tooltipformat: 'd mmm yyyy'
}
}
further information can be found at the chart.js documentation here and in the chart.js samples here.
note that i use chartjs-adapter-moment together with moment to make this work. the formats for parsing and displaying time values as desired can be found here.
please take a look at your amended code and see how it works.
var test = [
{ x: "2022-1-8", y: 950 },
{ x: "2022-1-9", y: 1100 },
{ x: "2022-1-10", y: 990 },
{ x: "2022-1-12", y: 1250 },
{ x: "2022-1-13", y: 1050 }
];
var chart = new chart('chart-line', {
type: 'scatter',
data: {
datasets: [{
data: test,
label: 'buys',
bordercolor: "#3e95cd"
}]
},
options: {
responsive: false,
scales: {
x: {
type: 'time',
time: {
parser: 'yyyy-m-d',
unit: 'day',
displayformats: {
day: 'd mmm yyyy'
},
tooltipformat: 'd mmm yyyy'
}
}
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/3.7.0/chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment-with-locales.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment@1.0.0"></script>
<canvas id="chart-line" height="200"></canvas>
Source: stackoverflow.com
Related Query
- How do you plot scatter graph with chart.js
- How to plot a single value with line in line chart graph using charts.js?
- chartjs: How to plot multi-line chart with irregular intervals
- Mixed chart scatter plot with chart.js
- How to access or get value of specific graph on chart plot by click event?
- Flask with Chart JS Scatter Plot struggle
- How do you make a progressive line chart with time as the X axis?
- How do you set up a chart.js scatter line chart through angular-chart.js?
- How to plot a line graph with x and y data
- How to use chart.js to plot line chart with x axis as time stamp in seconds
- How do you create a Radar chart using chart.js with a y-axis of 0 to 100?
- How to create a scatter plot where x-axis represents a day by hours with datetime object? chartJS
- How to plot line chart with multiple datas, but only 2 labels?
- How to create a chart.js scatter chart with data from two lists
- How to change bar color on a angular-chart and chart js bar graph with multiple datasets?
- How can I create a horizontal scrolling Chart.js line chart with a locked y axis?
- Chart.js - Plot line graph with X , Y coordinates
- How to prevent first/last bars from being cut off in a chart with time scale
- How do you hide the title of a chart tooltip?
- How to fix chart Legends width-height with overflow scroll in ChartJS
- How to display Line Chart dataset point labels with Chart.js?
- chart js how to fill legend box with colour
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- How to display inline values in a stacked bar chart with Chart.js?
- How to display data labels outside in pie chart with lines in ionic
- How to use 'time' (data from database, data type: timestamp ) for plotting graph in Chart JS
- Chart.js - Plot line graph with X , Y coordinates and connected by line
- How do you set pie chart colors in angular-chart.js
- How can I trigger the hover mode from outside the chart with charts.js 2?
- How to start the line graph from the left Y axis in a line/bar mixed chart (Chart.js)?
More Query from same tag
- I want to show the value of label inside the pie graph. (vue-chartjs / pieceLabel)
- add value to Line chart.js
- Tooltip does not appear
- Label is too long in Doughnut Chart
- Is it possible to print to pdf a Canvas with other div elements?
- Angular Chart.js Multiple Canvas
- Angular 9 chartJs is not updating view after data update
- Rendering charts using local Chart.js in overriding Django templates
- Dynamic array javascript
- How to change format of DateTime reading into chart.js chart?
- implementing horizontal bar chart
- How can i reformat dates
- Setting Limits on Chart.JS
- Update Chart in Javascript using Chart.js
- Chartjs: I only want left and right padding in pie chart
- Custom Legend ChartJS not showing the text decoration: line through
- How to change colours for Angular-Chart.js
- Have all label in Chartjs be at fixed positions
- ChartJs won't appear in DIV in same page
- How to fix chart looking blurry in ChartJS?
- How to add a ChartPoint to a DataSet in Chart.js with TypeScript?
- How can i add additional Data(Type) to chart.js
- Chart.js Line-Chart with different Labels for each Dataset
- ChartJS: line graph with labels on the y-axis
- Why is this Chart.js graph not showing the right colors?
- Show data values in Chart.js bars (version 3)
- after div display set to block nothing shows
- Can't find the chart.js v2 docs
- Chartjs Nested Doughnut Layers With Different Thickness
- How can I merge multiple HTTP calls to one entity model in Angular