B4J Library [B4X] [XUI] xChart Class and b4xlib

Kevin L. Johnson

Member
Licensed User
Longtime User
On the yxChart, Is there a way to plot multiple types of data but with differing amounts of data array lengths?

For example, limit lines (either vertical or horizontal) onto the Chart. Or one data set with 100 data points against another dataset with 50 data points.

The example plots three sets of yx scatter data but they all have the same number of points. This is causing me to scratch my head a bit to plot data points that come in once a second with data that comes in 4 times per second with maybe a vertical limit line etc.

Thanks for any help.
 

klaus

Expert
Licensed User
Longtime User
Try the attached version.
You can use sets with different number of points.
I changed the data structure for YXCharts.
You need to change the filling of the arrays.
One point per line.
New method:
YXChart1.AddYXPoint(LineIndex, X, Y)
Old methods, removed:
YXChart1.AddXYPointData(X, Y)
YXChart1.AddYXMultiPoints(XArray, YArray)




You see that there are much less green points.

EDIT: removed the zip file.
 
Last edited:

Kevin L. Johnson

Member
Licensed User
Longtime User
Klaus,

Your latest addition to YXChart is working nicely to add multiple datasets of differing numbers of datapoints.

Unfortunately, I seem to be having difficulty with the axis scaling (such as .YScaleMinValue = -5 and .YScaleMaxValue = 120 with or without also specifying the X max and min values within the internal designer.

In short, the scaling does not seem to work properly.

also ...
Q1: Is there a reason the chart type is called YXChart instead of XYChart?

Q2: Is there a reason the X min and max values can only be specified in the Internal Designer?

Thanks for all your efforts.

Kevin
 
Last edited:

klaus

Expert
Licensed User
Longtime User
In short, the scaling does not seem to work properly.
In the Designer, if you want to use the scale min and max values you must set Automatic scales to False, un check the property.
In version 1.9, when setting min and max scale values in the code, you needed to set also Automatic scales to False in the code, this is no more necessary in version 2.0.

Q1: Is there a reason the chart type is called YXChart instead of XYChart?
For me Y is a function of X, so YXChart.
I have in mind to eventually add a YtChart type (Y as a function of time).
Q2: Is there a reason the X min and max values can only be specified in the Internal Designer?
No, I missed to add these properties, done in version 2.0.

Attached version 2.0.
Added get / setXScaleMinValue and get / setXScaleMaxValue properties
Added Automatic = False when scale values are changed

When it is OK for you, I will update the project in the first post.

EDIT: 2018.07.30 Removed the zip file, it is in the first post.
 
Last edited:

Kevin L. Johnson

Member
Licensed User
Longtime User

Thanks Klaus,
Everytime I develop software using B4X, or one of its libraries (including user contributed code), I feel like I truly am 'Standing on the Shoulder of Giants'! THANKS FOR BEING A GIANT metaphorically that is. :--)

I am now able to control the plot scaling in order to view the data nicely. There are a few artifacts such as this,...


which can easily be controlled by making sure my axis scaling is appropriate for 'containing' the data values ... ( in an ideal world, data that falls outside of the scaled chart area would not plot or be seen, but I AM very much grateful for the current capability) .

And for a few more items that I have discovered ...
It appears as though while YXChart1.NbYIntervals = 10 can be set programmatically via the code interface

YXChart1.NbXIntervals cannot as it is NOT EXPOSED in the programmatic code interface

QUESTION1: Is there a way for me to Capture an image of the Chart in order to later produce an HTML Report of sorts?

QUESTION2: Is there any way to track the XY position of the Mouse as it moves over xChart through a mouse move event of sorts?

Furthermore ... In case this hasn't been mentioned yet ... recently when I have obtained the latest version(s) of this library, the first run of the Chart Demo produces this screen (I promptly circumvent it by commenting out the line, but would like to know what, if anything I might be doing wrong)...
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User

Do not comment out line 1556, change it to the following line.
B4X:
bc1.FillRadialGradient(bc1, Array As Int(Acol, Item.Color), rb)

Enjoy...
 

Kevin L. Johnson

Member
Licensed User
Longtime User
Do not comment out line 1556, change it to the following line.
B4X:
bc1.FillRadialGradient(bc1, Array As Int(Acol, Item.Color), rb)

Thanks Peter,

After doing this it still errors out with ..
Error description: Unknown member: fillradialgradient
Error occurred on line: 1560

However, when I change it from ...
bc1.FillRadialGradient(Array As Int(Acol, Item.Color), rb)
To
bc1.FillGradient(Array As Int(Acol, Item.Color), rb, "TOP_BOTTOM")

it does work ... but I'm not sure if this was the original intent.

Perhaps I have the wrong version of Bitmap creator? My IDE Library Manager indicates that it is jBitmap Creator Version: 3.11
 

klaus

Expert
Licensed User
Longtime User
You have the wrong jBitmapCreator library version, the latest is version 4.00.
It is included as a standard library in the latest versions of B4J. I think that it should work with version 3.61.
Which version of B4J do you use.

I will answer the other questions tomorrow.
 

Kevin L. Johnson

Member
Licensed User
Longtime User
You have the wrong jBitmapCreator library version, the latest is version 4.00.
It is included as a standard library in the latest versions of B4J. I think that it should work with version 3.61.
Which version of B4J do you use.

