how do I ignore weekend dates in time series data?

767 views
Skip to first unread message

jason

unread,
Aug 9, 2009, 2:15:36 PM8/9/09
to Flot graphs
Hi,

I have a time series but no data over the weekends. I wish to display
the data continuously and ignore the weekends on the chart so it
doesn't show up as a flat line from Friday to Monday. Any ideas on how
I can do this?

Thanks, Jason

George Roberts

unread,
Aug 9, 2009, 4:28:13 PM8/9/09
to flot-...@googlegroups.com
If you have exactly one time point per day (as opposed to maybe 2 or 20 or 100
points in a given day) then you can just skip time mode and use strings for the
x axis instead of time values.

- George Roberts
http://gr5.org

Marco

unread,
Aug 24, 2009, 9:07:15 AM8/24/09
to Flot graphs
hi, i have the same problem: what does it mean string instead of time
values? Afaik on the x-axis i can set up only numbers or time!

On 9 Ago, 22:28, "George Roberts" <gr-googlegrp...@spamarrest.com>
wrote:
> If you have exactly onetimepoint per day (as opposed to maybe 2 or 20 or 100
> points in a given day) then you can just skiptimemode and use strings for the
> x axis instead oftimevalues.
>
> - George Robertshttp://gr5.org
>
>
>
> ----- Original Message -----
> From: "jason" <jason.novo...@gmail.com>
> To: "Flot graphs" <flot-...@googlegroups.com>
> Sent: Sunday, August 09, 2009 2:15 PM
> Subject: how do I ignore weekend dates intimeseries data?
>
> > Hi,
>
> > I have atimeseries but no data over the weekends. I wish to display
> > the data continuously and ignore the weekends on the chart so it
> > doesn't show up as a flat line from Friday to Monday. Any ideas on how
> > I can do this?
>
> > Thanks, Jason- Nascondi testo citato
>
> - Mostra testo citato -

George Roberts

unread,
Aug 24, 2009, 8:53:08 PM8/24/09
to flot-...@googlegroups.com
>> > I have atimeseries but no data over the weekends. I wish to display

>> > the data continuously and ignore the weekends on the chart so it
>> > doesn't show up as a flat line from Friday to Monday. Any ideas on how
>> > I can do this?

> hi, i have the same problem: what does it mean string instead of time


> values? Afaik on the x-axis i can set up only numbers or time!

Oops. Never mind. Can't do strings on x-axis. What a shame. Would be useful
for bar graphs and other stuff.

You would have to setup your own ticks and tickFormatter. I would have a
function that converts the date into the number of non-weekend/non-holiday days
so far that year. Call it dateToDayNumber(). And another function that
converts it back again dayNumberToDateString(). If you need to graph across
years then Day number should be the number of business days since some given
date (say jan 1, 1800?).

Then convert all your x values using dateToDayNumber() and replace the tick
Formatter with dayNumberToDateString(). That change alone would be pretty good
but to make the tick lines prefer Mondays over other days and 1st of the month
over other days, you would want a few more lines of code to create the tick
spacing based on how many days per pixel there are for a given graph. This is
much easier than creating the two functions mentioned above.

Marco

unread,
Aug 25, 2009, 1:09:25 AM8/25/09
to Flot graphs



> You would have to setup your own ticks and tickFormatter.  I would have a
> function that converts the date into the number of non-weekend/non-holiday days
> so far that year.  Call it dateToDayNumber().  And another function that
> converts it back again dayNumberToDateString().  If you need to graph across
> years then Day number should be the number of business days since some given
> date (say jan 1, 1800?).
>
> Then convert all your x values using dateToDayNumber() and replace the tick
> Formatter with dayNumberToDateString().  That change alone would be pretty good
> but to make the tick lines prefer Mondays over other days and 1st of the month
> over other days, you would want a few more lines of code to create the tick
> spacing based on how many days per pixel there are for a given graph.  This is
> much easier than creating the two functions mentioned above.
>
> - George Robertshttp://gr5.org

well, i'll give it a try, thx!
btw wouldn't be much easier an option to force plotting the data
values only, without interpolation?
Marco

George Roberts

unread,
Aug 25, 2009, 10:53:14 AM8/25/09
to flot-...@googlegroups.com
>btw wouldn't be much easier an option to force plotting the data
>values only, without interpolation?

Okay, yeah. Assuming your data is already such that each point is the "next"
day (no days skipped other than holidays and weekends and no days with 2 points)
then, yes, there is an easier way and it will allow zooming and such.

Put your data in a format like this:
[ [0,5,'july 1'], [1,4,'july 2'] ]
Where the x values simply count up from 0, the y value is the y value for the
graph and the 3rd parameter which is ignored is for your own purposes (or store
the date in another array).

Then replace the tickformatter to show the 3rd parameter like this:

$.plot($("#placeholder"), data, { xaxis: { tickFormatter: function(val){return
data[0][val][2];}}});

- George Roberts
http://gr5.org

----- Original Message -----
From: "Marco" <marcop...@gmail.com>
To: "Flot graphs" <flot-...@googlegroups.com>

Sent: Tuesday, August 25, 2009 1:09 AM
Subject: Re: how do I ignore weekend dates in time series data?


> You would have to setup your own ticks and tickFormatter. I would have a
> function that converts the date into the number of non-weekend/non-holiday
> days
> so far that year. Call it dateToDayNumber(). And another function that
> converts it back again dayNumberToDateString(). If you need to graph across
> years then Day number should be the number of business days since some given
> date (say jan 1, 1800?).
>
> Then convert all your x values using dateToDayNumber() and replace the tick
> Formatter with dayNumberToDateString(). That change alone would be pretty good
> but to make the tick lines prefer Mondays over other days and 1st of the month
> over other days, you would want a few more lines of code to create the tick
> spacing based on how many days per pixel there are for a given graph. This is
> much easier than creating the two functions mentioned above.
>

> - George Robertshttp://gr5.org

well, i'll give it a try, thx!

Marco

Reply all
Reply to author
Forward
0 new messages