NJP
NJP

Reputation: 835

Show multiple values for a day in Highcharts time series

I have an array of information. Each value is from either the beginning or the end of each day.

To illustrate this, take this array: [5, 18, 7, 2]. 5 and 18 were recorded on June 7th, with 5 recorded in the morning, and 18 in the evening. 7 and 2 were recorded June 8th.

How would I represent this information in a Highcharts time series chart?

Upvotes: 0

Views: 298

Answers (1)

Mark
Mark

Reputation: 108512

my naive implementation would be to just space the points equal distance across the day.

For instance, if you have 2 points on June 7th:

 var seriesData = [];
 var milliInDay = 86400000; // milliseconds in a day
 var startOfDay = 1402099200000; // javascript timestamp for start of June 7th
 var numberOfPointsInDay = 2;
 var daySpacing = milliInDay / numberOfPointsInDay;
 seriesData.push([startOfDay + daySpacing, 5]);
 seriesData.push([startOfDay + (daySpacing * 2), 18]);

Upvotes: 1

Related Questions