Thanks Klaus ... Under the Help Menu and the About Sub-menu it indicates B4J Version 6.3
 

klaus

Expert
Licensed User
Longtime User
There are a few artifacts such as this,...
I prefer automatic scales, therfore, the scales are calculated automatically by default. You might use automatic scales.
Anyway, amended, I added a clip function to avoid drawing outsides the grid.
YXChart1.NbXIntervals cannot as it is NOT EXPOSED in the programmatic code interface
Added the NbXIntervals property.
QUESTION1: Is there a way for me to Capture an image of the Chart in order to later produce an HTML Report of sorts?
Added the Snapshot property (read only).
QUESTION2: Is there any way to track the XY position of the Mouse as it moves over xChart through a mouse move event of sorts?
What do you want to do with? Do you want scaled units or pixels.
Added a Touch event with scaled units for testing.



Clipped drawing.

EDIT: Removed the zip file.
 
Last edited:

Kevin L. Johnson

Member
Licensed User
Longtime User

WOW! I am Speechless, Thanks for adding all three, the Clipped drawing, NbXintervals and the snap-shot property (all these features make for great images in the HTML reports).

As for why I wanted the Mouse Move XY position (scaled units are desired), it was so that I might be able to more dynamically interact with the plots. For instance, placing crosshairs, displaying chart coordinates like in my past VB6 project days (I was hoping for the event to fire on mouse move – although the addition of the Touch event works out great too!). I tried it on a large 72” Dell Touch Monitor. Thanks very much.

(Slight Digression here, but related to xChart)
Lastly, I found another great discussion in the B4j Forums (this time in the B4A forum, re rotating a view in degrees) and low and behold it was Klaus again … in that post you recommended a separate post regarding ‘view utils’.

https://www.b4x.com/android/forum/threads/view-utils.39347/

This is critical for another B4J project (where I want to rotate photographs of Charts displayed on screens that are angled to the camera lens (I tried out your demo and it is perfect!, but coded for B4A). I did copy it over to B4J but it was confused about what type of ‘view’ was referred in the subroutines called interface. I tried several things but was never able to get it to run in B4J.

Also, believe it or not I have a bit of a need to rotate the xChart View within B4J to align the chart's data with the Screens VERTICAL sides, something like rotating to fit beside geographic features ‘on the ground’ that would be displayed in the background of the layout.

QUESTION1: Is it possible to use the View Utils for rotating views in B4J?

AND

QUESTION2: Would these ‘ported’ B4J version of ‘view utils’ work with the xChart View also in B4J?
 
Last edited:

klaus

Expert
Licensed User
Longtime User
QUESTION1: Is it possible to use the View Utils for rotating views in B4J?
No.
QUESTION2: Would these ‘ported’ B4J version of ‘view utils’ work with the xChart View also in B4J?
The best way to port this, is to use the cross platform XUI library.

The answer to your question is quite simple!
The B4XView has a Rotaion property. This is now implemented in the project below (I left the same version number).
As this is a cross platform object, it is valid for B4A, B4i and B4J !
This is the BIG advantage of using the XUI library, even for mono platform projects.




EDIT: 2018.07.30 Removed the zip file, it's in the first post.
 
Last edited:

Kevin L. Johnson

Member
Licensed User
Longtime User
Agreed! I will be developing with XUI as much as possible, I just had no idea that an XUI view's rotation was built in, And I appreciate your adding the feature(s) to your xChart class. Your work really is Awesome!
 
Last edited:

klaus

Expert
Licensed User
Longtime User
The xChart Class has been updated to version 2.1.

EDIT: 2018.07.30 Version 2.1
Added the NbXIntervals property
Added the SnapShot property
Added the Rotation property
Added the DrawOuterFramw property
Added a clip function to avoid lines being drawn outsides the grid
Added a Touch event for YXCharts returning the X and Y coordinates of the cursor

EDIT: 2018.07.19 Version 2.0
Added XScaleMinValue and XScaleMaxValue properties

EDIT: 2018.07.14 Version 1.9
Modified the data structure for YXChart to allow lines with different number of points.
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
Hello @klaus,
This is just a quick message to let you know that Bitmapcreator V4.0 breaks xChart. When I go back to BitmapCreator V3.2 it works again.

Using BitmapCreator V4.0 only breaks xChart in Release (Obfuscated) mode, xChart still works just fine whilst debugging in Debug mode and Release mode.

I've not had a chance to look at it properly though, I just reverted straight back to the previous BitmapCreator.

Please note that I may have missed something obvious though, I didn't really look that closely.

Cheers...
 
Last edited:

klaus

Expert
Licensed User
Longtime User
With which product do you get the problem B4A, B4i, B4J?
I suppose B4J, it's the only product with BitmapCreator version 4.00.
Do you get any error?
Can you test the attached project, amended some bugs.
EDIT removed the zip fils, outdated.
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
Good morning @klaus
Firstly sorry I got my messages mixed up as I was not concentrating when typing.
Yes B4J
Anyway everything appears to be working now, thank you for the code update.

Your attached project appears to have sorted everything out.

Have a nice relaxing day with your family...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…