How to insert Timestamp Data when using dojox.charting.Chart2D

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to insert Timestamp Data when using dojox.charting.Chart2D

krn1231
This post has NOT been accepted by the mailing list yet.
Hi ,

I am using dojox.charting.Chart2D to display Graphs/ Charts in our Application .

My Timestamp data would be in this format 2005-06-29 08:05:00 .

I am using dojox.charting.Chart2D to display Charts .


Could anybody please let me know how to insert this TimeStamp Data into the addSeries Method of Chart2D ??

Or please let me know what is the appropiate way for inserting Timestamp Data into DOJO Charts ??

help  me , my work has been struck .
Reply | Threaded
Open this post in threaded view
|

Re: How to insert Timestamp Data when using dojox.charting.Chart2D

krn1231
please anybody let me know the answer
Reply | Threaded
Open this post in threaded view
|

Re: How to insert Timestamp Data when using dojox.charting.Chart2D

Eugene Lazutkin
Let me try it again.

By default all time in JavaScript is measured in milliseconds since
midnight of January 1st 1970. If you have something as JavaScript's
Date, it is trivial to convert it to integer and back:

var t = new Date(); // now
var ts = t.getTime(); // integer in ms
var x = new Date(ts); // back as Date

dojo/date/stamp.js helps you to read formatted date and write it back as
ISO string. dojo/date/locale.js can help reading/writing localized dates.

I have no idea how your data is spaced in time. I assume it is taken
with a regular intervals, say every 5 minutes since 1/1/2010. Number
them like that, so 0 will be 1/1/2010, 1 will be 1/1/2010 + 5m, and so
on. You can easily calculate milliseconds from that data.

Next, calculate text labels corresponding to your numbers. You can do it
directly with labelFunc (like in test_chart2d.html):

chart.addAxis("x", {
  labelFunc: function(n){
    var ms = nToMs(n);
    var t = new Date(ms);
    return dojo.date.stamp.toISOString(t, yourFormat);
  },
  maxLabelSize: 50, // important!
});

Or supply them as an array  of labels:

chart.addAxis("x", {
  labels: [
    {value: 0, text: "0m"},
    {value: 1, text: "5m"},
    {value: 2, text: "10m"},
    {value: 3, text: "15m"},
    {value: 4, text: "20m"}
  ]
});

Labels should correspond tick marks, which will be calculated from
integer timestamps, so choose wisely.

Do not force to show more data points than you have pixels on screen
(typically ~1000). If you have much more you should "coarse" your data
using any algorithm from a school book, and renumber data points
accordingly. Usually it helps to have something like: yearly view,
monthly view, weekly, daily, and so on.

Cheers,

Eugene Lazutkin
Dojo Toolkit, Committer
http://lazutkin.com/

On 03/17/2011 12:03 AM, krn1231 wrote:

> please anybody let me know the answer
>
> --
> View this message in context: http://dojo-toolkit.33424.n3.nabble.com/How-to-insert-Timestamp-Data-when-using-dojox-charting-Chart2D-tp2688023p2692232.html
> Sent from the Dojo Toolkit mailing list archive at Nabble.com.
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://docs.dojocampus.org
> [hidden email]
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: How to insert Timestamp Data when using dojox.charting.Chart2D

José Moreira-2
In reply to this post by krn1231
Reply | Threaded
Open this post in threaded view
|

Re: How to insert Timestamp Data when using dojox.charting.Chart2D

krn1231
In reply to this post by Eugene Lazutkin
Thank you for your replies .
I have TimeStampData in this format (2010-01-30 18:09:58) Database and i am representing this in DOJO CHARTS .

Currently i am doing this way

var jStore = {"identifier":"mois",
                "items":[{"mois":1,  "bas":'2010-01-30 18:09:58',   "moy":122.5,   "haut":147},
        {"mois":12, "bas":'2011-05-30 18:09:58',   "moy":105,     "haut":126}]
        };


And i am putting this Data into my addSeries Method , but i dont knpw if its correct or not

 chart1.addAxis('x', { });
 chart1.addAxis('y' ,{});
 chart1.addSeries(
                          "Basse",
                          new dojox.charting.DataSeries(realStore, {query: {bas: "*"}}, "bas"),
                          {stroke: 'red', fill: 'pink'}
                        );


Could you please guide me ?? Waiting for your reply .
Reply | Threaded
Open this post in threaded view
|

Re: How to insert Timestamp Data when using dojox.charting.Chart2D

krn1231
In reply to this post by Eugene Lazutkin
Hi Eugene Lazutkin ,

I have Date in this format  '2011-05-30 18:09:58'  .
Should i convert this Date into Milliseconds and give as a input to the addSeries Method for rendering the Chart ??

Please suggest , thank you , waiting for your reply .
Reply | Threaded
Open this post in threaded view
|

Re: How to insert Timestamp Data when using dojox.charting.Chart2D

Christophe Jolif-2
Hi,

If you don't have regular intervals for your data (i.e. the time interval between 2 data points is varying) and you have line chart (column chart use only index based data) then yes you'll need to map your x-coordinate values (I suppose your date strings) to a Number (for example data milliseconds) for the line plot to use them as x-values. Then you can use a labelFunc on your axis as Eugene suggested to display that milliseconds in your format of preference.

In Eugene case he considered you have regular interval so he got rid of the x-values and used index based values (0, 1, ...) to transform them back to formatted dates. If that is not your case, consider the value pass to the label function is the data in milliseconds and format it as you want.

Hope this helps,
--
Christophe

On Thu, Mar 17, 2011 at 9:42 AM, krn1231 <[hidden email]> wrote:
Hi Eugene Lazutkin ,

I have Date in this format  '2011-05-30 18:09:58'  .
Should i convert this Date into Milliseconds and give as a input to the
addSeries Method for rendering the Chart ??

Please suggest , thank you , waiting for your reply .



_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest