- George Roberts
http://gr5.org
> 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.
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