X labels position on a date/time chart


« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Antonio Vianello on 4th April 2013
Hi all.
I have a problem dealing with x labels position in a date/time graph. I would like to put the x-labels reporting the date/hour just below the x axis ticks; until now I wasn't able to get them EXACTLY BELOW each x axis tick but always shifted to the right.
Is there a solution for this issue?

Thanks in advance
Posted by RGraph support on 4th April 2013
Hi there,

You can use specific label positions like this:

catter.Set('chart.labels', [['Q1',0],['Q2',90],['Q3',181],['Q3',272]]);

Or you can also use the drawing API X axis objectwhich allows a little more control over the label positioning.



PS Could you link to the RGraph website - thanks.

Richard, RGraph Support

1 Year Priority Support now reduced to £299:
   www.rgraph.net/support
Posted by Enter your name... on 4th April 2013
Hi there,

Another way to do it would be to use an X scale - which can be controlled with the axis properties:

dev.rgraph.net/docs/scatter.html#axis properties

Richard, RGraph support
Posted by Antonio Vianello on 22nd April 2013
Hi there,

I've tried the first solution:

theGraph.Set('chart.labels', [['00:00','04/03/2013 00:00'],['01:00','04/03/2013 01:00'], ....... ,'23:00','04/03/2013 23:00']);

but now I see all the labels overlapped and unreadable at the beginning of the chart and not under its own tick...!

Please help me!
Posted by RGraph support on 23rd April 2013
Hi there,

You haven't qaite got the format correct:. This example shows you the correct format:

dev.rgraph.net/fiddle/view/175cb782e2c48b238de1e3e4fd0e59d9



Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer
Posted by Antonio Vianello on 23rd April 2013
Hi there.

Ok, but what is my correct format? I deal with timestamps in the format DD/MM/YYYY HH:MM and not numbers

Thanks
Posted by RGraph support on 23rd April 2013
Hi there,

The format of the date doesn't matter - it's just a label. The number on the other hand corresponds to a value on the X scale:

obj.Set('chart.labels', [
                          ['1st January 2013',0],
                          ['1st April 2012',90],
                          ['1st July 2013',181],
                          ['1st October 2013',272]
                         ]);



Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer
Posted by Enter your name... on 23rd April 2013
Hi there,

My problem is exactly on the X scale! Is there that I have timestamps and not numbers! So what values I have to consider to put instead of your example values 0,90,181,...?

Thanks
Posted by RGraph support on 23rd April 2013
Hi there,

With the Scatter and date based X values you can use dates themselves as X values and not numeric values. The Scatter chart will convert them to numbers for you using Date.parse().

There's an example of this here:

dev.rgraph.net/demos/scatter-date-time-values.html

And you can also use dates in the xmax/xmin values like this:

scatter.Set('chart.xmin', '2012/01/01'); // Start of year
scatter.Set('chart.xmax', '2012/12/31 23:59:59'); // End of year

A word of warning - the Date.parse() function can be very particular about what it accept - so I suggest that you stick to the format shown above.



Richard, RGraph Support

1 Year Priority Support now reduced to £299:
   www.rgraph.net/support
Posted by Antonio Vianello on 23rd April 2013
Hi there.

No hope! I've tried ALL the solution above but still the labels appear huddled together at the left border of the canvas...
Frustrating indeed!

Please please help!
Posted by RGraph support on 23rd April 2013
Hi there,

Just copy the code from the example I gave you.



Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer
Posted by PauloASilva on 26th April 2013
@Antonio Vianello: I'm also using the Scatter chart with date/time values on xAxis and I had the same problem ("labels appear huddled together at the left border of the canvas")

I did surpass the problem creating the xAxis labels array like
[["my label",dateObj.getTime()],...]

Give it a try.

About labels positioning right below the tick, I was trying it too but I'm not sure it is possible without a custom xAxis.

Add a reply

 




« Back to message list
RGraph on social media