Ver Fonte

Support AAOptions

An An há 5 anos atrás
pai
commit
623e35deb3
21 ficheiros alterados com 522 adições e 292 exclusões
  1. 153 62
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAChartConfiger/AAChartModel.kt
  2. 33 17
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAChartConfiger/AAChartView.kt
  3. 176 131
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAChartConfiger/AAOptionsConstructor.kt
  4. 1 1
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAAnimation.kt
  5. 3 3
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAChart.kt
  6. 2 2
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAMarker.kt
  7. 81 0
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAOptions.kt
  8. 1 1
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AASeries.kt
  9. 4 4
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAStyle.kt
  10. 2 2
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AASubtitle.kt
  11. 1 1
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AATitle.kt
  12. 1 1
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AATooltip.kt
  13. 1 1
      app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAXAxis.kt
  14. 2 1
      app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/AdditionalContent/CustomTooltipWithJSFunctionActivity.kt
  15. 2 1
      app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/AdditionalContent/DrawChartWithAAOptionsActivity.kt
  16. 8 9
      app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/BasicContent/CommonChartActivity.kt
  17. 12 16
      app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/ChartOptionsComposer.kt
  18. 10 10
      app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/CustomStyleChartComposer.kt
  19. 18 18
      app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/CustomTooltipComposer.kt
  20. 5 5
      app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/MixedChartComposer.kt
  21. 6 6
      app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/SpecialChartComposer.kt

+ 153 - 62
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAChartConfiger/AAChartModel.kt

