Answered by:
LitDev Extension LDGraph Graph
Question

LitDev,
Is it possible to have LDGraph show whole numbers instead of 10ths. The following graph shows both value and days order as 10ths. The values that I am giving LDGraph are whole numbers. I think it would look better if whole numbers are given that the function would stay with whole numbers.
Thanks,
JR
Wednesday, August 6, 2014 8:01 PMAnswerer
Answers

Hello JR,
As there is no answer yet, I tested by adding
he following line before the AddSeriesPoints statement
LDGraph.AxesResolution=1
As you see then the scalevalues are rounded.
Jan [ WhTurner ] The Netherlands
 Marked as answer by jricestkEditor Sunday, August 10, 2014 1:41 PM
Sunday, August 10, 2014 11:58 AMAnswerer 
The new default method can be returned to what was there before using LDGraph.AutoScale="False" and the ScaleAxisX and ScaleAxisY still work, but for almost all cases now I think just changing the GridLines should work.
As I said, they are just a guide in the calculation to choose a suitable grid interval with a single significant figure of 1, 2 or 5  therefore the actual number of grids will vary depending on the actual range of values and I guess in most cases fewer in the Y than X is better.
 Marked as answer by jricestkEditor Tuesday, August 26, 2014 6:03 PM
Monday, August 11, 2014 6:14 PM
All replies

Hello JR,
As there is no answer yet, I tested by adding
he following line before the AddSeriesPoints statement
LDGraph.AxesResolution=1
As you see then the scalevalues are rounded.
Jan [ WhTurner ] The Netherlands
 Marked as answer by jricestkEditor Sunday, August 10, 2014 1:41 PM
Sunday, August 10, 2014 11:58 AMAnswerer 
Jan,
Thanks! I wasn't even thinking that LitDev had a Axes resolution function.
JR
Sunday, August 10, 2014 1:43 PMAnswerer 
Hi, Jan's approach works, but I can explain a bit more.
To calculate the scale axis values I do the following.
1] Find a start and and end point, rounding down and up respectively to a value with 2 significant figures. This is 0 and 14 in your case. Not 1 and 13 since this would leave the end points actually on the border which looks odd.
2] I then divide this into 10 equal intervals.
When Jan changed the AxesResolution to 1 sig fig, the range was 0 to 20 and when divided into 10 intervals gave integer values.
So you can change the sig figs used to do the scaling or alter the number of subdivisions using LDShapes.GridLines property. In the version I just uploaded these are GridLinesX and GridLinesY to set the number of divisions separately in the X and Y axes.
Sample here (with new version).
For i = 1 To 13 data[i] = i*Math.GetRandomNumber(10) EndFor graph = LDGraph.AddGraph(0,0,GraphicsWindow.Width,GraphicsWindow.Height,"TEST","X","Y") LDGraph.GridLinesX = Array.GetItemCount(data)+1 LDGraph.AddSeriesPoints(graph,"Data",data,"Blue") trend = LDGraph.CreateTrend(data,2) LDGraph.AddSeriesLine(graph,"Trend",trend,"Red")
 Edited by litdev Sunday, August 10, 2014 2:09 PM
 Proposed as answer by Ed Price  MSFTMicrosoft employee Tuesday, August 26, 2014 4:42 PM
Sunday, August 10, 2014 2:05 PM 
LitDev,
Thanks for the info. What Jan suggested did work for me in that particular instance and I think the 2 extra functions that you added will help, but I still have an issue. Looking at the above graph and Y values see how the bottom value is set at 2. This and incrementing the values 5.6 for each gridline makes the graph hard to read. Take any of the points and try to estimate the point value. It isn't easy.
So, from your graph I took what I thought the values were and put them into excel to see what it would do with them. As you can see it shows whole numbers for the Y values which makes it a lot easier to read.
I've tried different combinations for LDGridLinesY. 10 works pretty well, but on occasion it will still show values in 10ths. I think the problem starts with the bottom number being something like 2 or 5 and then the spread between the grid positions being like 5.6. So, it would be 2 then 3.6 and 9.2 and so on.
I don't know how excel does it, but it always seems to take the same Y value numbers and show whole values for the grid positions. I've tried it quite a few times and they always work. Is there anyway that can be done with LDGraph?
JR
Monday, August 11, 2014 12:33 AMAnswerer 
I will look at trying to improve the axes numbering (or at least give better control over it).
EDITUpload a version with ScaleAxisX and ScaleAxisY methods.
For i = 1 To 13 data[i] = i*Math.GetRandomNumber(10) EndFor graph = LDGraph.AddGraph(0,0,GraphicsWindow.Width,GraphicsWindow.Height,"TEST","X","Y") LDGraph.ScaleAxisX(graph,0,1) LDGraph.ScaleAxisY(graph,0,10) LDGraph.AddSeriesPoints(graph,"Data",data,"Blue") trend = LDGraph.CreateTrend(data,2) LDGraph.AddSeriesLine(graph,"Trend",trend,"Red")
 Edited by litdev Monday, August 11, 2014 9:19 AM
