From 12d6db5780d8a2121a3bef2d58bf897b24ff552a Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 12 六月 2024 15:54:29 +0800
Subject: [PATCH] Merge branch 'dev'
---
aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAOptionsConstructor.java | 305 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 305 insertions(+), 0 deletions(-)
diff --git a/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAOptionsConstructor.java b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAOptionsConstructor.java
new file mode 100644
index 0000000..7434cc7
--- /dev/null
+++ b/aa_chart_core/src/main/java/com/github/AAChartModel/AAChartCore/AAChartCreator/AAOptionsConstructor.java
@@ -0,0 +1,305 @@
+/**
+ * // AAOptionsConstructor.java
+ * // AAChartCore
+ * //
+ * // Created by AnAn on 2018/12/08.
+ * // Copyright 漏 2018骞� An An. All rights reserved.
+ * /**
+ * 鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼� ...... SOURCE CODE ......鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼�
+ * 鈼夆棄鈼�................................................... 鈼夆棄鈼�
+ * 鈼夆棄鈼� https://github.com/AAChartModel/AAChartCore 鈼夆棄鈼�
+ * 鈼夆棄鈼� https://github.com/AAChartModel/AAChartCore-Kotlin 鈼夆棄鈼�
+ * 鈼夆棄鈼�................................................... 鈼夆棄鈼�
+ * 鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼� ...... SOURCE CODE ......鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼夆棄鈼�
+ * <p>
+ * <p>
+ * -------------------------------------------------------------------------------
+ * <p>
+ * 馃寱 馃寲 馃寳 馃寴 鉂�鉂�鉂� WARM TIPS!!! 鉂�鉂�鉂� 馃寫 馃寬 馃寭 馃寯
+ * <p>
+ * Please contact me on GitHub,if there are any problems encountered in use.
+ * GitHub Issues : https://github.com/AAChartModel/AAChartCore/issues
+ * -------------------------------------------------------------------------------
+ * And if you want to contribute for this project, please contact me as well
+ * GitHub : https://github.com/AAChartModel
+ * StackOverflow : https://stackoverflow.com/users/7842508/codeforu
+ * JianShu : http://www.jianshu.com/u/f1e6753d4254
+ * SegmentFault : https://segmentfault.com/u/huanghunbieguan
+ * <p>
+ * -------------------------------------------------------------------------------
+ */
+
+/**
+ * -------------------------------------------------------------------------------
+ *
+ * 馃寱 馃寲 馃寳 馃寴 鉂�鉂�鉂� WARM TIPS!!! 鉂�鉂�鉂� 馃寫 馃寬 馃寭 馃寯
+ *
+ * Please contact me on GitHub,if there are any problems encountered in use.
+ * GitHub Issues : https://github.com/AAChartModel/AAChartCore/issues
+ * -------------------------------------------------------------------------------
+ * And if you want to contribute for this project, please contact me as well
+ * GitHub : https://github.com/AAChartModel
+ * StackOverflow : https://stackoverflow.com/users/7842508/codeforu
+ * JianShu : http://www.jianshu.com/u/f1e6753d4254
+ * SegmentFault : https://segmentfault.com/u/huanghunbieguan
+ *
+ * -------------------------------------------------------------------------------
+
+ */
+
+
+package com.github.AAChartModel.AAChartCore.AAChartCreator;
+
+import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartAnimationType;
+import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolStyleType;
+import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAAnimation;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AABar;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAChart;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAColumn;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAColumnrange;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AADataLabels;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAItemStyle;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AALabels;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AALegend;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAMarker;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAPie;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAPlotOptions;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AASeries;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAStyle;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AASubtitle;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AATitle;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AATooltip;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAXAxis;
+import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAYAxis;
+import com.github.AAChartModel.AAChartCore.AATools.AAColor;
+
+public class AAOptionsConstructor {
+ public static AAOptions configureChartOptions(
+ AAChartModel aaChartModel
+ ) {
+ AAChart aaChart = new AAChart()
+ .type(aaChartModel.chartType) //缁樺浘绫诲瀷
+ .inverted(aaChartModel.inverted) //璁剧疆鏄惁鍙嶈浆鍧愭爣杞达紝浣縓杞村瀭鐩达紝Y杞存按骞炽�� 濡傛灉鍊间负 true锛屽垯 x 杞撮粯璁ゆ槸 鍊掔疆 鐨勩�� 濡傛灉鍥捐〃涓嚭鐜版潯褰㈠浘绯诲垪锛屽垯浼氳嚜鍔ㄥ弽杞�
+ .backgroundColor(aaChartModel.backgroundColor) //璁剧疆鍥捐〃鐨勮儗鏅壊(鍖呭惈閫忔槑搴︾殑璁剧疆)
+ .pinchType(aaChartModel.zoomType) //璁剧疆鎵嬪娍缂╂斁鏂瑰悜
+ .panning(true) //璁剧疆鎵嬪娍缂╂斁鍚庢槸鍚﹀彲骞崇Щ
+ .polar(aaChartModel.polar) //鏄惁鏋佸寲鍥捐〃(寮�鍚瀬鍧愭爣妯″紡)
+ .margin(aaChartModel.margin) //鍥捐〃杈硅窛
+ .scrollablePlotArea(aaChartModel.scrollablePlotArea);
+
+ AATitle aaTitle = new AATitle()
+ .text(aaChartModel.title) //鏍囬鏂囨湰鍐呭
+ .style(aaChartModel.titleStyle);
+
+ AASubtitle aaSubtitle = new AASubtitle()
+ .text(aaChartModel.subtitle) //鍓爣棰樺唴瀹�
+ .align(aaChartModel.subtitleAlign) //鍥捐〃鍓爣棰樻枃鏈按骞冲榻愭柟寮忋�傚彲閫夌殑鍊兼湁 鈥渓eft鈥濓紝鈥漜enter鈥滃拰鈥渞ight鈥濄�� 榛樿鏄細center.
+ .style(aaChartModel.subtitleStyle);
+
+ AATooltip aaTooltip = new AATooltip()
+ .enabled(aaChartModel.tooltipEnabled) //鍚敤娴姩鎻愮ず妗�
+ .shared(true) //澶氱粍鏁版嵁鍏变韩涓�涓诞鍔ㄦ彁绀烘
+ .valueSuffix(aaChartModel.tooltipValueSuffix) //娴姩鎻愮ず妗嗙殑鍗曚綅鍚嶇О鍚庣紑
+ ;
+
+ AAPlotOptions aaPlotOptions = new AAPlotOptions()
+ .series(new AASeries()
+ .stacking(aaChartModel.stacking) //璁剧疆鏄惁鐧惧垎姣斿爢鍙犳樉绀哄浘褰�
+ );
+
+ if (!aaChartModel.animationType.equals(AAChartAnimationType.Linear)) {
+ aaPlotOptions.series.animation((new AAAnimation()
+ .easing(aaChartModel.animationType)
+ .duration(aaChartModel.animationDuration)
+ ));
+ }
+
+ configureAAPlotOptionsMarkerStyle(aaChartModel, aaPlotOptions);
+ configureAAPlotOptionsDataLabels(aaPlotOptions, aaChartModel);
+
+ AALegend aaLegend = new AALegend()
+ .enabled(aaChartModel.legendEnabled) //鏄惁鏄剧ず legend
+ .itemStyle(new AAItemStyle()
+ .color(aaChartModel.axesTextColor));
+
+ AAOptions aaOptions = new AAOptions()
+ .chart(aaChart)
+ .title(aaTitle)
+ .subtitle(aaSubtitle)
+ .tooltip(aaTooltip)
+ .plotOptions(aaPlotOptions)
+ .legend(aaLegend)
+ .series(aaChartModel.series)
+ .colors(aaChartModel.colorsTheme) //璁剧疆棰滆壊涓婚
+ .touchEventEnabled(aaChartModel.touchEventEnabled) //鏄惁鏀寔鐐瑰嚮浜嬩欢
+ ;
+
+ configureAxisContentAndStyle(aaOptions, aaChartModel);
+
+ return aaOptions;
+ }
+
+ private static void configureAAPlotOptionsMarkerStyle(
+ AAChartModel aaChartModel,
+ AAPlotOptions aaPlotOptions
+ ) {
+ String aaChartType = aaChartModel.chartType;
+ //鏁版嵁鐐规爣璁扮浉鍏抽厤缃紝鍙湁绾挎�у浘(鎶樼嚎鍥俱�佹洸绾垮浘銆佹姌绾垮尯鍩熷~鍏呭浘銆佹洸绾垮尯鍩熷~鍏呭浘銆佹暎鐐瑰浘銆佹姌绾胯寖鍥村~鍏呭浘銆佹洸绾胯寖鍥村~鍏呭浘銆佸杈瑰舰鍥�)鎵嶆湁鏁版嵁鐐规爣璁�
+ switch (aaChartType) {
+ case AAChartType.Area:
+ case AAChartType.Areaspline:
+ case AAChartType.Line:
+ case AAChartType.Spline:
+ case AAChartType.Scatter:
+ case AAChartType.Arearange:
+ case AAChartType.Areasplinerange:
+ case AAChartType.Polygon:
+ AAMarker aaMarker = new AAMarker()
+ .radius(aaChartModel.markerRadius) //鏇茬嚎杩炴帴鐐瑰崐寰勶紝榛樿鏄�4
+ .symbol(aaChartModel.markerSymbol); //鏇茬嚎鐐圭被鍨嬶細"circle", "square", "diamond", "triangle","triangle-down"锛岄粯璁ゆ槸"circle"
+
+ if (aaChartModel.markerSymbolStyle.equals(AAChartSymbolStyleType.InnerBlank)) {
+ aaMarker.fillColor(AAColor.White) //鐐圭殑濉厖鑹�(鐢ㄦ潵璁剧疆鎶樼嚎杩炴帴鐐圭殑濉厖鑹�)
+ .lineWidth(2f) //澶栨部绾跨殑瀹藉害(鐢ㄦ潵璁剧疆鎶樼嚎杩炴帴鐐圭殑杞粨鎻忚竟鐨勫搴�)
+ .lineColor(""); //澶栨部绾跨殑棰滆壊(鐢ㄦ潵璁剧疆鎶樼嚎杩炴帴鐐圭殑杞粨鎻忚竟棰滆壊锛屽綋鍊间负绌哄瓧绗︿覆鏃讹紝榛樿鍙栨暟鎹偣鎴栨暟鎹垪鐨勯鑹�)
+ } else if (aaChartModel.markerSymbolStyle.equals(AAChartSymbolStyleType.BorderBlank)) {
+ aaMarker.lineWidth(2f)
+ .lineColor(aaChartModel.backgroundColor);
+ }
+ AASeries aaSeries = aaPlotOptions.series;
+ aaSeries.marker(aaMarker);
+
+ break;
+ }
+ }
+
+
+ private static void configureAAPlotOptionsDataLabels(
+ AAPlotOptions aaPlotOptions,
+ AAChartModel aaChartModel
+ ) {
+ String aaChartType = aaChartModel.chartType;
+
+ AADataLabels aaDataLabels = new AADataLabels()
+ .enabled(aaChartModel.dataLabelsEnabled);
+ if (aaChartModel.dataLabelsEnabled) {
+ aaDataLabels
+ .style(aaChartModel.dataLabelsStyle);
+ }
+
+ switch (aaChartType) {
+ case AAChartType.Column:
+ AAColumn aaColumn = new AAColumn()
+ .borderWidth(0f)
+ .borderRadius(aaChartModel.borderRadius);
+ if (aaChartModel.polar) {
+ aaColumn.pointPadding(0f)
+ .groupPadding(0.005f);
+ }
+ aaPlotOptions.column(aaColumn);
+ break;
+ case AAChartType.Bar:
+ AABar aaBar = new AABar()
+ .borderWidth(0f)
+ .borderRadius(aaChartModel.borderRadius);
+ if (aaChartModel.polar) {
+ aaBar.pointPadding(0f)
+ .groupPadding(0.005f);
+ }
+ aaPlotOptions.bar(aaBar);
+ break;
+ case AAChartType.Pie:
+ AAPie aaPie = new AAPie()
+ .allowPointSelect(true)
+ .cursor("pointer")
+ .showInLegend(true);
+ if (aaChartModel.dataLabelsEnabled) {
+ aaDataLabels.format("<b>{point.name}</b>: {point.percentage:.1f} %");
+ }
+ aaPlotOptions.pie(aaPie);
+ break;
+ case AAChartType.Columnrange:
+ AAColumnrange aaColumnrange = new AAColumnrange()
+ .borderRadius(0f) //The color of the border surrounding each column or bar
+ .borderWidth(0f) //The corner radius of the border surrounding each column or bar. default锛�0
+ ;
+ aaPlotOptions.columnrange(aaColumnrange);
+ break;
+ }
+ aaPlotOptions.series.dataLabels(aaDataLabels);
+
+ }
+
+ private static void configureAxisContentAndStyle(
+ AAOptions aaOptions,
+ AAChartModel aaChartModel
+ ) {
+ String aaChartType = aaChartModel.chartType;
+ //x 杞村拰 Y 杞寸殑鐩稿叧閰嶇疆,鎵囧舰鍥俱�侀噾瀛楀鍥惧拰婕忔枟鍥惧垯涓嶉渶瑕佽缃� X 杞村拰 Y 杞寸殑鐩稿叧鍐呭
+ switch (aaChartType) {
+ case AAChartType.Column:
+ case AAChartType.Bar:
+ case AAChartType.Area:
+ case AAChartType.Areaspline:
+ case AAChartType.Line:
+ case AAChartType.Spline:
+ case AAChartType.Scatter:
+ case AAChartType.Bubble:
+ case AAChartType.Columnrange:
+ case AAChartType.Arearange:
+ case AAChartType.Areasplinerange:
+ case AAChartType.Boxplot:
+ case AAChartType.Waterfall:
+ case AAChartType.Polygon:
+ case AAChartType.Gauge:
+ if (!aaChartType.equals(AAChartType.Gauge)) {
+ Boolean aaXAxisLabelsEnabled = aaChartModel.xAxisLabelsEnabled;
+ AALabels aaXAxisLabels = new AALabels()
+ .enabled(aaXAxisLabelsEnabled);//璁剧疆 x 杞存槸鍚︽樉绀烘枃瀛�
+ if (aaXAxisLabelsEnabled) {
+ aaXAxisLabels.style(new AAStyle()
+ .color(aaChartModel.axesTextColor));
+ }
+
+ AAXAxis aaXAxis = new AAXAxis()
+ .labels(aaXAxisLabels) //璁剧疆 x 杞存槸鍚︽樉绀烘枃瀛�
+ .reversed(aaChartModel.xAxisReversed)
+ .gridLineWidth(aaChartModel.xAxisGridLineWidth) //x杞寸綉鏍肩嚎瀹藉害
+ .categories(aaChartModel.categories)
+ .visible(aaChartModel.xAxisVisible) //x杞存槸鍚﹀彲瑙�
+ .tickInterval(aaChartModel.xAxisTickInterval);//x杞村潗鏍囩偣闂撮殧鏁�
+
+ aaOptions.xAxis(aaXAxis);
+ }
+
+ Boolean aaYAxisLabelsEnabled = aaChartModel.yAxisLabelsEnabled;
+ AALabels aaYAxisLabels = new AALabels()
+ .enabled(aaChartModel.yAxisLabelsEnabled);
+ if (aaYAxisLabelsEnabled) {
+ aaYAxisLabels.style(new AAStyle()
+ .color(aaChartModel.axesTextColor));
+ }
+
+ AAYAxis aaYAxis = new AAYAxis()
+ .labels(aaYAxisLabels) //璁剧疆 y 杞存槸鍚︽樉绀烘暟瀛�
+ .min(aaChartModel.yAxisMin) //璁剧疆 y 杞存渶灏忓��,鏈�灏忓�肩瓑浜庨浂灏变笉鑳芥樉绀鸿礋鍊间簡
+ .max(aaChartModel.yAxisMax) //y杞存渶澶у��
+ .allowDecimals(aaChartModel.yAxisAllowDecimals) //鏄惁鍏佽鏄剧ず灏忔暟
+ .reversed(aaChartModel.yAxisReversed)
+ .gridLineWidth(aaChartModel.yAxisGridLineWidth) //y杞寸綉鏍肩嚎瀹藉害
+ .title(new AATitle()
+ .text(aaChartModel.yAxisTitle)
+ .style(new AAStyle()
+ .color(aaChartModel.axesTextColor)))
+ .lineWidth(aaChartModel.yAxisLineWidth) //璁剧疆 y杞磋酱绾跨殑瀹藉害,涓�0鍗虫槸闅愯棌 y杞磋酱绾�
+ .visible(aaChartModel.yAxisVisible);
+
+ aaOptions.yAxis(aaYAxis);
+ break;
+ }
+ }
+
+
+}
--
Gitblit v1.8.0