score:2
Accepted answer
In order for the second line to start at the end of the first, its data array needs to skip those values. What you can do is fill the second array with null
as many times as the first array has values.
In your chart configuration pasted above, in the second dataset, here is how you can assign the data
property:
// to start right after the end of the previous line
data: defaultData8.slice().fill(null).concat(defaultData18)
// to start on top of the end of the previous line
data: defaultData8.slice(1).fill(null).concat(defaultData18)
This will copy the first data array (too keep the original intact), override all its values with null
, the concatenate it with second like data, then assign it to the data
property of the second dataset.
Source: stackoverflow.com
Related Query
- chart.js: issue with concatening two line charts
- Chart.js - line chart with two yAxis: "TypeError: yScale is undefined"
- ChartJS - Line chart issue with only 1 point
- Chart.js: compare two periods like Google Analytics with a line chart
- angular-chart.js : issue with pointHoverBorderColor property for line chart
- Chart Js Change Label orientation on x-Axis for Line Charts
- How can I create a horizontal scrolling Chart.js line chart with a locked y axis?
- line chart with {x, y} point data displays only 2 values
- Display line chart with connected dots using chartJS
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- How to display Line Chart dataset point labels with Chart.js?
- Chart.js Mixed Bar and Line chart with different scales
- chart.js Line chart with different background colors for each section
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- Show X axis on top and bottom in line chart rendered with Chart.js 2.4.0
- Chart.js - Line charts with different colors for each border lines
- Chart.js: Line chart with partial dashed line
- Obtain max value of y axis of line chart rendered with Chart.js
- ChartJS - Line Chart with different size datasets
- Line chart with large number of labels on X axis
- ChartJs line chart - display permanent icon above some data points with text on hover
- Is it possible to revert x-axe values in line chart with chart.js
- Drawing line chart in chart.js with json response
- Chart.js line chart with area range
- Extending Line Chart with custom line
- Can we draw a Line Chart with both solid and dotted line in it?
- Chart js: Update line chart having two data sets
- chart.js pie chart issue with display: none
- ChartJS - how to display line chart with single element as a line? (not as a dot)
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
More Query from same tag
- Chart.js multiple datasets on one y axis
- Chart.js v2 - Partial Y -grid lines with bar chart
- Chart JS - Use time for xAxes
- How to connect Firebase in Chart.js?
- Chartjs / Javascript - My function not returning array properly, but console logs okay
- Chart.js - Where do I find which components should be registered?
- Put array in chart data
- charts.js update global variables
- ChartJS: Chart not displaying full range of data
- Chart.js - add gradient instead of solid color - implementing solution
- How to hide Chart.js data labels for small screens
- ChartJS + twig symfony
- Chart.js More than 1 charts on same web page
- Using ng2-charts, how to "zoom out"?
- Chart JS, Choose different Y-axis for different datasets
- How to change the Chart.js legend rectangles to squares
- chart.JS i want to put different color for each Y axis value grid line color
- pie chart inside donut chart using chart js
- Why does the horizontal bar size jump when resizing the chart?
- How can I display both values as labels when hovering over chart.js
- chart.js-plugin-annotations multiple horizontal lines in one chart
- Applying Callback To One Y-Axis
- dynamic number of chart.js charts on the same page
- Unable to make y-axis to begin at zero on Charts.js v2.1.4
- Load data from Google Analytics in a Chart.js chart
- How to fix bars in Chart.js with long labels
- ChartJS multiple annotations (vertical lines)
- How do I run Chart.js with Angular 10 SSR / universal?
- load a graph with chart.js and react
- injecting chart.js sparkline to jqxGrid widget in Angular with typescript