Android Question xChart x axis labels not appearing

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
I am using X chart to display a line graph, however the x axis labels are not appearing.

I am thinking that I must have made basic mistake.
If you tap the points on the screen then the correct value label appears.

1655460517966.png


The code I am using is:

B4X:
    xclGraph.ClearData
    xclGraph.Title = "Data"
    xclGraph.YAxisName = "Depth (m)"
    xclGraph.XAxisName = "Readings"
    xclGraph.AddLine2("water depth",Globals.gcol_primarycol, 2dip, "RHOMBUS", False, Globals.gcol_primarycol)
    xclGraph.AddLine("Pump depth",xui.Color_Blue)
    xclGraph.AddLine("Total depth",xui.Color_red)
    xclGraph.AutomaticTextSizes = True
    xclGraph.XScaleTextOrientation= "45 DEGREES"
    xclGraph.DrawXScale = True
    Private ymax=0,ymin=10000 As Double
    
    For Each rditem As Map In rdlist
        Private adata() As Double = Array As Double(rditem.GetDefault("MonitoringValueMeasurement",0),ThisMonitoringPoint.GetDefault("MonitoringPointPumpDepth",0),ThisMonitoringPoint.GetDefault("MonitoringPointBaseDepth",0))
        ymax = Max(ymax,Max(rditem.GetDefault("MonitoringValueMeasurement",0),Max(ThisMonitoringPoint.GetDefault("MonitoringPointPumpDepth",0),ThisMonitoringPoint.GetDefault("MonitoringPointBaseDepth",0))))
        ymin = Min(ymin,Min(rditem.GetDefault("MonitoringValueMeasurement",0),Min(ThisMonitoringPoint.GetDefault("MonitoringPointPumpDepth",0),ThisMonitoringPoint.GetDefault("MonitoringPointBaseDepth",0))))
        xclGraph.AddLineMultiplePoints("12 Jan",adata,False)
'        xclGraph.AddLineMultiplePoints(Misccode.ConvertDBDate(rditem.GetDefault("MonitoringValueDate","No Date"),"dd MMM"),adata,False)
    Next
    xclGraph.AutomaticScale = False
    xclGraph.YScaleMaxValue = ymax
    xclGraph.YScaleMinValue = ymin
    xclGraph.IncludeLegend = "BOTTOM"
    xclGraph.ReverseYScale = True
    xclGraph.ChartType = "LINE"
    xclGraph.DrawChart

Any Ideas?
 

klaus

Expert
Licensed User
Longtime User
The problem is in this line.
xclGraph.AddLineMultiplePoints("12 Jan",adata,False)
The last boolean parameter is ShowTicks.
You set it to False, therefore nothing will be displayed.
You need to set it to True !
You can also set it to true only for some points.
If you have numbers you could use, instead of True, something like this:
i Mod 2 = 0 'displays every second tick
i Mod 5 = 0 'displays every fifth
i Mod 10 = 0 'displays tenth tick
Or use a variable which you can set to True or False depending on particular conditions.
 
Upvote 0
Top