Browse Source

Add more useful samples for CustomStyleChartComposer

An An 3 years ago
parent
commit
53aaec778b

+ 2 - 0
sample/src/main/java/com/github/aachartmodel/aainfographics/demo/basiccontent/CustomStyleChartActivity.kt

@@ -104,6 +104,8 @@ class CustomStyleChartActivity : AppCompatActivity() {
              "configureColorfulDataLabelsStepLineChart"-> return CustomStyleChartComposer.configureColorfulDataLabelsStepLineChart()
              "configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart"-> return CustomStyleChartComposer.configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart()
              "disableSplineChartMarkerHoverEffect"-> return CustomStyleChartComposer.disableSplineChartMarkerHoverEffect()
+             "configureMaxAndMinDataLabelsForChart"-> return CustomStyleChartComposer.configureMaxAndMinDataLabelsForChart()
+             "customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag"-> return CustomStyleChartComposer.customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag()
         }
         return CustomStyleChartComposer.configureColorfulChart()
     }

+ 4 - 2
sample/src/main/java/com/github/aachartmodel/aainfographics/demo/basiccontent/MainActivity.kt

@@ -76,7 +76,8 @@ class MainActivity : AppCompatActivity() {
                 "configureColorfulDataLabelsStepLineChart---彩色 DataLabels 的直方折线图",
                 "configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart---彩色渐变效果且彩色 DataLabels 的直方折线填充图",
                 "disableSplineChartMarkerHoverEffect---禁用曲线图的手指滑动 marker 点的光圈变化放大的效果",
-                "Top Rounded Corners Stacking Column Chart---顶部为圆角的堆积柱状图"
+                "configureMaxAndMinDataLabelsForChart---为图表最大值最小值添加 DataLabels 标记",
+                "customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag---通过 HTML 的换行标签来实现图表的 X 轴的 分类文字标签的换行效果",
             ), arrayOf(
                 "customLegendStyle",
                 "drawChartWithOptionsOne",
@@ -203,7 +204,8 @@ class MainActivity : AppCompatActivity() {
                 "configureColorfulDataLabelsStepLineChart",
                 "configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart",
                 "disableSplineChartMarkerHoverEffect",
-                "topRoundedCornersStackingColumnChart"
+                "configureMaxAndMinDataLabelsForChart",
+                "customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag",
             ), arrayOf( /*使用AAOptions绘制图表*/
                 "customLegendStyle",
                 "AAPlotBandsForChart",

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

@@ -1088,4 +1088,78 @@ object CustomStyleChartComposer  {
             ))
     }
 
+
+    //https://github.com/AAChartModel/AAChartKit/issues/1203
+    fun configureMaxAndMinDataLabelsForChart(): AAChartModel {
+        val aaDataLabels = AADataLabels()
+            .enabled(true)
+            .format("{y} 美元")
+            .shape("callout")
+            .style(AAStyle.style(AAColor.Red, 15f, AAChartFontWeightType.Bold))
+            .backgroundColor(AAColor.White) // white color
+            .borderColor(AAColor.Red) // red color
+            .borderRadius(1.5f)
+            .borderWidth(1.3f)
+
+        val minData = AADataElement()
+            .dataLabels(aaDataLabels)
+            .y(2.5f)
+
+        val maxData = AADataElement()
+            .dataLabels(aaDataLabels)
+            .y(49.5f)
+
+        return AAChartModel()
+            .chartType(AAChartType.Spline)
+            .dataLabelsEnabled(false) //是否显示值
+            .tooltipEnabled(false)
+            .markerRadius(0f)
+            .xAxisVisible(false)
+            .yAxisVisible(false)
+            .series(arrayOf(
+                AASeriesElement()
+                    .name("Show The Max and Min values Data Labels")
+                    .lineWidth(7f)
+                    .data(arrayOf(7.0, 6.9, minData, 14.5, 18.2, maxData, 5.2, 26.5, 23.3, 26.5, 13.9, 9.6))
+                    .color(AAGradientColor.OceanBlue)
+            ))
+    }
+
+    //https://github.com/AAChartModel/AAChartKit/issues/1201
+    fun customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag(): AAChartModel {
+        return AAChartModel()
+            .chartType(AAChartType.Area)
+            .categories(arrayOf(
+                "孤<br>岛<br>危<br>机",
+                "使<br>命<br>召<br>唤",
+                "荣<br>誉<br>勋<br>章",
+                "狙<br>击<br>精<br>英",
+                "神<br>秘<br>海<br>域",
+                "最<br>后<br>生<br>还<br>者",
+                "巫<br>师<br>3<br>狂<br>猎",
+                "对<br>马<br>之<br>魂",
+                "蝙<br>蝠<br>侠<br>阿<br>甘<br>骑<br>士<br>",
+                "地<br>狱<br>边<br>境",
+                "闪<br>客",
+                "忍<br>者<br>之<br>印"
+            ))
+            .tooltipEnabled(false)
+            .borderRadius(3f)
+            .markerSymbolStyle(AAChartSymbolStyleType.InnerBlank)
+            .series(arrayOf(
+                AASeriesElement()
+                    .name("Tokyo")
+                    .data(arrayOf(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6)),
+                AASeriesElement()
+                    .name("NewYork")
+                    .data(arrayOf(0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5)),
+                AASeriesElement()
+                    .name("London")
+                    .data(arrayOf(0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0)),
+                AASeriesElement()
+                    .name("Berlin")
+                    .data(arrayOf(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8))
+            ))
+    }
+
 }