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

klaus

Expert
Licensed User
Longtime User
I tested the demo program with 3000 and it works OK it shows always 20 samples and the time is OK.
I check Allow Zoom Cursor and scroll back, it only shows 1 minute 30 seconds chart!!! and sometimes less or more!!!
So, I do not understand what happens to you.
 

thetrueman

Active Member
I tested the demo program with 3000 and it works OK it shows always 20 samples and the time is OK.

So, I do not understand what happens to you.
Oh sorry as I could not explain in well manner. As you said it is OK with 3000 and 20 samples always are visible with time stamp OK. Now after some time there should be memory buffer with 3000 readings. When 3001 comes the first is removed from buffer and it always maintains 3000 readings.
Now I Click on checkbox Allow Zoom Cursor and chart stops to update. Then I move Scroll bar cursor to left end and the first time stamp is only approximately 1 minute and 30 seconds before the last stamp. In other words it only shows chart for one and half minute by scrolling with mouse to left.
When update time is 100ms so every seconds there are 10 readings and even after 5 minutes there are only 900 reading to show instead of 3000. Thanks.
 

klaus

Expert
Licensed User
Longtime User
Sorry, but i do not understand what you are doing.
I tested the program with 50ms data update.
Do you use the demo program i posted in post #657 or anything else ?
Now I Click on checkbox Allow Zoom Cursor and chart stops to update.
Yes, the chart is not updated, but the data is updated.
When Allow Zoom Cursor is checked and you have the zoom cursor at the most left position or anywhere else and you slightly move the cursor the chart is updated with the last data.
Sorry, but I do not understand what exactly you are expecting ?

Attached my latest test program.
I tested also to update the data, lines 75 and 76, in the chart when Allow Zoom Cursor is checked, it updates the data where ever you are with the zoom cursor, but i find it very confusing.

 

Attachments

  • DynamicZoom2.zip
    166.4 KB · Views: 301
Last edited:

klaus

Expert
Licensed User
Longtime User
The xChart library has been updated to version 9.8.
Changed SetZoomIndexes Zoom.EndIndex not limited to previous Zoom.EndIndex
Set zoom min cursor width from 10dip to 15dip
The first change allows zooming with dynamic data input and move the zoom cursor at the end.
Demo program for dynamic data and zoom.
 

madru

Active Member
Licensed User
Longtime User
Hi, maybe I missed it, but is it possible to display the values for a STACKED_BAR?

THX
 

peacemaker

Expert
Licensed User
Longtime User
For ref: if think that useful - can be included:
B4X:
Public Sub GetBitmap As B4XBitmap
    Return mBase.Snapshot   
End Sub

I use it for saving the chart to PNG.
 

klaus

Expert
Licensed User
Longtime User
The xChart library has been updated to version 9.9
Changed the 0 axis highligt property, it is now behind the data lines
Added the MaxDigits, BarMarginMode, NumberFormatGroupingUsed and NumberFormatGroupingCharacter properties
The library has been updated in post #1
 

Wosl

Member
I created a very simple horizontal bar chart as a test and stripped it to a minimum: no y-axis, y-axis labels, no ticks, etc., but only labels for x-axis. May be I'm doing something wrong, because the chart looks strange. The outer boundary of the chart doesn't consider the labels (marked in red circles):


Following code is used:

Horizontal bar chart:
        Case 3

            HStackedBarChart1.ClearData
            HStackedBarChart1.AddBar("Pos", xui.Color_Green)
            HStackedBarChart1.AddBar("Neg", xui.Color_Red)
            HStackedBarChart1.HChartsXScaleOnTop = True
            HStackedBarChart1.HChartsTicksTopDown = True
            HStackedBarChart1.BarValueOrientation = "HORIZONTAL"
            HStackedBarChart1.DrawHorizontalGridLines = False
            HStackedBarChart1.IncludeLegend = False
            HStackedBarChart1.Title = ""
            HStackedBarChart1.Subtitle = ""
            HStackedBarChart1.XAxisName = ""
            HStackedBarChart1.YAxisName = ""
            HStackedBarChart1.ChartBackgroundColor = xui.Color_RGB(207,220,220)
            HStackedBarChart1.DrawYScale = False
            HStackedBarChart1.DrawXScale = True
            HStackedBarChart1.ScaleTextColor = xui.Color_Blue
            HStackedBarChart1.ValuesTextColor = xui.Color_Black
            Public directconsumption_share As Double = 15.2, autarky_degree As Double = 43.0
            For i = 0 To 1
                If i = 0 Then
                    HStackedBarChart1.AddBarMultiplePoint("Eigenanteil", Array As Double(directconsumption_share, 100.0-directconsumption_share))
                Else
                    HStackedBarChart1.AddBarMultiplePoint("Autarkiegrad", Array As Double(autarky_degree, 100.0-autarky_degree))
                End If
            Next
    End Select
    HStackedBarChart1.DrawChart

Do I miss something? Can somebody cross-check this simple chart?

PS: may be it is the result of an inconsistency because I use an older xChart.bas (from 2023, i don't have a newer one) together with the current xChart version 9.9.
 

Wosl

Member
How can I add additional text (beside title/subtitle) to a chart and place it somewhere using chart coordinates?
 

Wosl

Member
Thank you Peter,

here is the result:


It shows the x-tick labels now but the y-tick labels, too, what I don't want. It seems the scaling with DrawYScale=False results in a wrong scaling of the chart. Anyhow, if additional text to the chart (e.g. to highlight the percentages in the green bars) or drawing bar values is impossible, the y-tick labels could be the only alternative for now.

Thx, Wosl
 

klaus

Expert
Licensed User
Longtime User
Do I miss something? Can somebody cross-check this simple chart?
No, there was an error when DrawXScale or DrawYScale = False for horizontal charts.
Amended in version 10.0 in the first post.

PS: may be it is the result of an inconsistency because I use an older xChart.bas (from 2023, i don't have a newer one) together with the current xChart version 9.9.
Why do you use an old xChart.bas file ?
Use the xChart.b4xlib.
When you add an old xChart.bas file in the IDE, this will override the xChart.b4xlib.
The latest xChart.bas file is included in the xChart.b4xlib.
The only reason to use an xChart.bas file in the IDE is for debugging.

How can I add additional text (beside title/subtitle) to a chart and place it somewhere using chart coordinates?
As Peter Simpson already answered, this is not possible.
What kind of text do want to add ?