An An пре 10 месеци
родитељ
комит
f2d99fd15f

+ 2 - 1
charts/src/main/java/com/github/aachartmodel/aainfographics/aaoptionsmodel/AAAxis.kt

@@ -47,7 +47,8 @@ enum class AAChartAxisType(val value: String) {
     var offset: Number? = null //坐标轴垂直偏移
     var labels: AALabels? = null //用于设置坐标轴文字相关的
     var visible: Boolean? = null //用于设置坐标轴以及坐标轴文字是否显示
-    var startOnTick: Boolean? = null //Whether to force the axis to start on a tick. Use this option with the minPadding option to control the axis start. 默认是:false.
+    var startOnTick: Boolean? = null //Whether to force the axis to start on a tick. Use this option with the maxPadding option to control the axis start.This option is always disabled, when panning type is either y or xy. Defaults to true.
+    var endOnTick: Boolean? = null //Whether to force the axis to end on a tick. Use this option with the maxPadding option to control the axis end. This option is always disabled, when panning type is either y or xy. Defaults to true.
     var tickColor: String? = null //坐标轴轴线下方刻度线颜色
     var tickInterval: Number? = null //坐标轴刻度点间隔数(设置每隔几个点显示一个 坐标轴的内容:
     var tickmarkPlacement: String? = null //本参数只对分类轴有效。 当值为 on 时刻度线将在分类上方显示;当值为 between 时,刻度线将在两个分类中间显示。当 tickInterval 为 1 时,默认是 between,其他情况默认是 on。 默认是:null.

+ 5 - 0
charts/src/main/java/com/github/aachartmodel/aainfographics/aaoptionsmodel/AAXAxis.kt

@@ -185,6 +185,11 @@ open class AAXAxis: AAAxis() {
         return this
     }
 
+    fun endOnTick(prop: Boolean?): AAXAxis {
+        endOnTick = prop
+        return this
+    }
+
     fun opposite(prop: Boolean?): AAXAxis {
         opposite = prop
         return this

+ 5 - 0
charts/src/main/java/com/github/aachartmodel/aainfographics/aaoptionsmodel/AAYAxis.kt

@@ -191,6 +191,11 @@ open class AAYAxis: AAAxis() {
         return this
     }
 
+    fun endOnTick(prop: Boolean?): AAYAxis {
+        endOnTick = prop
+        return this
+    }
+
     fun opposite(prop: Boolean?): AAYAxis {
         opposite = prop
         return this

+ 45 - 0
sample/src/main/java/com/github/aachartmodel/aainfographics/demo/chartcomposer/ChartOptionsComposer.kt

@@ -1274,4 +1274,49 @@ function () {
         return aaOptions
     }
 
+    //https://github.com/AAChartModel/AAChartCore-Kotlin/issues/205
+    fun forceMaxAndMinValue() : AAOptions {
+        val aaChartModel = AAChartModel()
+            .chartType(AAChartType.Column)
+            .dataLabelsEnabled(false)
+            .borderRadius(4F)
+            .legendEnabled(false)
+            .touchEventEnabled(true)
+            .series(arrayOf(
+                AASeriesElement()
+                    .name("")
+                    .data(arrayOf(149.9, 154, 106.4, 129.2, 144.0, 154, 135.6, 154, 154, 154, 95.6, 54.4)) //里面最大值是154
+                    .color(AAGradientColor.linearGradient("rgba(242,82,70,0.2)","rgba(242,82,70,1.0)"))   //柱状图渐变色
+                    .borderWidth(2F)
+                    .dataLabels(AADataLabels()
+                        .enabled(true)
+                        .verticalAlign(AAChartVerticalAlignType.Middle)
+                        .x(0)
+                        .y(-10)
+                        .style(AAStyle.style("#333333",12,AAChartFontWeightType.Thin)))  //柱状图上面表示大小的文字
+            ))
+            .yAxisTitle("")
+            .yAxisMax(210 as Number)
+
+        val aaOptions = aaChartModel.aa_toAAOptions()
+
+        val aaLabels = AALabels()
+            .autoRotation(false)
+            .style(AAStyle().fontSize(12).color("#999999"))  //坐标轴上文字颜色
+
+        aaOptions.xAxis?.apply {
+            labels(aaLabels)
+                .lineColor("#EEEEEE")
+                .lineWidth(0.5)
+        }
+        aaOptions.yAxis?.apply {
+            minorGridLineColor("#EEEEEE")
+                .minorGridLineWidth(0.5)
+                .labels(aaLabels)
+                .startOnTick(false)
+                .endOnTick(false)
+        }
+        return aaOptions
+    }
+
 }