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

klaus

Expert
Licensed User
Longtime 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

  • xChart.b4xlib
    23.9 KB · Views: 247
  • xChart.bas
    143.7 KB · Views: 256

MbedAndroid

Active Member
Licensed User
Longtime 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
Longtime 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
Longtime 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
Longtime 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

 

MbedAndroid

Active Member
Licensed User
Longtime User
here you are Klaus. I can set it to invisible by code. The text "Zones" is part of the piechart.
 

Attachments

  • BLE.zip
    135.7 KB · Views: 236

winjiadh

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

I change the Designer PieChart1 Values text color like this

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
Longtime 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
Longtime 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 LegendTextColor property
Improved SubTitle display
 
Last edited:

winjiadh

Active Member
Licensed User
Longtime 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
 

winjiadh

Active Member
Licensed User
Longtime User
B4X:
PieChart1.LegendTextColor=xui.Color_Red
very good!
klaus,the best for you , thnks again!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…