Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make series follow up? #149

Closed
Paget96 opened this issue Dec 7, 2022 · 4 comments
Closed

How to make series follow up? #149

Paget96 opened this issue Dec 7, 2022 · 4 comments

Comments

@Paget96
Copy link

Paget96 commented Dec 7, 2022

I want to represent a battery history graph where both charging and discharging (ups and downs) will be shown. I want to use two separate series for these two.

Is there anything as a follow up, like a connect two series one after another so I can have different colors on one line?

Or I need to improvise?

@AAChartModel
Copy link
Owner

Do you have a design draft? Can you post it?

@Paget96
Copy link
Author

Paget96 commented Dec 8, 2022

Do you have a design draft? Can you post it?

Yes, want to make something like this

Example 1:
I do have 4 data sets in this order charging, discharging, charging, discharging, every set to have a different color and to make a follow up. By follow up I mean that at the end of first dataset, first line, the next line go after it.

Example 2:
I have 4 lists of 50 entries, when first one finish at index of 49, let's start next list at index of 50 and so on. So all 4 datasets will be at one. :)

@AAChartModel
Copy link
Owner

Configure AAChartModel instanse:

  fun customAreasplineChartWithColorfulGradientColorZones() :AAChartModel {
        val redStopsArr: Array<Any> = arrayOf(
            arrayOf(0.0, "#FF0000"),//颜色字符串设置支持十六进制类型和 rgba 类型
            arrayOf(1.0, AAColor.Clear)
        )

        val greenStopsArr: Array<Any> = arrayOf(
            arrayOf(0.0, "#00FF00"),//颜色字符串设置支持十六进制类型和 rgba 类型
            arrayOf(1.0, AAColor.Clear)
        )

        val blueStopsArr: Array<Any> = arrayOf(
            arrayOf(0.0, "#0000FF"),//颜色字符串设置支持十六进制类型和 rgba 类型
            arrayOf(1.0, AAColor.Clear)
        )

        val redGradientColorDic = AAGradientColor.linearGradient(
            AALinearGradientDirection.ToBottom,
            redStopsArr
        )

        val greenGradientColorDic = AAGradientColor.linearGradient(
            AALinearGradientDirection.ToBottom,
            greenStopsArr
        )

        val blueGradientColorDic = AAGradientColor.linearGradient(
            AALinearGradientDirection.ToBottom,
            blueStopsArr
        )

        val singleSpecialData = AADataElement()
            .marker(AAMarker()
                .radius(10f)//曲线连接点半径,默认是4
                .symbol(AAChartSymbolType.Circle.value)//曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
                .fillColor(AAColor.White)//点的填充色(用来设置折线连接点的填充色)
                .lineWidth(5f)//外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
                //外沿线的颜色(用来设置折线连接点的轮廓描边的颜色, 当值为空字符串时,默认取数据点或数据列的颜色)
                .lineColor("#1E90FF")//道奇蓝
            )
            .y(85.3f)


        return AAChartModel()
            .chartType(AAChartType.Areaspline)
            .backgroundColor(AAColor.Black)
            .categories(arrayOf("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
            .title("Colorful Gradient Color Zones")
            .subtitle("custom areaspline chart with colorful gradient color zones")
            .dataLabelsEnabled(false)
            .legendEnabled(false)
            .markerRadius(0f)
            .yAxisGridLineWidth(0f)
            .yAxisTitle("")
            .series(arrayOf(
                AASeriesElement()
                    .name("空气湿度")
                    .lineWidth(6f)
                    .zoneAxis("x")
                    .zones(arrayOf(
                        AAZonesElement()
                            .value(2)
                            .color(AAColor.Red)
                            .fillColor(redGradientColorDic),
                        AAZonesElement()
                            .value(5)
                            .color(AAColor.Green)
                            .fillColor(greenGradientColorDic),
                        AAZonesElement()
                            .color(AAColor.Blue)
                            .fillColor(blueGradientColorDic),
                    ))
                    .data(arrayOf(56.5, 33.3, 85.3, 23.9, 29.6, 34.5, 28.2, 26.5, 15.2, 56.5, 33.3, singleSpecialData))
            ))


    }

Final chart

Screenshot_20221214_175548

@Paget96
Copy link
Author

Paget96 commented Dec 14, 2022

How can I set the categories (bottom values) to be max 6, since for X I'm using timestamps then converted to the time only. Chart is getting updated each second so the categories needed to be updated as well :)
I'm going from MPAndroidChart so searching for the best alternative, it's not updated for quite long

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants