Skip to content

Commit e40b2a2

Browse files
committed
Fix #260 => Add colorful marker zones chart demo
Introduces a new chart example 'colorfulMarkerWithZonesChart' to demonstrate high-saturation wave charts with solid and hollow markers. Refactors zone and series element construction for improved readability and locale-aware formatting in CustomStyleChartComposer2.
1 parent 1e13d6a commit e40b2a2

File tree

2 files changed

+48
-53
lines changed

2 files changed

+48
-53
lines changed

sample/src/main/java/com/github/aachartmodel/aainfographics/demo/basiccontent/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class MainActivity : AppCompatActivity() {
110110
"connectNullsForSingleAASeriesElement---为单个 AASeriesElement 单独设置是否断点重连",
111111
"lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement---不同数据列数据量差异较大的折线图",
112112
"customAreasplineChartWithColorfulGradientColorZones---彩色渐变填充区域曲线图",
113+
114+
"colorfulMarkerWithZonesChart---高饱和度波浪图 — 实心与空心 Marker 对比"
113115
), arrayOf(
114116
"customLegendStyle",
115117
"drawChartWithOptionsOne",

sample/src/main/java/com/github/aachartmodel/aainfographics/demo/chartcomposer/CustomStyleChartComposer2.kt

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,66 +19,59 @@ object CustomStyleChartComposer2 {
1919
for (i in 0 until count) {
2020
val y = amplitude * sin((i * step) + phase) + 120
2121
val noisyY = y + (Math.random() - 0.5) * noise
22-
data.add(String.format("%.2f", noisyY).toDouble())
22+
data.add(String.format(java.util.Locale.getDefault(), "%.2f", noisyY).toDouble())
2323
}
2424
return data.toTypedArray()
2525
}
2626

2727
// 色系分区
2828
val zones = arrayOf(
29-
AAZonesElement().apply {
30-
value(80.0)
31-
color("#25547c")
32-
},
33-
AAZonesElement().apply {
34-
value(110.0)
35-
color("#1e90ff")
36-
},
37-
AAZonesElement().apply {
38-
value(140.0)
39-
color("#ffd066")
40-
},
41-
AAZonesElement().apply {
42-
value(170.0)
43-
color("#04d69f")
44-
},
45-
AAZonesElement().apply {
46-
color("#ef476f")
47-
}
29+
AAZonesElement()
30+
.value(80.0)
31+
.color("#25547c"),
32+
AAZonesElement()
33+
.value(110.0)
34+
.color("#1e90ff"),
35+
AAZonesElement()
36+
.value(140.0)
37+
.color("#ffd066"),
38+
AAZonesElement()
39+
.value(170.0)
40+
.color("#04d69f"),
41+
AAZonesElement()
42+
.color("#ef476f")
4843
)
4944

50-
return AAChartModel().apply {
51-
chartType(AAChartType.Scatter)
52-
title("⚡️高饱和度波浪图 — 实心与空心 Marker 对比")
53-
legendEnabled(true)
54-
tooltipEnabled(true)
55-
series(arrayOf(
56-
AASeriesElement().apply {
57-
name("实心数据")
58-
data(generateWaveData(85.0, 0.0, 0.25, 60, 4.0))
59-
zones(zones)
60-
zoneAxis("y")
61-
marker(AAMarker().apply {
62-
symbol(AAChartSymbolType.Circle.value)
63-
radius(6)
64-
lineWidth(1)
65-
})
66-
},
67-
AASeriesElement().apply {
68-
name("空心数据")
69-
data(generateWaveData(85.0, Math.PI / 2, 0.25, 60, 4.0))
70-
zones(zones)
71-
zoneAxis("y")
72-
marker(AAMarker().apply {
73-
symbol(AAChartSymbolType.Diamond.value)
74-
fillColor("transparent")
75-
lineColor(AANull())
76-
radius(7)
77-
lineWidth(2)
78-
})
79-
dashStyle(AAChartLineDashStyleType.DashDot)
80-
}
81-
))
82-
}
45+
return AAChartModel()
46+
.chartType(AAChartType.Scatter)
47+
.title("⚡️高饱和度波浪图 — 实心与空心 Marker 对比")
48+
.legendEnabled(true)
49+
.tooltipEnabled(true)
50+
.series(arrayOf(
51+
AASeriesElement()
52+
.name("实心数据")
53+
.data(generateWaveData(85.0, 0.0, 0.25, 60, 4.0))
54+
.zones(zones)
55+
.zoneAxis("y")
56+
.marker(AAMarker()
57+
.symbol(AAChartSymbolType.Circle.value)
58+
.radius(6)
59+
.lineWidth(1)
60+
),
61+
AASeriesElement()
62+
.name("空心数据")
63+
.data(generateWaveData(85.0, Math.PI / 2, 0.25, 60, 4.0))
64+
.zones(zones)
65+
.zoneAxis("y")
66+
.marker(AAMarker()
67+
.symbol(AAChartSymbolType.Diamond.value)
68+
.fillColor("transparent")
69+
.lineColor(AANull())
70+
.radius(7)
71+
.lineWidth(2)
72+
)
73+
.dashStyle(AAChartLineDashStyleType.DashDot)
74+
)
75+
)
8376
}
8477
}

0 commit comments

Comments
 (0)