tobiasz1985528 / flot

Automatically exported from code.google.com/p/flot
MIT License
0 stars 0 forks source link

Adding week day names to flot #295

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi I had a quick search through these pages but couldn't find anything on
the matter.

Does anyone know how to add week day names to flot's time tick renderer. I
would like to keep the existing renderer in flot but just make it so when
the graph range is within say 2 weeks, show ticks like "Thur Jan 21".

Any help will be greatly appreciated.

Cheers,

Joel

Original issue reported on code.google.com by joelough...@gmail.com on 20 Jan 2010 at 8:56

GoogleCodeExporter commented 8 years ago
Any ideas anyone?

Original comment by joelough...@gmail.com on 2 Feb 2010 at 7:58

GoogleCodeExporter commented 8 years ago
Hello,

On axis options you can use ticks options to specify with a Javascript Array 
which
ticks do you want to show and its labels.

It's not as easy as automatic ticks with timeformat. But you can model what you 
say
using javascript.

Also you can get the axis data with getAxes() and then create your array.

It's a little bit tricky for an easy situation (show day names) but is an 
option and
it works.

Original comment by jordi.ks...@gmail.com on 26 Mar 2010 at 12:19

GoogleCodeExporter commented 8 years ago
For those of you that are interested.

I solved this problem by adapting the jsDate code found here:
http://slingfive.com/pages/code/jsDate/jsDate.html

I had to change all the date functions to use the UTC functions to get timezones
working right.

In flot it was just a matter of using a Tic formatter, that creates and 
displays the
appropriate date format depending on the current x-axis range.

        tickFormatter: function (val, axis) {
          var range = axis.max - axis.min;
          if (range < 2*24*60*60*1000)
            return Date.Format(val, "h:nn");
          if (range < 5*24*60*60*1000)
            return Date.Format(val, "ddd hh:nn");
          if (range < 10*24*60*60*1000)
            return Date.Format(val, "ddd mmm d");
          if (range < 31*24*60*60*1000)
            return Date.Format(val, "mmm d");

          return Date.Format(val, "mmm d, yyyy");
        } 

Original comment by joelough...@gmail.com on 28 Mar 2010 at 9:43

GoogleCodeExporter commented 8 years ago
There was also a patch for Flot posted here:

http://groups.google.com/group/flot-graphs/browse_thread/thread/aa2154b22b5d60c1

Original comment by olau%iol...@gtempaccount.com on 14 Apr 2010 at 11:25

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 8 May 2012 at 12:11

GoogleCodeExporter commented 8 years ago
This was fixed in 
https://github.com/flot/flot/commit/a54ec4ad64311f13e4d75cd67f4d77c4906456d1 
when date formatting was standardized.

Original comment by mrcote on 3 Dec 2012 at 5:42