score:0
You need to use a scatter
chart and define the option showLine: true
on each dataset. Further you have to define the y-axis as a time cartesian axis as follows.
yAxes: [
{
type: "time",
time: {
parser: "YYYY/MM/DD",
unit: "day",
displayFormats: {
day: "YYYY/MM/DD"
}
},
ticks: {
reverse: true
}
}
]
Since the scatter chart expects the data in point format, you have to generate appropriate data structure in the ngOnInit
method as follows:
ngOnInit() {
this.lineChartData.forEach(ds => {
ds.data = ds.data.map((v, i) => ({ x: v, y: this.lineChartLabels[i] }));
});
}
Also remove [labels]="lineChartLabels"
from the canvas
, this is not needed when defining the data in point format.
Unfortunately however
ng2-charts
can't cope with this configuration and displays wrong colors for the data points and the legend labels. Therefore I also had to remove[colors]="lineChartColors"
from thecanvas
and define the colors on the datasets. You'll probably have to get rid of this wrapper library and use Chart.js directly in order to obtain the expected result.
Please take a look at your amended code in this StackBlitz.
Source: stackoverflow.com
Related Query
- How do I customize y-axis labels and randomly pick the value from the data range for x-axis in Chart js
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- In Chart.js >3.0, on axis of type time, how to show labels and ticks only for existing data points (make labels reflect data)?
- How to show tooltip value of all data falling on the same axis in chart js?
- How to sum the array value in javascript like chartjs data array and input value sum
- How can I display `Null` value data on Y Axis using the Primitive dataset format in Chart.js V3.7.0?
- How to start the chart from specific time and offest hour and then show the data on chart from target datetime in chartjs
- How to show tick marks and labels with grid line for the specific one on the X axis with Chart.js?
- How do you remove the data value from the mouse-over result in radar chart?
- Chart.js displaying each letter of label and data as a single value on chart. The data and labels provided are arrays
- How to set the data of chart in angular which is taken from the backend nodejs api that is store in mongodb and showing on the html page
- How do I customize the chart.js tooltip? Two labels have the same data, which I want to show you with each data
- How to get a value from function javascript and print it to the chart
- How to set max and min value for Y axis
- How do I prevent the scale labels from being cut off in chartjs?
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How can I display the xAxes and yAxes data in the tooltip, Chart JS?
- How to start the line graph from the left Y axis in a line/bar mixed chart (Chart.js)?
- How to hide zero data value from chartjs?
- How do I keep chart.js charts in one JS file, and not get errors when the ID from the JS file don't exist on one specific html page?
- Chart.js – how to remove data entries from the tooltip?
- Angular chart how to show the legend data value by default along with legend name
- How to achieve the best possible performance with mutable data and real-time charts in React?
- Charts.js - Need to remove the data value from the Tooltip
- Chartjs: Is it possible to hide the data labels on the axis but show up on the graph on hover?
- How to draw outer labels for polar chart using ng2-charts and chart.js at fixed positions outside the rings?
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- Ng2-charts + How to customize the position of X axis labels?
- How to get chart from data points (arrays) with inconsistent time intervals and chart.js?
- How to add labels for only some of the data point?
More Query from same tag
- ChartJS - Change legend to toggle buttons
- Angular chart from Chart.js
- Vertical Line chart with ChartJS
- ChartJS bar chart with legend which corresponds to each bar
- chartjs-plugin-streaming: onRefresh() callback isn't working
- line chart with {x, y} point data displays only 2 values
- ChartJS GridLine Dynamically
- How can I get suggestedMax number for yAxes?
- how to create line chart using chart.js in angular 2+
- Chart.Js pie chart click
- How to add a vertical line on Chart.js when hover a point?
- Passing json_encode to chart.js won't work
- Convert decimal values in array to percentages and pass all values into graph
- Is this graph possible using chart.js?
- How do you remove the data value from the mouse-over result in radar chart?
- How do I import a csv into chart.js?
- How to get item what been clicked on Chart (primeNg chart + angular application)
- Array is not being updated in useState hook?
- Chart.js shaded regions
- Remove data text from Chart.js on hover
- chart.js not working in browser with django. no error for template and static folder setting
- Want to multiple charts on same page with different data
- Chartjs, Bubble Chart, positioning problem with duplicate value in data labels
- How to sum/divide array values in chart.js?
- Chartjs Doughnut Chart smooth animation in countdown
- How to populate entire box inside a React chart (between two axes)
- Charts.JS Bars Not Alternating Color
- I want to show the value of label inside the pie graph. (vue-chartjs / pieceLabel)
- How to change width of the chart using Chart.js
- My pie chart (chartJs) does not appear