Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chartjs: How to plot multi-line chart with irregular intervals

Tags:

chart.js

I am trying to use chart.js to create a multi-line time series plot. The issue is that data points for each of the lines may not have the same interval, for eg. one line can have points at an interval of 5 sec. and another line can have points at an interval of 10 sec.

Can someone suggest me how to approach this.

The above use case can more correctly understood by looking at this.

like image 649
Vanshdeep Singh Avatar asked Jul 06 '15 07:07

Vanshdeep Singh


People also ask

What is multiple line chart?

A multi-line chart is a basic line chart with one or more additional lines that represent comparison trends.


2 Answers

Chartjs (v2.0 onwards) has added time-series chart, samples of which could be found in the their samples folder located in their github repository This lets one plot chart against a time series in X/Y axis.

like image 90
Atty Avatar answered Dec 10 '22 05:12

Atty


Chart.Scatter (http://dima117.github.io/Chart.Scatter/) is an addon for the Chart.js library - it is listed in the Chart.js documentation - http://www.chartjs.org/docs/#advanced-usage-community-extensions

Chart.Scatter adds a date scale to the chart options

// DATE SCALE

// String - scale type: "number" or "date"
scaleType: ...

You can see it in action on the Chart.Scatter home page.

like image 40
potatopeelings Avatar answered Dec 10 '22 06:12

potatopeelings