From 04f28d2f95d2d166f1932c46619fd2573502372c Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Thu, 25 Sep 2025 23:37:36 +0800
Subject: [PATCH 01/35] Add before/after draw JavaScript hooks to AAOptions
Introduces beforeDrawChartJavaScript and afterDrawChartJavaScript properties to AAOptions, allowing custom JavaScript execution before and after chart rendering. Updates AAChartView and AAChartView.js to handle these hooks, enabling advanced chart customization.
---
aa_chart_core/src/main/assets/AAChartView.js | 21 +++++++++++++++++++
.../AAChartCreator/AAChartView.java | 21 ++++++++++++++++++-
.../AAChartCore/AAOptionsModel/AAOptions.java | 12 +++++++++++
3 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/aa_chart_core/src/main/assets/AAChartView.js b/aa_chart_core/src/main/assets/AAChartView.js
index d8c39e9..c30a166 100644
--- a/aa_chart_core/src/main/assets/AAChartView.js
+++ b/aa_chart_core/src/main/assets/AAChartView.js
@@ -10,6 +10,12 @@ function loadTheHighChartView (sender,receivedWidth, receivedHeight) {
return value;
});
+ var beforeDrawScript = aaOptions.beforeDrawChartJavaScript;
+ var afterDrawScript = aaOptions.afterDrawChartJavaScript;
+
+ delete aaOptions.beforeDrawChartJavaScript;
+ delete aaOptions.afterDrawChartJavaScript;
+
if (aaOptions.xAxisArray) {
aaOptions.xAxis = aaOptions.xAxisArray
}
@@ -24,12 +30,27 @@ function loadTheHighChartView (sender,receivedWidth, receivedHeight) {
});
}
+ if (beforeDrawScript && beforeDrawScript.length > 0) {
+ try {
+ eval(beforeDrawScript);
+ } catch (error) {
+ console.error('Error executing beforeDrawChartJavaScript:', error);
+ }
+ }
+
if (aaOptions.plotOptions) {
configurePlotOptions(aaOptions);
}
aaGlobalChart = Highcharts.chart('container', aaOptions);
//全局配置(可通过全局配置设置主题)https://api.hcharts.cn/highcharts#Highcharts.setOptions
+ if (afterDrawScript && afterDrawScript.length > 0) {
+ try {
+ eval(afterDrawScript);
+ } catch (error) {
+ console.error('Error executing afterDrawChartJavaScript:', error);
+ }
+ }
};
function configurePlotOptions(aaOptions) {
diff --git a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAChartView.java b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAChartView.java
index e031176..3a20b0d 100644
--- a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAChartView.java
+++ b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAChartView.java
@@ -391,7 +391,26 @@ private void configureChartOptionsAndDrawChart(AAOptions aaOptions) {
}
Gson gson = new Gson();
- String aaOptionsJsonStr = gson.toJson(aaOptions);
+ String aaOptionsJsonStr;
+
+ String originalBeforeDrawScript = aaOptions.beforeDrawChartJavaScript;
+ String originalAfterDrawScript = aaOptions.afterDrawChartJavaScript;
+
+ try {
+ if (originalBeforeDrawScript != null) {
+ aaOptions.beforeDrawChartJavaScript = AAJSStringPurer.pureJavaScriptFunctionString(originalBeforeDrawScript);
+ }
+
+ if (originalAfterDrawScript != null) {
+ aaOptions.afterDrawChartJavaScript = AAJSStringPurer.pureJavaScriptFunctionString(originalAfterDrawScript);
+ }
+
+ aaOptionsJsonStr = gson.toJson(aaOptions);
+ } finally {
+ aaOptions.beforeDrawChartJavaScript = originalBeforeDrawScript;
+ aaOptions.afterDrawChartJavaScript = originalAfterDrawScript;
+ }
+
this.optionsJson = aaOptionsJsonStr;
String javaScriptStr = "loadTheHighChartView('"
+ aaOptionsJsonStr + "','"
diff --git a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAOptions.java b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAOptions.java
index a8e99b5..9eacff4 100644
--- a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAOptions.java
+++ b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAOptions.java
@@ -18,6 +18,8 @@ public class AAOptions {
public AALang defaultOptions;
public Boolean clickEventEnabled;
public Boolean touchEventEnabled;
+ public String beforeDrawChartJavaScript;
+ public String afterDrawChartJavaScript;
public AAOptions chart(AAChart prop) {
chart = prop;
@@ -104,6 +106,16 @@ public AAOptions touchEventEnabled(Boolean prop) {
return this;
}
+ public AAOptions beforeDrawChartJavaScript(String prop) {
+ beforeDrawChartJavaScript = prop;
+ return this;
+ }
+
+ public AAOptions afterDrawChartJavaScript(String prop) {
+ afterDrawChartJavaScript = prop;
+ return this;
+ }
+
public AAOptions() {
AACredits aaCredits = new AACredits();
From b11fa5321f3db90f18939f294744eb716a16b16f Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Fri, 26 Sep 2025 00:02:05 +0800
Subject: [PATCH 02/35] Enhance JS callback handling for chart rendering
Improved beforeDrawScript and afterDrawScript handling in AAChartView.js to support both function and string types. Updated AAChartView.java to use pureAnonymousJSFunctionString for JS callbacks. Added a demo for verifying before/after draw JS callbacks in JSFunctionForAAOptionsComposer and updated the corresponding activity to use it.
---
aa_chart_core/src/main/assets/AAChartView.js | 16 ++++++--
.../AAChartCreator/AAChartView.java | 4 +-
.../JSFunctionForAAOptionsActivity.java | 2 +-
.../JSFunctionForAAOptionsComposer.java | 38 +++++++++++++++++++
4 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/aa_chart_core/src/main/assets/AAChartView.js b/aa_chart_core/src/main/assets/AAChartView.js
index c30a166..bfad45f 100644
--- a/aa_chart_core/src/main/assets/AAChartView.js
+++ b/aa_chart_core/src/main/assets/AAChartView.js
@@ -30,9 +30,13 @@ function loadTheHighChartView (sender,receivedWidth, receivedHeight) {
});
}
- if (beforeDrawScript && beforeDrawScript.length > 0) {
+ if (beforeDrawScript) {
try {
- eval(beforeDrawScript);
+ if (typeof beforeDrawScript === 'function') {
+ beforeDrawScript.call(window);
+ } else if (typeof beforeDrawScript === 'string' && beforeDrawScript.length > 0) {
+ eval(beforeDrawScript);
+ }
} catch (error) {
console.error('Error executing beforeDrawChartJavaScript:', error);
}
@@ -44,9 +48,13 @@ function loadTheHighChartView (sender,receivedWidth, receivedHeight) {
aaGlobalChart = Highcharts.chart('container', aaOptions);
//全局配置(可通过全局配置设置主题)https://api.hcharts.cn/highcharts#Highcharts.setOptions
- if (afterDrawScript && afterDrawScript.length > 0) {
+ if (afterDrawScript) {
try {
- eval(afterDrawScript);
+ if (typeof afterDrawScript === 'function') {
+ afterDrawScript.call(aaGlobalChart, aaGlobalChart);
+ } else if (typeof afterDrawScript === 'string' && afterDrawScript.length > 0) {
+ eval(afterDrawScript);
+ }
} catch (error) {
console.error('Error executing afterDrawChartJavaScript:', error);
}
diff --git a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAChartView.java b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAChartView.java
index 3a20b0d..147fc3e 100644
--- a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAChartView.java
+++ b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAChartView.java
@@ -398,11 +398,11 @@ private void configureChartOptionsAndDrawChart(AAOptions aaOptions) {
try {
if (originalBeforeDrawScript != null) {
- aaOptions.beforeDrawChartJavaScript = AAJSStringPurer.pureJavaScriptFunctionString(originalBeforeDrawScript);
+ aaOptions.beforeDrawChartJavaScript = AAJSStringPurer.pureAnonymousJSFunctionString(originalBeforeDrawScript);
}
if (originalAfterDrawScript != null) {
- aaOptions.afterDrawChartJavaScript = AAJSStringPurer.pureJavaScriptFunctionString(originalAfterDrawScript);
+ aaOptions.afterDrawChartJavaScript = AAJSStringPurer.pureAnonymousJSFunctionString(originalAfterDrawScript);
}
aaOptionsJsonStr = gson.toJson(aaOptions);
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/AdditionalContent/JSFunctionForAAOptionsActivity.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/AdditionalContent/JSFunctionForAAOptionsActivity.java
index 5f9d4d1..f527959 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/AdditionalContent/JSFunctionForAAOptionsActivity.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/AdditionalContent/JSFunctionForAAOptionsActivity.java
@@ -31,7 +31,7 @@ AAOptions chartConfigurationWithSelectedIndex(String chartType) {
case "customDoubleXAxesChart": return customDoubleXAxesChart();//自定义双 X 轴图表
case "disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction": return disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction();//禁用柱状图图表的选中状态
case "customizeEveryDataLabelSinglelyByDataLabelsFormatter": return customizeEveryDataLabelSinglelyByDataLabelsFormatter();//自定义每个数据点的数据标签内容
- case "configureColorfulDataLabelsForPieChart": return configureColorfulDataLabelsForPieChart();//为饼图图表配置多彩的数据标签
+ case "configureColorfulDataLabelsForPieChart": return verifyBeforeAndAfterDrawJavaScriptCallbacks();//为饼图图表配置多彩的数据标签
default:
return customDoubleXAxesChart();
}
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
index 126b6b1..80392fb 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
@@ -252,6 +252,44 @@ public static AAOptions configureColorfulDataLabelsForPieChart() {
return aaOptions;
}
+ public static AAOptions verifyBeforeAndAfterDrawJavaScriptCallbacks() {
+ AAChartModel aaChartModel = new AAChartModel()
+ .chartType(AAChartType.Column)
+ .title("Before / After Draw JS Demo")
+ .subtitle("背景将由 beforeDraw 脚本修改")
+ .categories(new String[]{"一月", "二月", "三月", "四月", "五月", "六月"})
+ .series(new AASeriesElement[]{
+ new AASeriesElement()
+ .name("访客量")
+ .data(new Object[]{45, 88, 63, 72, 95, 102})
+ .color(AAGradientColor.MysticMauve)
+ });
+
+ AAOptions aaOptions = aaChartModel.aa_toAAOptions();
+
+ aaOptions
+ .beforeDrawChartJavaScript("function () {"
+ + "console.log('beforeDrawChartJavaScript fired');"
+ + "var container = document.getElementById('container');"
+ + "if (container) {"
+ + "container.style.background = 'linear-gradient(135deg, #FFEFD5 0%, #FFDAB9 100%)';"
+ + "container.setAttribute('data-before-draw', 'executed');"
+ + "}"
+ + "}")
+ .afterDrawChartJavaScript("function () {"
+ + "console.log('afterDrawChartJavaScript fired');"
+ + "if (typeof aaGlobalChart !== 'undefined' && aaGlobalChart) {"
+ + "aaGlobalChart.setTitle({ text: 'JS 回调已执行 ✅' });"
+ + "aaGlobalChart.renderer.label('afterDraw 已执行', 10, 10)"
+ + ".attr({ zIndex: 8, padding: 10 })"
+ + ".css({ color: '#FFFFFF', fontSize: '12px', backgroundColor: 'rgba(25, 118, 210, 0.75)' })"
+ + ".add();"
+ + "}"
+ + "}");
+
+ return aaOptions;
+ }
+
private static String javaScriptArrayStringWithJavaArray(Object[] javaArray) {
StringBuilder originalJsArrStr = new StringBuilder();
From e89f2c5e1e248c6a92b2f949f2065bf01f2ff6ff Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Fri, 26 Sep 2025 00:17:38 +0800
Subject: [PATCH 03/35] Enhance axis styling in chart options
Set x and y axis line width to 3 and apply a dashed stroke style to axis lines using Highcharts wrapper in beforeDrawChartJavaScript. Improves chart visual distinction and customizability.
---
.../JSFunctionForAAOptionsComposer.java | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
index 80392fb..5b7fc69 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
@@ -267,14 +267,22 @@ public static AAOptions verifyBeforeAndAfterDrawJavaScriptCallbacks() {
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
+ //设置x轴的轴线为一个粗线
+ aaOptions.xAxis.lineWidth = 3;
+ //设置y轴的轴线为一个粗线
+ aaOptions.yAxis.lineWidth = 3;
+
aaOptions
.beforeDrawChartJavaScript("function () {"
- + "console.log('beforeDrawChartJavaScript fired');"
- + "var container = document.getElementById('container');"
- + "if (container) {"
- + "container.style.background = 'linear-gradient(135deg, #FFEFD5 0%, #FFDAB9 100%)';"
- + "container.setAttribute('data-before-draw', 'executed');"
+ + "(function (H) {"
+ + "H.wrap(H.Axis.prototype, 'render', function (proceed) {"
+ + "proceed.apply(this, Array.prototype.slice.call(arguments, 1));"
+ + "var axis = this;"
+ + "if (axis.axisLine) {"
+ + "axis.axisLine.attr({'stroke-dasharray': '4,2'});"
+ "}"
+ + "});"
+ + "}(Highcharts));"
+ "}")
.afterDrawChartJavaScript("function () {"
+ "console.log('afterDrawChartJavaScript fired');"
From 8a8448e3183f0634ccc612cb1d3bd0f966089e1e Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Fri, 26 Sep 2025 00:20:35 +0800
Subject: [PATCH 04/35] Update JSFunctionForAAOptionsComposer.java
---
.../JSFunctionForAAOptionsComposer.java | 27 ++++++++++++++-----
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
index 5b7fc69..003d209 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
@@ -267,23 +267,38 @@ public static AAOptions verifyBeforeAndAfterDrawJavaScriptCallbacks() {
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
- //设置x轴的轴线为一个粗线
+ // 设置轴线样式, 方便 beforeDraw 脚本里读取颜色并应用不同虚线样式
+ String xAxisColor = "#1E90FF"; // 道奇蓝
+ String yAxisColor = "#FF7F50"; // 珊瑚橙
+
aaOptions.xAxis.lineWidth = 3;
- //设置y轴的轴线为一个粗线
+ aaOptions.xAxis.lineColor = xAxisColor;
+
aaOptions.yAxis.lineWidth = 3;
+ aaOptions.yAxis.lineColor = yAxisColor;
- aaOptions
- .beforeDrawChartJavaScript("function () {"
+ String beforeDrawScript = String.format("function () {"
+ "(function (H) {"
+ "H.wrap(H.Axis.prototype, 'render', function (proceed) {"
+ "proceed.apply(this, Array.prototype.slice.call(arguments, 1));"
+ "var axis = this;"
+ + "if (axis.horiz) {"
+ + "if (axis.axisLine) {"
+ + "axis.axisLine.attr({'stroke-dasharray': '3,2,1,2','stroke': '%s'});"
+ + "}"
+ + "} else {"
+ "if (axis.axisLine) {"
- + "axis.axisLine.attr({'stroke-dasharray': '4,2'});"
+ + "axis.axisLine.attr({'stroke-dasharray': '8,3,1,3,1,3','stroke': '%s'});"
+ + "}"
+ "}"
+ "});"
+ "}(Highcharts));"
- + "}")
+ + "}",
+ xAxisColor,
+ yAxisColor);
+
+ aaOptions
+ .beforeDrawChartJavaScript(beforeDrawScript)
.afterDrawChartJavaScript("function () {"
+ "console.log('afterDrawChartJavaScript fired');"
+ "if (typeof aaGlobalChart !== 'undefined' && aaGlobalChart) {"
From cfb460bd7b44f9cca12cd685cdc924f6817effb5 Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Fri, 26 Sep 2025 00:24:49 +0800
Subject: [PATCH 05/35] Refactor JS callback string formatting for chart
options
Improved readability and maintainability of JavaScript callback strings by using multi-line formatting and extracting the afterDraw script into a separate variable. No functional changes to chart behavior.
---
.../JSFunctionForAAOptionsComposer.java | 66 +++++++++++--------
1 file changed, 40 insertions(+), 26 deletions(-)
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
index 003d209..96f1885 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/JSFunctionForAAOptionsComposer.java
@@ -277,38 +277,52 @@ public static AAOptions verifyBeforeAndAfterDrawJavaScriptCallbacks() {
aaOptions.yAxis.lineWidth = 3;
aaOptions.yAxis.lineColor = yAxisColor;
- String beforeDrawScript = String.format("function () {"
- + "(function (H) {"
- + "H.wrap(H.Axis.prototype, 'render', function (proceed) {"
- + "proceed.apply(this, Array.prototype.slice.call(arguments, 1));"
- + "var axis = this;"
- + "if (axis.horiz) {"
- + "if (axis.axisLine) {"
- + "axis.axisLine.attr({'stroke-dasharray': '3,2,1,2','stroke': '%s'});"
- + "}"
- + "} else {"
- + "if (axis.axisLine) {"
- + "axis.axisLine.attr({'stroke-dasharray': '8,3,1,3,1,3','stroke': '%s'});"
- + "}"
- + "}"
- + "});"
- + "}(Highcharts));"
+ String beforeDrawScript = String.format(
+ "function () {\n"
+ + " (function (H) {\n"
+ + " H.wrap(H.Axis.prototype, 'render', function (proceed) {\n"
+ + " proceed.apply(this, Array.prototype.slice.call(arguments, 1));\n"
+ + " var axis = this;\n"
+ + " if (axis.horiz) {\n"
+ + " if (axis.axisLine) {\n"
+ + " axis.axisLine.attr({\n"
+ + " 'stroke-dasharray': '3,2,1,2',\n"
+ + " 'stroke': '%s'\n"
+ + " });\n"
+ + " }\n"
+ + " } else {\n"
+ + " if (axis.axisLine) {\n"
+ + " axis.axisLine.attr({\n"
+ + " 'stroke-dasharray': '8,3,1,3,1,3',\n"
+ + " 'stroke': '%s'\n"
+ + " });\n"
+ + " }\n"
+ + " }\n"
+ + " });\n"
+ + " }(Highcharts));\n"
+ "}",
xAxisColor,
yAxisColor);
+ String afterDrawScript = "function () {\n"
+ + " console.log('afterDrawChartJavaScript fired');\n"
+ + " if (typeof aaGlobalChart !== 'undefined' && aaGlobalChart) {\n"
+ + " aaGlobalChart.setTitle({ text: 'JS 回调已执行 ✅' });\n"
+ + " aaGlobalChart.renderer\n"
+ + " .label('afterDraw 已执行', 10, 10)\n"
+ + " .attr({ zIndex: 8, padding: 10 })\n"
+ + " .css({\n"
+ + " color: '#FFFFFF',\n"
+ + " fontSize: '12px',\n"
+ + " backgroundColor: 'rgba(25, 118, 210, 0.75)'\n"
+ + " })\n"
+ + " .add();\n"
+ + " }\n"
+ + "}";
+
aaOptions
.beforeDrawChartJavaScript(beforeDrawScript)
- .afterDrawChartJavaScript("function () {"
- + "console.log('afterDrawChartJavaScript fired');"
- + "if (typeof aaGlobalChart !== 'undefined' && aaGlobalChart) {"
- + "aaGlobalChart.setTitle({ text: 'JS 回调已执行 ✅' });"
- + "aaGlobalChart.renderer.label('afterDraw 已执行', 10, 10)"
- + ".attr({ zIndex: 8, padding: 10 })"
- + ".css({ color: '#FFFFFF', fontSize: '12px', backgroundColor: 'rgba(25, 118, 210, 0.75)' })"
- + ".add();"
- + "}"
- + "}");
+ .afterDrawChartJavaScript(afterDrawScript);
return aaOptions;
}
From 1d1b9024549b8c7ddc420ff6919d70feb83f8f76 Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Fri, 26 Sep 2025 22:54:21 +0800
Subject: [PATCH 06/35] Refactor axis title to use AAAxisTitle class
Introduced AAAxisTitle class for axis title configuration, replacing AATitle in AAAxis, AAXAxis, and AAYAxis. Added AAChartAxisTitleAlignValueType enum for axis title alignment. Deprecated old title methods for backward compatibility and updated usage in ChartOptionsComposer.
---
.../AAChartAxisTitleAlignValueType.java | 17 +++++
.../AAChartCore/AAOptionsModel/AAAxis.java | 2 +-
.../AAOptionsModel/AAAxisTitle.java | 66 +++++++++++++++++++
.../AAChartCore/AAOptionsModel/AATitle.java | 4 +-
.../AAChartCore/AAOptionsModel/AAXAxis.java | 20 +++++-
.../AAChartCore/AAOptionsModel/AAYAxis.java | 20 +++++-
.../chartcomposer/ChartOptionsComposer.java | 3 +-
7 files changed, 126 insertions(+), 6 deletions(-)
create mode 100644 aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartEnum/AAChartAxisTitleAlignValueType.java
create mode 100644 aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAAxisTitle.java
diff --git a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartEnum/AAChartAxisTitleAlignValueType.java b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartEnum/AAChartAxisTitleAlignValueType.java
new file mode 100644
index 0000000..d904427
--- /dev/null
+++ b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartEnum/AAChartAxisTitleAlignValueType.java
@@ -0,0 +1,17 @@
+package com.github.AAChartModel.AAChartCore.AAChartEnum;
+
+public enum AAChartAxisTitleAlignValueType {
+ High("high"),
+ Low("low"),
+ Middle("middle");
+
+ private final String value;
+
+ AAChartAxisTitleAlignValueType(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
\ No newline at end of file
diff --git a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAAxis.java b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAAxis.java
index a564058..48bba9a 100644
--- a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAAxis.java
+++ b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAAxis.java
@@ -4,7 +4,7 @@ public class AAAxis {
public Boolean allowDecimals;
public Object alternateGridColor;
public AACrosshair crosshair; //准星线样式设置
- public AATitle title;
+ public AAAxisTitle title;
public String type;
public AADateTimeLabelFormats dateTimeLabelFormats;
public AAPlotBandsElement[] plotBands;
diff --git a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAAxisTitle.java b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAAxisTitle.java
new file mode 100644
index 0000000..570f2dc
--- /dev/null
+++ b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAAxisTitle.java
@@ -0,0 +1,66 @@
+package com.github.AAChartModel.AAChartCore.AAOptionsModel;
+
+import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartAxisTitleAlignValueType;
+
+public class AAAxisTitle {
+ public String align;
+ public String margin;
+ public Number offset;
+ public Number rotation;
+ public AAStyle style;
+ public String text;
+ public String textAlign;
+ public Boolean useHTML;
+ public Number x;
+ public Number y;
+
+ public AAAxisTitle align(AAChartAxisTitleAlignValueType prop) {
+ align = prop.getValue();
+ return this;
+ }
+
+ public AAAxisTitle margin(String prop) {
+ margin = prop;
+ return this;
+ }
+
+ public AAAxisTitle offset(Number prop) {
+ offset = prop;
+ return this;
+ }
+
+ public AAAxisTitle rotation(Number prop) {
+ rotation = prop;
+ return this;
+ }
+
+ public AAAxisTitle style(AAStyle prop) {
+ style = prop;
+ return this;
+ }
+
+ public AAAxisTitle text(String prop) {
+ text = prop;
+ return this;
+ }
+
+ public AAAxisTitle textAlign(String prop) {
+ textAlign = prop;
+ return this;
+ }
+
+ public AAAxisTitle useHTML(Boolean prop) {
+ useHTML = prop;
+ return this;
+ }
+
+ public AAAxisTitle x(Number prop) {
+ x = prop;
+ return this;
+ }
+
+ public AAAxisTitle y(Number prop) {
+ y = prop;
+ return this;
+ }
+}
\ No newline at end of file
diff --git a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AATitle.java b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AATitle.java
index a94452a..cbd07e9 100644
--- a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AATitle.java
+++ b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AATitle.java
@@ -10,7 +10,7 @@ public class AATitle {
public String verticalAlign;
public Number x;
public Number y;
- public Boolean userHTML;
+ public Boolean useHTML;
public AATitle text(String prop) {
text = prop;
@@ -43,7 +43,7 @@ public AATitle y(Number prop) {
}
public AATitle userHTML(Boolean prop) {
- userHTML = prop;
+ useHTML = prop;
return this;
}
}
diff --git a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAXAxis.java b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAXAxis.java
index eaada4c..64378fa 100644
--- a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAXAxis.java
+++ b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAXAxis.java
@@ -16,11 +16,29 @@ public AAXAxis crosshair(AACrosshair prop) {
return this;
}
- public AAXAxis title(AATitle prop) {
+ public AAXAxis title(AAAxisTitle prop) {
title = prop;
return this;
}
+ // 为了保持向后兼容性,添加对 AATitle 的支持
+ // 同时添加方法废弃警告⚠️, 提示用户使用新的 AAAxisTitle 类型
+ @Deprecated
+ public AAXAxis title(AATitle prop) {
+ if (prop != null) {
+ AAAxisTitle axisTitle = new AAAxisTitle()
+ .text(prop.text)
+ .style(prop.style)
+ .x(prop.x)
+ .y(prop.y)
+ .useHTML(prop.useHTML);
+ title = axisTitle;
+ } else {
+ title = null;
+ }
+ return this;
+ }
+
public AAXAxis type(String prop) {
type = prop;
return this;
diff --git a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAYAxis.java b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAYAxis.java
index a16633a..89ff04c 100644
--- a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAYAxis.java
+++ b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAOptionsModel/AAYAxis.java
@@ -36,11 +36,29 @@ public AAYAxis crosshair(AACrosshair prop) {
return this;
}
- public AAYAxis title(AATitle prop) {
+ public AAYAxis title(AAAxisTitle prop) {
title = prop;
return this;
}
+ // 为了保持向后兼容性,添加对 AATitle 的支持
+ // 同时添加方法废弃警告⚠️, 提示用户使用新的 AAAxisTitle 类型
+ @Deprecated
+ public AAYAxis title(AATitle prop) {
+ if (prop != null) {
+ AAAxisTitle axisTitle = new AAAxisTitle()
+ .text(prop.text)
+ .style(prop.style)
+ .x(prop.x)
+ .y(prop.y)
+ .useHTML(prop.useHTML);
+ title = axisTitle;
+ } else {
+ title = null;
+ }
+ return this;
+ }
+
public AAYAxis type(String prop) {
type = prop;
return this;
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/ChartOptionsComposer.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/ChartOptionsComposer.java
index a120043..2e28148 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/ChartOptionsComposer.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/chartcomposer/ChartOptionsComposer.java
@@ -18,6 +18,7 @@
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartVerticalAlignType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartZoomType;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAAnimation;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAAxisTitle;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AABoxplot;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AABubble;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAChart;
@@ -1749,7 +1750,7 @@ public static AAOptions logarithmicAxisScatterChart() {
.tickInterval(1)
.minorTickInterval(0.1)
.gridLineWidth(1)
- .title(null))
+ .title((AAAxisTitle)null))
.series(new AASeriesElement[]{
new AASeriesElement()
.marker(aaMarker)
From 0c287cce6984693996da42c8ea178022453e5644 Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Sat, 27 Sep 2025 00:16:01 +0800
Subject: [PATCH 07/35] Add chart list feature with RecyclerView
Introduces ChartListActivity and ChartListAdapter to display a list of charts using RecyclerView. Updates MainActivity and activity_main.xml to include a button for navigating to the chart list. Adds necessary layout files for the chart list and list items, and registers the new activity in AndroidManifest.xml.
---
app/src/main/AndroidManifest.xml | 1 +
.../MainContent/ChartListActivity.java | 36 ++++++++++++
.../MainContent/ChartListAdapter.java | 55 +++++++++++++++++++
.../ChartsDemo/MainContent/MainActivity.java | 8 +++
.../main/res/layout/activity_chart_list.xml | 5 ++
app/src/main/res/layout/activity_main.xml | 12 +++-
app/src/main/res/layout/list_item_chart.xml | 21 +++++++
7 files changed, 135 insertions(+), 3 deletions(-)
create mode 100644 app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
create mode 100644 app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListAdapter.java
create mode 100644 app/src/main/res/layout/activity_chart_list.xml
create mode 100644 app/src/main/res/layout/list_item_chart.xml
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 96cb818..caacc26 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -41,6 +41,7 @@
android:theme="@style/AppTheme.NoActionBar" />
+
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
new file mode 100644
index 0000000..69997ab
--- /dev/null
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
@@ -0,0 +1,36 @@
+package com.example.anan.AAChartCore.ChartsDemo.MainContent;
+
+import android.os.Bundle;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.BasicChartComposer;
+import com.example.anan.AAChartCore.R;
+import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
+
+public class ChartListActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_chart_list);
+
+ RecyclerView recyclerView = findViewById(R.id.recycler_view);
+ recyclerView.setLayoutManager(new LinearLayoutManager(this));
+
+ AAChartModel[] chartModels = {
+ BasicChartComposer.configureAreaChart(),
+ BasicChartComposer.configureColumnChartAndBarChart(),
+ BasicChartComposer.configureColumnChartAndBarChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Bar),
+ BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line),
+ BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Spline),
+ BasicChartComposer.configureStepAreaChartAndStepLineChart(),
+ BasicChartComposer.configureStepAreaChartAndStepLineChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line),
+ };
+
+ ChartListAdapter adapter = new ChartListAdapter(this, chartModels);
+ recyclerView.setAdapter(adapter);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListAdapter.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListAdapter.java
new file mode 100644
index 0000000..ec75259
--- /dev/null
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListAdapter.java
@@ -0,0 +1,55 @@
+package com.example.anan.AAChartCore.ChartsDemo.MainContent;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.example.anan.AAChartCore.R;
+import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
+import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
+
+public class ChartListAdapter extends RecyclerView.Adapter {
+
+ private Context mContext;
+ private AAChartModel[] mChartModels;
+
+ public ChartListAdapter(Context context, AAChartModel[] chartModels) {
+ mContext = context;
+ mChartModels = chartModels;
+ }
+
+ @NonNull
+ @Override
+ public ChartViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(mContext).inflate(R.layout.list_item_chart, parent, false);
+ return new ChartViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull ChartViewHolder holder, int position) {
+ AAChartModel chartModel = mChartModels[position];
+ holder.chartTitle.setText(chartModel.title);
+ holder.chartView.aa_drawChartWithChartModel(chartModel);
+ }
+
+ @Override
+ public int getItemCount() {
+ return mChartModels.length;
+ }
+
+ static class ChartViewHolder extends RecyclerView.ViewHolder {
+ TextView chartTitle;
+ AAChartView chartView;
+
+ ChartViewHolder(@NonNull View itemView) {
+ super(itemView);
+ chartTitle = itemView.findViewById(R.id.chart_title);
+ chartView = itemView.findViewById(R.id.chart_view);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/MainActivity.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/MainActivity.java
index dd83271..1f24501 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/MainActivity.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/MainActivity.java
@@ -525,6 +525,14 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupExpandableListView();
+
+ findViewById(R.id.show_chart_list_button).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(MainActivity.this, ChartListActivity.class);
+ startActivity(intent);
+ }
+ });
}
void setupExpandableListView() {
diff --git a/app/src/main/res/layout/activity_chart_list.xml b/app/src/main/res/layout/activity_chart_list.xml
new file mode 100644
index 0000000..1096ae4
--- /dev/null
+++ b/app/src/main/res/layout/activity_chart_list.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index ba37864..a1947d7 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,15 +1,21 @@
-
+
+
-
+
diff --git a/app/src/main/res/layout/list_item_chart.xml b/app/src/main/res/layout/list_item_chart.xml
new file mode 100644
index 0000000..fd7e1d4
--- /dev/null
+++ b/app/src/main/res/layout/list_item_chart.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
From 16ad2fc4047910ea91e775a3b3d855ad2e282d40 Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Sat, 27 Sep 2025 00:27:18 +0800
Subject: [PATCH 08/35] Update ChartListActivity.java
---
.../MainContent/ChartListActivity.java | 102 +++++++++++++++++-
1 file changed, 98 insertions(+), 4 deletions(-)
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
index 69997ab..1cb8bf4 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
@@ -7,9 +7,15 @@
import androidx.recyclerview.widget.RecyclerView;
import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.BasicChartComposer;
+import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.CustomStyleChartComposer;
+import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.MixedChartComposer;
+import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.SpecialChartComposer;
import com.example.anan.AAChartCore.R;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
+import java.util.Arrays;
+import java.util.List;
+
public class ChartListActivity extends AppCompatActivity {
@Override
@@ -20,17 +26,105 @@ protected void onCreate(Bundle savedInstanceState) {
RecyclerView recyclerView = findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
- AAChartModel[] chartModels = {
+ List chartModels = new java.util.ArrayList<>(Arrays.asList(
BasicChartComposer.configureAreaChart(),
BasicChartComposer.configureColumnChartAndBarChart(),
BasicChartComposer.configureColumnChartAndBarChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Bar),
BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line),
BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Spline),
BasicChartComposer.configureStepAreaChartAndStepLineChart(),
- BasicChartComposer.configureStepAreaChartAndStepLineChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line),
- };
+ BasicChartComposer.configureStepAreaChartAndStepLineChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line)
+ ));
+
+ chartModels.addAll(Arrays.asList(
+ SpecialChartComposer.configurePolarColumnChart(),
+ SpecialChartComposer.configurePolarBarChart(),
+ SpecialChartComposer.configurePolarLineChart(),
+ SpecialChartComposer.configurePolarAreaChart(),
+ SpecialChartComposer.configurePieChart(),
+ SpecialChartComposer.configureBubbleChart(),
+ SpecialChartComposer.configureScatterChart(),
+ SpecialChartComposer.configureArearangeChart(),
+ SpecialChartComposer.configureAreasplinerangeChart(),
+ SpecialChartComposer.configureColumnrangeChart(),
+ SpecialChartComposer.configureStepLineChart(),
+ SpecialChartComposer.configureStepAreaChart(),
+ SpecialChartComposer.configureBoxplotChart(),
+ SpecialChartComposer.configureWaterfallChart(),
+ SpecialChartComposer.configurePyramidChart(),
+ SpecialChartComposer.configureFunnelChart(),
+ SpecialChartComposer.configureErrorbarChart(),
+ SpecialChartComposer.configureGaugeChart(),
+ SpecialChartComposer.configurePolygonChart()
+ ));
+
+ chartModels.addAll(Arrays.asList(
+ MixedChartComposer.arearangeMixedLine(),
+ MixedChartComposer.columnrangeMixedLine(),
+ MixedChartComposer.stackingColumnMixedLine(),
+ MixedChartComposer.dashStyleTypeMixed(),
+ MixedChartComposer.negativeColorMixed(),
+ MixedChartComposer.scatterMixedLine(),
+ MixedChartComposer.negativeColorMixedBubble(),
+ MixedChartComposer.polygonMixedScatter(),
+ MixedChartComposer.polarChartMixed(),
+ MixedChartComposer.configurePieMixedLineMixedColumnChart(),
+ MixedChartComposer.configureNegativeColorMixedAreasplineChart(),
+ MixedChartComposer.configureAerasplinerangeMixedColumnrangeMixedLineChart()
+ ));
+
+ chartModels.addAll(Arrays.asList(
+ CustomStyleChartComposer.configureColorfulChart(),
+ CustomStyleChartComposer.configureColorfulGradientColorChart(),
+ CustomStyleChartComposer.configureDiscontinuousDataChart(),
+ CustomStyleChartComposer.configureColorfulColumnChart(),
+ CustomStyleChartComposer.configureNightingaleRoseChart(),
+ CustomStyleChartComposer.configureChartWithShadowStyle(),
+ CustomStyleChartComposer.configureColorfulGradientAreaChart(),
+ CustomStyleChartComposer.configureColorfulGradientSplineChart(),
+ CustomStyleChartComposer.configureGradientColorAreasplineChart(),
+ CustomStyleChartComposer.configureSpecialStyleMarkerOfSingleDataElementChart(),
+ CustomStyleChartComposer.configureSpecialStyleColumnOfSingleDataElementChart(),
+ CustomStyleChartComposer.configureAreaChartThreshold(),
+ CustomStyleChartComposer.customScatterChartMarkerSymbolContent(),
+ CustomStyleChartComposer.customLineChartMarkerSymbolContent(),
+ CustomStyleChartComposer.configureTriangleRadarChart(),
+ CustomStyleChartComposer.configureQuadrangleRadarChart(),
+ CustomStyleChartComposer.configurePentagonRadarChart(),
+ CustomStyleChartComposer.configureHexagonRadarChart(),
+ CustomStyleChartComposer.adjustYAxisMaxAndMinValues(),
+ CustomStyleChartComposer.customSpecialStyleDataLabelOfSingleDataElementChart(),
+ CustomStyleChartComposer.customBarChartHoverColorAndSelectColor(),
+ CustomStyleChartComposer.customChartHoverAndSelectHaloStyle(),
+ CustomStyleChartComposer.customSplineChartMarkerStatesHoverStyle(),
+ CustomStyleChartComposer.splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle(),
+ CustomStyleChartComposer.customNormalStackingChartDataLabelsContentAndStyle(),
+ CustomStyleChartComposer.upsideDownPyramidChart(),
+ CustomStyleChartComposer.doubleLayerPieChart(),
+ CustomStyleChartComposer.disableSomeOfLinesMouseTrackingEffect(),
+ CustomStyleChartComposer.configureColorfulShadowSplineChart(),
+ CustomStyleChartComposer.configureColorfulDataLabelsStepLineChart(),
+ CustomStyleChartComposer.configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart(),
+ CustomStyleChartComposer.disableSplineChartMarkerHoverEffect(),
+ CustomStyleChartComposer.configureMaxAndMinDataLabelsForChart(),
+ CustomStyleChartComposer.customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag(),
+ CustomStyleChartComposer.noMoreGroupingAndOverlapEachOtherColumnChart(),
+ CustomStyleChartComposer.noMoreGroupingAndNestedColumnChart(),
+ CustomStyleChartComposer.topRoundedCornersStackingColumnChart(),
+ CustomStyleChartComposer.freeStyleRoundedCornersStackingColumnChart(),
+ CustomStyleChartComposer.customColumnChartBorderStyleAndStatesHoverColor(),
+ CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines(),
+ CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines2(),
+ CustomStyleChartComposer.drawLineChartWithPointsCoordinates(),
+ CustomStyleChartComposer.configureSpecialStyleColumnForNegativeDataMixedPositiveData(),
+ CustomStyleChartComposer.configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart(),
+ CustomStyleChartComposer.connectNullsForSingleAASeriesElement(),
+ CustomStyleChartComposer.lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement(),
+ CustomStyleChartComposer.largeDataStackingColumnChart(),
+ CustomStyleChartComposer.customAreasplineChartWithColorfulGradientColorZones()
+ ));
- ChartListAdapter adapter = new ChartListAdapter(this, chartModels);
+ ChartListAdapter adapter = new ChartListAdapter(this, chartModels.toArray(new AAChartModel[0]));
recyclerView.setAdapter(adapter);
}
}
\ No newline at end of file
From 8565aa1be3962f262123d762f810f13ae40a8662 Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Sat, 27 Sep 2025 00:36:28 +0800
Subject: [PATCH 09/35] Add chart category selection before chart list
Introduced ChartCategorySelectionActivity and its layout to allow users to select chart categories before viewing the chart list. Updated MainActivity to launch the new selection activity, and modified ChartListActivity to display charts based on the selected category. Registered the new activity in AndroidManifest.xml.
---
app/src/main/AndroidManifest.xml | 1 +
.../ChartCategorySelectionActivity.java | 60 ++++++
.../MainContent/ChartListActivity.java | 200 +++++++++---------
.../ChartsDemo/MainContent/MainActivity.java | 2 +-
.../activity_chart_category_selection.xml | 52 +++++
5 files changed, 217 insertions(+), 98 deletions(-)
create mode 100644 app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartCategorySelectionActivity.java
create mode 100644 app/src/main/res/layout/activity_chart_category_selection.xml
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index caacc26..215f3e9 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -42,6 +42,7 @@
+
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartCategorySelectionActivity.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartCategorySelectionActivity.java
new file mode 100644
index 0000000..0aa485e
--- /dev/null
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartCategorySelectionActivity.java
@@ -0,0 +1,60 @@
+package com.example.anan.AAChartCore.ChartsDemo.MainContent;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.example.anan.AAChartCore.R;
+
+public class ChartCategorySelectionActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_chart_category_selection);
+
+ Button basicChartsBtn = findViewById(R.id.basic_charts_button);
+ Button specialChartsBtn = findViewById(R.id.special_charts_button);
+ Button mixedChartsBtn = findViewById(R.id.mixed_charts_button);
+ Button customStyleChartsBtn = findViewById(R.id.custom_style_charts_button);
+
+ basicChartsBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(ChartCategorySelectionActivity.this, ChartListActivity.class);
+ intent.putExtra("chart_category", "basic");
+ startActivity(intent);
+ }
+ });
+
+ specialChartsBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(ChartCategorySelectionActivity.this, ChartListActivity.class);
+ intent.putExtra("chart_category", "special");
+ startActivity(intent);
+ }
+ });
+
+ mixedChartsBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(ChartCategorySelectionActivity.this, ChartListActivity.class);
+ intent.putExtra("chart_category", "mixed");
+ startActivity(intent);
+ }
+ });
+
+ customStyleChartsBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(ChartCategorySelectionActivity.this, ChartListActivity.class);
+ intent.putExtra("chart_category", "custom");
+ startActivity(intent);
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
index 1cb8bf4..6cdce02 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
@@ -26,103 +26,109 @@ protected void onCreate(Bundle savedInstanceState) {
RecyclerView recyclerView = findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
- List chartModels = new java.util.ArrayList<>(Arrays.asList(
- BasicChartComposer.configureAreaChart(),
- BasicChartComposer.configureColumnChartAndBarChart(),
- BasicChartComposer.configureColumnChartAndBarChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Bar),
- BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line),
- BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Spline),
- BasicChartComposer.configureStepAreaChartAndStepLineChart(),
- BasicChartComposer.configureStepAreaChartAndStepLineChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line)
- ));
-
- chartModels.addAll(Arrays.asList(
- SpecialChartComposer.configurePolarColumnChart(),
- SpecialChartComposer.configurePolarBarChart(),
- SpecialChartComposer.configurePolarLineChart(),
- SpecialChartComposer.configurePolarAreaChart(),
- SpecialChartComposer.configurePieChart(),
- SpecialChartComposer.configureBubbleChart(),
- SpecialChartComposer.configureScatterChart(),
- SpecialChartComposer.configureArearangeChart(),
- SpecialChartComposer.configureAreasplinerangeChart(),
- SpecialChartComposer.configureColumnrangeChart(),
- SpecialChartComposer.configureStepLineChart(),
- SpecialChartComposer.configureStepAreaChart(),
- SpecialChartComposer.configureBoxplotChart(),
- SpecialChartComposer.configureWaterfallChart(),
- SpecialChartComposer.configurePyramidChart(),
- SpecialChartComposer.configureFunnelChart(),
- SpecialChartComposer.configureErrorbarChart(),
- SpecialChartComposer.configureGaugeChart(),
- SpecialChartComposer.configurePolygonChart()
- ));
-
- chartModels.addAll(Arrays.asList(
- MixedChartComposer.arearangeMixedLine(),
- MixedChartComposer.columnrangeMixedLine(),
- MixedChartComposer.stackingColumnMixedLine(),
- MixedChartComposer.dashStyleTypeMixed(),
- MixedChartComposer.negativeColorMixed(),
- MixedChartComposer.scatterMixedLine(),
- MixedChartComposer.negativeColorMixedBubble(),
- MixedChartComposer.polygonMixedScatter(),
- MixedChartComposer.polarChartMixed(),
- MixedChartComposer.configurePieMixedLineMixedColumnChart(),
- MixedChartComposer.configureNegativeColorMixedAreasplineChart(),
- MixedChartComposer.configureAerasplinerangeMixedColumnrangeMixedLineChart()
- ));
-
- chartModels.addAll(Arrays.asList(
- CustomStyleChartComposer.configureColorfulChart(),
- CustomStyleChartComposer.configureColorfulGradientColorChart(),
- CustomStyleChartComposer.configureDiscontinuousDataChart(),
- CustomStyleChartComposer.configureColorfulColumnChart(),
- CustomStyleChartComposer.configureNightingaleRoseChart(),
- CustomStyleChartComposer.configureChartWithShadowStyle(),
- CustomStyleChartComposer.configureColorfulGradientAreaChart(),
- CustomStyleChartComposer.configureColorfulGradientSplineChart(),
- CustomStyleChartComposer.configureGradientColorAreasplineChart(),
- CustomStyleChartComposer.configureSpecialStyleMarkerOfSingleDataElementChart(),
- CustomStyleChartComposer.configureSpecialStyleColumnOfSingleDataElementChart(),
- CustomStyleChartComposer.configureAreaChartThreshold(),
- CustomStyleChartComposer.customScatterChartMarkerSymbolContent(),
- CustomStyleChartComposer.customLineChartMarkerSymbolContent(),
- CustomStyleChartComposer.configureTriangleRadarChart(),
- CustomStyleChartComposer.configureQuadrangleRadarChart(),
- CustomStyleChartComposer.configurePentagonRadarChart(),
- CustomStyleChartComposer.configureHexagonRadarChart(),
- CustomStyleChartComposer.adjustYAxisMaxAndMinValues(),
- CustomStyleChartComposer.customSpecialStyleDataLabelOfSingleDataElementChart(),
- CustomStyleChartComposer.customBarChartHoverColorAndSelectColor(),
- CustomStyleChartComposer.customChartHoverAndSelectHaloStyle(),
- CustomStyleChartComposer.customSplineChartMarkerStatesHoverStyle(),
- CustomStyleChartComposer.splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle(),
- CustomStyleChartComposer.customNormalStackingChartDataLabelsContentAndStyle(),
- CustomStyleChartComposer.upsideDownPyramidChart(),
- CustomStyleChartComposer.doubleLayerPieChart(),
- CustomStyleChartComposer.disableSomeOfLinesMouseTrackingEffect(),
- CustomStyleChartComposer.configureColorfulShadowSplineChart(),
- CustomStyleChartComposer.configureColorfulDataLabelsStepLineChart(),
- CustomStyleChartComposer.configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart(),
- CustomStyleChartComposer.disableSplineChartMarkerHoverEffect(),
- CustomStyleChartComposer.configureMaxAndMinDataLabelsForChart(),
- CustomStyleChartComposer.customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag(),
- CustomStyleChartComposer.noMoreGroupingAndOverlapEachOtherColumnChart(),
- CustomStyleChartComposer.noMoreGroupingAndNestedColumnChart(),
- CustomStyleChartComposer.topRoundedCornersStackingColumnChart(),
- CustomStyleChartComposer.freeStyleRoundedCornersStackingColumnChart(),
- CustomStyleChartComposer.customColumnChartBorderStyleAndStatesHoverColor(),
- CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines(),
- CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines2(),
- CustomStyleChartComposer.drawLineChartWithPointsCoordinates(),
- CustomStyleChartComposer.configureSpecialStyleColumnForNegativeDataMixedPositiveData(),
- CustomStyleChartComposer.configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart(),
- CustomStyleChartComposer.connectNullsForSingleAASeriesElement(),
- CustomStyleChartComposer.lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement(),
- CustomStyleChartComposer.largeDataStackingColumnChart(),
- CustomStyleChartComposer.customAreasplineChartWithColorfulGradientColorZones()
- ));
+ String category = getIntent().getStringExtra("chart_category");
+
+ List chartModels = new java.util.ArrayList<>();
+
+ if (category == null || category.equals("basic")) {
+ chartModels.addAll(Arrays.asList(
+ BasicChartComposer.configureAreaChart(),
+ BasicChartComposer.configureColumnChartAndBarChart(),
+ BasicChartComposer.configureColumnChartAndBarChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Bar),
+ BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line),
+ BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Spline),
+ BasicChartComposer.configureStepAreaChartAndStepLineChart(),
+ BasicChartComposer.configureStepAreaChartAndStepLineChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line)
+ ));
+ } else if (category.equals("special")) {
+ chartModels.addAll(Arrays.asList(
+ SpecialChartComposer.configurePolarColumnChart(),
+ SpecialChartComposer.configurePolarBarChart(),
+ SpecialChartComposer.configurePolarLineChart(),
+ SpecialChartComposer.configurePolarAreaChart(),
+ SpecialChartComposer.configurePieChart(),
+ SpecialChartComposer.configureBubbleChart(),
+ SpecialChartComposer.configureScatterChart(),
+ SpecialChartComposer.configureArearangeChart(),
+ SpecialChartComposer.configureAreasplinerangeChart(),
+ SpecialChartComposer.configureColumnrangeChart(),
+ SpecialChartComposer.configureStepLineChart(),
+ SpecialChartComposer.configureStepAreaChart(),
+ SpecialChartComposer.configureBoxplotChart(),
+ SpecialChartComposer.configureWaterfallChart(),
+ SpecialChartComposer.configurePyramidChart(),
+ SpecialChartComposer.configureFunnelChart(),
+ SpecialChartComposer.configureErrorbarChart(),
+ SpecialChartComposer.configureGaugeChart(),
+ SpecialChartComposer.configurePolygonChart()
+ ));
+ } else if (category.equals("mixed")) {
+ chartModels.addAll(Arrays.asList(
+ MixedChartComposer.arearangeMixedLine(),
+ MixedChartComposer.columnrangeMixedLine(),
+ MixedChartComposer.stackingColumnMixedLine(),
+ MixedChartComposer.dashStyleTypeMixed(),
+ MixedChartComposer.negativeColorMixed(),
+ MixedChartComposer.scatterMixedLine(),
+ MixedChartComposer.negativeColorMixedBubble(),
+ MixedChartComposer.polygonMixedScatter(),
+ MixedChartComposer.polarChartMixed(),
+ MixedChartComposer.configurePieMixedLineMixedColumnChart(),
+ MixedChartComposer.configureNegativeColorMixedAreasplineChart(),
+ MixedChartComposer.configureAerasplinerangeMixedColumnrangeMixedLineChart()
+ ));
+ } else if (category.equals("custom")) {
+ chartModels.addAll(Arrays.asList(
+ CustomStyleChartComposer.configureColorfulChart(),
+ CustomStyleChartComposer.configureColorfulGradientColorChart(),
+ CustomStyleChartComposer.configureDiscontinuousDataChart(),
+ CustomStyleChartComposer.configureColorfulColumnChart(),
+ CustomStyleChartComposer.configureNightingaleRoseChart(),
+ CustomStyleChartComposer.configureChartWithShadowStyle(),
+ CustomStyleChartComposer.configureColorfulGradientAreaChart(),
+ CustomStyleChartComposer.configureColorfulGradientSplineChart(),
+ CustomStyleChartComposer.configureGradientColorAreasplineChart(),
+ CustomStyleChartComposer.configureSpecialStyleMarkerOfSingleDataElementChart(),
+ CustomStyleChartComposer.configureSpecialStyleColumnOfSingleDataElementChart(),
+ CustomStyleChartComposer.configureAreaChartThreshold(),
+ CustomStyleChartComposer.customScatterChartMarkerSymbolContent(),
+ CustomStyleChartComposer.customLineChartMarkerSymbolContent(),
+ CustomStyleChartComposer.configureTriangleRadarChart(),
+ CustomStyleChartComposer.configureQuadrangleRadarChart(),
+ CustomStyleChartComposer.configurePentagonRadarChart(),
+ CustomStyleChartComposer.configureHexagonRadarChart(),
+ CustomStyleChartComposer.adjustYAxisMaxAndMinValues(),
+ CustomStyleChartComposer.customSpecialStyleDataLabelOfSingleDataElementChart(),
+ CustomStyleChartComposer.customBarChartHoverColorAndSelectColor(),
+ CustomStyleChartComposer.customChartHoverAndSelectHaloStyle(),
+ CustomStyleChartComposer.customSplineChartMarkerStatesHoverStyle(),
+ CustomStyleChartComposer.splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle(),
+ CustomStyleChartComposer.customNormalStackingChartDataLabelsContentAndStyle(),
+ CustomStyleChartComposer.upsideDownPyramidChart(),
+ CustomStyleChartComposer.doubleLayerPieChart(),
+ CustomStyleChartComposer.disableSomeOfLinesMouseTrackingEffect(),
+ CustomStyleChartComposer.configureColorfulShadowSplineChart(),
+ CustomStyleChartComposer.configureColorfulDataLabelsStepLineChart(),
+ CustomStyleChartComposer.configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart(),
+ CustomStyleChartComposer.disableSplineChartMarkerHoverEffect(),
+ CustomStyleChartComposer.configureMaxAndMinDataLabelsForChart(),
+ CustomStyleChartComposer.customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag(),
+ CustomStyleChartComposer.noMoreGroupingAndOverlapEachOtherColumnChart(),
+ CustomStyleChartComposer.noMoreGroupingAndNestedColumnChart(),
+ CustomStyleChartComposer.topRoundedCornersStackingColumnChart(),
+ CustomStyleChartComposer.freeStyleRoundedCornersStackingColumnChart(),
+ CustomStyleChartComposer.customColumnChartBorderStyleAndStatesHoverColor(),
+ CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines(),
+ CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines2(),
+ CustomStyleChartComposer.drawLineChartWithPointsCoordinates(),
+ CustomStyleChartComposer.configureSpecialStyleColumnForNegativeDataMixedPositiveData(),
+ CustomStyleChartComposer.configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart(),
+ CustomStyleChartComposer.connectNullsForSingleAASeriesElement(),
+ CustomStyleChartComposer.lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement(),
+ CustomStyleChartComposer.largeDataStackingColumnChart(),
+ CustomStyleChartComposer.customAreasplineChartWithColorfulGradientColorZones()
+ ));
+ }
ChartListAdapter adapter = new ChartListAdapter(this, chartModels.toArray(new AAChartModel[0]));
recyclerView.setAdapter(adapter);
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/MainActivity.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/MainActivity.java
index 1f24501..a2745d7 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/MainActivity.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/MainActivity.java
@@ -529,7 +529,7 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.show_chart_list_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- Intent intent = new Intent(MainActivity.this, ChartListActivity.class);
+ Intent intent = new Intent(MainActivity.this, ChartCategorySelectionActivity.class);
startActivity(intent);
}
});
diff --git a/app/src/main/res/layout/activity_chart_category_selection.xml b/app/src/main/res/layout/activity_chart_category_selection.xml
new file mode 100644
index 0000000..66321d8
--- /dev/null
+++ b/app/src/main/res/layout/activity_chart_category_selection.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From fa3d60f04211eef6e30855ad6160872911735299 Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Sat, 27 Sep 2025 00:59:13 +0800
Subject: [PATCH 10/35] Add chart options category and support AAOptions
Introduced a new 'chart options' category in ChartCategorySelectionActivity and ChartListActivity, allowing users to view charts configured with AAOptions. Updated ChartListAdapter to support both AAChartModel and AAOptions, and added a corresponding button in the category selection layout.
---
.../ChartCategorySelectionActivity.java | 10 +
.../MainContent/ChartListActivity.java | 252 ++++++++++--------
.../MainContent/ChartListAdapter.java | 24 +-
.../activity_chart_category_selection.xml | 9 +
4 files changed, 187 insertions(+), 108 deletions(-)
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartCategorySelectionActivity.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartCategorySelectionActivity.java
index 0aa485e..52e3835 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartCategorySelectionActivity.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartCategorySelectionActivity.java
@@ -56,5 +56,15 @@ public void onClick(View v) {
startActivity(intent);
}
});
+
+ Button chartOptionsBtn = findViewById(R.id.chart_options_button);
+ chartOptionsBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(ChartCategorySelectionActivity.this, ChartListActivity.class);
+ intent.putExtra("chart_category", "options");
+ startActivity(intent);
+ }
+ });
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
index 6cdce02..2b63071 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListActivity.java
@@ -7,11 +7,14 @@
import androidx.recyclerview.widget.RecyclerView;
import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.BasicChartComposer;
+import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.ChartOptionsComposer;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.CustomStyleChartComposer;
import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.MixedChartComposer;
import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.SpecialChartComposer;
import com.example.anan.AAChartCore.R;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import java.util.Arrays;
import java.util.List;
@@ -27,110 +30,151 @@ protected void onCreate(Bundle savedInstanceState) {
recyclerView.setLayoutManager(new LinearLayoutManager(this));
String category = getIntent().getStringExtra("chart_category");
-
- List chartModels = new java.util.ArrayList<>();
-
- if (category == null || category.equals("basic")) {
- chartModels.addAll(Arrays.asList(
- BasicChartComposer.configureAreaChart(),
- BasicChartComposer.configureColumnChartAndBarChart(),
- BasicChartComposer.configureColumnChartAndBarChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Bar),
- BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line),
- BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Spline),
- BasicChartComposer.configureStepAreaChartAndStepLineChart(),
- BasicChartComposer.configureStepAreaChartAndStepLineChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line)
- ));
- } else if (category.equals("special")) {
- chartModels.addAll(Arrays.asList(
- SpecialChartComposer.configurePolarColumnChart(),
- SpecialChartComposer.configurePolarBarChart(),
- SpecialChartComposer.configurePolarLineChart(),
- SpecialChartComposer.configurePolarAreaChart(),
- SpecialChartComposer.configurePieChart(),
- SpecialChartComposer.configureBubbleChart(),
- SpecialChartComposer.configureScatterChart(),
- SpecialChartComposer.configureArearangeChart(),
- SpecialChartComposer.configureAreasplinerangeChart(),
- SpecialChartComposer.configureColumnrangeChart(),
- SpecialChartComposer.configureStepLineChart(),
- SpecialChartComposer.configureStepAreaChart(),
- SpecialChartComposer.configureBoxplotChart(),
- SpecialChartComposer.configureWaterfallChart(),
- SpecialChartComposer.configurePyramidChart(),
- SpecialChartComposer.configureFunnelChart(),
- SpecialChartComposer.configureErrorbarChart(),
- SpecialChartComposer.configureGaugeChart(),
- SpecialChartComposer.configurePolygonChart()
- ));
- } else if (category.equals("mixed")) {
- chartModels.addAll(Arrays.asList(
- MixedChartComposer.arearangeMixedLine(),
- MixedChartComposer.columnrangeMixedLine(),
- MixedChartComposer.stackingColumnMixedLine(),
- MixedChartComposer.dashStyleTypeMixed(),
- MixedChartComposer.negativeColorMixed(),
- MixedChartComposer.scatterMixedLine(),
- MixedChartComposer.negativeColorMixedBubble(),
- MixedChartComposer.polygonMixedScatter(),
- MixedChartComposer.polarChartMixed(),
- MixedChartComposer.configurePieMixedLineMixedColumnChart(),
- MixedChartComposer.configureNegativeColorMixedAreasplineChart(),
- MixedChartComposer.configureAerasplinerangeMixedColumnrangeMixedLineChart()
- ));
- } else if (category.equals("custom")) {
- chartModels.addAll(Arrays.asList(
- CustomStyleChartComposer.configureColorfulChart(),
- CustomStyleChartComposer.configureColorfulGradientColorChart(),
- CustomStyleChartComposer.configureDiscontinuousDataChart(),
- CustomStyleChartComposer.configureColorfulColumnChart(),
- CustomStyleChartComposer.configureNightingaleRoseChart(),
- CustomStyleChartComposer.configureChartWithShadowStyle(),
- CustomStyleChartComposer.configureColorfulGradientAreaChart(),
- CustomStyleChartComposer.configureColorfulGradientSplineChart(),
- CustomStyleChartComposer.configureGradientColorAreasplineChart(),
- CustomStyleChartComposer.configureSpecialStyleMarkerOfSingleDataElementChart(),
- CustomStyleChartComposer.configureSpecialStyleColumnOfSingleDataElementChart(),
- CustomStyleChartComposer.configureAreaChartThreshold(),
- CustomStyleChartComposer.customScatterChartMarkerSymbolContent(),
- CustomStyleChartComposer.customLineChartMarkerSymbolContent(),
- CustomStyleChartComposer.configureTriangleRadarChart(),
- CustomStyleChartComposer.configureQuadrangleRadarChart(),
- CustomStyleChartComposer.configurePentagonRadarChart(),
- CustomStyleChartComposer.configureHexagonRadarChart(),
- CustomStyleChartComposer.adjustYAxisMaxAndMinValues(),
- CustomStyleChartComposer.customSpecialStyleDataLabelOfSingleDataElementChart(),
- CustomStyleChartComposer.customBarChartHoverColorAndSelectColor(),
- CustomStyleChartComposer.customChartHoverAndSelectHaloStyle(),
- CustomStyleChartComposer.customSplineChartMarkerStatesHoverStyle(),
- CustomStyleChartComposer.splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle(),
- CustomStyleChartComposer.customNormalStackingChartDataLabelsContentAndStyle(),
- CustomStyleChartComposer.upsideDownPyramidChart(),
- CustomStyleChartComposer.doubleLayerPieChart(),
- CustomStyleChartComposer.disableSomeOfLinesMouseTrackingEffect(),
- CustomStyleChartComposer.configureColorfulShadowSplineChart(),
- CustomStyleChartComposer.configureColorfulDataLabelsStepLineChart(),
- CustomStyleChartComposer.configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart(),
- CustomStyleChartComposer.disableSplineChartMarkerHoverEffect(),
- CustomStyleChartComposer.configureMaxAndMinDataLabelsForChart(),
- CustomStyleChartComposer.customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag(),
- CustomStyleChartComposer.noMoreGroupingAndOverlapEachOtherColumnChart(),
- CustomStyleChartComposer.noMoreGroupingAndNestedColumnChart(),
- CustomStyleChartComposer.topRoundedCornersStackingColumnChart(),
- CustomStyleChartComposer.freeStyleRoundedCornersStackingColumnChart(),
- CustomStyleChartComposer.customColumnChartBorderStyleAndStatesHoverColor(),
- CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines(),
- CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines2(),
- CustomStyleChartComposer.drawLineChartWithPointsCoordinates(),
- CustomStyleChartComposer.configureSpecialStyleColumnForNegativeDataMixedPositiveData(),
- CustomStyleChartComposer.configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart(),
- CustomStyleChartComposer.connectNullsForSingleAASeriesElement(),
- CustomStyleChartComposer.lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement(),
- CustomStyleChartComposer.largeDataStackingColumnChart(),
- CustomStyleChartComposer.customAreasplineChartWithColorfulGradientColorZones()
- ));
- }
- ChartListAdapter adapter = new ChartListAdapter(this, chartModels.toArray(new AAChartModel[0]));
- recyclerView.setAdapter(adapter);
+ if (category != null && category.equals("options")) {
+ // For options category, we use AAOptions instead of AAChartModel
+ AAOptions[] chartOptions = new AAOptions[]{
+ ChartOptionsComposer.customChartLegendStyle(),
+ ChartOptionsComposer.configureAAPlotBandsForChart(),
+ ChartOptionsComposer.configureAAPlotLinesForChart(),
+ ChartOptionsComposer.customAATooltipWithJSFunction(),
+ ChartOptionsComposer.customXAxisCrosshairStyle(),
+ ChartOptionsComposer.configureXAxisLabelsFontColorWithHTMLString(),
+ ChartOptionsComposer.configureXAxisLabelsFontColorAndFontSizeWithHTMLString(),
+ ChartOptionsComposer.configure_DataLabels_XAXis_YAxis_Legend_Style(),
+ ChartOptionsComposer.configureXAxisPlotBand(),
+ ChartOptionsComposer.configureTheMirrorColumnChart(),
+ ChartOptionsComposer.configureDoubleYAxisChartOptions(),
+ ChartOptionsComposer.configureTripleYAxesMixedChart(),
+ ChartOptionsComposer.customLineChartDataLabelsFormat(),
+ ChartOptionsComposer.configureDoubleYAxesAndColumnLineMixedChart(),
+ ChartOptionsComposer.configureDoubleYAxesMarketDepthChart(),
+ ChartOptionsComposer.customAreaChartTooltipStyleLikeHTMLTable(),
+ ChartOptionsComposer.simpleGaugeChart(),
+ ChartOptionsComposer.gaugeChartWithPlotBand(),
+ ChartOptionsComposer.doubleLayerHalfPieChart(),
+ ChartOptionsComposer.customAreasplineChartTooltipContentWithHeaderFormat(),
+ ChartOptionsComposer.customAreaChartTooltipStyleWithTotalValueHeader(),
+ ChartOptionsComposer.configureYAxisLabelsNumericSymbolsMagnitudeOfAerasplineChart(),
+ ChartOptionsComposer.timeDataWithIrregularIntervalsChart(),
+ ChartOptionsComposer.logarithmicAxisLineChart(),
+ ChartOptionsComposer.logarithmicAxisScatterChart(),
+ ChartOptionsComposer.disableMixedChartInactiveAnimationEffect(),
+ ChartOptionsComposer.adjustBubbleChartMinAndMax(),
+ ChartOptionsComposer.customLineChartDataLabelsFormat2(),
+ ChartOptionsComposer.complicatedScatterChart(),
+ ChartOptionsComposer.customColumnrangeChartGroupStyleAndSeriesStatesHoverColor(),
+ ChartOptionsComposer.customTitleStyle(),
+ ChartOptionsComposer.configureBoxplotChartWithSpecialStyle()
+ };
+
+ ChartListAdapter adapter = new ChartListAdapter(this, chartOptions);
+ recyclerView.setAdapter(adapter);
+ } else {
+ List chartModels = new java.util.ArrayList<>();
+
+ if (category == null || category.equals("basic")) {
+ chartModels.addAll(Arrays.asList(
+ BasicChartComposer.configureAreaChart(),
+ BasicChartComposer.configureColumnChartAndBarChart(),
+ BasicChartComposer.configureColumnChartAndBarChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Bar),
+ BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line),
+ BasicChartComposer.configureLineChartAndSplineChartStyle(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Spline),
+ BasicChartComposer.configureStepAreaChartAndStepLineChart(),
+ BasicChartComposer.configureStepAreaChartAndStepLineChart().chartType(com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType.Line)
+ ));
+ } else if (category.equals("special")) {
+ chartModels.addAll(Arrays.asList(
+ SpecialChartComposer.configurePolarColumnChart(),
+ SpecialChartComposer.configurePolarBarChart(),
+ SpecialChartComposer.configurePolarLineChart(),
+ SpecialChartComposer.configurePolarAreaChart(),
+ SpecialChartComposer.configurePieChart(),
+ SpecialChartComposer.configureBubbleChart(),
+ SpecialChartComposer.configureScatterChart(),
+ SpecialChartComposer.configureArearangeChart(),
+ SpecialChartComposer.configureAreasplinerangeChart(),
+ SpecialChartComposer.configureColumnrangeChart(),
+ SpecialChartComposer.configureStepLineChart(),
+ SpecialChartComposer.configureStepAreaChart(),
+ SpecialChartComposer.configureBoxplotChart(),
+ SpecialChartComposer.configureWaterfallChart(),
+ SpecialChartComposer.configurePyramidChart(),
+ SpecialChartComposer.configureFunnelChart(),
+ SpecialChartComposer.configureErrorbarChart(),
+ SpecialChartComposer.configureGaugeChart(),
+ SpecialChartComposer.configurePolygonChart()
+ ));
+ } else if (category.equals("mixed")) {
+ chartModels.addAll(Arrays.asList(
+ MixedChartComposer.arearangeMixedLine(),
+ MixedChartComposer.columnrangeMixedLine(),
+ MixedChartComposer.stackingColumnMixedLine(),
+ MixedChartComposer.dashStyleTypeMixed(),
+ MixedChartComposer.negativeColorMixed(),
+ MixedChartComposer.scatterMixedLine(),
+ MixedChartComposer.negativeColorMixedBubble(),
+ MixedChartComposer.polygonMixedScatter(),
+ MixedChartComposer.polarChartMixed(),
+ MixedChartComposer.configurePieMixedLineMixedColumnChart(),
+ MixedChartComposer.configureNegativeColorMixedAreasplineChart(),
+ MixedChartComposer.configureAerasplinerangeMixedColumnrangeMixedLineChart()
+ ));
+ } else if (category.equals("custom")) {
+ chartModels.addAll(Arrays.asList(
+ CustomStyleChartComposer.configureColorfulChart(),
+ CustomStyleChartComposer.configureColorfulGradientColorChart(),
+ CustomStyleChartComposer.configureDiscontinuousDataChart(),
+ CustomStyleChartComposer.configureColorfulColumnChart(),
+ CustomStyleChartComposer.configureNightingaleRoseChart(),
+ CustomStyleChartComposer.configureChartWithShadowStyle(),
+ CustomStyleChartComposer.configureColorfulGradientAreaChart(),
+ CustomStyleChartComposer.configureColorfulGradientSplineChart(),
+ CustomStyleChartComposer.configureGradientColorAreasplineChart(),
+ CustomStyleChartComposer.configureSpecialStyleMarkerOfSingleDataElementChart(),
+ CustomStyleChartComposer.configureSpecialStyleColumnOfSingleDataElementChart(),
+ CustomStyleChartComposer.configureAreaChartThreshold(),
+ CustomStyleChartComposer.customScatterChartMarkerSymbolContent(),
+ CustomStyleChartComposer.customLineChartMarkerSymbolContent(),
+ CustomStyleChartComposer.configureTriangleRadarChart(),
+ CustomStyleChartComposer.configureQuadrangleRadarChart(),
+ CustomStyleChartComposer.configurePentagonRadarChart(),
+ CustomStyleChartComposer.configureHexagonRadarChart(),
+ CustomStyleChartComposer.adjustYAxisMaxAndMinValues(),
+ CustomStyleChartComposer.customSpecialStyleDataLabelOfSingleDataElementChart(),
+ CustomStyleChartComposer.customBarChartHoverColorAndSelectColor(),
+ CustomStyleChartComposer.customChartHoverAndSelectHaloStyle(),
+ CustomStyleChartComposer.customSplineChartMarkerStatesHoverStyle(),
+ CustomStyleChartComposer.splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle(),
+ CustomStyleChartComposer.customNormalStackingChartDataLabelsContentAndStyle(),
+ CustomStyleChartComposer.upsideDownPyramidChart(),
+ CustomStyleChartComposer.doubleLayerPieChart(),
+ CustomStyleChartComposer.disableSomeOfLinesMouseTrackingEffect(),
+ CustomStyleChartComposer.configureColorfulShadowSplineChart(),
+ CustomStyleChartComposer.configureColorfulDataLabelsStepLineChart(),
+ CustomStyleChartComposer.configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart(),
+ CustomStyleChartComposer.disableSplineChartMarkerHoverEffect(),
+ CustomStyleChartComposer.configureMaxAndMinDataLabelsForChart(),
+ CustomStyleChartComposer.customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag(),
+ CustomStyleChartComposer.noMoreGroupingAndOverlapEachOtherColumnChart(),
+ CustomStyleChartComposer.noMoreGroupingAndNestedColumnChart(),
+ CustomStyleChartComposer.topRoundedCornersStackingColumnChart(),
+ CustomStyleChartComposer.freeStyleRoundedCornersStackingColumnChart(),
+ CustomStyleChartComposer.customColumnChartBorderStyleAndStatesHoverColor(),
+ CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines(),
+ CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines2(),
+ CustomStyleChartComposer.drawLineChartWithPointsCoordinates(),
+ CustomStyleChartComposer.configureSpecialStyleColumnForNegativeDataMixedPositiveData(),
+ CustomStyleChartComposer.configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart(),
+ CustomStyleChartComposer.connectNullsForSingleAASeriesElement(),
+ CustomStyleChartComposer.lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement(),
+ CustomStyleChartComposer.largeDataStackingColumnChart(),
+ CustomStyleChartComposer.customAreasplineChartWithColorfulGradientColorZones()
+ ));
+ }
+
+ ChartListAdapter adapter = new ChartListAdapter(this, chartModels.toArray(new AAChartModel[0]));
+ recyclerView.setAdapter(adapter);
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListAdapter.java b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListAdapter.java
index ec75259..9dc187b 100644
--- a/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListAdapter.java
+++ b/app/src/main/java/com/example/anan/AAChartCore/ChartsDemo/MainContent/ChartListAdapter.java
@@ -12,16 +12,25 @@
import com.example.anan.AAChartCore.R;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
public class ChartListAdapter extends RecyclerView.Adapter {
private Context mContext;
private AAChartModel[] mChartModels;
+ private AAOptions[] mChartOptions;
+ private boolean isOptionsMode = false;
public ChartListAdapter(Context context, AAChartModel[] chartModels) {
mContext = context;
mChartModels = chartModels;
}
+
+ public ChartListAdapter(Context context, AAOptions[] chartOptions) {
+ mContext = context;
+ mChartOptions = chartOptions;
+ isOptionsMode = true;
+ }
@NonNull
@Override
@@ -32,14 +41,21 @@ public ChartViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewTyp
@Override
public void onBindViewHolder(@NonNull ChartViewHolder holder, int position) {
- AAChartModel chartModel = mChartModels[position];
- holder.chartTitle.setText(chartModel.title);
- holder.chartView.aa_drawChartWithChartModel(chartModel);
+ if (isOptionsMode) {
+ AAOptions chartOption = mChartOptions[position];
+ // 由于AAOptions中可能没有直接的标题,我们暂时使用默认标题
+ holder.chartTitle.setText("Chart Options " + (position + 1));
+ holder.chartView.aa_drawChartWithChartOptions(chartOption);
+ } else {
+ AAChartModel chartModel = mChartModels[position];
+ holder.chartTitle.setText(chartModel.title);
+ holder.chartView.aa_drawChartWithChartModel(chartModel);
+ }
}
@Override
public int getItemCount() {
- return mChartModels.length;
+ return isOptionsMode ? mChartOptions.length : mChartModels.length;
}
static class ChartViewHolder extends RecyclerView.ViewHolder {
diff --git a/app/src/main/res/layout/activity_chart_category_selection.xml b/app/src/main/res/layout/activity_chart_category_selection.xml
index 66321d8..c57d4d2 100644
--- a/app/src/main/res/layout/activity_chart_category_selection.xml
+++ b/app/src/main/res/layout/activity_chart_category_selection.xml
@@ -47,6 +47,15 @@
android:layout_height="wrap_content"
android:text="自定义样式图表"
android:textSize="18sp"
+ android:layout_marginBottom="16dp"
+ android:padding="16dp" />
+
+
\ No newline at end of file
From 7c4ac19feabbfbf5342f5853f9cad9253ef48828 Mon Sep 17 00:00:00 2001
From: An An <2236368544@qq.com>
Date: Sun, 28 Sep 2025 23:02:30 +0800
Subject: [PATCH 11/35] Remove extra closing div tag in AAChartView.html
Deleted an unnecessary closing tag from the AAChartView.html file to correct the HTML structure.
---
aa_chart_core/src/main/assets/AAChartView.html | 1 -
1 file changed, 1 deletion(-)
diff --git a/aa_chart_core/src/main/assets/AAChartView.html b/aa_chart_core/src/main/assets/AAChartView.html
index d97f494..686b39d 100755
--- a/aa_chart_core/src/main/assets/AAChartView.html
+++ b/aa_chart_core/src/main/assets/AAChartView.html
@@ -21,7 +21,6 @@
-