@@ -29,6 +29,7 @@
 package com.example.chartcorekotlin.AAChartConfiger
 
 enum class AAChartAnimationType(val value :String){
+    Linear         ("Linear"),
     EaseInQuad     ("easeInQuad"),
     EaseOutQuad    ("easeOutQuad"),
     EaseInOutQuad  ("easeInOutQuad"),
@@ -144,15 +145,22 @@ enum class AAChartLineDashSyleType(val value: String) {
 
 class AAChartModel {
 
-    var animationType: String? = null          //动画类型
-    var animationDuration: Int? = null         //动画时间
-    var title: String? = null                  //标题内容
-    var subtitle: String? = null               //副标题内容
-    var chartType: String? = null              //图表类型
-    var stacking: String? = null               //堆积样式
-    var symbol: String? = null                 //折线曲线连接点的类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
-    var symbolStyle: String? = null
-    var zoomType: String? = null               //缩放类型 AAChartZoomTypeX表示可沿着 x 轴进行手势缩放
+    var animationType: String? = null         //动画类型
+    var animationDuration: Int? = null        //动画时间
+    var title: String? = null                 //标题内容
+    var titleFontColor: String? = null        //标题字体颜色
+    var titleFontSize: Float? = null          //标题字体大小
+    var titleFontWeight: String? = null       //标题字体粗细
+    var subtitle: String? = null              //副标题内容
+    var subtitleAlign: String? = null
+    var subtitleFontColor: String? = null     //副标题字体颜色
+    var subtitleFontSize: Float? = null       //副标题字体大小
+    var subtitleFontWeight: String? = null    //副标题字体粗细
+    var chartType: String? = null             //图表类型
+    var stacking: String? = null              //堆积样式
+    var markerSymbol: String? = null          //折线曲线连接点的类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
+    var markerSymbolStyle: String? = null
+    var zoomType: String? = null              //缩放类型 AAChartZoomTypeX表示可沿着 x 轴进行手势缩放
     var pointHollow: Boolean? = null           //折线或者曲线的连接点是否为空心的
     var inverted: Boolean? = null              //x 轴是否翻转(垂直)
     var xAxisReversed: Boolean? = null         //x 轴翻转
@@ -164,30 +172,33 @@ class AAChartModel {
     var polar: Boolean? = null                 //是否极化图形(变为雷达图)
     var marginLeft: Float? = null
     var marginRight: Float? = null
-    var dataLabelEnabled: Boolean? = null      //是否显示数据
+    var dataLabelsEnabled: Boolean? = null      //是否显示数据
+    var dataLabelsFontColor: String? = null
+    var dataLabelsFontSize: Float? = null
+    var dataLabelsFontWeight: String? = null
     var xAxisLabelsEnabled: Boolean? = null    //x轴是否显示数据
-    var categories: Array<String>? = null      //x轴是否显示数据
-    var xAxisGridLineWidth: Int? = null        //x轴网格线的宽度
+    var xAxisTickInterval: Int? = null
+    var categories: Array<String>? = null            //x轴是否显示数据
+    var xAxisGridLineWidth: Float? = null      //x轴网格线的宽度
     var xAxisVisible: Boolean? = null          //x 轴是否显示
     var yAxisVisible: Boolean? = null          //y 轴是否显示
     var yAxisLabelsEnabled: Boolean? = null    //y轴是否显示数据
     var yAxisTitle: String? = null             //y轴标题
     var yAxisLineWidth: Float? = null          //y 轴轴线的宽度
-
-    var yAxisGridLineWidth: Int? = null        //y轴网格线的宽度
-    var colorsTheme: Array<Any>? = null        //图表主题颜色数组
+    var yAxisMin: Float? = null
+    var yAxisMax: Float? = null
+    var yAxisAllowDecimals: Boolean? = null
+    var yAxisGridLineWidth: Float? = null      //y轴网格线的宽度
+    var colorsTheme: Array<Any>? = null           //图表主题颜色数组
     var legendEnabled: Boolean? = null         //是否显示图例
-    var legendLayout: String? = null           //图例数据项的布局。布局类型: "horizontal" 或 "vertical" 即水平布局和垂直布局 默认是:horizontal.
-    var legendAlign: String? = null            //设定图例在图表区中的水平对齐方式,合法值有left,center 和 right。
-    var legendVerticalAlign: String? = null    //设定图例在图表区中的垂直对齐方式,合法值有 top,middle 和 bottom。垂直位置可以通过 y 选项做进一步设定。
-    var backgroundColor: String? = null        //图表背景色
-    var borderRadius: Int? = null              //柱状图长条图头部圆角半径(可用于设置头部的形状,仅对条形图,柱状图有效)
-    var markerRadius: Int? = null              //折线连接点的半径长度
+    var backgroundColor: Any ? = null          //图表背景色
+    var borderRadius: Float? = null            //柱状图长条图头部圆角半径(可用于设置头部的形状,仅对条形图,柱状图有效)
+    var markerRadius: Float? = null            //折线连接点的半径长度
     var series: Array<AASeriesElement>? = null
     var titleColor: String? = null             //标题颜色
     var subTitleColor: String? = null          //副标题颜色
     var axisColor: String? = null              //x 轴和 y 轴文字颜色
-
+    var touchEventEnabled: Boolean? = null     //是否支持用户触摸事件
 
 
     fun animationType(prop: AAChartAnimationType): AAChartModel {
@@ -205,11 +216,46 @@ class AAChartModel {
         return this
     }
 
+    fun titleFontColor(prop: String): AAChartModel {
+        titleFontColor = prop
+        return this
+    }
+
+    fun titleFontSize(prop: Float?): AAChartModel {
+        titleFontSize = prop
+        return this
+    }
+
+    fun titleFontWeight(prop: String): AAChartModel {
+        titleFontWeight = prop
+        return this
+    }
+
     fun subtitle(prop: String): AAChartModel {
         subtitle = prop
         return this
     }
 
+    fun subtitleAlign(prop: String): AAChartModel {
+        subtitleAlign = prop
+        return this
+    }
+
+    fun subtitleFontColor(prop: String): AAChartModel {
+        subtitleFontColor = prop
+        return this
+    }
+
+    fun subtitleFontSize(prop: Float?): AAChartModel {
+        subtitleFontSize = prop
+        return this
+    }
+
+    fun subtitleFontWeight(prop: String): AAChartModel {
+        subtitleFontWeight = prop
+        return this
+    }
+
     fun chartType(prop: AAChartType): AAChartModel {
         chartType = prop.value
         return this
@@ -220,13 +266,13 @@ class AAChartModel {
         return this
     }
 
-    fun symbol(prop: AAChartSymbolType): AAChartModel {
-        symbol = prop.value
+    fun markerSymbol(prop: AAChartSymbolType): AAChartModel {
+        markerSymbol = prop.value
         return this
     }
 
-    fun symbolStyle(prop: AAChartSymbolStyleType): AAChartModel {
-        symbolStyle = prop.value
+    fun markerSymbolStyle(prop: AAChartSymbolStyleType): AAChartModel {
+        markerSymbolStyle = prop.value
         return this
     }
 
@@ -275,8 +321,33 @@ class AAChartModel {
         return this
     }
 
+    fun marginLeft(prop: Float?): AAChartModel {
+        marginLeft = prop
+        return this
+    }
+
+    fun marginright(prop: Float?): AAChartModel {
+        marginRight = prop
+        return this
+    }
+
     fun dataLabelsEnabled(prop: Boolean?): AAChartModel {
-        dataLabelEnabled = prop
+        dataLabelsEnabled = prop
+        return this
+    }
+
+    fun dataLabelsFontColor(prop: String): AAChartModel {
+        dataLabelsFontColor = prop
+        return this
+    }
+
+    fun dataLabelsFontSize(prop: Float?): AAChartModel {
+        dataLabelsFontSize = prop
+        return this
+    }
+
+    fun dataLabelsFontWeight(prop: String): AAChartModel {
+        dataLabelsFontWeight = prop
         return this
     }
 
@@ -285,16 +356,26 @@ class AAChartModel {
         return this
     }
 
+    fun xAxisTickInterval(prop: Int?): AAChartModel {
+        xAxisTickInterval = prop
+        return this
+    }
+
     fun categories(prop: Array<String>): AAChartModel {
         categories = prop
         return this
     }
 
-    fun xAxisGridLineWidth(prop: Int?): AAChartModel {
+    fun xAxisGridLineWidth(prop: Float?): AAChartModel {
         xAxisGridLineWidth = prop
         return this
     }
 
+    fun yAxisGridLineWidth(prop: Float?): AAChartModel {
+        yAxisGridLineWidth = prop
+        return this
+    }
+
     fun xAxisVisible(prop: Boolean?): AAChartModel {
         xAxisVisible = prop
         return this
@@ -305,11 +386,6 @@ class AAChartModel {
         return this
     }
 
-    fun yAxisGridLineWidth(prop: Int?): AAChartModel {
-        yAxisGridLineWidth = prop
-        return this
-    }
-
     fun yAxisLabelsEnabled(prop: Boolean?): AAChartModel {
         yAxisLabelsEnabled = prop
         return this
@@ -320,48 +396,48 @@ class AAChartModel {
         return this
     }
 
-    fun yAxisLineWidth(prop:Float): AAChartModel {
+    fun yAxisLineWidth(prop: Float?): AAChartModel {
         yAxisLineWidth = prop
         return this
     }
 
-    fun colorsTheme(prop: Array<Any>): AAChartModel {
-        colorsTheme = prop
+    fun yAxisMin(prop: Float?): AAChartModel {
+        yAxisMin = prop
         return this
     }
 
-    fun legendEnabled(prop: Boolean?): AAChartModel {
-        legendEnabled = prop
+    fun yAxisMax(prop: Float?): AAChartModel {
+        yAxisMax = prop
         return this
     }
 
-    fun legendLayout(prop: String): AAChartModel {
-        legendLayout = prop
-
+    fun yAxisAllowDecimals(prop: Boolean?): AAChartModel {
+        yAxisAllowDecimals = prop
         return this
     }
 
-    fun legendAlign(prop: String): AAChartModel {
-        legendAlign = prop
+    fun colorsTheme(prop: Array<Any>): AAChartModel {
+        colorsTheme = prop
         return this
     }
 
-    fun legendVerticalAlign(prop: AAChartVerticalAlignType): AAChartModel {
-        legendVerticalAlign = prop.value
+    fun legendEnabled(prop: Boolean?): AAChartModel {
+        legendEnabled = prop
         return this
     }
 
-    fun backgroundColor(prop: String): AAChartModel {
+    fun backgroundColor(prop: Any): AAChartModel {
         backgroundColor = prop
         return this
     }
 
-    fun borderRadius(prop: Int?): AAChartModel {
+
+    fun borderRadius(prop: Float?): AAChartModel {
         borderRadius = prop
         return this
     }
 
-    fun markerRadius(prop: Int?): AAChartModel {
+    fun markerRadius(prop: Float?): AAChartModel {
         markerRadius = prop
         return this
     }
@@ -371,34 +447,49 @@ class AAChartModel {
         return this
     }
 
-    init {
-        chartType = AAChartType.Line.toString()
-        animationType = AAChartAnimationType.EaseInBack.value
-        animationDuration = 800//以毫秒为单位
+    fun touchEventEnabled(prop: Boolean?): AAChartModel {
+        touchEventEnabled = prop
+        return this
+    }
+
+    fun AAChartModel() {
+        chartType = AAChartType.Line.value
+        animationDuration = 500//以毫秒为单位
+        animationType = AAChartAnimationType.Linear.value
         pointHollow = false
         inverted = false
         stacking = AAChartStackingType.False.value
         xAxisReversed = false
         yAxisReversed = false
         zoomType = "x"
-        colorsTheme = arrayOf("#fe117c", "#ffc069", "#06caf4", "#7dffc0")//默认的颜色数组(必须要添加默认数组,否则就会出错)
+        dataLabelsEnabled = false
+        markerSymbolStyle = AAChartSymbolStyleType.Normal.value
+        //        colorsTheme = new String[]{"#b5282a","#e7a701","#50c18d","#fd4800","#f1c6c5"};
+        colorsTheme =
+            arrayOf("#fe117c", "#ffc069", "#06caf4", "#7dffc0")//默认的颜色数组(必须要添加默认数组,否则就会出错)
         tooltipCrosshairs = true
         gradientColorEnable = false
         polar = false
-        dataLabelEnabled = false
         xAxisLabelsEnabled = true
-        xAxisGridLineWidth = 0
+        xAxisGridLineWidth = 0f
         yAxisLabelsEnabled = true
-        yAxisGridLineWidth = 1
+        yAxisGridLineWidth = 1f
         legendEnabled = true
-        legendLayout = "horizontal"
-        legendAlign = "center"
-        legendVerticalAlign = "bottom"
         backgroundColor = "#ffffff"
-        borderRadius = 0//柱状图长条图头部圆角半径(可用于设置头部的形状,仅对条形图,柱状图有效,设置为1000时,柱形图或者条形图头部为楔形)
-        markerRadius = 6//折线连接点的半径长度,如果值设置为0,这样就相当于不显示了
+        borderRadius = 0f//柱状图长条图头部圆角半径(可用于设置头部的形状,仅对条形图,柱状图有效,设置为1000时,柱形图或者条形图头部为楔形)
+        markerRadius = 6f//折线连接点的半径长度,如果值设置为0,这样就相当于不显示了
+        touchEventEnabled = true
+        titleFontColor = "#000000"//标题字体颜色为黑色
+        titleFontWeight = "regular"//常规字体
+        titleFontSize = 11f
+        subtitleFontColor = "#000000"//副标题字体颜色为黑色
+        subtitleFontWeight = "regular"//常规字体
+        subtitleFontSize = 9f
+        dataLabelsFontColor = "#000000"//数据标签默认颜色为黑色
+        dataLabelsFontWeight = "bold"//图表的数据字体为粗体
+        dataLabelsFontSize = 10f
 
     }
-}
 
 
+}

+ 33 - 17
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAChartConfiger/AAChartView.kt

@@ -50,6 +50,7 @@ import android.webkit.WebResourceRequest
 import android.webkit.WebView
 import android.webkit.WebViewClient
 import android.widget.Toast
+import com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel.AAOptions
 import com.example.chartcorekotlin.AAChartConfiger.AAChartModel
 import com.example.chartcorekotlin.AAChartConfiger.AAOptionsConstructor
 import com.example.chartcorekotlin.AAChartConfiger.AASeriesElement
@@ -81,11 +82,12 @@ class AAChartView : WebView {
 
     interface AAChartViewCallBack {
         fun chartViewDidFinishedLoad(aaChartView: AAChartView)
-        fun chartViewMoveOverEventMessage(aaChartView: AAChartView, messageModel: AAMoveOverEventMessageModel)
+        fun chartViewMoveOverEventMessage(
+            aaChartView: AAChartView,
+            messageModel: AAMoveOverEventMessageModel
+        )
     }
 
-
-
     constructor(context: Context) : super(context) {
         sharedConstructor()
     }
@@ -94,7 +96,11 @@ class AAChartView : WebView {
         sharedConstructor()
     }
 
-    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
+    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
+        context,
+        attrs,
+        defStyleAttr
+    ) {
         sharedConstructor()
     }
 
@@ -102,6 +108,7 @@ class AAChartView : WebView {
         // Do some initialize work.
         this.contentWidth = 320f
         this.contentHeight = 350f
+        //        //设置WebView支持JavaScript(这一句是十分关键的一句)
         this.settings.javaScriptEnabled = true
 //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
 //            this.setWebContentsDebuggingEnabled(true)
@@ -127,14 +134,14 @@ class AAChartView : WebView {
         return ""
     }
 
-    fun getEventMessageModel(messageBody: Map<*, *>): AAMoveOverEventMessageModel {
+    internal fun getEventMessageModel(messageBody: Map<*, *>): AAMoveOverEventMessageModel {
         val eventMessageModel = AAMoveOverEventMessageModel()
-        eventMessageModel.name = messageBody["name"]!!.toString()
-        eventMessageModel.x = messageBody["x"] as Double?
-        eventMessageModel.y = messageBody["y"] as Double?
-        eventMessageModel.category = messageBody["category"]!!.toString()
-        eventMessageModel.offset = messageBody["offset"] as LinkedTreeMap<*, *>?
-        eventMessageModel.index = messageBody["index"] as Double?
+        eventMessageModel.name = messageBody["name"].toString()
+        eventMessageModel.x = messageBody["x"] as Double
+        eventMessageModel.y = messageBody["y"] as Double
+        eventMessageModel.category = messageBody["category"].toString()
+        eventMessageModel.offset = messageBody["offset"] as LinkedTreeMap<*, *>
+        eventMessageModel.index = messageBody["index"] as Double
         return eventMessageModel
     }
 
@@ -152,7 +159,7 @@ class AAChartView : WebView {
         this.aa_refreshChartWithChartOptions(aaOptions)
     }
 
-    fun aa_drawChartWithChartOptions(chartOptions: HashMap<*, *>) {
+    fun aa_drawChartWithChartOptions(chartOptions: AAOptions) {
         this.loadUrl("file:///android_asset/AAChartView.html")
         this.webViewClient = object : WebViewClient() {
             override fun onPageFinished(view: WebView, url: String) {
@@ -164,7 +171,10 @@ class AAChartView : WebView {
             }
 
             @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
-            override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
+            override fun shouldOverrideUrlLoading(
+                view: WebView,
+                request: WebResourceRequest
+            ): Boolean {
                 super.shouldOverrideUrlLoading(view, request)
                 val urlStr = request.url.toString()
                 val jsBridgeName = "AAChartViewBridge".toLowerCase()
@@ -181,7 +191,12 @@ class AAChartView : WebView {
 
 
         this.webChromeClient = object : WebChromeClient() {
-            override fun onJsAlert(view: WebView, url: String, message: String, result: JsResult): Boolean {
+            override fun onJsAlert(
+                view: WebView,
+                url: String,
+                message: String,
+                result: JsResult
+            ): Boolean {
                 super.onJsAlert(view, url, message, result)
 
                 return true
@@ -197,11 +212,12 @@ class AAChartView : WebView {
         this.safeEvaluateJavaScriptString(javaScriptStr)
     }
 
-    fun aa_refreshChartWithChartOptions(chartOptions: HashMap<*, *>) {
+    fun aa_refreshChartWithChartOptions(chartOptions: AAOptions) {
         // 将对象编译成json
         val gson = Gson()
         val aaOptionsJsonStr = gson.toJson(chartOptions)
-        val javaScriptStr = "loadTheHighChartView('$aaOptionsJsonStr','$contentWidth','$contentHeight')"
+        val javaScriptStr =
+            "loadTheHighChartView('$aaOptionsJsonStr','$contentWidth','$contentHeight')"
         this.safeEvaluateJavaScriptString(javaScriptStr)
     }
 
@@ -216,7 +232,7 @@ class AAChartView : WebView {
         this.safeEvaluateJavaScriptString(javaScriptStr)
     }
 
-    private fun configureChartOptionsAndDrawChart(chartOptions: HashMap<*, *>) {
+    private fun configureChartOptionsAndDrawChart(chartOptions: AAOptions) {
         // 将对象编译成json
         val gson = Gson()
         val aaOptionsJsonStr = gson.toJson(chartOptions)

+ 176 - 131
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAChartConfiger/AAOptionsConstructor.kt

@@ -34,78 +34,75 @@
  */
 package com.example.chartcorekotlin.AAChartConfiger
 
-import java.util.HashMap
+import com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel.*
 
 
 object AAOptionsConstructor {
-    fun configureChartOptions(aaChartModel: AAChartModel): HashMap<String, Any?> {
-        val aaChart = HashMap<String, Any?>()
-        aaChart["type"] = aaChartModel.chartType//图表类型
-        aaChart["inverted"] = aaChartModel.inverted//设置是否反转坐标轴,使X轴垂直,Y轴水平。 如果值为 true,则 x 轴默认是 倒置 的。 如果图表中出现条形图系列,则会自动反转
-        aaChart["backgroundColor"] = aaChartModel.backgroundColor//图表背景色
-        aaChart["animation"] = true//是否开启图表渲染动画
-        aaChart["pinchType"] = aaChartModel.zoomType//设置手势缩放方向
-        aaChart["panning"] = true//设置手势缩放后是否可平移
-        aaChart["polar"] = aaChartModel.polar//是否极化图表(开启极坐标模式)
-        aaChart["marginLeft"] = aaChartModel.marginLeft/* 图表左边距 */
-        aaChart["marginRight"] = aaChartModel.marginRight//图表右边距
-
-        val aaTitle = HashMap<String, Any?>()
-        aaTitle["text"] = aaChartModel.title//标题文本内容
-        val aaTitleStyle = HashMap<String, Any?>()
-        aaTitleStyle["color"] = aaChartModel.titleColor//标题文字颜色
-        aaTitleStyle["fontSize"] = "12px"//标题文字大小
-        aaTitle["style"] = aaTitleStyle
-
-        val aaSubtitle = HashMap<String, Any?>()
-        aaSubtitle["text"] = aaChartModel.subtitle//富标题文本内容
-        val aaSubtitleStyle = HashMap<String, Any?>()
-        aaSubtitleStyle["color"] = aaChartModel.subTitleColor//副标题文字颜色
-        aaSubtitleStyle["fontSize"] = "9px"//副标题文字大小
-        aaSubtitle["style"] = aaSubtitleStyle
-
-        val aaTooltip = HashMap<String, Any?>()
-        aaTooltip["enabled"] = aaChartModel.tooltipEnabled//是否开启浮动提示框 tooltip
-        aaTooltip["valueSuffix"] = aaChartModel.tooltipValueSuffix// 浮动提示框数字的单位后缀
-        aaTooltip["shared"] = true//多组 series 数据时,是否共享浮动提示框,默认共享
-        aaTooltip["crosshairs"] = aaChartModel.tooltipCrosshairs
-
-        val aaSeries = HashMap<String, Any?>()
-        aaSeries["stacking"] = aaChartModel.stacking//图表堆叠样式类型
-        val aaAnimation = HashMap<String, Any?>()
-        aaAnimation["duration"] = aaChartModel.animationDuration//图表渲染的动画时间
-        aaAnimation["easing"] = aaChartModel.animationType//图表渲染的动画类型
-        aaSeries["animation"] = aaAnimation
-
-        var aaPlotOptions = HashMap<String, Any?>()
-        aaPlotOptions["series"] = aaSeries
-
-        //数据点标记的相关配置
-        aaPlotOptions = configureAAPlotOptionsMarkerStyle(aaChartModel, aaSeries, aaPlotOptions)
-        //配置 aaPlotOptions 的 dataLabels 等相关内容
-        aaPlotOptions = configureAAPlotOptionsDataLabels(aaPlotOptions, aaChartModel)
-
-        val aaLegend = HashMap<String, Any?>()
-        aaLegend["enabled"] = aaChartModel.legendEnabled//是否显示图表的图例,默认显示
-        aaLegend["layout"] = aaChartModel.legendLayout //图例数据项的布局。布局类型: "horizontal" 或 "vertical" 即水平布局和垂直布局 默认是:horizontal.
-        aaLegend["align"] = aaChartModel.legendAlign//设定图例在图表区中的水平对齐方式,合法值有left,center 和 right。
-        aaLegend["verticalAlign"] = aaChartModel.legendVerticalAlign//设定图例在图表区中的垂直对齐方式,合法值有 top,middle 和 bottom。垂直位置可以通过 y 选项做进一步设定。
-        aaLegend["borderWidth"] = 0
-        val aaLegendItemSyle = HashMap<String, Any?>()
-        aaLegend["color"] = aaChartModel.axisColor//图例的文字颜色,默认图例的文字颜色和X轴文字颜色一样
-        aaLegend["itemStyle"] = aaLegendItemSyle
-
-
-        val aaOptions = HashMap<String, Any?>()
-        aaOptions["chart"] = aaChart
-        aaOptions["title"] = aaTitle
-        aaOptions["subtitle"] = aaSubtitle
-        aaOptions["tooltip"] = aaTooltip
-        aaOptions["legend"] = aaLegend
-        aaOptions["plotOptions"] = aaPlotOptions
-        aaOptions["colors"] = aaChartModel.colorsTheme//图表的主体颜色数组
-        aaOptions["series"] = aaChartModel.series//图表的数据列数组
-        aaOptions["axisColor"] = aaChartModel.axisColor//图表的 x 轴颜色
+    fun configureChartOptions(
+        aaChartModel:AAChartModel
+    ):AAOptions {
+        val aaChart = AAChart()
+            .type(aaChartModel.chartType)//绘图类型
+            .inverted(aaChartModel.inverted)//设置是否反转坐标轴,使X轴垂直,Y轴水平。 如果值为 true,则 x 轴默认是 倒置 的。 如果图表中出现条形图系列,则会自动反转
+            .backgroundColor(aaChartModel.backgroundColor)//设置图表的背景色(包含透明度的设置)
+            .pinchType(aaChartModel.zoomType)//设置手势缩放方向
+            .panning(true)//设置手势缩放后是否可平移
+            .polar(aaChartModel.polar)//是否极化图表(开启极坐标模式)
+            .marginLeft(aaChartModel.marginLeft)//图表左边距
+            .marginRight(aaChartModel.marginRight)//图表右边距
+
+        val aaTitle = AATitle()
+            .text(aaChartModel.title)//标题文本内容
+            .style(AAStyle()
+                .color(aaChartModel.titleFontColor)//Title font color
+                .fontSize(aaChartModel.titleFontSize)//Title font size
+                .fontWeight(aaChartModel.titleFontWeight)//Title font weight
+            )
+
+        val aaSubtitle = AASubtitle()
+            .text(aaChartModel.subtitle)//副标题内容
+            .align(aaChartModel.subtitleAlign)//图表副标题文本水平对齐方式。可选的值有 “left”,”center“和“right”。 默认是:center.
+            .style(AAStyle()
+                .color(aaChartModel.subtitleFontColor)//Subtitle font color
+                .fontSize(aaChartModel.subtitleFontSize)//Subtitle font size
+                .fontWeight(aaChartModel.subtitleFontWeight)//Subtitle font weight
+            )
+
+        val aaTooltip = AATooltip()
+            .enabled(aaChartModel.tooltipEnabled)//启用浮动提示框
+            .shared(true)//多组数据共享一个浮动提示框
+            .crosshairs(true)//启用准星线
+            .valueSuffix(aaChartModel.tooltipValueSuffix)//浮动提示框的单位名称后缀
+
+        val aaPlotOptions = AAPlotOptions()
+            .series(AASeries()
+                .stacking(aaChartModel.stacking)//设置是否百分比堆叠显示图形
+            )
+
+        if (aaChartModel.animationType !== AAChartAnimationType.Linear.value) {
+            aaPlotOptions
+                .series?.animation(AAAnimation()
+                .easing(aaChartModel.animationType)
+                .duration(aaChartModel.animationDuration)
+            )
+        }
+
+        configureAAPlotOptionsMarkerStyle(aaChartModel, aaPlotOptions)
+        configureAAPlotOptionsDataLabels(aaPlotOptions, aaChartModel)
+
+        val aaLegend = AALegend()
+            .enabled(aaChartModel.legendEnabled)//是否显示 legend
+
+        val aaOptions = AAOptions()
+            .chart(aaChart)
+            .title(aaTitle)
+            .subtitle(aaSubtitle)
+            .tooltip(aaTooltip)
+            .plotOptions(aaPlotOptions)
+            .legend(aaLegend)
+            .series(aaChartModel.series)
+            .colors(aaChartModel.colorsTheme)//设置颜色主题
+            .touchEventEnabled(aaChartModel.touchEventEnabled)//是否支持点击事件
 
         configureAxisContentAndStyle(aaOptions, aaChartModel)
 
@@ -113,9 +110,8 @@ object AAOptionsConstructor {
     }
 
     private fun configureAAPlotOptionsMarkerStyle(aaChartModel: AAChartModel,
-                                                  aaSeries: HashMap<String, Any?>,
-                                                  aaPlotOptions: HashMap<String, Any?>
-    ): HashMap<String, Any?> {
+                                                  aaPlotOptions: AAPlotOptions
+    ): AAPlotOptions {
         val chartType = aaChartModel.chartType
         //数据点标记相关配置,只有线性图(折线图、曲线图、折线区域填充图、曲线区域填充图,散点图)才有数据点标记
         if (chartType === AAChartType.Area.value
@@ -123,83 +119,132 @@ object AAOptionsConstructor {
             || chartType === AAChartType.Line.value
             || chartType === AAChartType.Spline.value
             || chartType === AAChartType.Scatter.value) {
-            val aaMarker = HashMap<String, Any?>()
-            aaMarker["radius"] = aaChartModel.markerRadius//曲线连接点半径,默认是4
-            aaMarker["symbol"] = aaChartModel.symbol//曲线连接点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
-            //设置曲线连接点风格样式
-            if (aaChartModel.symbolStyle === AAChartSymbolStyleType.InnerBlank.value) {
-                aaMarker["fillColor"] = "#FFFFFF"//点的填充色(用来设置折线连接点的填充色)
-                aaMarker["lineWidth"] = 2//外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
-                aaMarker["lineColor"] = ""//外沿线的颜色(用来设置折线连接点的轮廓描边颜色,当值为空字符串时,默认取数据点或数据列的颜色。)
-            } else if (aaChartModel.symbolStyle === AAChartSymbolStyleType.BorderBlank.value) {
-                aaMarker["lineWidth"] = 2//外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
-                aaMarker["lineColor"] = aaChartModel.backgroundColor//外沿线的颜色(用来设置折线连接点的轮廓描边颜色,当值为空字符串时,默认取数据点或数据列的颜色。)
+            val aaMarker = AAMarker()
+                .radius(aaChartModel.markerRadius)//曲线连接点半径,默认是4
+                .symbol(aaChartModel.markerSymbol)//曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
+            if (aaChartModel.markerSymbolStyle === AAChartSymbolStyleType.InnerBlank.value) {
+                aaMarker.fillColor("#ffffff")//点的填充色(用来设置折线连接点的填充色)
+                    .lineWidth(2f)//外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
+                    .lineColor("")//外沿线的颜色(用来设置折线连接点的轮廓描边颜色,当值为空字符串时,默认取数据点或数据列的颜色)
+            } else if (aaChartModel.markerSymbolStyle == AAChartSymbolStyleType.BorderBlank.value) {
+                aaMarker.lineWidth(2f)
+                    .lineColor(aaChartModel.backgroundColor)
             }
-            aaSeries["marker"] = aaMarker
-            aaPlotOptions["series"] = aaSeries
+            val aaSeries = aaPlotOptions.series
+            aaSeries?.marker(aaMarker)
         }
         return aaPlotOptions
     }
 
 
-    private fun configureAAPlotOptionsDataLabels(aaPlotOptions: HashMap<String, Any?>,
-                                                 aaChartModel: AAChartModel): HashMap<String, Any?> {
+    private fun configureAAPlotOptionsDataLabels(
+        aaPlotOptions: AAPlotOptions,
+        aaChartModel: AAChartModel
+    ): AAPlotOptions {
 
         val chartType = aaChartModel.chartType
-        val aaDataLabels = HashMap<String, Any?>()
-        aaDataLabels["enabled"] = aaChartModel.dataLabelEnabled
-        val aaSomeTypeChart = HashMap<String, Any?>()
-
-        if (chartType === AAChartType.Column.value || chartType === AAChartType.Bar.value) {
-            aaSomeTypeChart["borderWidth"] = 0
-            aaSomeTypeChart["borderRadius"] = aaChartModel.borderRadius
-            aaSomeTypeChart["dataLabels"] = aaDataLabels
+
+        var aaDataLabels = AADataLabels()
+        if (aaChartModel.dataLabelsEnabled == true) {
+            aaDataLabels = aaDataLabels
+                .enabled(true)
+                .style(AAStyle()
+                        .color(aaChartModel.dataLabelsFontColor)
+                        .fontSize(aaChartModel.dataLabelsFontSize)
+                        .fontWeight(aaChartModel.dataLabelsFontWeight)
+                )
+        }
+
+        if (chartType == AAChartType.Column.value) {
+            val aaColumn = AAColumn()
+                .borderWidth(0f)
+                .borderRadius(aaChartModel.borderRadius)
+                .dataLabels(aaDataLabels)
             if (aaChartModel.polar == true) {
-                aaSomeTypeChart["pointPadding"] = 0
-                aaSomeTypeChart["groupPadding"] = 0.005
+                aaColumn.pointPadding(0f)
+                    .groupPadding(0.005f)
             }
-        } else if (chartType === AAChartType.Pie.value) {
-            aaSomeTypeChart["allowPointSelect"] = true
-            aaSomeTypeChart["cursor"] = "pointer"
-            aaSomeTypeChart["showInLegend"] = aaChartModel.legendEnabled
-            aaDataLabels["format"] = "{point.name}"
-            aaSomeTypeChart["dataLabels"] = aaDataLabels
-        } else {
-            aaSomeTypeChart["dataLabels"] = aaDataLabels
-        }
-        if (chartType != null) {
-            aaPlotOptions[chartType] = aaSomeTypeChart
+            aaPlotOptions.column(aaColumn)
+        } else if (chartType == AAChartType.Bar.value) {
+            val aaBar = AABar()
+                .borderWidth(0f)
+                .borderRadius(aaChartModel.borderRadius)
+                .dataLabels(aaDataLabels)
+            if (aaChartModel.polar == true) {
+                aaBar.pointPadding(0f)
+                    .groupPadding(0.005f)
+            }
+            aaPlotOptions.bar(aaBar)
+        } else if (chartType == AAChartType.Area.value) {
+            aaPlotOptions.area(AAArea().dataLabels(aaDataLabels))
+        } else if (chartType == AAChartType.Areaspline.value) {
+            aaPlotOptions.areaspline(AAAreaspline().dataLabels(aaDataLabels))
+        } else if (chartType == AAChartType.Line.value) {
+            aaPlotOptions.line(AALine().dataLabels(aaDataLabels))
+        } else if (chartType == AAChartType.Spline.value) {
+            aaPlotOptions.spline(AASpline().dataLabels(aaDataLabels))
+        } else if (chartType == AAChartType.Pie.value) {
+            val aaPie = AAPie()
+                .allowPointSelect(true)
+                .cursor("pointer")
+                .showInLegend(true)
+            if (aaChartModel.dataLabelsEnabled == true) {
+                aaPie.dataLabels(aaDataLabels.format("<b>{point.name}</b>: {point.percentage:.1f} %"))
+            } else {
+                aaPie.dataLabels(AADataLabels().enabled(false))
+            }
+            aaPlotOptions.pie(aaPie)
+        } else if (chartType == AAChartType.Columnrange.value) {
+            val columnRangeMap = mapOf(
+                "borderRadius" to 0,//The color of the border surrounding each column or bar
+                "borderWidth" to 0,//The corner radius of the border surrounding each column or bar. default:0
+                "dataLabels" to aaDataLabels
+                )
+            aaPlotOptions.columnrange(columnRangeMap)
+        } else if (chartType == AAChartType.Arearange.value) {
+            val areaRangeMap = mapOf(
+                "dataLabels" to aaDataLabels
+            )
+            aaPlotOptions.arearange(areaRangeMap)
         }
-
         return aaPlotOptions
     }
 
-    private fun configureAxisContentAndStyle(aaOptions: HashMap<String, Any?>,
-                                             aaChartModel: AAChartModel) {
 
+    private fun configureAxisContentAndStyle(aaOptions: AAOptions,
+                                             aaChartModel: AAChartModel) {
         if (aaChartModel.chartType !== AAChartType.Pie.value
             && aaChartModel.chartType !== AAChartType.Pyramid.value
             && aaChartModel.chartType !== AAChartType.Funnel.value) {
-            val aaAxisLabel = HashMap<String, Any?>()
-            aaAxisLabel["enabled"] = aaChartModel.xAxisLabelsEnabled
-
-            val aaXAxis = HashMap<String, Any?>()
-            aaXAxis["label"] = aaAxisLabel
-            aaXAxis["reversed"] = aaChartModel.xAxisReversed
-            aaXAxis["gridLineWidth"] = aaChartModel.xAxisGridLineWidth
-            aaXAxis["categories"] = aaChartModel.categories
-            aaXAxis["visible"] = aaChartModel.xAxisVisible
-
-            val aaYAxis = HashMap<String, Any?>()
-            aaYAxis["label"] = aaAxisLabel
-            aaYAxis["reversed"] = aaChartModel.yAxisReversed
-            aaYAxis["gridLineWidth"] = aaChartModel.yAxisGridLineWidth
-            aaYAxis["title"] = aaChartModel.yAxisTitle
-            aaYAxis["lineWidth"] = aaChartModel.yAxisLineWidth
-            aaYAxis["visible"] = aaChartModel.yAxisVisible
-
-            aaOptions["xAxis"] = aaXAxis
-            aaOptions["yAxis"] = aaYAxis
+            val aaXAxis = AAXAxis()
+                .labels(AALabels()
+                    .enabled(aaChartModel.xAxisLabelsEnabled)//设置 x 轴是否显示文字
+                )
+                .reversed(aaChartModel.xAxisReversed)
+                .gridLineWidth(aaChartModel.xAxisGridLineWidth)//x轴网格线宽度
+                .categories(aaChartModel.categories)
+                .visible(aaChartModel.xAxisVisible)//x轴是否可见
+                .tickInterval(aaChartModel.xAxisTickInterval) //x轴坐标点间隔数
+
+
+            val aaYAxis = AAYAxis()
+                .labels(AALabels()
+                    .enabled(aaChartModel.yAxisLabelsEnabled)
+                )//设置 y 轴是否显示数字
+                .min(aaChartModel.yAxisMin)//设置 y 轴最小值,最小值等于零就不能显示负值了
+                .max(aaChartModel.yAxisMax)//y轴最大值
+                .allowDecimals(aaChartModel.yAxisAllowDecimals)//是否允许显示小数
+                .reversed(aaChartModel.yAxisReversed)
+                .gridLineWidth(aaChartModel.yAxisGridLineWidth)//y轴网格线宽度
+                .title( AATitle()
+                    .text(aaChartModel.yAxisTitle)
+                )//y 轴标题
+                .lineWidth(aaChartModel.yAxisLineWidth)//设置 y轴轴线的宽度,为0即是隐藏 y轴轴线
+                .visible(aaChartModel.yAxisVisible)
+
+
+            aaOptions.xAxis(aaXAxis)
+                .yAxis(aaYAxis)
         }
     }
 

+ 1 - 1
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAAnimation.kt

@@ -17,7 +17,7 @@ class AAAnimation {
         return this
     }
 
-    fun easing(prop: String): AAAnimation {
+    fun easing(prop: String?): AAAnimation {
         easing = prop
         return this
     }

+ 3 - 3
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAChart.kt

@@ -21,12 +21,12 @@ class AAChart {
     private var marginLeft: Float? = null
     private var marginRight: Float? = null
 
-    fun type(prop: String): AAChart {
+    fun type(prop: String?): AAChart {
         type = prop
         return this
     }
 
-    fun backgroundColor(prop: Any): AAChart {
+    fun backgroundColor(prop: Any?): AAChart {
         backgroundColor = prop
         return this
     }
@@ -36,7 +36,7 @@ class AAChart {
         return this
     }
 
-    fun pinchType(prop: String): AAChart {
+    fun pinchType(prop: String?): AAChart {
         pinchType = prop
         return this
     }

+ 2 - 2
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAMarker.kt

@@ -21,7 +21,7 @@ class AAMarker {
         return this
     }
 
-    fun symbol(prop: String): AAMarker {
+    fun symbol(prop: String?): AAMarker {
         symbol = prop
         return this
     }
@@ -36,7 +36,7 @@ class AAMarker {
         return this
     }
 
-    fun lineColor(prop: Any): AAMarker {
+    fun lineColor(prop: Any?): AAMarker {
         lineColor = prop
         return this
     }

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

@@ -0,0 +1,81 @@
+/**
+ * Copyright (C), 2015-2019
+ * FileName: AAOptions
+ * Author: AnAn
+ * Date: 2019-08-30 14:18
+ * Description:
+ * History:
+ */
+package com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel
+
+import com.example.chartcorekotlin.AAChartConfiger.AASeriesElement
+
+class AAOptions {
+    var chart: AAChart? = null
+    var title: AATitle? = null
+    var subtitle: AASubtitle? = null
+    var xAxis: AAXAxis? = null
+    var yAxis: AAYAxis? = null
+    var tooltip: AATooltip? = null
+    var plotOptions: AAPlotOptions? = null
+    var series: Array<AASeriesElement>? = null
+    var legend: AALegend? = null
+    var colors: Array<Any>? = null
+    var touchEventEnabled: Boolean? = null
+
+    fun chart(prop: AAChart): AAOptions {
+        chart = prop
+        return this
+    }
+
+    fun title(prop: AATitle): AAOptions {
+        title = prop
+        return this
+    }
+
+    fun subtitle(prop: AASubtitle): AAOptions {
+        subtitle = prop
+        return this
+    }
+
+    fun xAxis(prop: AAXAxis): AAOptions {
+        xAxis = prop
+        return this
+    }
+
+    fun yAxis(prop: AAYAxis): AAOptions {
+        yAxis = prop
+        return this
+    }
+
+    fun tooltip(prop: AATooltip): AAOptions {
+        tooltip = prop
+        return this
+    }
+
+    fun plotOptions(prop: AAPlotOptions): AAOptions {
+        plotOptions = prop
+        return this
+    }
+
+    fun series(prop: Array<AASeriesElement>?): AAOptions {
+        series = prop
+        return this
+    }
+
+    fun legend(prop: AALegend): AAOptions {
+        legend = prop
+        return this
+    }
+
+    fun colors(prop: Array<Any>?): AAOptions {
+        colors = prop
+        return this
+    }
+
+    fun touchEventEnabled(prop: Boolean?): AAOptions {
+        touchEventEnabled = prop
+        return this
+    }
+
+}

+ 1 - 1
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AASeries.kt

@@ -29,7 +29,7 @@ class AASeries {
         return this
     }
 
-    fun stacking(prop: String): AASeries {
+    fun stacking(prop: String?): AASeries {
         stacking = prop
         return this
     }

+ 4 - 4
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAStyle.kt

@@ -15,17 +15,17 @@ class AAStyle {
     private var fontWeight: String? = null
     private var textOutLine: String? = null
 
-    fun color(prop: String): AAStyle {
+    fun color(prop: String?): AAStyle {
         color = prop
         return this
     }
 
-    fun fontSize(prop: String): AAStyle {
-        fontSize = prop
+    fun fontSize(prop: Float?): AAStyle {
+        fontSize = "$prop px"
         return this
     }
 
-    fun fontWeight(prop: String): AAStyle {
+    fun fontWeight(prop: String?): AAStyle {
         fontWeight = prop
         return this
     }

+ 2 - 2
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AASubtitle.kt

@@ -19,7 +19,7 @@ class AASubtitle {
     private var y: Float? = null
     private var userHTML: Boolean? = null
 
-    fun text(prop: String): AASubtitle {
+    fun text(prop: String?): AASubtitle {
         text = prop
         return this
     }
@@ -29,7 +29,7 @@ class AASubtitle {
         return this
     }
 
-    fun align(prop: String): AASubtitle {
+    fun align(prop: String?): AASubtitle {
         align = prop
         return this
     }

+ 1 - 1
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AATitle.kt

@@ -20,7 +20,7 @@ class AATitle {
     private var y: Float? = null
     private var userHTML: Boolean? = null
 
-    fun text(prop: String): AATitle {
+    fun text(prop: String?): AATitle {
         text = prop
         return this
     }

+ 1 - 1
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AATooltip.kt

@@ -127,7 +127,7 @@ class AATooltip {
         return this
     }
 
-    fun valueSuffix(prop: String): AATooltip {
+    fun valueSuffix(prop: String?): AATooltip {
         valueSuffix = prop
         return this
     }

+ 1 - 1
app/src/main/java/com/aachartmodel/aainfographics/AAInfographicsLib/AAOptionsModel/AAXAxis.kt

@@ -44,7 +44,7 @@ class AAXAxis {
         return this
     }
 
-    fun categories(prop: Array<String>): AAXAxis {
+    fun categories(prop: Array<String>?): AAXAxis {
         categories = prop
         return this
     }

+ 2 - 1
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/AdditionalContent/CustomTooltipWithJSFunctionActivity.kt

@@ -29,6 +29,7 @@ package com.aachartmodel.aainfographics.ChartsDemo.AdditionalContent
 
 import android.support.v7.app.AppCompatActivity
 import android.os.Bundle
+import com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel.AAOptions
 import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.CustomTooltipComposer
 import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.CustomTooltipComposer.Companion.customAreaChartTooltipStyleWithFormatterFunction1
 import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.CustomTooltipComposer.Companion.customAreaChartTooltipStyleWithFormatterFunction2
@@ -54,7 +55,7 @@ class CustomTooltipWithJSFunctionActivity : AppCompatActivity() {
 
     }
 
-    private fun configureTheChartOptions(chartType: String): HashMap<*, *> {
+    private fun configureTheChartOptions(chartType: String): AAOptions {
         when (chartType) {
             "formatterFunction1" -> return customAreaChartTooltipStyleWithFormatterFunction1()
             "formatterFunction2" -> return customAreaChartTooltipStyleWithFormatterFunction2()

+ 2 - 1
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/AdditionalContent/DrawChartWithAAOptionsActivity.kt

@@ -29,6 +29,7 @@ package com.aachartmodel.aainfographics.ChartsDemo.AdditionalContent
 
 import android.support.v7.app.AppCompatActivity
 import android.os.Bundle
+import com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel.AAOptions
 import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.ChartOptionsComposer.Companion.configureAAPlotBandsForChart
 import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.ChartOptionsComposer.Companion.configureAAPlotLinesForChart
 import com.aachartmodel.aainfographics.ChartsDemo.ChartComposer.ChartOptionsComposer.Companion.customAATooltipWithJSFuntion
@@ -53,7 +54,7 @@ class DrawChartWithAAOptionsActivity : AppCompatActivity() {
 
     }
 
-    private fun configureTheChartOptions(chartType: String): HashMap<*, *> {
+    private fun configureTheChartOptions(chartType: String): AAOptions {
         when (chartType) {
             "configureAAPlotBandsForChart" -> return configureAAPlotBandsForChart()
             "configureAAPlotLinesForChart" -> return configureAAPlotLinesForChart()

+ 8 - 9
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/BasicContent/CommonChartActivity.kt

@@ -73,8 +73,7 @@ class CommonChartActivity : AppCompatActivity(), RadioGroup.OnCheckedChangeListe
             .subtitle("subtitle")
             .backgroundColor("#4b2b7f")
             .dataLabelsEnabled(false)
-            .yAxisGridLineWidth(0)
-            .legendVerticalAlign(AAChartVerticalAlignType.Bottom)
+            .yAxisGridLineWidth(0f)
             .series(arrayOf(
                     AASeriesElement()
                         .name("Tokyo")
@@ -129,10 +128,10 @@ class CommonChartActivity : AppCompatActivity(), RadioGroup.OnCheckedChangeListe
 
         if (chartType == AAChartType.Area.value
             || chartType == AAChartType.Arearange.value) {
-            aaChartModel.symbolStyle(AAChartSymbolStyleType.InnerBlank)
+            aaChartModel.markerSymbolStyle(AAChartSymbolStyleType.InnerBlank)
         } else if (chartType == AAChartType.Line.value
             || chartType == AAChartType.Spline.value) {
-            aaChartModel.symbolStyle(AAChartSymbolStyleType.BorderBlank)
+            aaChartModel.markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)
         }
 
 
@@ -193,11 +192,11 @@ class CommonChartActivity : AppCompatActivity(), RadioGroup.OnCheckedChangeListe
             }
         } else {
             when (group.checkedRadioButtonId) {
-                R.id.symbol1 -> aaChartModel!!.symbol(AAChartSymbolType.Circle)
-                R.id.symbol2 -> aaChartModel!!.symbol(AAChartSymbolType.Diamond)
-                R.id.symbol3 -> aaChartModel!!.symbol(AAChartSymbolType.Square)
-                R.id.symbol4 -> aaChartModel!!.symbol(AAChartSymbolType.Triangle)
-                R.id.symbol5 -> aaChartModel!!.symbol(AAChartSymbolType.TriangleDown)
+                R.id.symbol1 -> aaChartModel!!.markerSymbol(AAChartSymbolType.Circle)
+                R.id.symbol2 -> aaChartModel!!.markerSymbol(AAChartSymbolType.Diamond)
+                R.id.symbol3 -> aaChartModel!!.markerSymbol(AAChartSymbolType.Square)
+                R.id.symbol4 -> aaChartModel!!.markerSymbol(AAChartSymbolType.Triangle)
+                R.id.symbol5 -> aaChartModel!!.markerSymbol(AAChartSymbolType.TriangleDown)
             }
         }
 

+ 12 - 16
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/ChartOptionsComposer.kt

@@ -37,16 +37,15 @@ package com.aachartmodel.aainfographics.ChartsDemo.ChartComposer
 
 import com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel.*
 import com.example.chartcorekotlin.AAChartConfiger.*
-import java.util.HashMap
 
 class ChartOptionsComposer {
     companion object {
 
-     fun configureAAPlotBandsForChart(): HashMap<String, Any?> {
+     fun configureAAPlotBandsForChart(): AAOptions {
         val aaChartModel = AAChartModel()
             .chartType(AAChartType.Spline)//图形类型
             .dataLabelsEnabled(false)
-            .markerRadius(0)
+            .markerRadius(0f)
             .series(arrayOf(
                     AASeriesElement()
                         .name("Tokyo")
@@ -84,12 +83,11 @@ class ChartOptionsComposer {
                 .color("#acf08f")
         )
 
-        val aaYAxis = aaOptions["yAxis"] as HashMap<String, Any>
-        aaYAxis["plotBands"] = aaPlotBandsElementArr
+         aaOptions.yAxis?.plotBands(aaPlotBandsElementArr)
         return aaOptions
     }
 
-     fun configureAAPlotLinesForChart(): HashMap<String, Any?> {
+     fun configureAAPlotLinesForChart(): AAOptions {
         val zonesArr = arrayOf(
             mapOf(
                 "value" to 12,
@@ -161,18 +159,17 @@ class ChartOptionsComposer {
                         )
                 )
         )
+         aaOptions.yAxis?.plotLines(aaPlotLinesElementsArr)
 
-        val aaYAxis = aaOptions["yAxis"] as HashMap<String, Any>?
-        aaYAxis!!["plotLines"] = aaPlotLinesElementsArr
-        return aaOptions
+         return aaOptions
     }
 
-     fun customAATooltipWithJSFuntion():HashMap<*, *> {
+     fun customAATooltipWithJSFuntion(): AAOptions {
         val aaChartModel = AAChartModel()
             .chartType(AAChartType.Area)//图形类型
             .title("近三个月金价起伏周期图")//图表主标题
             .subtitle("金价(元/克)")//图表副标题
-            .symbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
+            .markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
             .dataLabelsEnabled(false)
             .categories(arrayOf(
                 "10-01", "10-02", "10-03", "10-04", "10-05", "10-06", "10-07", "10-08", "10-09", "10-10",
@@ -216,14 +213,14 @@ function () {
             .borderColor("#000000")
             .style(AAStyle()
                 .color("#FFD700")
-                .fontSize("12 px")
+                .fontSize(12f)
             )
         val aaOptions = AAOptionsConstructor.configureChartOptions(aaChartModel)
-        aaOptions["tooltip"] = aaTooltip
+        aaOptions.tooltip = aaTooltip
         return aaOptions
     }
 
-     fun customXAxisCrosshairStyle(): HashMap<*, *> {
+     fun customXAxisCrosshairStyle(): AAOptions {
         val aaChartModel = AAChartModel()
             .chartType(AAChartType.Line)//图表类型
             .series(arrayOf(
@@ -272,8 +269,7 @@ function () {
             .color(AAColor.redColor())
             .width(1f)
             .dashStyle(AAChartLineDashSyleType.LongDashDotDot)
-        val aaXAxis = aaOptions["xAxis"] as HashMap<String, Any>
-        aaXAxis["crosshair"] = aaCrosshair
+         aaOptions.xAxis?.crosshair(aaCrosshair)
         return aaOptions
     }
 

+ 10 - 10
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/CustomStyleChartComposer.kt

@@ -224,9 +224,9 @@ class CustomStyleChartComposer  {
             .subtitle("")
             .categories(arrayOf("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"))
             .yAxisTitle("")
-            .markerRadius(0)
+            .markerRadius(0f)
             .yAxisLineWidth(0f)
-            .yAxisGridLineWidth(0)
+            .yAxisGridLineWidth(0f)
             .legendEnabled(false)
             .series(arrayOf(
                 AASeriesElement()
@@ -262,9 +262,9 @@ class CustomStyleChartComposer  {
             .subtitle("")
             .categories(arrayOf("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"))
             .yAxisTitle("")
-            .markerRadius(0)
+            .markerRadius(0f)
             .yAxisLineWidth(0f)
-            .yAxisGridLineWidth(0)
+            .yAxisGridLineWidth(0f)
             .legendEnabled(false)
             .series(arrayOf(
                     AASeriesElement()
@@ -296,9 +296,9 @@ class CustomStyleChartComposer  {
             .subtitle("")
             .categories(arrayOf("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"))
             .yAxisTitle("")
-            .markerRadius(0)
+            .markerRadius(0f)
             .yAxisLineWidth(0f)
-            .yAxisGridLineWidth(0)
+            .yAxisGridLineWidth(0f)
             .legendEnabled(false)
             .series(arrayOf(
                     AASeriesElement()
@@ -328,11 +328,11 @@ class CustomStyleChartComposer  {
             .subtitle("")
             .categories(arrayOf("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"))
             .yAxisTitle("")
-            .markerRadius(8)//marker点半径为8个像素
-            .symbolStyle(AAChartSymbolStyleType.InnerBlank)//marker点为空心效果
-            .symbol(AAChartSymbolType.Circle)//marker点为圆形点○
+            .markerRadius(8f)//marker点半径为8个像素
+            .markerSymbolStyle(AAChartSymbolStyleType.InnerBlank)//marker点为空心效果
+            .markerSymbol(AAChartSymbolType.Circle)//marker点为圆形点○
             .yAxisLineWidth(0f)
-            .yAxisGridLineWidth(0)
+            .yAxisGridLineWidth(0f)
             .legendEnabled(false)
             .series(arrayOf(
                     AASeriesElement()

+ 18 - 18
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/CustomTooltipComposer.kt

@@ -35,19 +35,19 @@
  */
 package com.aachartmodel.aainfographics.ChartsDemo.ChartComposer
 
+import com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel.AAOptions
 import com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel.AAStyle
 import com.aachartmodel.aainfographics.AAInfographicsLib.AAOptionsModel.AATooltip
 import com.example.chartcorekotlin.AAChartConfiger.*
-import java.util.HashMap
 
 class CustomTooltipComposer {
     companion object {
-     fun customAreaChartTooltipStyleWithFormatterFunction1(): HashMap<*, *> {
+     fun customAreaChartTooltipStyleWithFormatterFunction1(): AAOptions {
         val aaChartModel = AAChartModel()
             .chartType(AAChartType.Area)//图形类型
             .title("近三个月金价起伏周期图")//图表主标题
             .subtitle("金价(元/克)")//图表副标题
-            .symbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
+            .markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
             .dataLabelsEnabled(false)
             .categories(arrayOf(
                 "10-01", "10-02", "10-03", "10-04", "10-05", "10-06", "10-07", "10-08", "10-09", "10-10", "10-11",
@@ -96,19 +96,19 @@ function () {
             .style(
                 AAStyle()
                     .color("#FFD700")
-                    .fontSize("12 px")
+                    .fontSize(12f)
             )
         val aaOptions = AAOptionsConstructor.configureChartOptions(aaChartModel)
-        aaOptions["tooltip"] = aaTooltip
+         aaOptions.tooltip(aaTooltip)
         return aaOptions
     }
 
-     fun customAreaChartTooltipStyleWithFormatterFunction2():HashMap<*, *> {
+     fun customAreaChartTooltipStyleWithFormatterFunction2(): AAOptions {
         val aaChartModel = AAChartModel()
             .chartType(AAChartType.Area)//图形类型
             .title("2014 ~ 2020 汪星人生存指数")//图表主标题
             .subtitle("数据来源:www.无任何可靠依据.com")//图表副标题
-            .symbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
+            .markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
             .dataLabelsEnabled(false)
             .colorsTheme(arrayOf<Any>("#ff0000", "#0000ff"))
             .stacking(AAChartStackingType.Normal)
@@ -143,16 +143,16 @@ function () {
              """.trimIndent()
             )
         val aaOptions = AAOptionsConstructor.configureChartOptions(aaChartModel)
-        aaOptions["tooltip"] = aaTooltip
+         aaOptions.tooltip = aaTooltip
         return aaOptions
     }
 
-     fun customAreaChartTooltipStyleWithFormatterFunction3():HashMap<*, *> {
+     fun customAreaChartTooltipStyleWithFormatterFunction3(): AAOptions {
         val aaChartModel = AAChartModel()
             .chartType(AAChartType.Area)//图形类型
             .title("2014 ~ 2020 汪星人生存指数")//图表主标题
             .subtitle("数据来源:www.无任何可靠依据.com")//图表副标题
-            .symbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
+            .markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
             .dataLabelsEnabled(false)
             .categories(arrayOf("临床一期", "临床二期", "临床三期"))
             .series(arrayOf(
@@ -193,20 +193,20 @@ function () {
                 """.trimIndent()
             )
         val aaOptions = AAOptionsConstructor.configureChartOptions(aaChartModel)
-        aaOptions["tooltip"] = aaTooltip
+         aaOptions.tooltip = aaTooltip
         return aaOptions
     }
 
-     fun customAreaChartTooltipStyleWithFormatterFunction4():HashMap<*, *> {
+     fun customAreaChartTooltipStyleWithFormatterFunction4(): AAOptions {
         val aaChartModel = AAChartModel()
             .chartType(AAChartType.Areaspline)//图形类型
             .title("")//图表主标题
             .subtitle("")//图表副标题
-            .symbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
+            .markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
             .dataLabelsEnabled(false)
             .colorsTheme(arrayOf<Any>("#04d69f", "#1e90ff", "#ef476f", "#ffd066"))
             .stacking(AAChartStackingType.Normal)
-            .markerRadius(0)
+            .markerRadius(0f)
             .series(arrayOf(
                 AASeriesElement()
                     .name("Tokyo Hot")
@@ -257,11 +257,11 @@ function () {
             .backgroundColor("#050505")
             .borderColor("#050505")
         val aaOptions = AAOptionsConstructor.configureChartOptions(aaChartModel)
-        aaOptions["tooltip"] = aaTooltip
+         aaOptions.tooltip = aaTooltip
         return aaOptions
     }
 
-     fun customBoxplotTooltipContent(): HashMap<*, *> {
+     fun customBoxplotTooltipContent(): AAOptions {
         val aaChartModel = AAChartModel()
             .chartType(AAChartType.Boxplot)
             .title("BOXPLOT CHART")
@@ -301,10 +301,10 @@ function () {
             .borderColor("#000000")
             .style(AAStyle()
                     .color("#1e90ff")
-                    .fontSize("12 px")
+                    .fontSize(12f)
             )
         val aaOptions = AAOptionsConstructor.configureChartOptions(aaChartModel)
-        aaOptions["tooltip"] = aaTooltip
+         aaOptions.tooltip = aaTooltip
         return aaOptions
     }
     }

+ 5 - 5
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/MixedChartComposer.kt

@@ -127,7 +127,7 @@ companion object {
             .subtitle("")//图形副标题
             .chartType(AAChartType.Line)
             .dataLabelsEnabled(false)
-            .symbolStyle(AAChartSymbolStyleType.BorderBlank)
+            .markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)
             .series(arrayOf(
                 AASeriesElement()
                     .name("Temperature")
@@ -196,7 +196,7 @@ companion object {
             .chartType(AAChartType.Spline)//图形类型
             .dataLabelsEnabled(false)//是否显示数字
             .stacking(AAChartStackingType.Normal)
-            .markerRadius(0)
+            .markerRadius(0f)
             .series(arrayOf(
                 AASeriesElement()
                     .name("SolidLine")
@@ -250,9 +250,9 @@ companion object {
         return AAChartModel()
             .dataLabelsEnabled(false)//是否显示数字
             .chartType(AAChartType.Scatter)
-            .symbolStyle(AAChartSymbolStyleType.InnerBlank)
-            .symbol(AAChartSymbolType.Circle)
-            .markerRadius(8)
+            .markerSymbolStyle(AAChartSymbolStyleType.InnerBlank)
+            .markerSymbol(AAChartSymbolType.Circle)
+            .markerRadius(8f)
             .series(arrayOf(
                 AASeriesElement()
                     .name("Scatter")

+ 6 - 6
app/src/main/java/com/aachartmodel/aainfographics/ChartsDemo/ChartComposer/SpecialChartComposer.kt

@@ -268,8 +268,8 @@ object SpecialChartComposer{
             .chartType(AAChartType.Scatter)
             .title("Height and weight distribution by sex")
             .yAxisTitle("kg")
-            .markerRadius(8)
-            .symbolStyle(AAChartSymbolStyleType.InnerBlank)
+            .markerRadius(8f)
+            .markerSymbolStyle(AAChartSymbolStyleType.InnerBlank)
             .series(seriesElements)
     }
 
@@ -768,8 +768,8 @@ object SpecialChartComposer{
             .title("STEP LINE CHART")//图形标题
             .subtitle("2020/08/08")//图形副标题
             .dataLabelsEnabled(false)//是否显示数字
-            .symbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式
-            .markerRadius(7)//折线连接点半径长度,为0时相当于没有折线连接点
+            .markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式
+            .markerRadius(7f)//折线连接点半径长度,为0时相当于没有折线连接点
             .series(arrayOf(
                 AASeriesElement()
                     .name("Berlin")
@@ -794,8 +794,8 @@ object SpecialChartComposer{
             .title("STEP AREA CHART")//图形标题
             .subtitle("2049/08/08")//图形副标题
             .dataLabelsEnabled(false)//是否显示数字
-            .symbolStyle(AAChartSymbolStyleType.InnerBlank)//折线连接点样式
-            .markerRadius(0)//折线连接点半径长度,为0时相当于没有折线连接点
+            .markerSymbolStyle(AAChartSymbolStyleType.InnerBlank)//折线连接点样式
+            .markerRadius(0f)//折线连接点半径长度,为0时相当于没有折线连接点
             .series(arrayOf(
                 AASeriesElement()
                     .name("Berlin")