Skip to content

how to set X axis value for example by default 0 5 10 series , I want set Monday,tuesday, Wednesday so on #83

Open
@prafulargiddi

Description

@prafulargiddi

HI developer
I want to set X axis value . I not able to set could you please know how to set x axis value in SplineChart.

Thank you in advance

Activity

changed the title [-]how to set X axis value for example by default 0 5 10 serious I want set Monday,tuesday, Wednesday so on[/-] [+]how to set X axis value for example by default 0 5 10 series , I want set Monday,tuesday, Wednesday so on[/+] on Sep 14, 2018
TimeDelta

TimeDelta commented on Sep 18, 2018

@TimeDelta
Contributor

I've been trying to figure out something similar. I found this: #68, which says that the x-axis values can be strings. I tried it out like this (as an anonymous lambda inside of a map function for the array of values that I want to display):

let rawXValue = try! sample.value(of: self.xAxisAttribute)
var xValue: Any = rawXValue
if !(self.xAxisAttribute is NumericAttribute) {
	xValue = try! self.xAxisAttribute.convertToDisplayableString(from: rawXValue)
}
return [xValue, self.getDouble(for: self.yAxisAttribute, from: sample)]

When the sample's attribute that I want to display is numeric, it shows the double value, otherwise, it converts the x-value to a string (I have tested it with dates).

Here's a screenshot of it running (It shows the array indices on the x-axis but you can just call .xAxisLabelsEnabled(false) on the AAChartModel object to make it not show them there):
52e70739-3118-4e07-9633-6b23125db363

AAChartModel

AAChartModel commented on Sep 19, 2018

@AAChartModel
Owner
 aaChartModel = AAChartModel.init()
            .chartType(AAChartType.Column)//Can be any of the chart types listed under `AAChartType`.
            .animationType(AAChartAnimationType.Bounce)
            .title("TITLE")//The chart title
            .subtitle("subtitle")//The chart subtitle
            .dataLabelEnabled(false) //Enable or disable the data labels. Defaults to false
            .tooltipValueSuffix("USD")//the value suffix of the chart tooltip
            .categories(["Jan", "Feb", "Mar", "Apr", "May", "Jun",
                         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"])
            .colorsTheme(["#fe117c","#ffc069","#06caf4","#7dffc0"])
            .series([
                AASeriesElement()
                    .name("Tokyo")
                    .data([7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6])
                    .toDic()!,
                AASeriesElement()
                    .name("New York")
                    .data([0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5])
                    .toDic()!,
                AASeriesElement()
                    .name("Berlin")
                    .data([0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0])
                    .toDic()!,
                AASeriesElement()
                    .name("London")
                    .data([3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8])
                    .toDic()!,])

As I wrote in the README of AAChartKit-Swift

  .categories(["Jan", "Feb", "Mar", "Apr", "May", "Jun",
                         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"])

configure the property categories , you can change the X axis value to be string

The finally style just like this picture as follow
lineChart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @TimeDelta@AAChartModel@prafulargiddi

        Issue actions

          how to set X axis value for example by default 0 5 10 series , I want set Monday,tuesday, Wednesday so on · Issue #83 · AAChartModel/AAChartKit-Swift