Data array with null values not aligning with vertical lines

« 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 Luis on 18th September 2012

I am making a graph with the following characteristics:
* It's a Line Graph
* I have one data array with 12 values. Each value corresponds to a month.
* The last 3 values of the array are null since we don't know those values yet. (So my data array looks something like [1,2,3,4,5,6,7,8,9,,,])
* Since I want to show the vertical lines of the grid (vlines) aligned to each month on the X axis, I am using "grid.autofit = true; grid.autofit.numvlines = 11;"

When the array has all 12 values, all the tickmarks are perfectly aligned with each vertical line in the grid. But when I only have the first 9 values (leaving the last three values null in the array), the tickmarks get slightly off to the right for each month and they do not show aligned with the grid.

How do I align the tickmarks with the vertical lines of the grid when I have null values in the data array?

Posted by on 19th September 2012

This looks OK:

Keep in mind that if you specify a value for chart.hmargin then that will throw the alignment out of whack.
Posted by on 21st September 2012
Thank you! So it has to say "null" inside the array when there is no value. I was just leaving it blank. I tried it and it displays fine now. Thank you again!
Posted by on 21st September 2012

Yes, but ensure that you don't use quotes - otherwise it's a string (that just happens to say null):

[1,9,4,3,1,9,8,4,8,null,null,null, 8, 9, 7]

« Back to message list
RGraph on social media