An An 4 жил өмнө
parent
commit
17b05cc63e

+ 6 - 0
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAOptions.kt

@@ -22,6 +22,7 @@ class AAOptions {
     var plotOptions: AAPlotOptions? = null
     var series: Array<AASeriesElement>? = null
     var legend: AALegend? = null
+    var pane: AAPane? = null
     var colors: Array<Any>? = null
     var touchEventEnabled: Boolean? = null
 
@@ -80,6 +81,11 @@ class AAOptions {
         return this
     }
 
+    fun pane(prop: AAPane?): AAOptions {
+        pane = prop
+        return this
+    }
+
     fun colors(prop: Array<Any>?): AAOptions {
         colors = prop
         return this

+ 77 - 0
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAPane.kt

@@ -0,0 +1,77 @@
+package com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel
+
+class AAPane {
+    var background: AABackground? = null
+    var center: Array<Any>? = null
+    var endAngle: Float? = null
+    var size: Float? = null
+    var startAngle: Float? = null
+    fun background(prop: AABackground?): AAPane {
+        background = prop
+        return this
+    }
+
+    fun center(prop: Array<Any>): AAPane {
+        center = prop
+        return this
+    }
+
+    fun endAngle(prop: Float?): AAPane {
+        endAngle = prop
+        return this
+    }
+
+    fun size(prop: Float?): AAPane {
+        size = prop
+        return this
+    }
+
+    fun startAngle(prop: Float?): AAPane {
+        startAngle = prop
+        return this
+    }
+}
+
+class AABackground {
+    var backgroundColor: Any? = null
+    var borderColor: String? = null
+    var borderWidth: Float? = null
+    var className: String? = null
+    var innerRadius: Float? = null
+    var outerRadius: Float? = null
+    var shape: String? = null
+    fun backgroundColor(prop: Any?): AABackground {
+        backgroundColor = prop
+        return this
+    }
+
+    fun borderColor(prop: String?): AABackground {
+        borderColor = prop
+        return this
+    }
+
+    fun borderWidth(prop: Float?): AABackground {
+        borderWidth = prop
+        return this
+    }
+
+    fun className(prop: String?): AABackground {
+        className = prop
+        return this
+    }
+
+    fun innerRadius(prop: Float?): AABackground {
+        innerRadius = prop
+        return this
+    }
+
+    fun outerRadius(prop: Float?): AABackground {
+        outerRadius = prop
+        return this
+    }
+
+    fun shape(prop: String?): AABackground {
+        shape = prop
+        return this
+    }
+}

+ 4 - 0
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/AdditionalContent/DrawChartWithAAOptionsActivity.kt

@@ -47,6 +47,8 @@ import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.ChartOptionsComp
 import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.ChartOptionsComposer.Companion.customAreaChartTooltipStyleLikeHTMLTable
 import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.ChartOptionsComposer.Companion.customLineChartDataLabelsFormat
 import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.ChartOptionsComposer.Companion.customXAxisCrosshairStyle
+import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.ChartOptionsComposer.Companion.gaugeChartWithPlotBand
+import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.ChartOptionsComposer.Companion.simpleGaugeChart
 import com.aachartmodel.aainfographics.R
 
 class DrawChartWithAAOptionsActivity : AppCompatActivity() {
@@ -83,6 +85,8 @@ class DrawChartWithAAOptionsActivity : AppCompatActivity() {
             "configureDoubleYAxesAndColumnLineMixedChart"-> return configureDoubleYAxesAndColumnLineMixedChart()
             "configureDoubleYAxesMarketDepthChart"-> return configureDoubleYAxesMarketDepthChart()
             "customAreaChartTooltipStyleLikeHTMLTable"-> return customAreaChartTooltipStyleLikeHTMLTable()
+             "simpleGaugeChart" -> return simpleGaugeChart()
+             "gaugeChartWithPlotBand" -> return gaugeChartWithPlotBand()
         }
         return configureAAPlotBandsForChart()
     }

+ 9 - 5
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/BasicContent/MainActivity.kt

@@ -113,6 +113,8 @@ class MainActivity : AppCompatActivity() {
         "configureDoubleYAxesAndColumnLineMixedChart",
         "configureDoubleYAxesMarketDepthChart",
         "customAreaChartTooltipStyleLikeHTMLTable",
+        "simpleGaugeChart",
+        "gaugeChartWithPlotBand",
         /*即时刷新📈📊图表数据*/
         /*即时刷新📈📊图表数据*/"/*即时刷新📈📊图表数据*/Column Chart---柱形图--------------",
         "Bar Chart---条形图",
@@ -215,6 +217,8 @@ class MainActivity : AppCompatActivity() {
         "configureDoubleYAxesAndColumnLineMixedChart",
         "configureDoubleYAxesMarketDepthChart",
         "customAreaChartTooltipStyleLikeHTMLTable",
+        "simpleGaugeChart",
+        "gaugeChartWithPlotBand",
         /*即时刷新📈📊图表数据*/
         AAChartType.Column.value,
         AAChartType.Bar.value,
@@ -268,15 +272,15 @@ class MainActivity : AppCompatActivity() {
                     goToMixedChartActivity(position)
                 } else if (position <= 47) { /*自定义样式图表*/
                     goToCustomStyleChartActivity(position)
-                } else if (position <= 63) { /*使用AAOptions绘制图表*/
+                } else if (position <= 65) { /*使用AAOptions绘制图表*/
                     goToDrawChartWithAAOptionsActivity(position)
-                } else if (position <= 72) { /*即时刷新📈📊图表数据*/
+                } else if (position <= 74) { /*即时刷新📈📊图表数据*/
                     goToOnlyRefreshChartDataActivity(position)
-                } else if (position <= 85) { /*formatter js function*/
+                } else if (position <= 87) { /*formatter js function*/
                     goToCustomTooltipWithJSFunctionActivity(position)
-                } else if (position <= 87) { /*eval JS Function*/
+                } else if (position <= 89) { /*eval JS Function*/
                     goToEvaluateJSStringFunctionActivity(position)
-                } else { /*Double Charts Linked Work*/
+                }else { /*Double Charts Linked Work*/
                     goToDoubleChartsLinkedWorkActivity(position)
                 }
             }

+ 63 - 1
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/ChartOptionsComposer.kt

@@ -35,8 +35,8 @@
  */
 package com.aachartmodel.aainfographics.ChartsDemo.ChartComposer
 
-import com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel.*
 import com.aachartmodel.aainfographics.AAInfographicsLib.AAChartConfiger.*
+import com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel.*
 
 class ChartOptionsComposer {
     companion object {
@@ -1160,6 +1160,68 @@ function () {
             return aaOptions
         }
 
+        fun simpleGaugeChart(): AAOptions {
+            return AAOptions()
+                .chart(AAChart()
+                        .type(AAChartType.Gauge)
+                )
+                .pane(AAPane()
+                        .startAngle(-150f)
+                        .endAngle(150f)
+                )
+                .yAxis(AAYAxis()
+                        .min(0f)
+                        .max(100f)
+                        .plotBands(arrayOf(
+                                AAPlotBandsElement()
+                                    .from(0f)
+                                    .to(60f)
+                                    .color("#FF0000")
+                            )
+                        )
+                )
+                .series(arrayOf(
+                        AASeriesElement()
+                            .data(arrayOf(80))
+                    )
+                )
+        }
+
+        fun gaugeChartWithPlotBand(): AAOptions {
+            return AAOptions()
+                .chart(AAChart()
+                        .type(AAChartType.Gauge))
+                .title(AATitle()
+                        .text("速度仪"))
+                .pane(AAPane()
+                        .startAngle(-150f)
+                        .endAngle(150f))
+                .yAxis(AAYAxis()
+                        .min(0f)
+                        .max(200f)
+                        .title(AATitle()
+                                .text("km/h"))
+                        .plotBands(arrayOf(
+                                AAPlotBandsElement()
+                                    .from(0f)
+                                    .to(120f)
+                                    .color("#ffc069"),
+                                AAPlotBandsElement()
+                                    .from(120f)
+                                    .to(160f)
+                                    .color("#fe117c"),
+                                AAPlotBandsElement()
+                                    .from(160f)
+                                    .to(200f)
+                                    .color("#06caf4")
+                            )
+                        )
+                )
+                .series(arrayOf(
+                        AASeriesElement()
+                            .data(arrayOf(80))
+                    ))
+        }
 
     }
 }