B4J Question xGraph: Sizing of plotting surfaces

rgarnett1955

Active Member
Licensed User
Longtime User
Hi,

When I change the x values of a fixed number data points for a line plot the overall size of the plotting surface isn't maintained viz:

Snag_36c051db.png



Snag_36c08232.png



These two plots had 1200 points, with the difference between them being only the x values:

Upper => -200 to 0.
Lower => -1200 to 0.

I have played around with the no of x tick intervals, but haven't been able to fix it.

Am I using xGraph incorrectly?

Is there a way of preventing this?

Best regards
Rob
 

klaus

Expert
Licensed User
Longtime User
This is how it is designed.
This library is based on a program I had written some decades ago to do graphic data analysis.
In this program we could export graphs to Word for our reports.
These graphs had two grid types : 10mm or 5mm on the printed paper.
This gave also fixed grid values on the screen.

In the library, I calculate the available width for the graph depending on the margins, scale values and axis text.
Then I divide this width by the number of X intervals which gives the width of the grid and this remains constant.
Then, I calculate the optimum scale interval values which are either 1, 2, 2.5, 5, 10 (1!2!2.5!5!10).
Depending on the scale interval value, the number of grid intervals is not the same.
In your example you have:
-200 to 0, gives a scale interval value of 10 and 20 intervals.
-1200 to 0 gives a scale interval value of 100 but with only 12 intervals, and because the grid width is the same the graph width is smaller.

What you could do is to select the other ScaleXValues property with these values 1, 1.2, 1.5, 1.8, 2, 2.5, 3, 4, 5, 6, 7, 8, 9, 10 (1!1.2!1.5!1.8!2!2.5!3!4!5!6!7!8!9!10).
Or you can define your own, the first number must be 1 and the last must be 10. In between you can add any numbers separated by an exclamation point.
 
Last edited:
Upvote 0

rgarnett1955

Active Member
Licensed User
Longtime User
This is how it is designed.
This library is based on a program I had written some decades ago to do graphic data analysis.
In this program we could export graphs to Word for our reports.
These graphs had two grid types : 10mm or 5mm on the printed paper.
This gave also fixed grid values on the screen.

In the library, I calculate the available width for the graph depending on the margins, scale values and axis text.
Then I divide this width by the number of X intervals which gives the width of the grid and this remains constant.
Then, I calculate the optimum scale interval values which are either 1, 2, 2.5, 5, 10 (1!2!2.5!5!10).
Depending on the scale interval value, the number of grid intervals is not the same.
In your example you have:
-200 to 0, gives a scale interval value of 10 and 20 intervals.
-1200 to 0 gives a scale interval value of 100 but with only 12 intervals, and because the grid width is the same the graph width is smaller.

What you could do is to select the other ScaleXValues property with these values 1, 1.2, 1.5, 1.8, 2, 2.5, 3, 4, 5, 6, 7, 8, 9, 10 (1!1.2!1.5!1.8!2!2.5!3!4!5!6!7!8!9!10).
Or you can define your own, the first number must be 1 and the last must be 10. In between you can add any numbers separated by an exclamation point.
Thanks's Klaus, that helps.

I will play around a bit more.

Best regards
Rob
 
Upvote 0
Top