Public Sub Initialize (Callback As Object, EventName As String)
Prepare the instance before its other methods.
ELEVATEUI · B4A · XUI
Show how several contributions build category totals.
Charts & visualizations
Show how several contributions build category totals.
Animated conceptual demonstration, not an exact Android control screenshot.
In an analytics screen, choose this visualization when the user needs to compare the values represented by its axes or series.
Before integrating, examine its methods, events and Designer options.
Tutorials are based on existing project examples or audited APIs. Check each example’s prerequisites; B4A compilation is not claimed.
Review required libraries, Designer views and input data before compiling in B4A.
' Ejemplo autocontenido para la Activity principal de B4A.
' Habilitar las bibliotecas XUI y ElevateUI.
Sub Process_Globals
Private xui As XUI
End Sub
Sub Globals
Private Root As B4XView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Root = xui.CreatePanel("")
Activity.AddView(Root, 0, 0, 100%x, 100%y)
Root.Color = 0xFFF8FAFC
Dim chart As UIStackedBarChart
chart.Initialize(Me, "Composition")
chart.AddToParent(Root, 12dip, 20dip, 100%x - 24dip, 260dip)
Dim series As List
series.Initialize
series.Add(L(Array As Object(12,18,20)))
series.Add(L(Array As Object(6,10,15)))
chart.setData(L(Array As Object("Q1","Q2","Q3")), series)
chart.setLegend(L(Array As Object("Producto A","Producto B")))
chart.setColorsList(L(Array As Object(0xFF8B5CF6,0xFF06B6D4)))
chart.setBarThicknessFactor(0.7)
chart.setGradient(True)
End Sub
' Convierte un array de Object en una lista B4A.
' Necesario para las firmas que aceptan List.
Private Sub L(Values() As Object) As List
Dim Result As List
Result.Initialize
Result.AddAll(Values)
Return Result
End Sub
Private Sub Composition_MouseClicked
Log("Se pulsó el gráfico apilado")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause(UserClosed As Boolean)
End Sub
29 audited signatures
Public Sub Initialize (Callback As Object, EventName As String)
Prepare the instance before its other methods.
Public Sub DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
Invoked automatically by the B4A Visual Designer; do not call manually.
Public Sub AddToParent(Parent As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
Add this view to a parent container using the supplied bounds and options.
Public Sub setData(PointsX As List, ValuesMulti As List)
Update data at runtime when this setting changes.
Public Sub setTitleFont(Font As B4XFont)
Update title font at runtime when this setting changes.
Public Sub setTitleColor(Color As Int)
Update title color at runtime when this setting changes.
Public Sub setXAxisTextColor(Color As Int)
Update xaxis text color at runtime when this setting changes.
Public Sub setTextTitle(Title As String)
Update text title at runtime when this setting changes.
Public Sub setColorsList(ColorsList As List)
Update colors list at runtime when this setting changes.
Public Sub setGradient(Use As Boolean)
Update gradient at runtime when this setting changes.
Public Sub setLegend(Names As List)
Update legend at runtime when this setting changes.
Public Sub setValueSuffix(Suffix As String)
Update value suffix at runtime when this setting changes.
Public Sub setBarThicknessFactor(Factor As Float)
Update bar thickness factor at runtime when this setting changes.
Public Sub setBarWidth(Width As Float)
Update bar width at runtime when this setting changes.
Original catalog note: Rounds only the outer/top end of each stacked column when enabled. Space between categories in pixels. Pass 5dip, for example; -1 restores automatic spacing. Spacing changes positions only; bar width is independent. Column width in current pixels. Pass 28dip, for example.
Public Sub getBarWidth As Float
Read the current bar width value for validation or UI synchronization.
Returns: Float
Public Sub setBarSpacing(Spacing As Float)
Update bar spacing at runtime when this setting changes.
Public Sub getBarSpacing As Float
Read the current bar spacing value for validation or UI synchronization.
Returns: Float
Public Sub setRoundedBars(Enabled As Boolean)
Update rounded bars at runtime when this setting changes.
Public Sub SaveAsPNG(Dir As String, FileName As String) As Boolean
Use SaveAsPNG for its named operation; follow its exact signature.
Returns: Boolean
Public Sub setShowAxes(Show As Boolean)
Update show axes at runtime when this setting changes.
Original catalog note: Shows or hides X and Y axis lines without hiding category labels.
Public Sub getShowAxes As Boolean
Read the current show axes value for validation or UI synchronization.
Returns: Boolean
Public Sub setShowYAxisValues(Show As Boolean)
Update show yaxis values at runtime when this setting changes.
Original catalog note: Numeric Y-axis scale visibility is independent of individual data values.
Public Sub getShowYAxisValues As Boolean
Read the current show yaxis values value for validation or UI synchronization.
Returns: Boolean
Public Sub setShowGrid(Show As Boolean)
Update show grid at runtime when this setting changes.
Public Sub getShowGrid As Boolean
Read the current show grid value for validation or UI synchronization.
Returns: Boolean
Public Sub setGridColor(Color As Int)
Update grid color at runtime when this setting changes.
Public Sub getGridColor As Int
Read the current grid color value for validation or UI synchronization.
Returns: Int
Public Sub setGridInterval(Interval As Float)
Update grid interval at runtime when this setting changes.
Public Sub getGridInterval As Float
Read the current grid interval value for validation or UI synchronization.
Returns: Float
#DesignerProperty: Key: BarColors, DisplayName: Bar Colors, FieldType: String, DefaultValue: #FF6C5CE7;#FF00CEC9;#FF55EFC4;#FFFDCB6E;#FFD63031;#FF0984E3;#FFFAB1A0;#FF74B9FF;#FFA29BFE;#FF81ECEC, Description: Modern fresh colors for the bars (separated by semicolons, format #AARRGGBB)#DesignerProperty: Key: MarkerText, DisplayName: Title Text, FieldType: String, DefaultValue: Net Income, Description: Title text for the chart#DesignerProperty: Key: Animate, DisplayName: Animate, FieldType: Boolean, DefaultValue: True#DesignerProperty: Key: Duration, DisplayName: Animation Duration, FieldType: Int, DefaultValue: 1000, Description: Duration in milliseconds#DesignerProperty: Key: SeriesNames, DisplayName: Series Names, FieldType: String, DefaultValue: Serie1;Serie2;Serie3;Serie4;Serie5;Serie6;Serie7;Serie8;Serie9;Serie10, Description: Names of the series#DesignerProperty: Key: UseGradient, DisplayName: Use Gradient Fill, FieldType: Boolean, DefaultValue: False, Description: Use a gradient fill for the bars#DesignerProperty: Key: ValueSuffix, DisplayName: Value Suffix, FieldType: String, DefaultValue: , Description: Suffix for bar values (e.g., %, $, etc.)#DesignerProperty: Key: BarThicknessFactor, DisplayName: Bar Thickness Factor, FieldType: Float, DefaultValue: 0.5, Description: Bar width multiplier (0.1 to 1.0). The default 0.5 uses BarWidth unchanged, independently of spacing.#DesignerProperty: Key: ShowGrid, DisplayName: Show Grid, FieldType: Boolean, DefaultValue: False, Description: Shows or hides the horizontal grid lines#DesignerProperty: Key: GridColor, DisplayName: Grid Color, FieldType: Color, DefaultValue: 0xFF64748B, Description: Color of the horizontal grid lines#DesignerProperty: Key: GridInterval, DisplayName: Grid Interval, FieldType: Float, DefaultValue: 0, Description: Step interval value for grid lines (e.g. 100, 1000). Set to 0 for automatic division.Initialize with Me and the event prefix Demo, then add the following handler to your B4A module. Names and arguments come from the library declaration.
Raised when the user taps the control; use it to trigger a real action.
B4A handler signature with Demo prefix
Private Sub Demo_MouseClicked()
Log("MouseClicked")
End Sub
For code-created controls use Initialize(Me, "Demo") when that signature exists; for Designer controls set the event name there. Replace Demo with the actual prefix.
Public mBase As B4XView