Android Question xChart: reduce the number of x-axis labels and intervals?

doncx

Active Member
Licensed User
Longtime User
xChart is an incredible library! It looks great, works easily, and has tons of options.

When I create a line chart and use the AutomaticScale=True option it works well when there are a limited number of data values, but when there's a lot of values then the labels on the x-axis are very densely populated and the vertical grid lines blend together into a single gray background.

See the two images below. The first image with just 19 data values looks great. The second image, with 2700 data values, exhibits the problem.

How can I reduce the number of x-axis labels and vertical gridlines?

Any assistance will be most appreciated!

_1.jpg


_2.jpg
 
Solution
How do you add the data to the line ?
In these two methods:
AddLinePointData (X As String, Y As Double, ShowTick As Boolean)
AddLineMultiplePoints (X As String, YArray As Double, ShowTick As Boolean)

The last parameter is ShowTick, with this you can limit the number of ticks and vertical lines.
With True the tick is drawn and with False it is not drawn.

In the code below, with i Mod 10 = 0, only every tenth thick is drawn.
B4X:
    For i = 0 To 500
        LineChart1.AddLinePointData(i, Rnd(-100, 101), i Mod 10 = 0)
    Next

klaus

Expert
Licensed User
Longtime User
How do you add the data to the line ?
In these two methods:
AddLinePointData (X As String, Y As Double, ShowTick As Boolean)
AddLineMultiplePoints (X As String, YArray As Double, ShowTick As Boolean)

The last parameter is ShowTick, with this you can limit the number of ticks and vertical lines.
With True the tick is drawn and with False it is not drawn.

In the code below, with i Mod 10 = 0, only every tenth thick is drawn.
B4X:
    For i = 0 To 500
        LineChart1.AddLinePointData(i, Rnd(-100, 101), i Mod 10 = 0)
    Next
 
Upvote 1
Solution
Top