Monday, August 11, 2014 8:14 AM 
LitDev,
Setting the scale Axis works. The issue that I have doing it that way is that I have 1 subroutine that I do the graph with and I have 7 different graphs that I would need to set the Axis minimum for. I can do that for each set of values that I want to graph and I know it will work, but maybe it could be better!
If I don't change the minimums though the values don't get centered in the graph. One's that have higher values get pushed to the top. Like in the below. So, is it possible to have the extension pick the minimum value? I'm thinking if I set the increment to 10 then the program could only set the axis minimum to an increment of 10. It knows what the range of values are so it would choose a value just below the range. Your original setup was pretty close to doing this. It did have the values centered pretty well.
As always thanks for your help and extension!
picture.
JR
Monday, August 11, 2014 11:51 AMAnswerer 
I was sort of thinking the same  in the uploaded version, if the interval is negative, then the min is autoset.
For i = 10 To 13 data[i] = i*Math.GetRandomNumber(10) EndFor graph = LDGraph.AddGraph(0,0,GraphicsWindow.Width,GraphicsWindow.Height,"TEST","X","Y") LDGraph.ScaleAxisX(graph,0,1) LDGraph.ScaleAxisY(graph,0,10) LDGraph.AddSeriesPoints(graph,"Data",data,"Blue") trend = LDGraph.CreateTrend(data,2) LDGraph.AddSeriesLine(graph,"Trend",trend,"Red")
Monday, August 11, 2014 12:11 PM 
The stuff in the last post is still there, but I have hopefully improved the default behavior so perhaps try without any of the additional controls we have been trying.
This is in recent upload  so try this with your original code. There is a property LDGraph.AutoScale to revert to the old scaling.
Monday, August 11, 2014 1:41 PM 
LitDev,
Here's what it looks like with the new default behavior. The first view is still showing the Y values in 10ths and in the second view the Y values are too close to each other. Would seem like the extension should have chosen a larger interval. The good part is all of the graphs show the values properly centered in the graphs.
It looks like for the Systolic graph the values are centered, but their are too many grid segments. If the interval between segments was increased and the quantity of segments decreased it would show better.
Your last change where I set the min and the increment works the best so far. I am fine with doing that. If you want to keep working on it I would be glad to do that too. It would be nice to nail it!
Another view.
JR
Monday, August 11, 2014 3:48 PMAnswerer 
Its tricky to get a form that works for all cases, can I get a copy of your program, or just the data to plot and test a bit?
EDIT:
On second thoughts, I don't need your files to see the issue.
looking at your plots I think it is working as I would expect, perhaps just reduce GridLinesY. The default values of 10 are used as a guide to trying to find suitable steps sizes.
Since the step sizes are limited to having a single significant figure of 1, 2 or 5, (e.g 0.5, 0.002, 1000 or 50 etc) the actual number of gridlines will usually be between 5 and 20.
If the graph is smallish there is not enough room for more than around 5 grid steps in the Y direction if the numbers are in the 100s and take 3 or 4 characters.
Similarly in the X direction if the numbers are integers (1 or 3 characters) then we can do more of them.
You could try GridLinesY=5 and perhaps GridLinesX = 15
I guess the algorithm could start counting the number of characters to display on a given axis and cut the number of grid accordingly, but...
The main improvement is that the step size will always be a single significant digit of 1, 2 or 5.
 Edited by litdev Monday, August 11, 2014 4:27 PM
Monday, August 11, 2014 3:58 PM 
LitDev,
With the new default and setting the gridlines to (Y=5) (X=15) works well for all of my graphs. Looks like allowing the gridlines for y to be less than the default (10) allows it to work properly. With the value set at 5 the graph for weight and systolic went to 8 gridlines. Seems like allowing 5 to be the min that the program ranges up from that and works well. Let me know if you want to do anything else. Also, are you going to keep all of the changes that were made?
Another improvement is the graphs are a lot easier to read due to the step sizing.
Thanks,
JR
 Edited by jricestkEditor Monday, August 11, 2014 6:05 PM Update
Monday, August 11, 2014 6:00 PMAnswerer 
The new default method can be returned to what was there before using LDGraph.AutoScale="False" and the ScaleAxisX and ScaleAxisY still work, but for almost all cases now I think just changing the GridLines should work.
As I said, they are just a guide in the calculation to choose a suitable grid interval with a single significant figure of 1, 2 or 5  therefore the actual number of grids will vary depending on the actual range of values and I guess in most cases fewer in the Y than X is better.
 Marked as answer by jricestkEditor Tuesday, August 26, 2014 6:03 PM
Monday, August 11, 2014 6:14 PM 
LitDev,
I went back and tried it with the old default and using (X=15) (Y=5). Graphs didn't look as good. So, I'm using the new default with (X=15)(Y=5) and that is great. Thanks for your help.
JR
Monday, August 11, 2014 6:29 PMAnswerer