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

LucaMs

Expert
Licensed User
Longtime User
Premising what I have already written in a previous post (a bit different)...

the usual great Klaus.

I want to give him a gift: more work

It would be great if you could touch a point on a chart and get more related details.


[Note that for the moment I do not use graphic charts, although I have an app in mind for which I would use them, and that as it is, it's absolutely great!]
 

LucaMs

Expert
Licensed User
Longtime User
Hi, great Klaus .

I changed this little part of DrawGrid (in a non-elegant way but it works ):
B4X:
    For i = 0 To Scale.NbYIntervals
        Private txt As String
        txt = NumberFormat2(Scale.MaxVal - i * Scale.YInterval, 1, Abs(Scale.Exp), 0, False)
        y = Graph.Top + i * Graph.YInterval
        xcvsGraph.DrawLine(Graph.Left - 4dip, y, Graph.Left, y, Graph.GridFrameColor, 2dip)
        If txt = "0" Then
            xcvsGraph.DrawLine(Graph.Left, y, Graph.Right, y, Graph.GridColor, 3dip)
        Else
            xcvsGraph.DrawLine(Graph.Left, y, Graph.Right, y, Graph.GridColor, 1dip)
        End If
#if B4A

Just to highlight the line for value zero, if present.
 

LucaMs

Expert
Licensed User
Longtime User
I had added it for the Bar charts but not for the line charts.
Yes, I had seen it, in the examples.

[In your examples I also see that the line graphs are complete, but if I pass N values, it seems to add a space for another one at the end]
B4X:
    For i = 0 To 9
       xChart1.AddLineMultiplePoints(i, Array As Double(Rnd(-100, 101), Rnd(-100, 101), Rnd(-100, 101)), True)
   Next
 

Harris

Expert
Licensed User
Longtime User
Are you sure it does work in a ABMATERIAL App? I´m not.

Give ab some time... I'm sure he can morph it.

I use it (XUI canvas and other objects) with my ABM app (not in) using shell, to create a graph.

B4X:
Sub DoImages(pid As String)
    Dim shl As Shell
    shl.Initialize("shl", "java.exe", _
    Array As String("-cp", "Charts.jar", "b4j.example.main", pid))
    shl.WorkingDirectory = File.DirApp
    shl.Run(30000) 'set a timeout of 30 seconds
 
End Sub

In the Charts.jar, I create the graph, save it as a bitmap to disk, and use it later in ABM.

B4X:
    Dim Out As OutputStream = File.OpenOutput(File.DirApp, sfilename, False)
    Dim bmp As B4XBitmap =  BD.Canvas.CreateBitmap
    bmp = bmp.Rotate(90)  ' rotate to simulate horizontal graph
    bmp.WriteToStream( Out,100,"PNG")
    Out.Close

Here is an example of the output graphs (each graph is a separate saved bitmap). Each graph is added as a blob to a table so NextReports can produce a report with these images included - output as PDF.



The image above shows these graphs clean and clear.
However, when these are printed (from a PDF), the graph section (images) become blurred / grainy. The bitmap below is a bad example since it is not the original PDF created.


If I take the same PDF file myself, and output it to a printer - the graph images are crystal clear...
This bothers the living heck out of me trying to determine what went wrong, where and how to resolve. The images are not scaled (resized) up or down - original size included.

Thanks
 
Last edited:

Harris

Expert
Licensed User
Longtime User
I don't know, I have never used ABMaterial.
Gosh, I wish you would (yet I know B4x is just a hobby for you).
I can only imagine what would result given your knowledge of all else B4X...

Say Cheeze!
 

rossati

Active Member
Licensed User
Longtime User
Thanks Manfred
I've seen it, but I do not think there's a page to download the library from.
 

LucaMs

Expert
Licensed User
Longtime User
Allow me to complain (not about this great view!!!)

1) I have to check if I can resize a chart (line chart) at runtime (b4a), because I tried (casually) and I got an error;
2) have to study if it is possible to change the line stroke width and even different widths in a single line chart;
3) have to study if I can create dotted lines (again a mix of different kind of lines in a single chart);
4) have to study if I can highlight points in common (coinciding, same value y) between two or more lines. drawing asterisks or other.

Maybe this is too much work to get ... 2 downloads in the next 10 years
 

klaus

Expert
Licensed User
Longtime User
1) Luca, are you kidding me?
Must I really post 'What error do you get' like for newbies?

2,3) I have not yet looked to add different line strokes nor line types.
4) Maybe, part of it will come.

For the moment, I don't want to make a hudge project for this.
The more options, the more difficult it will become to set a chart.

Do you have a concrete example of a chart where you need different strokes or line types in the SAME line ?

As I already wrote, I am probably old fashioned, but often amazed how many people are more concerned on aesthetics rather than on the concrete data values.
I have worked for 25 years in measurements and analysis in a mechanical industry and my concern was always the values and their evolution over time simple and efficient diagrams.

Again, I am open to suggestions and if I find those useful, I will add those!
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…