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

stevel05

Expert
Licensed User
Longtime User
@klaus Yes that's true. You've already made the mods in that one and it is working for me.

Works pertectly in release mode, also works in debug mode but I do get an error:

B4X:
Unexpected event (missing RaiseSynchronousEvents): xpnlcursor_touch

Have you got version 0.6 of the jFX8Print library?
 

klaus

Expert
Licensed User
Longtime User
Have you got version 0.6 of the jFXPrint library?
Yes, I have version 0.6.
I thought that it might be because of Java11.
I tested it also with Java 8, same error.

This error
Unexpected event (missing RaiseSynchronousEvents)
is considered as harmless warning only in Debug mode, according to Erel in several threads.
 

Alessandro71

Well-Known Member
Licensed User
Longtime User
I noticed a strange behavior in XY_CHART
Here is a screenshot of the same dataset, plotted in LINE mode an XY_CHART mode
I assume to get the same result, while, the XY one is totally wierd

a B4J project is attached
I'm using version 6.40
 

Attachments

  • testcharts.zip
    5.4 KB · Views: 157

klaus

Expert
Licensed User
Longtime User
The problem is that you have all Y values either on the top or bottom line of the chart.
In the drawing routine the outer frame of the chart is redrawn after the lines, I will remove this for the next update.
I changed the code in your project like this:
B4X:
    xC_chartmulti.IncludeLegend = "NONE"
'    xC_chartmulti.AutomaticScale = True
'    xC_chartmulti.DifferentScales = True
    xC_chartmulti.YZeroAxis = False
    xC_chartmulti.YZeroAxisHighlight = False
    xC_chartmulti.IncludeLegend = "TOP_RIGHT"
    xC_chartmulti.YScaleMaxValue = 13.55
    xC_chartmulti.YScaleMinValue = 13.35
Commented the first two lines and added manual scales, the two last lines.

And the result is as expected:

 

Alessandro71

Well-Known Member
Licensed User
Longtime User
looks like it doesn't behave any different
i was expecting the autoscale of the YX chart will set Y axis to leave some room upper and lower, just as the line one

 

klaus

Expert
Licensed User
Longtime User
I am afraid that I uploaded an older version.
Attached a newer one, I modified it to better show lines on the edges..



EDIT: 2021.03.15
Removed the xChart.b4xlib file, it has been updated in the first post.
 
Last edited:

Alessandro71

Well-Known Member
Licensed User
Longtime User
It still doesn't work for me


thank you for your effort, but still please consider, where scale is set to Auto, to add some more space between data points and axis
 

klaus

Expert
Licensed User
Longtime User
I am afraid that you still have an older version of the library.
I downloaded the xChart.b4xlib from my previous post, copied it in my AdditionalLibraries folder and it works as shown in post #352.
You should see the Y scale values in black instead of red.

Attached your project with the xChart.bas file in the project.
Which version number do you see in the Libraries Manager?
 

Attachments

  • testcharts1.zip
    32.9 KB · Views: 161
Last edited:

klaus

Expert
Licensed User
Longtime User
xChart has been update to Version 6.6.

Version 6.6
Added horizontal bar types H_BAR and H_STACKED_BAR, the bars are displayed horizontally instead of vertically.
Added HBarsXScaleOnTop property, displays the horizontal scale on top instead on bottom, only for for H_BAR and H_STACKED_BAR charts.
Added HBarsTicksTopDown property, displays the tick values from top to bottom, only for for H_BAR and H_STACKED_BAR charts.

Version 6.5
Added CursorTouch(Action As Int, CursorIndex As Int) event
Added KeepDisplayValues property, allows to keep the values display displayed after Touch_Up.
Added ClearDisplayValues method, allows to clear the values display.
Set Points (point data) and Items (item data, Lines, Bars etc) lists as Public
 

Alessandro71

Well-Known Member
Licensed User
Longtime User
Is an intended behavior that on YX_CHART, even with DisplayValues = True no values are displayed when touching the chart?
 

klaus

Expert
Licensed User
Longtime User
Yes, it is an intended behavior and there is a reason behind.
For Line and Bar charts we have on the horizontal axis ticks, which are strings.
For each tick we have one or more numeric values.
When we click on the chart and move the cursor, we know the position of the cursor on the horizontal axis, we can calculate the nearest tick and display the numeric values of this tick.
In YXCharts the data structure is different, we have curves and each curve contains a certain number of points which are defined by their x and y coordinates.
Clicking on the chart and moving the cursor, we know the position of the cursor. But all we could do is check for the nearest point and display its coordinates and the curve name it belongs to. I did not add this possibility because I find it not really useful.
But, you can define a Touch event routine in your code, this one returns the Action and the x and y coordinates of the cursor position in real coordinates.
And you can do whatever you want

PS: For the next edition, I added a remark, in the in line help, that DisplayValues is not valid for YX_CHARTs.
 

Alessandro71

Well-Known Member
Licensed User
Longtime User
I understand, but please consider displaying the nearest point on touch events, for the next release.
Also for the next release, some descriptions in the designer have a mispell, eg: Y min vlaue
 

klaus

Expert
Licensed User
Longtime User
I reconsidered your request.
Yes it can be interesting to know the coordinates of the cursor position.
I added three new properties:
YXChartDisplayValues, displays the cursor positions coordinates on YXCharts.
YXChartDisplayCrossHair, displays the cursor positions as a cross hair cursor on YXCharts.
YXChartCrossHairColor, color for the cross hair cursor on YXCharts.
When the two first properties are set to True then:
- When you hover over a YXChart, the cursor position is displayed with two lines and the coordinate values are displayed in a rectangle in a corner.
- When the cursor is near an existing point, the cursor snaps to the point coordinates and the cross hair lines color changes to the curve color.
- When the cursor is near an existing point and no point is drawn, a small circle is drawn around the points coordinates.

Can you please test this new version ?
Attached the B4J demo program and the b4xlib and bas files.

In the image you see the cursor at a point on the blue line



EDIT 2021.02.23
Removed the zip files, they are in the first post.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…