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

FernandoGuedes

Member
Licensed User
Longtime User
Klaus parabéns pela criação. Por favor, como formatar corretos os valores do eixo X?

Muito obrigado !!!

 

FernandoGuedes

Member
Licensed User
Longtime User
X axis or Y axis?
For the Y axis, when the value exceeds 999999 then the scientific notation is used.
This cannot be changed.

Desculpe minha falta de atenção é realmente no Eixo Y. Sem problemas Klaus, obrigado pela resposta !!!
 

klaus

Expert
Licensed User
Longtime User
Not directly.
You can display dynamic data, but at the beginning it does not display like an oscilloscope.
If you are looking for B4A, you may have a look at Oscilloscope.
If you are looking for B4J, you may have a look at B4J Oscilloscope.
You may also have a look at THIS.
It will also depend on the sample rate you want to achieve.
 

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
Great work!!!
Thanks.

A minor issue. In at least the B4XPages version you should add "RadarChart1.Visible = False" in the rest of the _click events or else, once you click to see the radar, you will no longer be able to see any of the others.
 

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
Is there a way to mask the pie chart values?

I'm trying to configure it with "PieChart1.SetBarMeanValueFormat (1,2,2, True)" but it doesn't work.

See attached image.
 

Attachments

  • Captura.JPG
    45.2 KB · Views: 164

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
Uncheck Include values:

View attachment 104413
Or set in the code:
PieChart1.IncludeValues = False

This formatting:
SetBarMeanValueFormat
is valid only for single bar charts:

It's a shame.

Anyway thank you very much.

I am trying to make the printing part that is commented in the B4XPages example work and I have already managed to make it pay attention to the page orientation and launch the printing. The problem is that after printing, the program closes itself.
 

klaus

Expert
Licensed User
Longtime User
The problem is that after printing, the program closes itself.
Sorry, but how do you expect me to help you without giving any concrete information on what platform you are using, what you have done and how and what error message you get!
 

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
Sorry, but how do you expect me to help you without giving any concrete information on what platform you are using, what you have done and how and what error message you get!

Sorry, I'm doing practices with B4J variant.

 

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
Strange, because I tested it in Debug mode and it works.

I attach all the log that appears to me from the moment I click on the print button.

First, errors appear when launching the window to configure the page, and then after launching the printing, the rest of the errors appear and finally the application closes completely.

But only in debug mode.


 

klaus

Expert
Licensed User
Longtime User
Well, I see the error too, but without any crash.
I have not found why this happens, maybe Erel has an answer.

The error is in this line:
Answ = PJ.ShowPageSetupDialog(Null)
in the printing routine below.
B4X:
'This routine prints the YX_Chart1 chart
'If you want to print another chart you need to replace YX_Chart1 by the chart to print
Private Sub btnPrint_Click
    Private bmpSnapShot As B4XBitmap
    Private imvDummy As ImageView

    imvDummy.Initialize("")
   
    bmpSnapShot = YXChart1.Snapshot
    MainForm.RootPane.AddNode(imvDummy, 0, 0, YXChart1.Width, YXChart1.Height)

    imvDummy.SetImage(bmpSnapShot)
   
    'Print with dialogs
    Private Answ As Boolean
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob
    Private P As Printer = PJ.GetPrinter
    Answ = PJ.ShowPageSetupDialog(Null)
    If Answ = True Then
        Answ = PJ.ShowPrintDialog(Null)
        If Answ = True Then
            Private DPL As PageLayout = P.GetDefaultPageLayout
           
            Private Scale As Double
            Private Orientation As String
           
            If DPL.GetPrintableWidth / DPL.GetPrintableHeight < bmpSnapShot.Width / bmpSnapShot.Height Then
                Orientation = "LANDSCAPE"
            Else
                Orientation = "PORTRAIT"
            End If
           
            Private PL As PageLayout
            PL = P.CreatePageLayout(DPL.GetPaper, Orientation, DPL.GetLeftMargin, DPL.GetRightMargin, DPL.GetTopMargin, DPL.GetBottomMargin)
            If Orientation = "LANDSCAPE" Then
                Scale = DPL.GetPrintableWidth / bmpSnapShot.Width
            Else
                Scale = DPL.GetPrintableHeight / bmpSnapShot.Height
            End If
           
            Private SJO As JavaObject
            SJO.InitializeNewInstance("javafx.scene.transform.Scale", Array(Scale, Scale))
            Private NJO As JavaObject = imvDummy
            NJO.RunMethodJO("getTransforms", Null).RunMethod("add", Array(SJO))
           
            PJ.PrintPage2(PL, imvDummy)
        End If
    End If
    PJ.EndJob
   
    imvDummy.RemoveNodeFromParent
End Sub

The whole program is the B4J xChartDemo program in the first post.
 

stevel05

Expert
Licensed User
Longtime User
Strange, I only get an error on the line:
B4X:
Private PL As PageLayout
            PL = P.CreatePageLayout(DPL.GetPaper, Orientation, PL.GetLeftMargin, PL.GetRightMargin, PL.GetTopMargin, PL.GetBottomMargin)

Which I guess should be:

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

The job prints and in Release mode, just need to set the YXChart.Visible to True again.

In debug mode I get the error:
B4X:
Unexpected event (missing RaiseSynchronousEvents): mainform_focuschanged

before the print dialog, and it crashes after the printing completes with the error:

B4X:
Error occurred on line: 406 (B4XPagesManager)
java.lang.NullPointerException
    at b4j.B4XPagesxChartDemo.b4xpagesmanager._mainform_focuschanged(b4xpagesmanager.java:536)
    at b4j.B4XPagesxChartDemo.b4xpagesdelegator._mainform_focuschanged(b4xpagesdelegator.java:79)
    at b4j.B4XPagesxChartDemo.main._mainform_focuschanged(main.java:129)
    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 anywheresoftware.b4a.shell.Shell$1.run(Shell.java:206)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(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$4(WinApplication.java:187)
    at java.lang.Thread.run(Thread.java:748)

Presumably because of the first error.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…