AAChartCore-Kotlin icon indicating copy to clipboard operation
AAChartCore-Kotlin copied to clipboard

Not sure how to label the x-axis items

Open mdg121212 opened this issue 5 years ago β€’ 6 comments

Creating a graph of type Column, and the Y axis values are labeled, and the X axis values show properly (the correct number of items and the correct values associated with each item), but I cannot figure out how to label them as the Y axis values are labeled.

mdg121212 avatar Dec 03 '20 20:12 mdg121212

I would like to know how to customize the values shown on the X axis too. Can a series be applied to X axis values? Thanks!

sebastinto avatar Dec 18 '20 21:12 sebastinto

Found this which seems to answer my question: https://github.com/AAChartModel/AAChartKit-Swift/issues/83#issuecomment-422625259

Use .categories(arrayOf("label1", "label2", "label")) when you initialize your AAChartModel().

You can then use .xAxisTickInterval(2) if you want to skip every other label.

Does it answer your question as well @mdg121212?

sebastinto avatar Dec 19 '20 04:12 sebastinto

I am generating the series elements and list of labels in a for loop, and trying to display them like so:

`aaChartModel.apply { chartType(AAChartType.Column) when (graphInt) { 0 -> { title = "U.S. Deaths (Monthly Totals)" yAxisTitle = "Deaths" } 1 -> { title = "U.S. Hospitalizations (Monthly Totals)" yAxisTitle = "Hospitalizations" } 2 -> { title = "U.S. Total Tests (Monthly Totals)" yAxisTitle = "Tests" } 3 -> { title = "U.S. Positive Tests (Monthly Totals)" yAxisTitle = "Positive Tests" } } backgroundColor = Color.DKGRAY categories = categoryListForGraph series = listForGraph xAxisTickInterval = 2 legendEnabled = false dataLabelsEnabled = true xAxisVisible = true xAxisLabelsEnabled = true animationType = AAChartAnimationType.EaseInBack }

    statChart.aa_drawChartWithChartModel(aaChartModel)`

Here categoryListForGraph is a string array, there are ten items in this array, and the graph only shows the last item. The tick interval does not seem to have any effect.

mdg121212 avatar Jan 03 '21 19:01 mdg121212