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

klaus

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

Set the Base_Resize routine Public.
Amended Width and Height property setting.

Files updated in post #1.

You are right Erel, with Base_Resize it works as expected.
I amended also the Width and Height property setting.
In your example, both work now, but using Base_Resize is more efficient because the chart is redrawn only once.
Attached the prove.
 

Attachments

  • CoronaChartV4_7.zip
    259.5 KB · Views: 357

Cableguy

Expert
Licensed User
Longtime User
Looks really great. Thank you Klaus.

Will I be able to use this in ABMaterial ?
I don't think so, You can however use the csv link and use it with the already available Chart Component in ABM
 

Cableguy

Expert
Licensed User
Longtime User
I keep getting an error;
B4X:
SharedMain - 52: Unknown member: column_type_void
 

klaus

Expert
Licensed User
Longtime User
This is an answer to THIS post in the [B4X] Corona Cases - Cross platform Example thread.

Hopefully, all the properties available now for the left Yaxis will also be available for the right Yaxis such as text color, size,, spacing intervals, etc.
The scale colors are the line colors, otherwise we don't know which line has which scale.
The skipping of Y axis scale values is calculated automatically. Not a property.
Currently, the right scale option works only with Line charts and only if there are two lines.
I will also make it available for YX_Charts.
I intend to extend it to up to four lines, with four different scales, two per tick on both sides . Not sure if I will do it, because for small charts there is not enough room. Don't know yet how to handle it without many properties.
Four scales are already implemented in the xGraph class / b4xlib.
 

klaus

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

Added limit of Y scale values if there is not enough place
Improved values display layout
Added different scales for 2 up to 4 lines in LINE and YX_CHART charts

Files updated in post #1.
 

Mahares

Expert
Licensed User
Longtime User
The xChart Class has been updated to version 4.8.
1. Although the library has been updated to 4.80, the 2 example projects in post #1 still use the 'Class' modules. Is that intentional?
2. Also, you have been working to include a 2nd Yaxis scaling. Was that done in 4.80. If so, what are the members and do you refer to it as 'different scales for 2 up to 4' in your previous post.
 

klaus

Expert
Licensed User
Longtime User
1. Is that intentional? Yes, these are my test projects.
You can always remove the class module and select the xChart b4xlib after having updated it in the AdditionalLibraries folder.

2. The property is xChart.DifferentScales = True.
Can be set in the Designer and in the code.
Nothing else is needed.

I just tested it with different data and saw that there is still a problem with different scales.
Will update it very soon.
 

klaus

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

Amended an error with different scales.
The xChartDemo project uses the xChart.bas module, this is my test project.
The CCP_Demo and the B4J_LogScales project now use the xChart library and not the xChart.bas class module.
Don't forget to copy the new xChart.b4xlib file into your AdditionalLibraries folder before testing.
Suggestion for the structure of your AdditionalLibraries folder, if it is not already done.

Files updated in post #1.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

Jorge M A

Well-Known Member
Licensed User
Hi, Klaus,
Thank you very much for sharing your fine and elegant work.
I'm trying to learn how to use it, with the B4J example of xChartDemo_V5_1.zip.
When I want to see how the graphic is printed, it shows me errors and crashes.
I have no idea if it is relative to the example or to the jfx8Print library.
I tried the example in Debug and Realease mode, with Java jdk1.8.0_211 and jdk-11.0.1, with the same result.
Would you be so kind to guide me to solve it?
Thank you very much in advance.

Log Error (No Crash)
Waiting for debugger to connect...
Program started.
Unexpected event (missing RaiseSynchronousEvents): xpnlcursor_touch
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1336)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:199)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at anywheresoftware.b4j.objects.PaneWrapper$5.handle(PaneWrapper.java:136)
at anywheresoftware.b4j.objects.PaneWrapper$5.handle(PaneWrapper.java:1)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$358(GlassViewEventHandler.java:432)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._enterNestedEventLoopImpl(Native Method)
at com.sun.glass.ui.win.WinApplication._enterNestedEventLoop(WinApplication.java:204)
at com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:511)
at com.sun.glass.ui.EventLoop.enter(EventLoop.java:107)
at com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:590)
at com.sun.prism.j2d.print.J2DPrinterJob.showPageDialogFromNestedLoop(J2DPrinterJob.java:284)
at com.sun.prism.j2d.print.J2DPrinterJob.showPageDialog(J2DPrinterJob.java:253)
at javafx.print.PrinterJob.showPageSetupDialog(PrinterJob.java:343)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4j.example.printerjob._showpagesetupdialog(printerjob.java:145)
at b4j.ChartsDemo.main._btnprint_click(main.java:1300)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:216)
at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)

Ok, to print (crash)
Error occurred on line: 585 (Main)
java.lang.NullPointerException
at b4j.example.pagelayout._getleftmargin(pagelayout.java:60)
at b4j.ChartsDemo.main._btnprint_click(main.java:1335)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:216)
at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)

Ok, to print (crash)
main._btnprint_click (java line: 320)
java.lang.NullPointerException
at b4j.example.pagelayout._getleftmargin(pagelayout.java:60)
at b4j.ChartsDemo.main._btnprint_click(main.java:320)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA$1.run(BA.java:216)
at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
 

stevel05

Expert
Licensed User
Longtime User
Unless Klaus has something different in mind, Line 585 in Main should probably be:

B4X:
PL = P.CreatePageLayout(DPL.GetPaper, Orientation, DPL.GetLeftMargin, DPL.GetRightMargin, DPL.GetTopMargin, DPL.GetBottomMargin)

as PL is not initialized at this point.

This will get you running.

The first error I will have to leave to Klaus to look at.
 

klaus

Expert
Licensed User
Longtime User
Thank you stevel05 for your help !
Amended in the demo program.

Concerning the first problem, don't worry, it's a warning of the compiler.
The problem happens only with the print method.
When you click on the Print button and then you hover over the chart, the warning is displayed.
I tried different possibilities to remove it, but no success.
I had this kind of warning in other applications and had asked Erel about it, but no problem we can ignore it.
I have modified the demo program a bit to show the Print button only when the YX_Chart is displayed, because it's this chart which is displayed.
This will be updated quite soon.
 

rbghongade

Active Member
Licensed User
Longtime User
Dear Klaus,
Thanks for the wonderful ( and much needed charting library). I am wondering ,if it would be possible to have X scale also logarithmic for Line charts.
Also if we can have cursor display for YX chart.
thanks again.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…