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

klaus

Expert
Licensed User
The x axis can already be set, in the Designer or in the code.
Only in the values display the name is set to 'x'.
Test the attached xChart library, I replaced x by the x axis name.
 

Attachments

MbedAndroid

Active Member
Licensed User
one thing i noticed Klaus, is that i cant set the titlecolor in Piecharts.
Or has this to do as i'm calling Piecharts from a service? I can set the background color.
(the piecharts sub is located in main activity of course)
B4X:
    PieChart1.ClearData
    PieChart1.Subtitle="Zones"
    PieChart1.Left=50%x
    PieChart1.Height=25%y
    PieChart1.titleTextColor=Colors.Blue
solution: change this line in the library subroutine drawpies

B4X:
If Graph.Title <> "" Then
        xcvsGraph.DrawText(Graph.Title, xcvsGraph.TargetRect.Width / 2, 1.2 * Texts.TitleTextHeight, Texts.TitleFont, Texts.TitleTextColor, "CENTER")
    End If
 
Last edited:

MbedAndroid

Active Member
Licensed User
another issue is visible=false doesnt affect Pie's title. All items are invisible except the Title. Setting in the designer or in the program has no effect on the Title. Lines/bars are ok
 

klaus

Expert
Licensed User
another issue is visible=false doesnt affect Pie's title.
What exactly is the problem?
In the demo program I set PieChart1.Visible = False and nothing is displayed.
Setting the PieChart1Title to "" removes the title and the chart is readjusted.
 

MbedAndroid

Active Member
Licensed User
here you are Klaus
See screenshots: Piechart1 is set invisible in the designer. Still when the app starts up i get the Title text.
Compare it with screenshot 2 when the app is running the program sets Piechart1 to visible
Note: when i set during startup Piechart1 to invisible by code it works. Thus the problem is only the designer.
Lines and Bars are working via the designer visible/invisible.
Minor problem

Screen Shot 08-01-20 at 01.47 PM 001.PNG
Screen Shot 08-01-20 at 01.47 PM.PNG
Screen Shot 08-01-20 at 01.48 PM.PNG
 

klaus

Expert
Licensed User
Are you sure that the title is part of the chart?
Its position and size look strange to me.
And the Visible property is handled the same for all chart types.
Can you post your test project?
 

winjiadh

Active Member
Licensed User
I download the demo, It's very good!
but I want to change the PieChart Values color, like the screenshot
screenshort.png

I change the Designer PieChart1 Values text color like this
sss.png

but the color is Black
so, I change the Private Sub CreatePieData , add codes
PieChart1.ValuesTextColor=xui.Color_Red
and the color is Black
How to change the values's color?
thank you!
 

MbedAndroid

Active Member
Licensed User
in code it is this
B4X:
PieChart1.AddPie("Slice #1", z(0), Grade(0)) '0 = random color
    PieChart1.AddPie("Slice #2", z(1), Grade(1))
    PieChart1.AddPie("Slice #3", z(2), Grade(2))
    PieChart1.AddPie("Slice #4", z(3), Grade(3))
    PieChart1.AddPie("Slice #5", z(4), Grade(4))
    PieChart1.AddPie("Slice #6", z(5), Grade(5))
grade(x) is something i use, could be also xui.Color_xxxx
 

klaus

Expert
Licensed User
How to change the values's color?
It was not possible until today.

The xChart class has been update to versio 6.1 in the first post.
Added LagendTextColor property
Improved SubTitle display
 

winjiadh

Active Member
Licensed User
B4X:
    Values(0) = 8
    Values(1) = 30
    Values(2) = 25
    Values(3) = 15
    Values(4) = 20
    
    PieChart1.AddPie("Slice #1", Values(0), xui.Color_Blue) '0 = random color
    PieChart1.AddPie("Slice #2", Values(1), xui.Color_Red)
    PieChart1.AddPie("Slice #3", Values(2), xui.Color_Yellow)
    PieChart1.AddPie("Slice #4", Values(3), xui.Color_Cyan)
    PieChart1.AddPie("Slice #5", Values(4), xui.Color_Green)
    PieChart1.ValuesTextColor=xui.Color_Red
    PieChart1.DrawChart
the color is the Values head square's color not the Values's Color
thanks
 
Top