This commit is contained in:
coco
2026-07-03 15:56:07 +08:00
commit caef23209c
5767 changed files with 1004268 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/build
+40
View File
@@ -0,0 +1,40 @@
apply plugin: 'com.android.application'
apply plugin: 'maven-publish'
android {
defaultConfig {
applicationId "com.example.anan.AAChartCore"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
compileSdk rootProject.ext.compileSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'com.example.anan.AAChartCore'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':aa_chart_core')
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.code.gson:gson:2.10.1'
}
+21
View File
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -0,0 +1,27 @@
package com.example.anan.AAChartCore;
import android.content.Context;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.anan.AAChartCore", appContext.getPackageName());
}
}
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ChartsDemo.AdditionalContent.AdvancedUpdatingFeatureActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.UpdateChartBackgroundColorActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.ScrollableChartActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.DoubleChartsLinkedWorkActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.ScrollingUpdateDataActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.JSFunctionForAATooltipActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.EvaluateJSStringFunctionActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.OnlyRefreshChartDataActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.HideOrShowChartSeriesActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.DrawChartWithAAOptionsActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.JSFunctionForAAAxisActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.JSFunctionForAALegendActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.JSFunctionForAAChartEventsActivity" />
<activity android:name=".ChartsDemo.AdditionalContent.JSFunctionForAAOptionsActivity" />
<activity android:name=".ChartsDemo.MainContent.MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ChartsDemo.MainContent.BasicChartActivity"
android:label="@string/title_activity_common_chart"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".ChartsDemo.MainContent.SpecialChartActivity"
android:label="@string/title_activity_special_chart"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".ChartsDemo.MainContent.CustomStyleChartActivity" />
<activity android:name=".ChartsDemo.MainContent.MixedChartActivity" />
</application>
</manifest>
@@ -0,0 +1,213 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import android.os.Bundle;
import android.util.Log;
import android.widget.CompoundButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartStackingType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
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.AADataLabels;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAMarker;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAPlotOptions;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AASeries;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAXAxis;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAYAxis;
import com.example.anan.AAChartCore.ChartsDemo.MainContent.BasicChartActivity;
import com.example.anan.AAChartCore.R;
public class AdvancedUpdatingFeatureActivity extends BasicChartActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
Object options = new Object();
switch (group.getId()) {
case R.id.stackingTypeRadioGroup: {
String stackingType = "";
switch (group.getCheckedRadioButtonId()) {
case R.id.noStackingRadio:
stackingType = AAChartStackingType.False;
break;
case R.id.normalStackingRadio:
stackingType = AAChartStackingType.Normal;
break;
case R.id.percentStackingRadio:
stackingType = AAChartStackingType.Percent;
break;
}
AAPlotOptions aaPlotOptions = new AAPlotOptions()
.series(new AASeries()
.stacking(stackingType));
options = aaPlotOptions;
break;
}
case R.id.cornerStyleTypeRadioGroup: {
Float borderRadius = null;
switch (group.getCheckedRadioButtonId()) {
case R.id.squareCornersRadio:
borderRadius = 1f;
break;
case R.id.roundedCornersRadio:
borderRadius = 10f;
break;
case R.id.wedgeCornersRadio:
borderRadius = 100f;
break;
}
AAPlotOptions aaPlotOptions;
if (chartType.equals(AAChartType.Column)) {
aaPlotOptions = new AAPlotOptions()
.column(new AAColumn()
.borderRadius(borderRadius));
} else {
aaPlotOptions = new AAPlotOptions()
.bar(new AABar()
.borderRadius(borderRadius));
}
options = aaPlotOptions;
break;
}
default: {
String markerSymbol = "";
switch (group.getCheckedRadioButtonId()) {
case R.id.circleSymbolRadio:
markerSymbol = AAChartSymbolType.Circle;
break;
case R.id.diamondSymbolRadio:
markerSymbol = AAChartSymbolType.Diamond;
break;
case R.id.squareSymbolRadio:
markerSymbol = AAChartSymbolType.Square;
break;
case R.id.triangleSymbolRadio:
markerSymbol = AAChartSymbolType.Triangle;
break;
case R.id.triangleDownSymbolRadio:
markerSymbol = AAChartSymbolType.Triangle_down;
break;
}
AAPlotOptions aaPlotOptions = new AAPlotOptions()
.series(new AASeries()
.marker(new AAMarker()
.symbol(markerSymbol)));
options = aaPlotOptions;
break;
}
}
aaChartView.aa_updateChartWithOptions(options, true);
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Object options = new Object();
boolean isOn = isChecked;
switch (buttonView.getId()) {
case R.id.xReversedSwitch: {
AAXAxis aaXAxis = new AAXAxis()
.reversed(isOn);
options = aaXAxis;
break;
}
case R.id.yReversedSwitch: {
AAYAxis aaYAxis = new AAYAxis()
.reversed(isOn);
options = aaYAxis;
break;
}
case R.id.xInvertedSwitch : {
if (this.aaChartModel.chartType.equals(AAChartType.Bar)) {
Toast.makeText(this,
"⚠️⚠️⚠️inverted is useless for Bar Chart",
Toast.LENGTH_SHORT)
.show();
Log.d("", "⚠️⚠️⚠️inverted is useless for Bar Chart");
}
AAChart aaChart = new AAChart()
.inverted(isOn)
.polar(this.aaChartModel.polar);
options = aaChart;
break;
}
case R.id.polarSwitch: {
this.aaChartModel.polar = isOn;
AAChart aaChart = new AAChart()
.polar(isOn)
.inverted(this.aaChartModel.inverted);
options = aaChart;
if (this.aaChartModel.chartType.equals(AAChartType.Column)) {
if (this.aaChartModel.polar) {
options = new AAOptions()
.chart(aaChart)
.plotOptions(new AAPlotOptions()
.column(new AAColumn()
.pointPadding(0f)
.groupPadding(0.005f)));
} else {
options = new AAOptions()
.chart(aaChart)
.plotOptions(new AAPlotOptions()
.column(new AAColumn()
.pointPadding(0.1f)
.groupPadding(0.2f)));
}
} else if (this.aaChartModel.chartType.equals(AAChartType.Bar)) {
if (this.aaChartModel.polar) {
options = new AAOptions()
.chart(aaChart)
.plotOptions(new AAPlotOptions()
.bar(new AABar()
.pointPadding(0f)
.groupPadding(0.005f)));
} else {
options = new AAOptions()
.chart(aaChart)
.plotOptions(new AAPlotOptions()
.bar(new AABar()
.pointPadding(0.1f)
.groupPadding(0.2f)));
}
}
break;
}
case R.id.dataShowSwitch: {
AAPlotOptions aaPlotOptions = new AAPlotOptions()
.series(new AASeries()
.dataLabels(new AADataLabels()
.enabled(isOn)));
options = aaPlotOptions;
break;
}
case R.id.markerHideSwitch: {
AAMarker aaMarker = isOn ?
new AAMarker()
.enabled(false)
:
new AAMarker()
.enabled(true)
.radius(6f);
AAPlotOptions aaPlotOptions = new AAPlotOptions()
.series(new AASeries()
.marker(aaMarker));
options = aaPlotOptions;
break;
}
}
aaChartView.aa_updateChartWithOptions(options, true);
}
}
@@ -0,0 +1,189 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import android.os.Handler;
import android.os.Looper;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAMoveOverEventMessageModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAOptionsConstructor;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AADataElement;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.github.AAChartModel.AAChartCore.AATools.AAGradientColor;
import com.example.anan.AAChartCore.R;
import java.util.Map;
public class DoubleChartsLinkedWorkActivity extends AppCompatActivity implements AAChartView.AAChartViewCallBack {
private Map selectedGradientColor;
private AAChartView aaChartView1;
private AAChartView aaChartView2;
private Map[] gradientColorsArr;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_double_charts_linked_work);
aaChartView1 = findViewById(R.id.AAChartView1);
aaChartView1.callBack = this;
aaChartView2 = findViewById(R.id.AAChartView2);
aaChartView1.aa_drawChartWithChartOptions(configureChartOptions1());
aaChartView2.aa_drawChartWithChartOptions(configureChartOptions2());
}
private AAOptions configureChartOptions1() {
String[] gradientColorNamesArr = {
"oceanBlue",
"sanguine",
"lusciousLime",
"purpleLake",
"freshPapaya",
"ultramarine",
"pinkSugar",
"lemonDrizzle",
"victoriaPurple",
"springGreens",
"mysticMauve",
"reflexSilver",
"neonGlowColor",
"berrySmoothieColor",
"newLeaf",
"cottonCandy",
"pixieDust",
"fizzyPeach",
"sweetDream",
"firebrick",
"wroughtIron",
"deepSea",
"coastalBreeze",
"eveningDelight",
"neonGlowColor",
"berrySmoothieColor"
};
Map[] gradientColorArr = {
AAGradientColor.OceanBlue,
AAGradientColor.Sanguine,
AAGradientColor.LusciousLime,
AAGradientColor.PurpleLake,
AAGradientColor.FreshPapaya,
AAGradientColor.Ultramarine,
AAGradientColor.PinkSugar,
AAGradientColor.LemonDrizzle,
AAGradientColor.VictoriaPurple,
AAGradientColor.SpringGreens,
AAGradientColor.MysticMauve,
AAGradientColor.ReflexSilver,
AAGradientColor.NewLeaf,
AAGradientColor.CottonCandy,
AAGradientColor.PixieDust,
AAGradientColor.FizzyPeach,
AAGradientColor.SweetDream,
AAGradientColor.Firebrick,
AAGradientColor.WroughtIron,
AAGradientColor.DeepSea,
AAGradientColor.CoastalBreeze,
AAGradientColor.EveningDelight,
AAGradientColor.NeonGlow,
AAGradientColor.BerrySmoothie
};
this.gradientColorsArr = gradientColorArr;
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Column)
.categories(gradientColorNamesArr)
.colorsTheme(gradientColorArr)
.xAxisReversed(true)
.yAxisReversed(true)
.inverted(true)
.legendEnabled(false)
.touchEventEnabled(true)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Tokyo")
.data(new Object[]{211,183,157,133,111,91,73,57,43,31,21,13,
211,183,157,133,111,91,73,57,43,31,21,13,})
.colorByPoint(true)
});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.plotOptions.column.groupPadding = 0f;
return aaOptions;
}
private AAOptions configureChartOptions2() {
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Column)
.legendEnabled(false)
.yAxisGridLineWidth(0f)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Tokyo")
.data(new Object[]{
149.9, 171.5, 106.4, 129.2, 144.0, 176.0, 135.6, 188.5, 276.4, 214.1, 95.6, 54.4,
149.9, 171.5, 106.4, 129.2, 144.0, 176.0, 135.6, 188.5, 276.4, 214.1, 95.6, 54.4})
});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.plotOptions.column.groupPadding = 0f;
return aaOptions;
}
private AADataElement[] configureSeriesDataArray() {
int maxRange = 40;
AADataElement[] numberArr1 = new AADataElement[maxRange];
double y1;
int max = 38, min = 1;
int random = (int) (Math.random() * (max - min) + min);
for (int i = 0; i < maxRange; i++) {
y1 = Math.sin(random * (i * Math.PI / 180)) + i * 2 * 0.01;
AADataElement aaDataElement = new AADataElement()
.color(selectedGradientColor)
.y((float) y1);
numberArr1[i] = aaDataElement;
}
return numberArr1;
}
@Override
public void chartViewDidFinishLoad(AAChartView aaChartView) {
}
@Override
public void chartViewMoveOverEventMessage(AAChartView aaChartView, AAMoveOverEventMessageModel messageModel) {
this.selectedGradientColor = gradientColorsArr[messageModel.index];
Handler mainHandler = new Handler(Looper.getMainLooper());
mainHandler.post(new Runnable() {
@Override
public void run() {
//已在主线程中,可以更新UI
AASeriesElement[] aaSeriesElementsArr = new AASeriesElement[]{
new AASeriesElement()
.data(configureSeriesDataArray())
};
aaChartView2.aa_onlyRefreshTheChartDataWithChartOptionsSeriesArray(aaSeriesElementsArr);
}
});
}
}
@@ -0,0 +1,104 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.ChartOptionsComposer.*;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.example.anan.AAChartCore.R;
public class DrawChartWithAAOptionsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_draw_chart_with_aaoptions);
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
AAOptions aaOptions = configureTheChartOptions(chartType);
AAChartView aaChartView = findViewById(R.id.AAChartView);
aaChartView.aa_drawChartWithChartOptions(aaOptions);
}
private AAOptions configureTheChartOptions(String chartType) {
switch (chartType) {
case "customLegendStyle":
return customChartLegendStyle();
case "AAPlotBandsForChart":
return configureAAPlotBandsForChart();
case "AAPlotLinesForChart":
return configureAAPlotLinesForChart();
case "customAATooltipWithJSFunction":
return customAATooltipWithJSFunction();
case "customXAxisCrosshairStyle":
return customXAxisCrosshairStyle();
case "XAxisLabelsFontColorWithHTMLString":
return configureXAxisLabelsFontColorWithHTMLString();
case "XAxisLabelsFontColorAndFontSizeWithHTMLString":
return configureXAxisLabelsFontColorAndFontSizeWithHTMLString();
case "_DataLabels_XAXis_YAxis_Legend_Style":
return configure_DataLabels_XAXis_YAxis_Legend_Style();
case "XAxisPlotBand":
return configureXAxisPlotBand();
case "configureTheMirrorColumnChart":
return configureTheMirrorColumnChart();
case "configureDoubleYAxisChartOptions":
return configureDoubleYAxisChartOptions();
case "configureTripleYAxesMixedChart":
return configureTripleYAxesMixedChart();
case "customLineChartDataLabelsFormat":
return customLineChartDataLabelsFormat();
case "configureDoubleYAxesAndColumnLineMixedChart":
return configureDoubleYAxesAndColumnLineMixedChart();
case "configureDoubleYAxesMarketDepthChart":
return configureDoubleYAxesMarketDepthChart();
case "customAreaChartTooltipStyleLikeHTMLTable":
return customAreaChartTooltipStyleLikeHTMLTable();
case "simpleGaugeChart":
return simpleGaugeChart();
case "gaugeChartWithPlotBand":
return gaugeChartWithPlotBand();
case "doubleLayerHalfPieChart":
return doubleLayerHalfPieChart();
case "customAreasplineChartTooltipContentWithHeaderFormat":
return customAreasplineChartTooltipContentWithHeaderFormat(); //通过 tooltip 的 headerFormat 属性来自定义 曲线填充图的 to
case "customAreaChartTooltipStyleWithTotalValueHeader":
return customAreaChartTooltipStyleWithTotalValueHeader(); //浮动提示框 header 显示总值信息
case "configureYAxisLabelsNumericSymbolsMagnitudeOfAerasplineChart":
return configureYAxisLabelsNumericSymbolsMagnitudeOfAerasplineChart(); //自定义 Y 轴的 Labels 国际单位符基数及国际单位符
case "timeDataWithIrregularIntervalsChart":
return timeDataWithIrregularIntervalsChart(); //X 轴时间不连续的折线图
case "logarithmicAxisLineChart":
return logarithmicAxisLineChart(); //对数轴折线图📈
case "logarithmicAxisScatterChart":
return logarithmicAxisScatterChart(); //对数轴散点图
case "disableMixedChartInactiveAnimationEffect":
return disableMixedChartInactiveAnimationEffect(); //禁用混合图表的 inactive 动画效果
case "adjustBubbleChartMinAndMax":
return adjustBubbleChartMinAndMax(); //调整气泡图的 min 和 max 相关属性
case "customLineChartDataLabelsFormat1":
return customLineChartDataLabelsFormat(); //自定义曲线图的 DataLabels 的 format 属性
case "customLineChartDataLabelsFormat2":
return customLineChartDataLabelsFormat2(); //自定义曲线图的 DataLabels 的 format 属性(更简易方法)
case "complicatedScatterChart":
return complicatedScatterChart(); //复杂的自定义散点图
case "customColumnrangeChartGroupStyleAndSeriesStatesHoverColor":
return customColumnrangeChartGroupStyleAndSeriesStatesHoverColor(); //自定义柱状图的 groupStyle 和 seriesStates hoverColor 属性
case "customTitleStyle":
return customTitleStyle(); //自定义标题样式
case "configureBoxplotChartWithSpecialStyle":
return configureBoxplotChartWithSpecialStyle(); //自定义盒须图样式
}
return configureAAPlotBandsForChart();
}
}
@@ -0,0 +1,258 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAMoveOverEventMessageModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartFontWeightType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartStackingType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AADataLabels;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAStyle;
import com.github.AAChartModel.AAChartCore.AATools.AAColor;
import com.github.AAChartModel.AAChartCore.AATools.AAGradientColor;
import com.example.anan.AAChartCore.R;
public class EvaluateJSStringFunctionActivity extends AppCompatActivity implements AAChartView.AAChartViewCallBack {
private AAChartView aaChartView;
private String chartType;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_evaluate_jsstring_function);
Intent intent = getIntent();
chartType = intent.getStringExtra("chartType");
aaChartView = findViewById(R.id.AAChartView);
AAChartModel aaChartModel = configureChartModel();
aaChartView.aa_drawChartWithChartModel(aaChartModel);
aaChartView.callBack = this;
}
AAChartModel configureChartModel() {
if (chartType.equals("evalJSFunction3")) {
return configureStackingColumnMixedLineChart();
}
return new AAChartModel()
.chartType(AAChartType.Line)
.dataLabelsEnabled(true)
.tooltipEnabled(true)
.backgroundColor(AAGradientColor.OceanBlue)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Tokyo")
.data(new Object[]{29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4})
.color(AAGradientColor.DeepSea)
});
}
AAChartModel configureStackingColumnMixedLineChart() {
AASeriesElement[] aaSeriesArr = {
new AASeriesElement()
.name("新用户")
.data(new Object[] {82.89,67.54,62.07,59.43,67.02,67.09,35.66,71.78,81.61,78.85,79.12,72.30})
.dataLabels(
new AADataLabels()
.enabled(true)
.style(new AAStyle()
.color(AAColor.Red)
.fontSize(11f)
)
)
,
new AASeriesElement()
.name("老用户")
.data(new Object[] {198.66,330.81,151.95,160.12,222.56,229.05,128.53,250.91,224.47,473.99,126.85,260.50})
.dataLabels(
new AADataLabels()
.enabled(true)
.style(new AAStyle()
.color("#000000")
.fontSize(11f)
)
),
new AASeriesElement()
.name("总量")
.type(AAChartType.Line)
.data(new Object[] {281.55,398.35,214.02,219.55,289.57,296.14,164.18,322.69,306.08,552.84,205.97,332.79})
.dataLabels(
new AADataLabels()
.enabled(true)
.style(new AAStyle()
.color("#000000")
.fontSize(15f)
.fontWeight(AAChartFontWeightType.Bold)
)
)
,
};
return new AAChartModel()
.title("16年1月-16年11月充值客单分析")//图形标题
.subtitle("BY MICVS")//图形副标题
.chartType(AAChartType.Column)
.stacking(AAChartStackingType.Normal)
.legendEnabled(true)
.colorsTheme(new Object[] {
AAGradientColor.OceanBlue,
AAGradientColor.Sanguine,
AAGradientColor.LusciousLime,
})
.series(aaSeriesArr);
}
@Override
public void chartViewDidFinishLoad(AAChartView aaChartView) {
Log.i("","🔥🔥🔥🔥🔥 AAChartView content did finish load!!!");
String jsFunctionStr;
if (chartType.equals("evalJSFunction1")) {
jsFunctionStr = configureMaxMiniDataLabelJSFunctionString();
} else if (chartType.equals("evalJSFunction2")) {
jsFunctionStr = configureFirstSecondThirdDataLabelJSFunctionString();
} else {
jsFunctionStr = configureFirstSecondThirdStackLabelJSFunctionString();
}
aaChartView.aa_evaluateTheJavaScriptStringFunction(jsFunctionStr);
}
@Override
public void chartViewMoveOverEventMessage(AAChartView aaChartView, AAMoveOverEventMessageModel messageModel) {
}
String configureMaxMiniDataLabelJSFunctionString() {
String jsStr =
" function render(aaGlobalChart, point, text) {\n" +
" return aaGlobalChart.renderer.label(text + ': ' + point.y, point.plotX + aaGlobalChart.plotLeft -20 , point.plotY + aaGlobalChart.plotTop - 45, 'callout', point.plotX + aaGlobalChart.plotLeft, point.plotY + aaGlobalChart.plotTop)\n" +
" .css({\n" +
" color: '#FFFFFF',\n" +
" align: 'center',\n" +
" })\n" +
" .attr({\n" +
" fill: 'rgba(0, 0, 0, 0.75)',\n" +
" padding: 8,\n" +
" r: 5,\n" +
" zIndex: 6\n" +
" })\n" +
" .add();\n" +
" }\n" +
" function renderMinMaxLabel(aaGlobalChart) {\n" +
" var min = 1000,\n" +
" max = 0,\n" +
" pointsToShow = [0, 0],\n" +
" points = aaGlobalChart.series[0].points;\n" +
" Highcharts.each(points, function(p) {\n" +
" if(p.y>max) {\n" +
" pointsToShow[0] = p.index;\n" +
" max = p.y;\n" +
" }\n" +
" if(p.y<min) {\n" +
" pointsToShow[1] = p.index;\n" +
" min = p.y;\n" +
" }\n" +
" });\n" +
" render(aaGlobalChart, points[pointsToShow[0]], 'Max');\n" +
" render(aaGlobalChart, points[pointsToShow[1]], 'Min');\n" +
" }\n" +
" \n" +
" renderMinMaxLabel(aaGlobalChart);";
return jsStr;
}
String configureFirstSecondThirdDataLabelJSFunctionString() {
Integer firstMaxNumberIndex = 8;
Integer secondMaxNumberIndex = 9;
Integer thirdMaxNumberIndex = 5;
String jsStr =
"function render(aaGlobalChart, point, text) {\n" +
" return aaGlobalChart.renderer.label(text + ': ' + point.y, point.plotX + aaGlobalChart.plotLeft -20 , point.plotY + aaGlobalChart.plotTop - 45, 'callout', point.plotX + aaGlobalChart.plotLeft, point.plotY + aaGlobalChart.plotTop)\n" +
" .css({\n" +
" color: '#FFFFFF',\n" +
" align: 'center',\n" +
" })\n" +
" .attr({\n" +
" fill: 'rgba(0, 0, 0, 0.75)',\n" +
" padding: 8,\n" +
" r: 5,\n" +
" zIndex: 6\n" +
" })\n" +
" .add();\n" +
" }\n" +
" function renderFirstSecondThirdLabel(aaGlobalChart) {\n" +
" var points = aaGlobalChart.series[0].points;\n" +
" render(aaGlobalChart, points[firstMaxNumberIndex], '第一名');\n" +
" render(aaGlobalChart, points[secondMaxNumberIndex], '第二名');\n" +
" render(aaGlobalChart, points[thirdMaxNumberIndex], '第三名');\n" +
" }\n" +
" \n" +
" renderFirstSecondThirdLabel(aaGlobalChart);";
String firstMaxNumberIndexStr = String.valueOf(firstMaxNumberIndex);
String secondMaxNumberIndexStr = String.valueOf(secondMaxNumberIndex);
String thirdMaxNumberIndexStr = String.valueOf(thirdMaxNumberIndex);
jsStr = jsStr.replace("firstMaxNumberIndex",firstMaxNumberIndexStr);
jsStr = jsStr.replace("secondMaxNumberIndex",secondMaxNumberIndexStr);
jsStr = jsStr.replace("thirdMaxNumberIndex",thirdMaxNumberIndexStr);
return jsStr;
}
String configureFirstSecondThirdStackLabelJSFunctionString() {
Integer firstMaxNumberIndex = 9;
Integer secondMaxNumberIndex = 1;
Integer thirdMaxNumberIndex = 11;
String jsStr =
"function render(aaGlobalChart, point, text,colorIndex) {\n" +
" var colorsArray = [\"#1e90ff\",\"#ef476f\",\"#ffd066\",];\n" +
" var colorHexString = colorsArray[colorIndex];\n" +
" return aaGlobalChart.renderer.label(' '+text, point.plotX + aaGlobalChart.plotLeft -20 , point.plotY + aaGlobalChart.plotTop - 60, 'callout', point.plotX + aaGlobalChart.plotLeft, point.plotY + aaGlobalChart.plotTop)\n" +
" .css({\n" +
" color: '#FFFFFF',\n" +
" align: 'center',\n" +
" weight: 'bold',\n" +
" })\n" +
" .attr({\n" +
" fill: colorHexString,\n" +
" padding: 8,\n" +
" r: 5,\n" +
" zIndex: 6\n" +
" })\n" +
" .add();\n" +
" }\n" +
" function renderFirstSecondThirdLabel(aaGlobalChart) {\n" +
" var points = aaGlobalChart.series[0].points;\n" +
" render(aaGlobalChart, points[firstMaxNumberIndex], '第一名',0);\n" +
" render(aaGlobalChart, points[secondMaxNumberIndex], '第二名',1);\n" +
" render(aaGlobalChart, points[thirdMaxNumberIndex], '第三名',2);\n" +
" }\n" +
" \n" +
" renderFirstSecondThirdLabel(aaGlobalChart);";
String firstMaxNumberIndexStr = String.valueOf(firstMaxNumberIndex);
String secondMaxNumberIndexStr = String.valueOf(secondMaxNumberIndex);
String thirdMaxNumberIndexStr = String.valueOf(thirdMaxNumberIndex);
jsStr = jsStr.replace("firstMaxNumberIndex",firstMaxNumberIndexStr);
jsStr = jsStr.replace("secondMaxNumberIndex",secondMaxNumberIndexStr);
jsStr = jsStr.replace("thirdMaxNumberIndex",thirdMaxNumberIndexStr);
return jsStr;
}
}
@@ -0,0 +1,210 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.RadioGroup;
import android.widget.Switch;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolStyleType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAMoveOverEventMessageModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
import com.example.anan.AAChartCore.R;
import com.google.gson.Gson;
public class HideOrShowChartSeriesActivity extends AppCompatActivity
implements
RadioGroup.OnCheckedChangeListener,
CompoundButton.OnCheckedChangeListener,
AAChartView.AAChartViewCallBack {
private AAChartModel aaChartModel;
private AAChartView aaChartView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hide_or_show_chart_series);
setUpRadioButtonsAndSwitches();
setUpAAChartView();
}
void setUpAAChartView() {
aaChartView = findViewById(R.id.AAChartView);
aaChartView.callBack = this;
aaChartModel = configureAAChartModel();
aaChartView.aa_drawChartWithChartModel(aaChartModel);
}
AAChartModel configureAAChartModel() {
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
int position = intent.getIntExtra("position",0);
AAChartModel aaChartModel = new AAChartModel()
.chartType(chartType)
.title("title")
.subtitle("subtitle")
.backgroundColor("#4b2b7f")
.dataLabelsEnabled(true)
.yAxisGridLineWidth(0f)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Tokyo")
.data(new Object[]{7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6}),
new AASeriesElement()
.name("NewYork")
.data(new Object[]{0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5}),
new AASeriesElement()
.name("London")
.data(new Object[]{0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0}),
new AASeriesElement()
.name("Berlin")
.data(new Object[]{3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8})
});
if (position == 4 || position == 5) {
aaChartModel.series(new AASeriesElement[]{
new AASeriesElement()
.name("Tokyo")
.step(true)
.data(new Object[]{149.9, 171.5, 106.4, 129.2, 144.0, 176.0, 135.6, 188.5, 276.4, 214.1, 95.6, 54.4})
,
new AASeriesElement()
.name("NewYork")
.step(true)
.data(new Object[]{83.6, 78.8, 188.5, 93.4, 106.0, 84.5, 105.0, 104.3, 131.2, 153.5, 226.6, 192.3})
,
new AASeriesElement()
.name("London")
.step(true)
.data(new Object[]{48.9, 38.8, 19.3, 41.4, 47.0, 28.3, 59.0, 69.6, 52.4, 65.2, 53.3, 72.2})
,
});
} else {
aaChartModel.series(new AASeriesElement[]{
new AASeriesElement()
.name("Tokyo")
.data(new Object[]{7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6}),
new AASeriesElement()
.name("NewYork")
.data(new Object[]{0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5}),
new AASeriesElement()
.name("London")
.data(new Object[]{0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0}),
new AASeriesElement()
.name("Berlin")
.data(new Object[]{3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8})
});
}
if (chartType.equals(AAChartType.Area)
|| chartType.equals(AAChartType.Arearange)) {
aaChartModel.markerSymbolStyle(AAChartSymbolStyleType.InnerBlank);
} else if (chartType.equals(AAChartType.Line)
||chartType.equals(AAChartType.Spline)) {
aaChartModel.markerSymbolStyle(AAChartSymbolStyleType.BorderBlank);
}
return aaChartModel;
}
void setUpRadioButtonsAndSwitches() {
RadioGroup radioGroup1 = findViewById(R.id.stackingTypeRadioGroup);
radioGroup1.setOnCheckedChangeListener(this);
RadioGroup radioGroup2 = findViewById(R.id.markerSymbolTypeRadioGroup);
radioGroup2.setOnCheckedChangeListener(this);
Switch boolSwitch1 = findViewById(R.id.switch1);
boolSwitch1.setOnCheckedChangeListener(this);
//
// Switch boolSwitch2 = findViewById(R.id.switch2);
// boolSwitch2.setOnCheckedChangeListener(this);
//
// Switch boolSwitch3 = findViewById(R.id.switch3);
// boolSwitch3.setOnCheckedChangeListener(this);
//
// Switch boolSwitch4 = findViewById(R.id.switch4);
// boolSwitch4.setOnCheckedChangeListener(this);
//
// Switch boolSwitch5 = findViewById(R.id.switch5);
// boolSwitch5.setOnCheckedChangeListener(this);
}
/**
* 重写的状态改变的事件的方法
* @param group 单选组合框
* @param checkedId 其中的每个RadioButton的Id
*/
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (group.getId() == R.id.stackingTypeRadioGroup) {
//根据不同ID 弹出不同的吐司
switch (group.getCheckedRadioButtonId()) {
case R.id.hide1: aaChartView.aa_hideTheSeriesElementContent(0);
break;
case R.id.hide2: aaChartView.aa_hideTheSeriesElementContent(1);
break;
case R.id.hide3: aaChartView.aa_hideTheSeriesElementContent(2);
break;
case R.id.hide4: aaChartView.aa_hideTheSeriesElementContent(3);
break;
}
} else {
switch (group.getCheckedRadioButtonId()) {
case R.id.show1: aaChartView.aa_showTheSeriesElementContent(0);
break;
case R.id.show2: aaChartView.aa_showTheSeriesElementContent(1);
break;
case R.id.show3: aaChartView.aa_showTheSeriesElementContent(2);
break;
case R.id.show4: aaChartView.aa_showTheSeriesElementContent(3);
break;
}
}
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.switch1: aaChartView.setChartSeriesHidden(isChecked);
break;
case R.id.switch2: aaChartView.setContentHeight(60f);
break;
case R.id.switch3: aaChartView.setContentWidth(80f);
break;
// case R.id.switch4: aaChartModel.polar(isChecked);
// break;
// case R.id.switch5: aaChartModel.dataLabelsEnabled(isChecked);
// break;
}
}
@Override
public void chartViewDidFinishLoad(AAChartView aaChartView) {
System.out.println("🔥图表加载完成回调方法!!!!!!!! ");
}
@Override
public void chartViewMoveOverEventMessage(AAChartView aaChartView, AAMoveOverEventMessageModel messageModel) {
Gson gson = new Gson();
System.out.println("🚀move over event message " + gson.toJson(messageModel));
}
}
@@ -0,0 +1,48 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.JSFunctionForAAAxisComposer.*;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.JSFunctionForAAAxisComposer.customYAxisLabels;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.example.anan.AAChartCore.R;
public class JSFunctionForAAAxisActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_tooltip_with_jsfunction);
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
AAOptions aaOptions = chartConfigurationWithSelectedIndex(chartType);
AAChartView aaChartView = findViewById(R.id.AAChartView);
aaChartView.aa_drawChartWithChartOptions(aaOptions);
}
AAOptions chartConfigurationWithSelectedIndex(String chartType) {
switch (chartType) {
case "customYAxisLabels": return customYAxisLabels();//自定义Y轴文字
case "customYAxisLabels2": return customYAxisLabels2();//自定义Y轴文字2
case "customAreaChartXAxisLabelsTextUnitSuffix1": return customAreaChartXAxisLabelsTextUnitSuffix1();//自定义X轴文字单位后缀(通过 formatter 函数)
case "customAreaChartXAxisLabelsTextUnitSuffix2": return customAreaChartXAxisLabelsTextUnitSuffix2();//自定义X轴文字单位后缀(不通过 formatter 函数)
case "configureTheAxesLabelsFormattersOfDoubleYAxesChart": return configureTheAxesLabelsFormattersOfDoubleYAxesChart();//配置双 Y 轴图表的 Y 轴文字标签的 Formatter 函数 示例 1
case "configureTheAxesLabelsFormattersOfDoubleYAxesChart2": return configureTheAxesLabelsFormattersOfDoubleYAxesChart2();//配置双 Y 轴图表的 Y 轴文字标签的 Formatter 函数 示例 2
case "configureTheAxesLabelsFormattersOfDoubleYAxesChart3": return configureTheAxesLabelsFormattersOfDoubleYAxesChart3();//配置双 Y 轴图表的 Y 轴文字标签的 Formatter 函数 示例 3
case "customColumnChartXAxisLabelsTextByInterceptTheFirstFourCharacters": return customColumnChartXAxisLabelsTextByInterceptTheFirstFourCharacters();//通过截取前四个字符来自定义 X 轴 labels
case "customSpiderChartStyle": return customSpiderChartStyle();//自定义蜘蛛🕷🕸图样式
case "customizeEveryDataLabelSinglelyByDataLabelsFormatter": return customizeEveryDataLabelSinglelyByDataLabelsFormatter();//通过 DataLabels 的 formatter 函数来实现单个数据标签🏷自定义
case "customXAxisLabelsBeImages": return customXAxisLabelsBeImages();//自定义 X轴 labels 为一组图片
default:
return customYAxisLabels();
}
}
}
@@ -0,0 +1,47 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.JSFunctionForAAChartEventsComposer.*;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.example.anan.AAChartCore.R;
public class JSFunctionForAAChartEventsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_tooltip_with_jsfunction);
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
AAOptions aaOptions = configureTheChartOptions(chartType);
AAChartView aaChartView = findViewById(R.id.AAChartView);
aaChartView.aa_drawChartWithChartOptions(aaOptions);
}
AAOptions configureTheChartOptions(String chartType) {
switch (chartType) {
case "setCrosshairAndTooltipToTheDefaultPositionAfterLoadingChart": return setCrosshairAndTooltipToTheDefaultPositionAfterLoadingChart(); //图表加载完成后,自动设置默认的十字准星和浮动提示框的位置
case "generalDrawingChart": return generalDrawingChart(); //自由绘图
case "advancedTimeLineChart": return advancedTimeLineChart(); //高级时间线图
case "configureBlinkMarkerChart": return configureBlinkMarkerChart(); //配置闪烁的标记点
case "configureSpecialStyleMarkerOfSingleDataElementChartWithBlinkEffect": return configureSpecialStyleMarkerOfSingleDataElementChartWithBlinkEffect(); //配置单个数据元素的特殊样式标记点即闪烁特效
case "configureScatterChartWithBlinkEffect": return configureScatterChartWithBlinkEffect(); //配置散点图的闪烁特效
case "automaticallyHideTooltipAfterItIsShown": return automaticallyHideTooltipAfterItIsShown(); //图表加载完成后,自动隐藏浮动提示框
case "dynamicHeightGridLineAreaChart": return dynamicHeightGridLineAreaChart(); //动态高度网格线的区域填充图
case "customizeYAxisPlotLinesLabelBeSpecialStyle": return customizeYAxisPlotLinesLabelBeSpecialStyle(); //自定义 Y 轴轴线上面的标签文字特殊样式
case "configureECGStyleChart": return configureECGStyleChart(); //配置 ECG 样式的图表
}
return null;
}
}
@@ -0,0 +1,40 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.JSFunctionForAALegendComposer.*;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.example.anan.AAChartCore.R;
public class JSFunctionForAALegendActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_tooltip_with_jsfunction);
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
AAOptions aaOptions = chartConfigurationWithSelectedIndex(chartType);
AAChartView aaChartView = findViewById(R.id.AAChartView);
aaChartView.aa_drawChartWithChartOptions(aaOptions);
}
AAOptions chartConfigurationWithSelectedIndex(String chartType) {
switch (chartType) {
case "disableLegendClickEventForNormalChart": return disableLegendClickEventForNormalChart();//禁用普通图表的图例点击事件
case "disableLegendClickEventForPieChart": return disableLegendClickEventForPieChart();//禁用饼图图表的图例点击事件
case "customLegendItemClickEvent": return customLegendItemClickEvent();//自定义图例点击事件
default:
return disableLegendClickEventForNormalChart();
}
}
}
@@ -0,0 +1,40 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.JSFunctionForAAOptionsComposer.*;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.example.anan.AAChartCore.R;
public class JSFunctionForAAOptionsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_tooltip_with_jsfunction);
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
AAOptions aaOptions = chartConfigurationWithSelectedIndex(chartType);
AAChartView aaChartView = findViewById(R.id.AAChartView);
aaChartView.aa_drawChartWithChartOptions(aaOptions);
}
AAOptions chartConfigurationWithSelectedIndex(String chartType) {
switch (chartType) {
case "customDoubleXAxesChart": return customDoubleXAxesChart();//自定义双 X 轴图表
case "disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction": return disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction();//禁用柱状图图表的选中状态
case "customizeEveryDataLabelSinglelyByDataLabelsFormatter": return customizeEveryDataLabelSinglelyByDataLabelsFormatter();//自定义每个数据点的数据标签内容
case "configureColorfulDataLabelsForPieChart": return configureColorfulDataLabelsForPieChart();//为饼图图表配置多彩的数据标签
default:
return customDoubleXAxesChart();
}
}
}
@@ -0,0 +1,67 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.JSFunctionForAATooltipComposer.*;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.example.anan.AAChartCore.R;
public class JSFunctionForAATooltipActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_tooltip_with_jsfunction);
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
AAOptions aaOptions = configureTheChartOptions(chartType);
AAChartView aaChartView = findViewById(R.id.AAChartView);
aaChartView.aa_drawChartWithChartOptions(aaOptions);
}
AAOptions configureTheChartOptions(String chartType) {
switch (chartType) {
case "customAreaChartTooltipStyleWithSimpleFormatString":
return customAreaChartTooltipStyleWithSimpleFormatString();//简单字符串拼接
case "customAreaChartTooltipStyleWithDifferentUnitSuffix":
return customAreaChartTooltipStyleWithDifferentUnitSuffix();//自定义不同单位后缀
case "customAreaChartTooltipStyleWithColorfulHtmlLabels":
return customAreaChartTooltipStyleWithColorfulHtmlLabels();//自定义多彩颜色文字
case "customLineChartTooltipStyleWhenValueBeZeroDoNotShow":
return customLineChartTooltipStyleWhenValueBeZeroDoNotShow();//值为0时,在tooltip中不显示
case "customBoxplotTooltipContent":
return customBoxplotTooltipContent();
case "customStackedAndGroupedColumnChartTooltip":
return customStackedAndGroupedColumnChartTooltip();
case "customArearangeChartTooltip":
return customArearangeChartTooltip();
case "customLineChartOriginalPointPositionByConfiguringXAxisFormatterAndTooltipFormatter":
return customLineChartOriginalPointPositionByConfiguringXAxisFormatterAndTooltipFormatter();
case "customTooltipWhichDataSourceComeFromOutSideRatherThanSeries":
return customTooltipWhichDataSourceComeFromOutSideRatherThanSeries();
case "customTooltipPostionerFunction":
return customTooltipPostionerFunction();//自定义浮动提示框 Positioner 函数
case "fixedTooltipPositionByCustomPositionerFunction":
return fixedTooltipPositionByCustomPositionerFunction();//通过 Positioner 函数来实现一个位置固定的提示框
case "customPlotAreaOutsideComlicatedTooltipStyle":
return customPlotAreaOutsideComlicatedTooltipStyle();//通过 Positioner 函数来实现绘图区外的复杂浮动提示框样式
case "disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction":
return disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction();//通过 Series 的 Point 的选中事件函数来禁用条形图反选效果
case "customAreasplineChartTooltipStyleByDivWithCSS":
return customAreasplineChartTooltipStyleByDivWithCSS();//通过自定义 div 的 css 样式来自定义复杂效果的 tooltip 浮动提示框
case "makePieChartShow0Data":
return makePieChartShow0Data();//使饼图显示为 0 的数据
case "customColumnChartBorderStyleAndStatesHoverColor":
return customColumnChartBorderStyleAndStatesHoverColor();//自定义📊柱状图的 border 样式和手指或鼠标 hover 时的显示效果
}
return customAreaChartTooltipStyleWithSimpleFormatString();
}
}
@@ -0,0 +1,164 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import android.content.Intent;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAOptionsConstructor;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartStackingType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.github.AAChartModel.AAChartCore.AATools.AAGradientColor;
import com.github.AAChartModel.AAChartCore.AATools.AALinearGradientDirection;
import com.example.anan.AAChartCore.R;
import java.util.Map;
public class OnlyRefreshChartDataActivity extends AppCompatActivity {
private AAChartModel aaChartModel;
private AAChartView aaChartView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_only_refresh_chart_data);
setUpAAChartView();
repeatUpdateChartData();
}
void setUpAAChartView() {
aaChartView = findViewById(R.id.AAChartView);
aaChartModel = configureAAChartModel();
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
if (aaChartModel.chartType.equals(AAChartType.Column)) {
aaOptions.plotOptions.column
.groupPadding(0f)
.pointPadding(0f)
.borderRadius(5f);
} else if (aaChartModel.chartType.equals(AAChartType.Bar)) {
aaOptions.plotOptions.bar
.groupPadding(0f)
.pointPadding(0f)
.borderRadius(5f);
}
aaChartView.aa_drawChartWithChartOptions(aaOptions);
}
private AAChartModel configureAAChartModel() {
AAChartModel aaChartModel = configureChartBasicContent();
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
AASeriesElement[] aaSeriesElementsArr = configureChartSeriesArray();
if (chartType.equals("stepArea") || chartType.equals("stepLine")) {
for (int i =0; i < aaSeriesElementsArr.length; i++ ) {
AASeriesElement aaSeriesElement = aaSeriesElementsArr[i];
aaSeriesElement.step(true);
}
}
aaChartModel.series(aaSeriesElementsArr);
return aaChartModel;
}
private AAChartModel configureChartBasicContent() {
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
if (chartType.equals("stepArea") ) {
chartType = AAChartType.Area;
} else if (chartType.equals("stepLine")) {
chartType = AAChartType.Line;
}
Map gradientColorMap1 = AAGradientColor.linearGradient(
AALinearGradientDirection.ToBottom,
"rgba(138,43,226,1)",
"rgba(30,144,255,1)"
);
Map gradientColorMap2 = AAGradientColor.linearGradient(
AALinearGradientDirection.ToBottom,
"#00BFFF",
"#00FA9A"
);
return new AAChartModel()
.chartType(chartType)
.xAxisVisible(true)
.yAxisVisible(false)
.yAxisTitle("摄氏度")
.colorsTheme(new Object[]{
gradientColorMap1,
gradientColorMap2,
AAGradientColor.Sanguine,
AAGradientColor.WroughtIron
})
.stacking(AAChartStackingType.Normal)
;
}
private AASeriesElement[] configureChartSeriesArray() {
int maxRange = 40;
Object[] numberArr1 = new Object[maxRange];
Object[] numberArr2 = new Object[maxRange];
double y1, y2;
int max = 38, min = 1;
int random = (int) (Math.random() * (max - min) + min);
for (int i = 0; i < maxRange; i++) {
y1 = Math.sin(random * (i * Math.PI / 180)) + i * 2 * 0.01;
y2 = Math.cos(random * (i * Math.PI / 180)) + i * 3 * 0.01;
numberArr1[i] = y1;
numberArr2[i] = y2;
}
AASeriesElement[] aaSeriesElementsArr = new AASeriesElement[]{
new AASeriesElement()
.name("2017")
.data(numberArr1),
new AASeriesElement()
.name("2018")
.data(numberArr2),
new AASeriesElement()
.name("2019")
.data(numberArr1),
new AASeriesElement()
.name("2020")
.data(numberArr2),
};
return aaSeriesElementsArr;
}
void repeatUpdateChartData() {
final Handler mHandler = new Handler();
Runnable r = new Runnable() {
@Override
public void run() {
AASeriesElement[] aaSeriesElementsArr = configureChartSeriesArray();
aaChartView.aa_onlyRefreshTheChartDataWithChartOptionsSeriesArray(aaSeriesElementsArr);
//每隔1s循环执行run方法
mHandler.postDelayed(this, 1000);
}
};
mHandler.postDelayed(r, 2000);//延时2000毫秒
}
}
@@ -0,0 +1,261 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAOptionsConstructor;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartAnimationType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolStyleType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAChart;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AADataElement;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAScrollablePlotArea;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AASubtitle;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AATitle;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAXAxis;
import com.github.AAChartModel.AAChartCore.AATools.AAJSStringPurer;
import com.example.anan.AAChartCore.R;
public class ScrollableChartActivity extends AppCompatActivity {
private AAChartView aaChartView1;
private AAChartModel aaChartModel;
private AAOptions aaOptions;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scollable_chart);
aaChartView1 = findViewById(R.id.AAChartView1);
AAChartModel aaChartModel = configureChartModel();
if (aaOptions == null) {
aaOptions = aaChartModel.aa_toAAOptions();
}
aaChartView1.aa_drawChartWithChartOptions(aaOptions);
}
private AAChartModel configureChartModel() {
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
int position = intent.getIntExtra("position",0);
AAChartModel aaChartModel = new AAChartModel()
.chartType(chartType)
.legendEnabled(false)
.yAxisGridLineWidth(0f)
.scrollablePlotArea(
new AAScrollablePlotArea()
.minWidth(3000)
.scrollPositionX(1f)
)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Tokyo")
.data(configureSeriesDataArray())
});
this.aaChartModel = aaChartModel;
configureTheStyleForDifferentTypeChart(chartType,position);
return aaChartModel;
}
void configureTheStyleForDifferentTypeChart(String chartType,int position) {
if ((chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Line))
&& (position == 93 || position == 94)) {
configureStepAreaChartAndStepLineChart();
} else if (chartType.equals(AAChartType.Column) || chartType.equals(AAChartType.Bar)) {
configureColumnChartAndBarChartStyle();
} else if (chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Areaspline)) {
configureAreaChartAndAreasplineChartStyle(chartType);
} else if (chartType.equals(AAChartType.Line) || chartType.equals(AAChartType.Spline)) {
configureLineChartAndSplineChartStyle(chartType);
}
}
private void configureStepAreaChartAndStepLineChart() {
AASeriesElement element1 = new AASeriesElement()
.name("Tokyo")
.step(true)
.data(new Object[]{149.9, 171.5, 106.4, 129.2, 144.0, 176.0, 135.6, 188.5, 276.4, 214.1, 95.6, 54.4});
AASeriesElement element2 = new AASeriesElement()
.name("NewYork")
.step(true)
.data(new Object[]{83.6, 78.8, 188.5, 93.4, 106.0, 84.5, 105.0, 104.3, 131.2, 153.5, 226.6, 192.3});
AASeriesElement element3 = new AASeriesElement()
.name("London")
.step(true)
.data(new Object[]{48.9, 38.8, 19.3, 41.4, 47.0, 28.3, 59.0, 69.6, 52.4, 65.2, 53.3, 72.2});
aaChartModel.series(new AASeriesElement[]{element1, element2, element3});
}
private void configureColumnChartAndBarChartStyle() {
if (aaChartModel.chartType.equals(AAChartType.Bar) ) {
String pureJSStr = AAJSStringPurer.pureJavaScriptFunctionString(
"Source: <a href=\"https://highcharts.uservoice.com/forums/55896-highcharts-javascript-api\">UserVoice</a>");
AASeriesElement element = new AASeriesElement()
.data(new Object[][]{
{"Gantt chart", 1000},
{"Autocalculation and plotting of trend lines", 575},
{"Allow navigator to have multiple data series", 523},
{"Implement dynamic font size", 427},
{"Multiple axis alignment control", 399},
{"Stacked area (spline etc) in irregular datetime series", 309},
{"Adapt chart height to legend height", 278},
{"Export charts in excel sheet", 239},
{"Toggle legend box", 235},
{"Venn Diagram", 203},
{"Add ability to change Rangeselector position", 182},
{"Draggable legend box", 157},
{"Sankey Diagram", 149},
{"Add Navigation bar for Y-Axis in Highstock", 144},
{"Grouped x-axis", 143},
{"ReactJS plugin", 137},
{"3D surface charts", 134},
{"Draw lines over a stock chart, for analysis purpose", 118},
{"Data module for database tables", 118},
{"Draggable points", 117}
});
AAOptions aaOptions = new AAOptions()
.chart(new AAChart()
.type(AAChartType.Bar)
.scrollablePlotArea(
new AAScrollablePlotArea()
.minHeight(900)
))
.title(new AATitle()
.text("Most popular ideas by April 2016"))
.subtitle(new AASubtitle()
.text(pureJSStr))
.xAxis(new AAXAxis()
.type("category"))
.series(new AASeriesElement[]{element});
this.aaOptions = aaOptions;
} else {
aaChartModel
.categories(new String[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"})
.legendEnabled(true)
.colorsTheme(new String[]{"#fe117c","#ffc069","#06caf4","#7dffc0"})
.animationType(AAChartAnimationType.EaseOutCubic)
.animationDuration(1200);
}
}
private void configureAreaChartAndAreasplineChartStyle(String chartType) {
aaChartModel
.animationType(AAChartAnimationType.EaseOutQuart)
.legendEnabled(true)
.markerRadius(5f)
.markerSymbol(AAChartSymbolType.Circle)
.markerSymbolStyle(AAChartSymbolStyleType.InnerBlank);
if (chartType.equals(AAChartType.Areaspline)) {
AASeriesElement element1 = new AASeriesElement()
.name("Predefined symbol")
.data(new Object[]{0.45, 0.43, 0.50, 0.55, 0.58, 0.62, 0.83, 0.39, 0.56, 0.67, 0.50, 0.34, 0.50, 0.67, 0.58, 0.29, 0.46, 0.23, 0.47, 0.46, 0.38, 0.56, 0.48, 0.36});
AASeriesElement element2 = new AASeriesElement()
.name("Image symbol")
.data(new Object[]{0.38, 0.31, 0.32, 0.32, 0.64, 0.66, 0.86, 0.47, 0.52, 0.75, 0.52, 0.56, 0.54, 0.60, 0.46, 0.63, 0.54, 0.51, 0.58, 0.64, 0.60, 0.45, 0.36, 0.67});
AASeriesElement element3 = new AASeriesElement()
.name("Base64 symbol (*)")
.data(new Object[]{0.46, 0.32, 0.53, 0.58, 0.86, 0.68, 0.85, 0.73, 0.69, 0.71, 0.91, 0.74, 0.60, 0.50, 0.39, 0.67, 0.55, 0.49, 0.65, 0.45, 0.64, 0.47, 0.63, 0.64});
AASeriesElement element4 = new AASeriesElement()
.name("Custom symbol")
.data(new Object[]{0.60, 0.51, 0.52, 0.53, 0.64, 0.84, 0.65, 0.68, 0.63, 0.47, 0.72, 0.60, 0.65, 0.74, 0.66, 0.65, 0.71, 0.59, 0.65, 0.77, 0.52, 0.53, 0.58, 0.53});
aaChartModel
.animationType(AAChartAnimationType.EaseFrom)//设置图表渲染动画类型为 EaseFrom
.series(new AASeriesElement[]{element1, element2, element3, element4});
}
}
private void configureLineChartAndSplineChartStyle(String chartType) {
aaChartModel
.markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//设置折线连接点样式为:边缘白色
.markerRadius(6f);
if (chartType.equals(AAChartType.Line)) {
AASeriesElement element1 = new AASeriesElement()
.name("Hestavollane")
.data(new Object[]{0.2, 0.8, 0.8, 0.8, 1, 1.3, 1.5, 2.9, 1.9, 2.6, 1.6, 3, 4, 3.6,
5.5, 6.2, 5.5, 4.5, 4, 3.1, 2.7, 4, 2.7, 2.3, 2.3, 4.1, 7.7, 7.1,
5.6, 6.1, 5.8, 8.6, 7.2, 9, 10.9, 11.5, 11.6, 11.1, 12, 12.3, 10.7,
9.4, 9.8, 9.6, 9.8, 9.5, 8.5, 7.4, 7.6});
AASeriesElement element2 = new AASeriesElement()
.name("Vik")
.data(new Object[]{0, 0, 0.6, 0.9, 0.8, 0.2, 0, 0, 0, 0.1, 0.6, 0.7, 0.8, 0.6, 0.2,
0, 0.1, 0.3, 0.3, 0, 0.1, 0, 0, 0, 0.2, 0.1, 0, 0.3, 0, 0.1, 0.2,
0.1, 0.3, 0.3, 0, 3.1, 3.1, 2.5, 1.5, 1.9, 2.1, 1, 2.3, 1.9, 1.2,
0.7, 1.3, 0.4, 0.3});
aaChartModel
.series(new AASeriesElement[]{element1,element2});
} else if (chartType.equals(AAChartType.Spline)) {
AASeriesElement element1 = new AASeriesElement()
.name("Tokyo")
.lineWidth(7f)
.data(new Object[]{50, 320, 230, 370, 230, 400,});
AASeriesElement element2 = new AASeriesElement()
.name("Berlin")
.lineWidth(7f)
.data(new Object[]{80, 390, 210, 340, 240, 350,});
AASeriesElement element3 = new AASeriesElement()
.name("New York")
.lineWidth(7f)
.data(new Object[]{100, 370, 180, 280, 260, 300,});
AASeriesElement element4 = new AASeriesElement()
.name("London")
.lineWidth(7f)
.data(new Object[]{130, 350, 160, 310, 250, 268,});
aaChartModel
.animationType(AAChartAnimationType.SwingFromTo)
.series(new AASeriesElement[]{element1, element2, element3, element4});
}
}
private AADataElement[] configureSeriesDataArray() {
int maxRange = 388;
AADataElement[] numberArr1 = new AADataElement[maxRange];
double y1;
int max = 38, min = 1;
int random = (int) (Math.random() * (max - min) + min);
for (int i = 0; i < maxRange; i++) {
y1 = Math.sin(random * (i * Math.PI / 180)) + i * 2 * 0.01;
AADataElement aaDataElement = new AADataElement()
.y((float) y1);
numberArr1[i] = aaDataElement;
}
return numberArr1;
}
}
@@ -0,0 +1,15 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.anan.AAChartCore.R;
public class ScrollingUpdateDataActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling_update_data);
}
}
@@ -0,0 +1,70 @@
package com.example.anan.AAChartCore.ChartsDemo.AdditionalContent;
import android.graphics.Color;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import com.example.anan.AAChartCore.R;
public class UpdateChartBackgroundColorActivity extends AppCompatActivity {
private Button lastSelectedBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update_chart_background_color);
}
void setupUpdateBackgroundColorButtons() {
String[] titleArr = new String[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
int titleArrLength = titleArr.length;
//获取屏幕大小,以合理设定 按钮 大小及位置
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = 100;
//自定义layout组件
RelativeLayout layout = new RelativeLayout(this);
int j = -1;
for (int i = 0; i < titleArrLength; i++) {
Button btn = new Button(this);
btn.setId(i);
btn.setText(titleArr[i]);
RelativeLayout.LayoutParams btnParams = new RelativeLayout.LayoutParams((width - 50) / 4, height); //设置按钮的宽度和高度
//每行放置4个按钮
if (i % 4 == 0) {
j++;
}
btnParams.leftMargin = 10 + ((width - 50) / 4 + 10) * (i % 4); //横坐标定位
btnParams.topMargin = 20 + height * j; //纵坐标定位
layout.addView(btn,btnParams); //将按钮放入layout组件
btn.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View btn) {
int id = btn.getId();
if (lastSelectedBtn != null && id != lastSelectedBtn.getId()) {
lastSelectedBtn.setBackgroundColor(Color.GRAY);
}
btn.setBackgroundColor(Color.RED);
lastSelectedBtn = (Button) btn;
}
});
}
this.setContentView(layout);
}
}
@@ -0,0 +1,209 @@
package com.example.anan.AAChartCore.ChartsDemo.MainContent;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.RadioGroup;
import android.widget.Switch;
import android.widget.TextView;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartStackingType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAMoveOverEventMessageModel;
import com.example.anan.AAChartCore.ChartsDemo.chartcomposer.BasicChartComposer;
import com.example.anan.AAChartCore.R;
import com.google.gson.Gson;
public class BasicChartActivity extends AppCompatActivity
implements
RadioGroup.OnCheckedChangeListener,
CompoundButton.OnCheckedChangeListener,
AAChartView.AAChartViewCallBack
{
public AAChartModel aaChartModel;
public AAChartView aaChartView;
public String chartType;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_basic_chart);
setUpRadioButtonsAndSwitches();
setUpAAChartView();
}
void setUpAAChartView() {
aaChartView = findViewById(R.id.AAChartView);
aaChartView.callBack = this;
aaChartModel = configureAAChartModel();
aaChartView.aa_drawChartWithChartModel(aaChartModel);
}
AAChartModel configureAAChartModel() {
Intent intent = getIntent();
chartType = intent.getStringExtra("chartType");
int position = intent.getIntExtra("position",0);
aaChartModel = BasicChartComposer.configureAreaChart();
configureTheStyleForDifferentTypeChart(chartType,position);
configureViewsVisibility(chartType);
return aaChartModel;
}
void configureTheStyleForDifferentTypeChart(String chartType,int position) {
if ((chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Line))
&& (position == 4 || position == 5)) {
aaChartModel = BasicChartComposer.configureStepAreaChartAndStepLineChart();
} else if (chartType.equals(AAChartType.Column) || chartType.equals(AAChartType.Bar)) {
aaChartModel = BasicChartComposer.configureColumnChartAndBarChart();
} else if (chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Areaspline)) {
aaChartModel = BasicChartComposer.configureAreaChartAndAreasplineChartStyle(chartType);
} else if (chartType.equals(AAChartType.Line) || chartType.equals(AAChartType.Spline)) {
aaChartModel = BasicChartComposer.configureLineChartAndSplineChartStyle(chartType);
}
aaChartModel.chartType = chartType;
}
void configureViewsVisibility(String chartType) {
RadioGroup squareCornersRadio = findViewById(R.id.cornerStyleTypeRadioGroup);
RadioGroup markerSymbolTypeRadioGroup = findViewById(R.id.markerSymbolTypeRadioGroup);
if (chartType.equals(AAChartType.Column) || chartType.equals(AAChartType.Bar)) {
squareCornersRadio.setVisibility(View.VISIBLE);
markerSymbolTypeRadioGroup.setVisibility(View.GONE);
Switch markerHideSwitch = findViewById(R.id.markerHideSwitch);
markerHideSwitch.setVisibility(View.GONE);
TextView markerHideTextView = findViewById(R.id.markerHideTextView);
markerHideTextView.setVisibility(View.GONE);
} else {
squareCornersRadio.setVisibility(View.GONE);
markerSymbolTypeRadioGroup.setVisibility(View.VISIBLE);
}
}
void setUpRadioButtonsAndSwitches() {
RadioGroup stackingTypeRadioGroup = findViewById(R.id.stackingTypeRadioGroup);
stackingTypeRadioGroup.setOnCheckedChangeListener(this);
RadioGroup cornerStyleTypeRadioGroup = findViewById(R.id.cornerStyleTypeRadioGroup);
cornerStyleTypeRadioGroup.setOnCheckedChangeListener(this);
RadioGroup markerSymbolTypeRadioGroup = findViewById(R.id.markerSymbolTypeRadioGroup);
markerSymbolTypeRadioGroup.setOnCheckedChangeListener(this);
Switch boolSwitch1 = findViewById(R.id.xReversedSwitch);
boolSwitch1.setOnCheckedChangeListener(this);
Switch boolSwitch2 = findViewById(R.id.yReversedSwitch);
boolSwitch2.setOnCheckedChangeListener(this);
Switch boolSwitch3 = findViewById(R.id.polarSwitch);
boolSwitch3.setOnCheckedChangeListener(this);
Switch boolSwitch4 = findViewById(R.id.xInvertedSwitch);
boolSwitch4.setOnCheckedChangeListener(this);
Switch boolSwitch5 = findViewById(R.id.dataShowSwitch);
boolSwitch5.setOnCheckedChangeListener(this);
Switch boolSwitch6 = findViewById(R.id.markerHideSwitch);
boolSwitch6.setOnCheckedChangeListener(this);
}
/**
* 重写的状态改变的事件的方法
* @param group 单选组合框
* @param checkedId 其中的每个RadioButton的Id
*/
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (group.getId() == R.id.stackingTypeRadioGroup) {
switch (group.getCheckedRadioButtonId()) {
case R.id.noStackingRadio:
aaChartModel.stacking(AAChartStackingType.False);
break;
case R.id.normalStackingRadio:
aaChartModel.stacking(AAChartStackingType.Normal);
break;
case R.id.percentStackingRadio:
aaChartModel.stacking(AAChartStackingType.Percent);
break;
}
} else if (group.getId() == R.id.cornerStyleTypeRadioGroup) {
switch (group.getCheckedRadioButtonId()) {
case R.id.squareCornersRadio:
aaChartModel.borderRadius(1f);
break;
case R.id.roundedCornersRadio:
aaChartModel.borderRadius(10f);
break;
case R.id.wedgeCornersRadio:
aaChartModel.borderRadius(100f);
break;
}
} else {
switch (group.getCheckedRadioButtonId()) {
case R.id.circleSymbolRadio:
aaChartModel.markerSymbol(AAChartSymbolType.Circle);
break;
case R.id.squareSymbolRadio:
aaChartModel.markerSymbol(AAChartSymbolType.Square);
break;
case R.id.diamondSymbolRadio:
aaChartModel.markerSymbol(AAChartSymbolType.Diamond);
break;
case R.id.triangleSymbolRadio:
aaChartModel.markerSymbol(AAChartSymbolType.Triangle);
break;
case R.id.triangleDownSymbolRadio:
aaChartModel.markerSymbol(AAChartSymbolType.Triangle_down);
break;
}
}
aaChartView.aa_refreshChartWithChartModel(aaChartModel);
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.xReversedSwitch: aaChartModel.xAxisReversed(isChecked);
break;
case R.id.yReversedSwitch: aaChartModel.yAxisReversed(isChecked);
break;
case R.id.xInvertedSwitch: aaChartModel.inverted(isChecked);
break;
case R.id.polarSwitch: aaChartModel.polar(isChecked);
break;
case R.id.dataShowSwitch: aaChartModel.dataLabelsEnabled(isChecked);
break;
case R.id.markerHideSwitch: aaChartModel.markerRadius(isChecked ? 0f : 6f);
}
aaChartView.aa_refreshChartWithChartModel(aaChartModel);
}
@Override
public void chartViewDidFinishLoad(AAChartView aaChartView) {
System.out.println("🔥🔥🔥🔥🔥图表加载完成回调方法!!!!!!!! ");
}
@Override
public void chartViewMoveOverEventMessage(AAChartView aaChartView, AAMoveOverEventMessageModel messageModel) {
Gson gson = new Gson();
System.out.println("👌👌👌👌👌move over event message " + gson.toJson(messageModel));
}
}
@@ -0,0 +1,141 @@
package com.example.anan.AAChartCore.ChartsDemo.MainContent;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.example.anan.AAChartCore.R;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.CustomStyleChartComposer.*;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.CustomStyleChartComposer.configureColorfulChart;
public class CustomStyleChartActivity extends AppCompatActivity {
private AAChartModel aaChartModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_style_chart);
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
aaChartModel = configureTheAAChartModel(chartType);
AAChartView aaChartView = findViewById(R.id.AAChartView);
aaChartView.aa_drawChartWithChartModel(aaChartModel);
}
private AAChartModel configureTheAAChartModel(String chartType) {
switch (chartType) {
case "colorfulChart":
return configureColorfulChart();
case "gradientColorfulChart":
return configureColorfulGradientColorChart();
case "discontinuousDataChart":
return configureDiscontinuousDataChart();
case "colorfulColumnChart":
return configureColorfulColumnChart();
case "nightingaleRoseChart":
return configureNightingaleRoseChart();
case "chartWithShadowStyle":
return configureChartWithShadowStyle();
case "colorfulGradientAreaChart":
return configureColorfulGradientAreaChart();
case "colorfulGradientSplineChart":
return configureColorfulGradientSplineChart();
case "gradientColorAreasplineChart":
return configureGradientColorAreasplineChart();
case "SpecialStyleMarkerOfSingleDataElementChart":
return configureSpecialStyleMarkerOfSingleDataElementChart();
case "SpecialStyleColumnOfSingleDataElementChart":
return configureSpecialStyleColumnOfSingleDataElementChart();
case "AreaChartThreshold":
return configureAreaChartThreshold();
case "customScatterChartMarkerSymbolContent":
return customScatterChartMarkerSymbolContent();
case "customLineChartMarkerSymbolContent":
return customLineChartMarkerSymbolContent();
case "TriangleRadarChart":
return configureTriangleRadarChart();
case "QuadrangleRadarChart":
return configureQuadrangleRadarChart();
case "PentagonRadarChart":
return configurePentagonRadarChart();
case "HexagonRadarChart":
return configureHexagonRadarChart();
case "adjustYAxisMaxAndMinValues":
return adjustYAxisMaxAndMinValues();
case "customSpecialStyleDataLabelOfSingleDataElementChart":
return customSpecialStyleDataLabelOfSingleDataElementChart();
case "customBarChartHoverColorAndSelectColor":
return customBarChartHoverColorAndSelectColor();
case "customChartHoverAndSelectHaloStyle":
return customChartHoverAndSelectHaloStyle();
case "customSplineChartMarkerStatesHoverStyle":
return customSplineChartMarkerStatesHoverStyle();
case "splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle":
return splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle();
case "customNormalStackingChartDataLabelsContentAndStyle":
return customNormalStackingChartDataLabelsContentAndStyle();
case "upsideDownPyramidChart":
return upsideDownPyramidChart();
case "doubleLayerPieChart":
return doubleLayerPieChart();
case "disableSomeOfLinesMouseTrackingEffect":
return disableSomeOfLinesMouseTrackingEffect();
case "configureColorfulShadowSplineChart":
return configureColorfulShadowSplineChart();
case "configureColorfulDataLabelsStepLineChart":
return configureColorfulDataLabelsStepLineChart();
case "configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart":
return configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart();
case "disableSplineChartMarkerHoverEffect":
return disableSplineChartMarkerHoverEffect();
case "configureMaxAndMinDataLabelsForChart":
return configureMaxAndMinDataLabelsForChart();
case "customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag":
return customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag();
case "noMoreGroupingAndOverlapEachOtherColumnChart":
return noMoreGroupingAndOverlapEachOtherColumnChart();
case "noMoreGroupingAndNestedColumnChart":
return noMoreGroupingAndNestedColumnChart();
case "topRoundedCornersStackingColumnChart":
return topRoundedCornersStackingColumnChart();
case "freeStyleRoundedCornersStackingColumnChart":
return freeStyleRoundedCornersStackingColumnChart();
case "customColumnChartBorderStyleAndStatesHoverColor":
return customColumnChartBorderStyleAndStatesHoverColor();
case "customLineChartWithColorfulMarkersAndLines":
return customLineChartWithColorfulMarkersAndLines();
case "customLineChartWithColorfulMarkersAndLines2":
return customLineChartWithColorfulMarkersAndLines2();
case "drawLineChartWithPointsCoordinates":
return drawLineChartWithPointsCoordinates();
case "configureSpecialStyleColumnForNegativeDataMixedPositiveData":
return configureSpecialStyleColumnForNegativeDataMixedPositiveData();
case "configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart":
return configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart();
case "connectNullsForSingleAASeriesElement":
return connectNullsForSingleAASeriesElement();
case "lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement":
return lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement();
case "customAreasplineChartWithColorfulGradientColorZones":
return customAreasplineChartWithColorfulGradientColorZones();
case "largeDataStackingColumnChart":
return largeDataStackingColumnChart();
}
return configureColorfulChart();
}
}
@@ -0,0 +1,721 @@
package com.example.anan.AAChartCore.ChartsDemo.MainContent;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.Toast;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.AdvancedUpdatingFeatureActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.DoubleChartsLinkedWorkActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.JSFunctionForAAAxisActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.JSFunctionForAALegendActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.JSFunctionForAAOptionsActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.JSFunctionForAATooltipActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.DrawChartWithAAOptionsActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.EvaluateJSStringFunctionActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.HideOrShowChartSeriesActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.JSFunctionForAAChartEventsActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.OnlyRefreshChartDataActivity;
import com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.ScrollableChartActivity;
import com.example.anan.AAChartCore.R;
public class MainActivity extends AppCompatActivity {
private static final String kChartTypeKey = "chartType";
private String[][] chartTypeNameArr = {
/*基础类型图表*/
{
"Column Chart---柱形图",
"Bar Chart---条形图",
"Area Chart---折线填充图",
"Areaspline Chart---曲线填充图",
"Step Area Chart--- 直方折线填充图",
"Step Line Chart--- 直方折线图",
"Line Chart---折线图",
"Spline Chart---曲线图",
},
/*特殊类型图表*/
{
"Polar Column Chart---玫瑰图",
"Polar Bar Chart---径向条形图",
"Polar Line Chart---蜘蛛图",
"Polar Area Chart---雷达图",
"Step Line Chart--- 直方折线图",
"Step Area Chart--- 直方折线填充图",
"Pie Chart---扇形图",
"Bubble Chart---气泡图",
"Scatter Chart---散点图",
"Arearange Chart---区域范围图",
"Columnrange Chart--- 柱形范围图",
"Boxplot Chart--- 箱线图",
"Waterfall Chart--- 瀑布图",
"Pyramid Chart---金字塔图",
"Funnel Chart---漏斗图",
"Errorbar Chart---误差图",
"Gauge Chart---仪表图",
"Polygon Chart---多边形图"
},
/*Mixed Chart---混合图*/
{
"arearangeMixedLine---区域范围填充图混合折线图",
"columnrangeMixedLine---柱形范围填充图混合折线图",
"stackingColumnMixedLine---堆积柱形填充图混合折线图",
"dashStyleTypeMixed---虚线风格混合折线图",
"negativeColorMixed---负数颜色混合折线图",
"scatterMixedLine---散点图混合折线图",
"negativeColorMixedBubble---负数颜色混合气泡图",
"polygonMixedScatter---多边形图混合散点图",
"polarChartMixed---极地图混合图",
"configurePieMixedLineMixedColumnChart---配置饼图混合折线柱形图",
"configureNegativeColorMixedAreasplineChart---配置负数颜色混合曲线填充图",
"configureAerasplinerangeMixedColumnrangeMixedLineChart---配置曲线填充图混合柱形范围填充图混合折线图",
},
/*自定义样式图表*/
{
"colorfulChart---彩色图",
"gradientColorfulChart---渐变色图",
"discontinuousDataChart---数值不连续图",
"colorfulColumnChart---彩色柱形图",
"nightingaleRoseChart---南丁格尔玫瑰图",
"chartWithShadowStyle---带阴影样式图表",
"colorfulGradientAreaChart---彩色渐变填充图",
"colorfulGradientSplineChart---彩色渐变曲线图",
"gradientColorAreasplineChart---渐变色填充图",
"SpecialStyleMarkerOfSingleDataElementChart---单个数据元素 marker 特殊样式图表",
"SpecialStyleColumnOfSingleDataElementChart---单个数据元素特殊样式柱形图",
"AreaChartThreshold---区域图阈值",
"customScatterChartMarkerSymbolContent---自定义散点图 marker 特殊样式图表",
"customLineChartMarkerSymbolContent---自定义折线图 marker 特殊样式图表",
"TriangleRadarChart---三角形雷达图",
"QuadrangleRadarChart---四边形雷达图",
"PentagonRadarChart---五边形雷达图",
"HexagonRadarChart---六边形雷达图",
"adjustYAxisMaxAndMinValues---调整 X 轴和 Y 轴最大值",
"custom Special Style DataLabel Of Single Data Element Chart---指定单个数据元素的 DataLabel 为特殊样式",
"custom Bar Chart Hover Color and Select Color---自定义条形图手指滑动颜色和单个长条被选中颜色",
"custom Line Chart Chart Hover And Select Halo Style---自定义直线图手指略过和选中的 Halo 样式",
"custom Spline Chart Marker States Hover Style---自定义曲线图手指略过时的 Marker 样式",
"splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle---曲线图手指掠过时的线条不变化且自定义 Marker 样式",
"customNormalStackingChartDataLabelsContentAndStyle---自定义堆积柱状图 DataLabels 的内容及样式",
"upsideDownPyramidChart---倒立的金字塔图",
"doubleLayerPieChart---双层嵌套扇形图",
"disableSomeOfLinesMouseTrackingEffect---针对部分数据列关闭鼠标或手指跟踪行为",
"configureColorfulShadowChart---彩色阴影效果的曲线图",
"configureColorfulDataLabelsStepLineChart---彩色 DataLabels 的直方折线图",
"configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart---彩色渐变效果且彩色 DataLabels 的直方折线填充图",
"disableSplineChartMarkerHoverEffect---禁用曲线图的手指滑动 marker 点的光圈变化放大的效果",
"configureMaxAndMinDataLabelsForChart---为图表最大值最小值添加 DataLabels 标记",
"customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag---通过 HTML 的换行标签来实现图表的 X 轴的 分类文字标签的换行效果",
"noMoreGroupingAndOverlapEachOtherColumnChart---不分组的相互重叠柱状图📊",
"noMoreGroupingAndNestedColumnChart---不分组的嵌套柱状图📊",
"topRoundedCornersStackingColumnChart---顶部为圆角的堆积柱状图📊",
"freeStyleRoundedCornersStackingColumnChart---各个圆角自由独立设置的堆积柱状图📊",
"customColumnChartBorderStyleAndStatesHoverColor---自定义柱状图 border 样式及手指掠过图表 series 元素时的柱形颜色",
"customLineChartWithColorfulMarkersAndLines---彩色连接点和连接线的折线图📈",
"customLineChartWithColorfulMarkersAndLines2---彩色连接点和连接线的多组折线的折线图📈",
"drawLineChartWithPointsCoordinates---通过点坐标来绘制折线图",
"configureSpecialStyleColumnForNegativeDataMixedPositiveData---为正负数混合的柱形图自定义特殊样式效果",
"configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart---多层次半透明渐变效果的曲线填充图混合折线图📈",
"connectNullsForSingleAASeriesElement---为单个 AASeriesElement 单独设置是否断点重连",
"lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement---不同 series 元素数据量差异较大的折线图📈",
"customAreasplineChartWithColorfulGradientColorZones---彩色分区渐变填充区域图📈",
"largeDataStackingColumnChart---大数据量的堆积柱状图📊",
},
/*使用AAOptions绘制图表*/
{
"customLegendStyle",
"drawChartWithOptionsOne",
"AAPlotLinesForChart",
"customAATooltipWithJSFunction",
"customXAxisCrosshairStyle",
"XAxisLabelsFontColorWithHTMLString",
"XAxisLabelsFontColorAndFontSizeWithHTMLString",
"_DataLabels_XAXis_YAxis_Legend_Style",
"XAxisPlotBand",
"configureTheMirrorColumnChart",
"configureDoubleYAxisChartOptions",
"configureTripleYAxesMixedChart",
"customLineChartDataLabelsFormat",
"configureDoubleYAxesAndColumnLineMixedChart",
"configureDoubleYAxesMarketDepthChart",
"customAreaChartTooltipStyleLikeHTMLTable",
"simpleGaugeChart",
"gaugeChartWithPlotBand",
"doubleLayerHalfPieChart",
"customAreasplineChartTooltipContentWithHeaderFormat---通过 tooltip 的 headerFormat 属性来自定义 曲线填充图的 tooltip",
"customAreaChartTooltipStyleWithTotalValueHeader---浮动提示框 header 显示总值信息",
"configureYAxisLabelsNumericSymbolsMagnitudeOfAerasplineChart---自定义 Y 轴的 Labels 国际单位符基数及国际单位符",
"timeDataWithIrregularIntervalsChart---X 轴时间不连续的折线图",
"logarithmicAxisLineChart---对数轴折线图📈",
"logarithmicAxisScatterChart---对数轴散点图",
"disableMixedChartInactiveAnimationEffect---禁用混合图表的 inactive 动画效果",
"adjustBubbleChartMinAndMax---调整气泡图的 min 和 max 相关属性",
"customLineChartDataLabelsFormat---自定义曲线图的 DataLabels 的 format 属性",
"customLineChartDataLabelsFormat2---自定义曲线图的 DataLabels 的 format 属性(更简易方法)",
"complicatedScatterChart---复杂的自定义散点图",
"customColumnrangeChartGroupStyleAndSeriesStatesHoverColor---自定义柱状图 group 样式及 series 元素时的柱形颜色",
"customTitleStyle---自定义标题样式",
"configureBoxplotChartWithSpecialStyle---自定义盒须图样式",
},
/*即时刷新📈📊图表数据*/
{
"Column Chart---柱形图",
"Bar Chart---条形图",
"Area Chart---折线填充图",
"Areaspline Chart---曲线填充图",
"Step Area Chart--- 直方折线填充图",
"Step Line Chart--- 直方折线图",
"Line Chart---折线图",
"Spline Chart---曲线图",
"Scatter Chart---散点图",},
/*图表高级更新功能*/
{
"Column Chart---柱形图",
"Bar Chart---条形图",
"Area Chart---折线填充图",
"Areaspline Chart---曲线填充图",
"Step Area Chart--- 直方折线填充图",
"Step Line Chart--- 直方折线图",
"Line Chart---折线图",
"Spline Chart---曲线图",},
/*自定义 formatter 函数*/
{
"简单字符串拼接",
"自定义不同单位后缀",
"自定义多彩颜色文字",
"值为0时,在tooltip中不显示",
"自定义箱线图的浮动提示框头部内容",
"自定义分组堆积柱状图tooltip内容",
"customArearangeChartTooltip---自定义折线范围图的tooltip",
"调整折线图的 X 轴左边距",
"通过来自外部的数据源来自定义 tooltip (而非常规的来自图表的 series)",
"customTooltipPostionerFunction---自定义浮动提示框 Positioner 函数",
"fixedTooltipPositionByCustomPositionerFunction---通过 Positioner 函数来实现一个位置固定的提示框",
"customPlotAreaOutsideComlicatedTooltipStyle---通过 Positioner 函数来实现绘图区外的复杂浮动提示框样式",
"disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction---通过 Series 的 Point 的选中事件函数来禁用条形图反选效果",
"customAreasplineChartTooltipStyleByDivWithCSS---通过自定义 div 的 css 样式来自定义复杂效果的 tooltip 浮动提示框",
"makePieChartShow0Data---使饼图显示为 0 的数据",
"setCrosshairAndTooltipToTheDefaultPositionAfterLoadingChart---图表加载完成后, 在指定位置默认显示 crosshair 和 tooltip",
"customColumnChartBorderStyleAndStatesHoverColor---自定义📊柱状图的 border 样式和手指或鼠标 hover 时的显示效果",
},
/*执行由 JavaScript 字符串映射转换成的 js function 函数*/
{
"eval JS function 1",
"eval JS function 2",
"eval JS function 3",},
/*Double Charts Linked Work---双表联动*/
{
"doubleChartsLinkedWork",},
/*Scrollable Chart---可滚动图表*/
{
"Column Chart---柱形图",
"Bar Chart---条形图",
"Area Chart---折线填充图",
"Areaspline Chart---曲线填充图",
"Step Area Chart--- 直方折线填充图",
"Step Line Chart--- 直方折线图",
"Line Chart---折线图",
"Spline Chart---曲线图",},
/*JS Function For AAAXis Labels*/
{
"customYAxisLabels---自定义Y轴文字",
"customYAxisLabels2---自定义Y轴文字2",
"customAreaChartXAxisLabelsTextUnitSuffix1---自定义X轴文字单位后缀(通过 formatter 函数)",
"customAreaChartXAxisLabelsTextUnitSuffix2---自定义X轴文字单位后缀(不通过 formatter 函数)",
"configureTheAxesLabelsFormattersOfDoubleYAxesChart---配置双 Y 轴图表的 Y 轴文字标签的 Formatter 函数 示例 1",
"configureTheAxesLabelsFormattersOfDoubleYAxesChart2---配置双 Y 轴图表的 Y 轴文字标签的 Formatter 函数 示例 2",
"configureTheAxesLabelsFormattersOfDoubleYAxesChart3---配置双 Y 轴图表的 Y 轴文字标签的 Formatter 函数 示例 3",
"customColumnChartXAxisLabelsTextByInterceptTheFirstFourCharacters---通过截取前四个字符来自定义 X 轴 labels",
"customSpiderChartStyle---自定义蜘蛛🕷🕸图样式",
"customizeEveryDataLabelSinglelyByDataLabelsFormatter---通过 DataLabels 的 formatter 函数来实现单个数据标签🏷自定义",
"customXAxisLabelsBeImages---自定义 X轴 labels 为一组图片",
},
/*JS Function For AALegend*/
{
"disableLegendClickEventForNormalChart---禁用常规图表 legend 点击事件",
"disableLegendClickEventForPieChart---禁用饼图 legend 点击事件",
"customLegendItemClickEvent---自定义图例 legend 的点击事件",
},
/*JS Function For AAChartEvents*/
{
"setCrosshairAndTooltipToTheDefaultPositionAfterLoadingChart---图表加载完成后设置 crosshair 和 tooltip 到默认位置",
"generalDrawingChart---普通绘图",
"advancedTimeLineChart---高级时间轴绘图",
"configureBlinkMarkerChart---配置闪烁特效的 marker 图表",
"configureSpecialStyleMarkerOfSingleDataElementChartWithBlinkEffect---配置闪烁特效的 marker 图表2",
"configureScatterChartWithBlinkEffect---配置闪烁特效的散点图",
"automaticallyHideTooltipAfterItIsShown---在浮动提示框显示后自动隐藏",
"dynamicHeightGridLineAreaChart---动态高度的网格线区域填充图",
"customizeYAxisPlotLinesLabelBeSpecialStyle---自定义 Y 轴轴线上面的标签文字特殊样式",
"configureECGStyleChart---配置心电图样式的图表",
},
/*JS Function For AAOptions*/
{
"customDoubleXAxesChart---自定义双 X 轴图表",
"disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction---通过 Series 的 Point 的选中事件函数来禁用条形图反选效果",
"customizeEveryDataLabelSinglelyByDataLabelsFormatter---通过 formatter 来自定义单个 dataLabels 元素",
"configureColorfulDataLabelsForPieChart---为饼图配置多彩 dataLabels"
},
};
String[][] chartTypeArr = {
{
/*基础类型图表*/
AAChartType.Column,
AAChartType.Bar,
AAChartType.Area,
AAChartType.Areaspline,
AAChartType.Area,
AAChartType.Line,
AAChartType.Line,
AAChartType.Spline,
},
{
/*特殊类型图表*/
AAChartType.Column,
AAChartType.Bar,
AAChartType.Line,
AAChartType.Area,
AAChartType.Pie,
AAChartType.Bubble,
AAChartType.Scatter,
AAChartType.Arearange,
AAChartType.Columnrange,
AAChartType.Scatter,
AAChartType.Areaspline,
AAChartType.Boxplot,
AAChartType.Waterfall,
AAChartType.Pyramid,
AAChartType.Funnel,
AAChartType.Errorbar,
AAChartType.Gauge,
},
{
/*Mixed Chart---混合图*/
"arearangeMixedLine",
"columnrangeMixedLine",
"stackingColumnMixedLine",
"dashStyleTypeMixed",
"negativeColorMixed",
"scatterMixedLine",
"negativeColorMixedBubble",
"polygonMixedScatter",
"polarChartMixed",
"configurePieMixedLineMixedColumnChart",
"configureNegativeColorMixedAreasplineChart",
},
{
/*自定义样式图表*/
"colorfulChart",
"gradientColorfulChart",
"discontinuousDataChart",
"colorfulColumnChart",
"nightingaleRoseChart",
"chartWithShadowStyle",
"colorfulGradientAreaChart",
"colorfulGradientSplineChart",
"gradientColorAreasplineChart",
"SpecialStyleMarkerOfSingleDataElementChart",
"SpecialStyleColumnOfSingleDataElementChart",
"AreaChartThreshold",
"customScatterChartMarkerSymbolContent",
"customLineChartMarkerSymbolContent",
"TriangleRadarChart",
"QuadrangleRadarChart",
"PentagonRadarChart",
"HexagonRadarChart",
"adjustYAxisMaxAndMinValues",
"customSpecialStyleDataLabelOfSingleDataElementChart",
"customBarChartHoverColorAndSelectColor",
"customChartHoverAndSelectHaloStyle",
"customSplineChartMarkerStatesHoverStyle",
"splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle",
"customNormalStackingChartDataLabelsContentAndStyle",
"upsideDownPyramidChart",
"doubleLayerPieChart",
"disableSomeOfLinesMouseTrackingEffect",
"configureColorfulShadowSplineChart",
"configureColorfulDataLabelsStepLineChart",
"configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart",
"disableSplineChartMarkerHoverEffect",
"configureMaxAndMinDataLabelsForChart",
"customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag",
"noMoreGroupingAndOverlapEachOtherColumnChart",
"noMoreGroupingAndNestedColumnChart",
"topRoundedCornersStackingColumnChart",
"freeStyleRoundedCornersStackingColumnChart",
"customColumnChartBorderStyleAndStatesHoverColor",
"customLineChartWithColorfulMarkersAndLines",
"customLineChartWithColorfulMarkersAndLines2",
"drawLineChartWithPointsCoordinates",
"configureSpecialStyleColumnForNegativeDataMixedPositiveData",
"configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart",
"connectNullsForSingleAASeriesElement",
"lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement",
"customAreasplineChartWithColorfulGradientColorZones",
"largeDataStackingColumnChart"
},
{
/*使用AAOptions绘制图表*/
"customLegendStyle",
"AAPlotBandsForChart",
"AAPlotLinesForChart",
"customAATooltipWithJSFunction",
"customXAxisCrosshairStyle",
"XAxisLabelsFontColorWithHTMLString",
"XAxisLabelsFontColorAndFontSizeWithHTMLString",
"_DataLabels_XAXis_YAxis_Legend_Style",
"XAxisPlotBand",
"configureTheMirrorColumnChart",
"configureDoubleYAxisChartOptions",
"configureTripleYAxesMixedChart",
"customLineChartDataLabelsFormat",
"configureDoubleYAxesAndColumnLineMixedChart",
"configureDoubleYAxesMarketDepthChart",
"customAreaChartTooltipStyleLikeHTMLTable",
"simpleGaugeChart",
"gaugeChartWithPlotBand",
"doubleLayerHalfPieChart",
"customAreasplineChartTooltipContentWithHeaderFormat",
"customAreaChartTooltipStyleWithTotalValueHeader",
"configureYAxisLabelsNumericSymbolsMagnitudeOfAerasplineChart",
"timeDataWithIrregularIntervalsChart",
"logarithmicAxisLineChart",
"logarithmicAxisScatterChart",
"disableMixedChartInactiveAnimationEffect",
"adjustBubbleChartMinAndMax",
"customLineChartDataLabelsFormat",
"customLineChartDataLabelsFormat2",
"complicatedScatterChart",
"customColumnrangeChartGroupStyleAndSeriesStatesHoverColor",
},
{
/*即时刷新📈📊图表数据*/
AAChartType.Column,
AAChartType.Bar,
AAChartType.Area,
AAChartType.Areaspline,
"stepArea",
"stepLine",
AAChartType.Line,
AAChartType.Spline,
AAChartType.Scatter,
},
{
/*图表高级更新功能*/
AAChartType.Column,
AAChartType.Bar,
AAChartType.Area,
AAChartType.Areaspline,
AAChartType.Area,
AAChartType.Line,
AAChartType.Line,
AAChartType.Spline,
},
{
/*自定义 formatter 函数*/
"customAreaChartTooltipStyleWithSimpleFormatString",
"customAreaChartTooltipStyleWithDifferentUnitSuffix",
"customAreaChartTooltipStyleWithColorfulHtmlLabels",
"customLineChartTooltipStyleWhenValueBeZeroDoNotShow",
"customBoxplotTooltipContent",
"customStackedAndGroupedColumnChartTooltip",
"customArearangeChartTooltip",
"customLineChartOriginalPointPositionByConfiguringXAxisFormatterAndTooltipFormatter",
"customTooltipWhichDataSourceComeFromOutSideRatherThanSeries",
"customTooltipPostionerFunction",
"fixedTooltipPositionByCustomPositionerFunction",
"customPlotAreaOutsideComlicatedTooltipStyle",
"disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction",
"customAreasplineChartTooltipStyleByDivWithCSS",
"makePieChartShow0Data",
"customColumnChartXAxisLabelsTextByInterceptTheFirstFourCharacters",
"customColumnChartBorderStyleAndStatesHoverColor",
},
{
/*执行由 JavaScript 字符串映射转换成的 js function 函数*/
"evalJSFunction1",
"evalJSFunction2",
"evalJSFunction3",
},
{
/*Double Charts Linked Work---双表联动*/
"doubleChartsLinkedWork",
},
{
/*Scrollable Chart---可滚动图表*/
AAChartType.Column,
AAChartType.Bar,
AAChartType.Area,
AAChartType.Areaspline,
AAChartType.Area,
AAChartType.Line,
AAChartType.Line,
AAChartType.Spline,
},
{
/*JS Function For AAAXis Labels*/
"customYAxisLabels",
"customYAxisLabels2",
"customAreaChartXAxisLabelsTextUnitSuffix1",
"customAreaChartXAxisLabelsTextUnitSuffix2",
"configureTheAxesLabelsFormattersOfDoubleYAxesChart",
"configureTheAxesLabelsFormattersOfDoubleYAxesChart2",
"configureTheAxesLabelsFormattersOfDoubleYAxesChart3",
"customColumnChartXAxisLabelsTextByInterceptTheFirstFourCharacters",
"customSpiderChartStyle",
"customizeEveryDataLabelSinglelyByDataLabelsFormatter",
"customXAxisLabelsBeImages",
},
{
/*JS Function For AALegend*/
"disableLegendClickEventForNormalChart",
"disableLegendClickEventForPieChart",
"customLegendItemClickEvent",
},
{
/*JS Function For AAChartEvents*/
"setCrosshairAndTooltipToTheDefaultPositionAfterLoadingChart",
"generalDrawingChart",
"advancedTimeLineChart",
"configureBlinkMarkerChart",
"configureSpecialStyleMarkerOfSingleDataElementChartWithBlinkEffect",
"configureScatterChartWithBlinkEffect",
"automaticallyHideTooltipAfterItIsShown",
"dynamicHeightGridLineAreaChart",
"customizeYAxisPlotLinesLabelBeSpecialStyle",
"configureECGStyleChart",
},
{
/*JS Function For AAOptions*/
"customDoubleXAxesChart",
"disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction",
"customizeEveryDataLabelSinglelyByDataLabelsFormatter",
"configureColorfulDataLabelsForPieChart"
},
};
private String chartType;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupExpandableListView();
}
void setupExpandableListView() {
String[] groupTitleArr = {
"Basic Type Chart | 基础类型图表",
"Special Type Chart | 特殊类型图表",
"Mixed Chart | 混合图形",
"Custom Style Chart | 一些自定义风格样式图表",
"Draw Chart With AAOptions | 通过Options绘图",
"Only Refresh data | 即时刷新图表数据",
"Chart Options Advanced Updating | 图表高级更新",
"JS Function For AAOptions | 通过带有 JS 函数的 Options 绘图",
"Evaluate JS String Function | 执行js函数",
"Double Charts Linked Work | 双表联动",
"Scrollable chart | 可滚动的图表",
"JS Function For AAAxis Labels | 通过带有 JS 函数的自定义 AAAxis 的文字标签",
"JS Function For AALegend | 通过带有 JS 函数的自定义 AALegend",
"JS Function For AAChartEvents---通过 JSFunction 自定义 AAChartEvents 的事件",
"JS Function For AAOptions---通过 JSFunction 自定义 AAOptions 内容",
};
ExpandableListView listView = (ExpandableListView) findViewById(R.id.exlist_lol);
MyBaseExpandableListAdapter myAdapter = new MyBaseExpandableListAdapter(groupTitleArr, chartTypeNameArr,this);
listView.setAdapter(myAdapter);
//为列表设置点击事件
listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
String chartType = chartTypeArr[groupPosition][childPosition];
switch (groupPosition) {
case 0: /*基础类型图表*/
goToCommonChartActivity(chartType,childPosition);
break;
case 1: /*特殊类型图表*/
goToSpecialChartActivity(chartType);
break;
case 2: /*Mixed Chart---混合图*/
goToMixedChartActivity(chartType);
break;
case 3: /*自定义样式图表*/
goToCustomStyleChartActivity(chartType);
break;
case 4: /*使用AAOptions绘制图表*/
goToDrawChartWithAAOptionsActivity(chartType);
break;
case 5: /*即时刷新📈📊图表数据*/
goToOnlyRefreshChartDataActivity(chartType);
break;
case 6: /*图表高级更新功能*/
goToAdvancedUpdatingFeatureActivity(chartType,childPosition);
break;
case 7: /*formatter js function*/
goToCustomTooltipWithJSFunctionActivity(chartType);
break;
case 8: /*eval JS Function*/
goToEvaluateJSStringFunctionActivity(chartType);
break;
case 9: /*Double Charts Linked Work*/
goToDoubleChartsLinkedWorkActivity(chartType);
break;
case 10: /*Scrollable Chart---可滚动图表*/
gotoScrollableChartActivity(chartType,childPosition);
break;
case 11: /*JJS Function For AAAxis Labels | 通过带有 JS 函数的自定义 AAAxis 的文字标签*/
gotoJSFunctionForAAAxisActivity(chartType,childPosition);
break;
case 12: /*JS Function For AALegend | 通过带有 JS 函数的自定义 AALegend*/
gotoJSFunctionForAALegendActivity(chartType,childPosition);
break;
case 13: /*JS Function For AAChartEvents---通过 JSFunction 自定义 AAChartEvents 的事件*/
gotoJSFunctionForAAChartEventsActivity(chartType,childPosition);
break;
case 14: /*JS Function For AAOptions---通过 JSFunction 自定义 AAOptions 内容*/
gotoJSFunctionForAAOptionsActivity(chartType,childPosition);
break;
}
Toast.makeText(MainActivity.this, "你点击了:" + chartTypeNameArr[groupPosition][childPosition], Toast.LENGTH_SHORT).show();
return true;
}
});
}
void goToCommonChartActivity(String chartType, int position) {
Intent intent = new Intent(this, BasicChartActivity.class);
intent.putExtra(kChartTypeKey, chartType);
intent.putExtra("position",position);
startActivity(intent);
}
void goToSpecialChartActivity(String chartType) {
Intent intent = new Intent(this, SpecialChartActivity.class);
intent.putExtra(kChartTypeKey, chartType);
startActivity(intent);
}
void goToCustomStyleChartActivity(String chartType) {
Intent intent = new Intent(this, CustomStyleChartActivity.class);
intent.putExtra(kChartTypeKey, chartType);
startActivity(intent);
}
void goToMixedChartActivity(String chartType) {
Intent intent = new Intent(this, MixedChartActivity.class);
intent.putExtra(kChartTypeKey, chartType);
startActivity(intent);
}
void goToDrawChartWithAAOptionsActivity(String chartType) {
Intent intent = new Intent(this, DrawChartWithAAOptionsActivity.class);
intent.putExtra(kChartTypeKey, chartType);
startActivity(intent);
}
void goToOnlyRefreshChartDataActivity(String chartType) {
Intent intent = new Intent(this, OnlyRefreshChartDataActivity.class);
intent.putExtra(kChartTypeKey, chartType);
startActivity(intent);
}
void goToAdvancedUpdatingFeatureActivity(String chartType, int position) {
Intent intent = new Intent(this, AdvancedUpdatingFeatureActivity.class);
intent.putExtra(kChartTypeKey, chartType);
intent.putExtra("position",position);
startActivity(intent);
}
void goToCustomTooltipWithJSFunctionActivity(String chartType) {
Intent intent = new Intent(this, JSFunctionForAATooltipActivity.class);
intent.putExtra(kChartTypeKey, chartType);
startActivity(intent);
}
void goToEvaluateJSStringFunctionActivity(String chartType) {
Intent intent = new Intent(this, EvaluateJSStringFunctionActivity.class);
intent.putExtra(kChartTypeKey, chartType);
startActivity(intent);
}
void goToHideOrShowChartSeriesActivity(String chartType) {
Intent intent = new Intent(this, HideOrShowChartSeriesActivity.class);
intent.putExtra(kChartTypeKey, chartType);
startActivity(intent);
}
void goToDoubleChartsLinkedWorkActivity(String chartType) {
Intent intent = new Intent(this, DoubleChartsLinkedWorkActivity.class);
intent.putExtra(kChartTypeKey, chartType);
startActivity(intent);
}
void gotoScrollableChartActivity(String chartType, int position) {
Intent intent = new Intent(this, ScrollableChartActivity.class);
intent.putExtra(kChartTypeKey, chartType);
intent.putExtra("position",position);
startActivity(intent);
}
void gotoJSFunctionForAAAxisActivity(String chartType, int position) {
Intent intent = new Intent(this, JSFunctionForAAAxisActivity.class);
intent.putExtra(kChartTypeKey, chartType);
intent.putExtra("position",position);
startActivity(intent);
}
void gotoJSFunctionForAALegendActivity(String chartType, int position) {
Intent intent = new Intent(this, JSFunctionForAALegendActivity.class);
intent.putExtra(kChartTypeKey, chartType);
intent.putExtra("position",position);
startActivity(intent);
}
void gotoJSFunctionForAAChartEventsActivity(String chartType, int position) {
Intent intent = new Intent(this, JSFunctionForAAChartEventsActivity.class);
intent.putExtra(kChartTypeKey, chartType);
intent.putExtra("position",position);
startActivity(intent);
}
void gotoJSFunctionForAAOptionsActivity(String chartType, int position) {
Intent intent = new Intent(this, JSFunctionForAAOptionsActivity.class);
intent.putExtra(kChartTypeKey, chartType);
intent.putExtra("position",position);
startActivity(intent);
}
}
@@ -0,0 +1,61 @@
package com.example.anan.AAChartCore.ChartsDemo.MainContent;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.MixedChartComposer.*;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.example.anan.AAChartCore.R;
public class MixedChartActivity extends AppCompatActivity {
private AAChartModel aaChartModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mixed_chart);
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
this.aaChartModel = configureTheAAChartModel(chartType);
AAChartView aaChartView = findViewById(R.id.AAChartView);
aaChartView.aa_drawChartWithChartModel(this.aaChartModel);
}
private AAChartModel configureTheAAChartModel(String chartType) {
switch (chartType) {
case "arearangeMixedLine":
return arearangeMixedLine();
case "columnrangeMixedLine":
return columnrangeMixedLine();
case "stackingColumnMixedLine":
return stackingColumnMixedLine();
case "dashStyleTypeMixed":
return dashStyleTypeMixed();
case "negativeColorMixed":
return negativeColorMixed();
case "scatterMixedLine":
return scatterMixedLine();
case "negativeColorMixedBubble":
return negativeColorMixedBubble();
case "polygonMixedScatter":
return polygonMixedScatter();
case "polarChartMixed":
return polarChartMixed();
case "configurePieMixedLineMixedColumnChart":
return configurePieMixedLineMixedColumnChart();
case "configureNegativeColorMixedAreasplineChart":
return configureNegativeColorMixedAreasplineChart();
case "configureAerasplinerangeMixedColumnrangeMixedLineChart":
return configureAerasplinerangeMixedColumnrangeMixedLineChart();
}
return arearangeMixedLine();
}
}
@@ -0,0 +1,138 @@
package com.example.anan.AAChartCore.ChartsDemo.MainContent;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import com.example.anan.AAChartCore.R;
public class MyBaseExpandableListAdapter extends BaseExpandableListAdapter {
private String[] gData;
private String[][] iData;
private Context mContext;
private String[] colorsArr = new String[]{
"#5470c6",
"#91cc75",
"#fac858",
"#ee6666",
"#73c0de",
"#3ba272",
"#fc8452",
"#9a60b4",
"#ea7ccc",
"#5470c6",
"#91cc75",
"#fac858",
"#ee6666",
"#73c0de",
"#3ba272",
"#fc8452",
"#9a60b4",
"#ea7ccc",
};
public MyBaseExpandableListAdapter(String[] gData, String[][] iData, Context mContext) {
this.gData = gData;
this.iData = iData;
this.mContext = mContext;
}
@Override
public int getGroupCount() {
return gData.length;
}
@Override
public int getChildrenCount(int groupPosition) {
return iData[groupPosition].length;
}
@Override
public String getGroup(int groupPosition) {
return gData[groupPosition];
}
@Override
public String getChild(int groupPosition, int childPosition) {
return iData[groupPosition][childPosition];
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public boolean hasStableIds() {
return false;
}
//取得用于显示给定分组的视图. 这个方法仅返回分组的视图对象
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
ViewHolderGroup groupHolder;
if(convertView == null){
convertView = LayoutInflater.from(mContext).inflate(
R.layout.item_exlist_group, parent, false);
groupHolder = new ViewHolderGroup();
groupHolder.tv_group_name = (TextView) convertView.findViewById(R.id.tv_group_name);
convertView.setTag(groupHolder);
}else{
groupHolder = (ViewHolderGroup) convertView.getTag();
}
groupHolder.tv_group_name.setText(gData[groupPosition]);
return convertView;
}
//取得显示给定分组给定子位置的数据用的视图
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
ViewHolderItem itemHolder;
if(convertView == null){
convertView = LayoutInflater.from(mContext).inflate(
R.layout.item_exlist_item, parent, false);
itemHolder = new ViewHolderItem();
itemHolder.tv_color_dot = (TextView) convertView.findViewById(R.id.tv_colorful_index);
itemHolder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
convertView.setTag(itemHolder);
}else{
itemHolder = (ViewHolderItem) convertView.getTag();
}
String colorStr = colorsArr[groupPosition];
itemHolder.tv_color_dot.setTextColor(Color.parseColor(colorStr));
// itemHolder.tv_color_dot.setBackgroundColor(Color.parseColor(colorStr));
itemHolder.tv_color_dot.setText((childPosition + 1) + "");
itemHolder.tv_name.setText(iData[groupPosition][childPosition]);
return convertView;
}
//设置子列表是否可选中
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
private static class ViewHolderGroup{
private TextView tv_group_name;
}
private static class ViewHolderItem{
private TextView tv_color_dot;
private TextView tv_name;
}
}
@@ -0,0 +1,83 @@
package com.example.anan.AAChartCore.ChartsDemo.MainContent;
import static com.example.anan.AAChartCore.ChartsDemo.chartcomposer.SpecialChartComposer.*;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import com.example.anan.AAChartCore.R;
;
public class SpecialChartActivity extends AppCompatActivity {
private AAChartModel aaChartModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_special_chart);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
AAChartView aaChartView = (AAChartView) findViewById(R.id.AAChartView);
Intent intent = getIntent();
String chartType = intent.getStringExtra("chartType");
aaChartModel = configureChartModelWithChartType(chartType);
aaChartView.aa_drawChartWithChartModel(aaChartModel);
}
AAChartModel configureChartModelWithChartType(String chartType) {
switch (chartType) {
case AAChartType.Column:
return configurePolarColumnChart();
case AAChartType.Bar:
return configurePolarBarChart();
case AAChartType.Line:
return configurePolarLineChart();
case AAChartType.Area:
return configurePolarAreaChart();
case AAChartType.Pie:
return configurePieChart();
case AAChartType.Bubble:
return configureBubbleChart();
case AAChartType.Scatter:
return configureScatterChart();
case AAChartType.Arearange:
return configureArearangeChart();
case AAChartType.Areasplinerange:
return configureAreasplinerangeChart();
case AAChartType.Columnrange:
return configureColumnrangeChart();
case AAChartType.Spline:
return configureStepLineChart();
case AAChartType.Areaspline:
return configureStepAreaChart();
case AAChartType.Boxplot:
return configureBoxplotChart();
case AAChartType.Waterfall:
return configureWaterfallChart();
case AAChartType.Pyramid:
return configurePyramidChart();
case AAChartType.Funnel:
return configureFunnelChart();
case AAChartType.Errorbar:
return configureErrorbarChart();
case AAChartType.Gauge:
return configureGaugeChart();
case AAChartType.Polygon:
return configurePolygonChart();
default:
break;
}
return configurePolarColumnChart();
}
}
@@ -0,0 +1,11 @@
package com.example.anan.AAChartCore.ChartsDemo.chartcomposer;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolType;
public class AAChartSymbolConst {
public static final String predefinedSymbol1 = AAChartSymbolType.Triangle;
public static final String predefinedSymbol2 = AAChartSymbolType.Circle;
public static final String imageSymbol = "url(https://www.highcharts.com/samples/graphics/sun.png)";
public static final String base64Symbol = "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5Si +ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVi +pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+ 1dT1gvWd+ 1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx+ 1/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb+ 16EHTh0kX/i +c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAVVJREFUeNpi/P37NwOxYM2pHtm7lw8uYmBgYGAiVtPC3RWh+88vuneT474Dv4DkcUZibJy8PG72le/nkn+zMzAaMhnNyY1clMpCjKbz/86lMLAzMMA0MTAwMOC1Ea6JgYFB9pPwncbMg6owOaY1p3pk15zqkcWnie8j63ddY18nZHmWI2eW3vzN/Jf168c3UfGuHathAXHl+7lkBnYGBtafDP8NVd3jQ8xKHiNrZMyeqPPtE/9vTgYGBgb1H4oHlHXt43ZfWfDwNzsDIwMDA4POX831RXGrg9BdxLhob63VgTurjsAUsv5k+A9jC3/g/NCdfVoQm/+ZIu3qjhnyW3XABJANMNL19cYVcPBQrZpq9eyFwCdJmIT6D8UD5cmbHXFphKccI9Mgc84vTH9goYhPE4rGELOSx0bSjsUMDAwMunJ2FQST0+/fv1Hw5BWJbehi2DBgAHTKsWmiz+rJAAAAAElFTkSuQmCC)";
}
@@ -0,0 +1,150 @@
package com.example.anan.AAChartCore.ChartsDemo.chartcomposer;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartAnimationType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolStyleType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AATools.AAGradientColor;
import com.github.AAChartModel.AAChartCore.AATools.AALinearGradientDirection;
import java.util.Map;
public class BasicChartComposer {
public static AAChartModel configureBasicOptions() {
return new AAChartModel()
.backgroundColor("#4b2b7f")
.dataLabelsEnabled(false)
.yAxisGridLineWidth(0)
.touchEventEnabled(true);
}
public static AAChartModel configureAreaChart() {
AASeriesElement element1 = new AASeriesElement()
.name("Tokyo")
.data(new Object[]{7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6});
AASeriesElement element2 = new AASeriesElement()
.name("NewYork")
.data(new Object[]{0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5});
AASeriesElement element3 = new AASeriesElement()
.name("London")
.data(new Object[]{0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0});
AASeriesElement element4 = new AASeriesElement()
.name("Berlin")
.data(new Object[]{3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8});
return configureBasicOptions()
.chartType(AAChartType.Area)
.categories(new String[]{"Java","Swift","Python","Ruby", "PHP","Go","C","C#","C++"})
.series(new AASeriesElement[]{element1, element2, element3, element4});
}
public static AAChartModel configureStepAreaChartAndStepLineChart() {
AASeriesElement element1 = new AASeriesElement()
.name("Tokyo")
.step(true)
.data(new Object[]{149.9, 171.5, 106.4, 129.2, 144.0, 176.0, 135.6, 188.5, 276.4, 214.1, 95.6, 54.4});
AASeriesElement element2 = new AASeriesElement()
.name("NewYork")
.step(true)
.data(new Object[]{83.6, 78.8, 188.5, 93.4, 106.0, 84.5, 105.0, 104.3, 131.2, 153.5, 226.6, 192.3});
AASeriesElement element3 = new AASeriesElement()
.name("London")
.step(true)
.data(new Object[]{48.9, 38.8, 19.3, 41.4, 47.0, 28.3, 59.0, 69.6, 52.4, 65.2, 53.3, 72.2});
return configureBasicOptions()
.chartType(AAChartType.Area)
.series(new AASeriesElement[]{element1, element2, element3,});
}
public static AAChartModel configureColumnChartAndBarChart() {
return configureAreaChart()
.categories(new String[]{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
})
.legendEnabled(true)
.colorsTheme(new String[]{"#fe117c","#ffc069","#06caf4","#7dffc0"})
.animationType(AAChartAnimationType.EaseOutCubic)
.animationDuration(1200);
}
public static AAChartModel configureAreaChartAndAreasplineChartStyle(String chartType) {
AAChartModel aaChartModel = configureAreaChart()
.animationType(AAChartAnimationType.EaseOutQuart)
.legendEnabled(true)
.markerRadius(6)
.markerSymbol(AAChartSymbolType.Circle)
.markerSymbolStyle(AAChartSymbolStyleType.InnerBlank);
if (chartType.equals(AAChartType.Areaspline)) {
Map<String, Object> gradientColorDic = AAGradientColor.linearGradient(
AALinearGradientDirection.ToBottomRight,
"rgba(138,43,226,1)",
"rgba(30,144,255,1)" //颜色字符串设置支持十六进制类型和 rgba 类型
);
AASeriesElement element1 = new AASeriesElement()
.name("Predefined symbol")
.fillColor(gradientColorDic)
.data(new Object[]{0.45, 0.43, 0.50, 0.55, 0.58, 0.62, 0.83, 0.39, 0.56, 0.67, 0.50, 0.34, 0.50, 0.67, 0.58, 0.29, 0.46, 0.23, 0.47, 0.46, 0.38, 0.56, 0.48, 0.36});
AASeriesElement element2 = new AASeriesElement()
.name("Image symbol")
.data(new Object[]{0.38, 0.31, 0.32, 0.32, 0.64, 0.66, 0.86, 0.47, 0.52, 0.75, 0.52, 0.56, 0.54, 0.60, 0.46, 0.63, 0.54, 0.51, 0.58, 0.64, 0.60, 0.45, 0.36, 0.67});
AASeriesElement element3 = new AASeriesElement()
.name("Base64 symbol (*)")
.data(new Object[]{0.46, 0.32, 0.53, 0.58, 0.86, 0.68, 0.85, 0.73, 0.69, 0.71, 0.91, 0.74, 0.60, 0.50, 0.39, 0.67, 0.55, 0.49, 0.65, 0.45, 0.64, 0.47, 0.63, 0.64});
AASeriesElement element4 = new AASeriesElement()
.name("Custom symbol")
.data(new Object[]{0.60, 0.51, 0.52, 0.53, 0.64, 0.84, 0.65, 0.68, 0.63, 0.47, 0.72, 0.60, 0.65, 0.74, 0.66, 0.65, 0.71, 0.59, 0.65, 0.77, 0.52, 0.53, 0.58, 0.53});
aaChartModel
.animationType(AAChartAnimationType.EaseFrom)//设置图表渲染动画类型为 EaseFrom
.series(new AASeriesElement[]{element1, element2, element3, element4});
}
return aaChartModel;
}
public static AAChartModel configureLineChartAndSplineChartStyle(String chartType) {
AAChartModel aaChartModel = configureAreaChart()
.chartType(chartType)
.markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//设置折线连接点样式为:边缘白色
.markerRadius(6);
if (chartType.equals(AAChartType.Spline)) {
AASeriesElement element1 = new AASeriesElement()
.name("Tokyo")
.lineWidth(7)
.data(new Object[]{50, 320, 230, 370, 230, 400,});
AASeriesElement element2 = new AASeriesElement()
.name("Berlin")
.lineWidth(7)
.data(new Object[]{80, 390, 210, 340, 240, 350,});
AASeriesElement element3 = new AASeriesElement()
.name("New York")
.lineWidth(7)
.data(new Object[]{100, 370, 180, 280, 260, 300,});
AASeriesElement element4 = new AASeriesElement()
.name("London")
.lineWidth(7)
.data(new Object[]{130, 350, 160, 310, 250, 268,});
aaChartModel
.animationType(AAChartAnimationType.SwingFromTo)
.series(new AASeriesElement[]{element1, element2, element3, element4});
}
return aaChartModel;
}
}
@@ -0,0 +1,823 @@
package com.example.anan.AAChartCore.ChartsDemo.chartcomposer;
import static com.github.AAChartModel.AAChartCore.AATools.AAColor.AARgba;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartAlignType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartFontWeightType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartLayoutType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartLineDashStyleType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartStackingType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolStyleType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartVerticalAlignType;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAChart;
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.AAMarker;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
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.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;
import com.github.AAChartModel.AAChartCore.AATools.AAGradientColor;
import com.github.AAChartModel.AAChartCore.AATools.AALinearGradientDirection;
import java.util.Map;
public class JSFunctionForAAAxisComposer {
public static AAOptions customYAxisLabels() {
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Line)//图形类型
.markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
.dataLabelsEnabled(false)
.colorsTheme(new String[]{"#04d69f","#1e90ff","#ef476f","#ffd066",})
.stacking(AAChartStackingType.Normal)
.markerRadius(8)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Tokyo Hot")
.lineWidth(5.0)
.fillOpacity(0.4)
.data(new Object[]{29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4})
,
});
AALabels aaYAxisLabels = new AALabels()
.formatter("function () {\n" +
" let yValue = this.value;\n" +
" if (yValue >= 200) {\n" +
" return \"极佳\";\n" +
" } else if (yValue >= 150 && yValue < 200) {\n" +
" return \"非常棒\";\n" +
" } else if (yValue >= 100 && yValue < 150) {\n" +
" return \"相当棒\";\n" +
" } else if (yValue >= 50 && yValue < 100) {\n" +
" return \"还不错\";\n" +
" } else {\n" +
" return \"一般\";\n" +
" }\n" +
" }");
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.yAxis.labels(aaYAxisLabels);
return aaOptions;
}
public static AAOptions customYAxisLabels2() {
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Line)//图形类型
.markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
.dataLabelsEnabled(false)
.colorsTheme(new String[]{"#04d69f","#1e90ff","#ef476f","#ffd066",})
.stacking(AAChartStackingType.Normal)
.markerRadius(8)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Tokyo Hot")
.lineWidth(5.0)
.fillOpacity(0.4)
.data(new Object[]{229.9, 771.5, 1106.4, 1129.2, 6644.0, 1176.0, 8835.6, 148.5, 8816.4, 6694.1, 7795.6, 9954.4})
,
});
AALabels aaYAxisLabels = new AALabels()
.style(new AAStyle()
.fontSize(10)
.fontWeight(AAChartFontWeightType.Bold)
.color(AAColor.Gray)
)
.formatter("function () {\n" +
" let yValue = this.value;\n" +
" if (yValue == 0) {\n" +
" return \"0\";\n" +
" } else if (yValue == 2500) {\n" +
" return \"25%\";\n" +
" } else if (yValue == 5000) {\n" +
" return \"50%\";\n" +
" } else if (yValue == 7500) {\n" +
" return \"75%\";\n" +
" } else if (yValue == 10000) {\n" +
" return \"100%\";\n" +
" }\n" +
" }");
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.yAxis
.opposite(true)
.tickWidth(2)
.lineWidth(1.5)//Y轴轴线颜色
.lineColor(AAColor.LightGray)//Y轴轴线颜色
.gridLineWidth(0)//Y轴网格线宽度
.tickPositions(new Object[]{0,2500,5000,7500,10000})
.labels(aaYAxisLabels);
return aaOptions;
}
//Stupid method
public static AAOptions customAreaChartXAxisLabelsTextUnitSuffix1() {
Map<String, Object> gradientColorDic1 = AAGradientColor.linearGradient(
AALinearGradientDirection.ToTop,
"#7052f4",
"#00b0ff"
);
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Area)
.title("Custom X Axis Labels Text")
.subtitle("By Using JavaScript Formatter Function")
.markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)
.yAxisGridLineWidth(0)
.series(new AASeriesElement[]{
new AASeriesElement()
.lineWidth(1.5)
.color("#00b0ff")
.fillColor(gradientColorDic1)
.name("2018")
.data(new Object[]{
1.51, 6.7, 0.94, 1.44, 1.6, 1.63, 1.56, 1.91, 2.45, 3.87, 3.24, 4.90, 4.61, 4.10,
4.17, 3.85, 4.17, 3.46, 3.46, 3.55, 3.50, 4.13, 2.58, 2.28, 1.51, 12.7, 0.94, 1.44,
18.6, 1.63, 1.56, 1.91, 2.45, 3.87, 3.24, 4.90, 4.61, 4.10, 4.17, 3.85, 4.17, 3.46,
3.46, 3.55, 3.50, 4.13, 2.58, 2.28, 1.33, 4.68, 1.31, 1.10, 13.9, 1.10, 1.16, 1.67,
2.64, 2.86, 3.00, 3.21, 4.14, 4.07, 3.68, 3.11, 3.41, 3, 3.32, 3.07, 3.92, 3.05,
2.18, 3.24, 3.23, 3.15, 2.90, 1.81, 2.11, 2.43, 5.59, 3.09, 4.09, 6.14, 5.33, 6.05,
5.71, 6.22, 6.56, 4.75, 5.27, 6.02, 5.48,
})
});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.xAxis.labels
.formatter(
"function () {" +
"const xValue = this.value;" +
"if (xValue%10 == 0) {" +
"return xValue + \" sec\";" +
"} else {" +
"return \"\";" +
"}" +
"}"
);
return aaOptions;
}
//Smart method
public static AAOptions customAreaChartXAxisLabelsTextUnitSuffix2() {
AAOptions aaOptions = customAreaChartXAxisLabelsTextUnitSuffix1();
aaOptions.xAxis.labels
.step(10)
.format("{value} sec");
return aaOptions;
}
//https://github.com/AAChartModel/AAChartKit/issues/901
//https://github.com/AAChartModel/AAChartKit/issues/952
public static AAOptions configureTheAxesLabelsFormattersOfDoubleYAxesChart() {
AAChart aaChart = new AAChart()
.backgroundColor(AAColor.White);
AATitle aaTitle = new AATitle()
.text("");
AAXAxis aaXAxis = new AAXAxis()
.visible(true)
.min(0)
.categories(new String[]{
"Java", "Swift", "Python", "Ruby", "PHP", "Go","C",
"C#", "C++", "Perl", "R", "MATLAB", "SQL"
});
AAPlotOptions aaPlotOptions = new AAPlotOptions()
.series(new AASeries()
.marker(new AAMarker()
.radius(7)//曲线连接点半径,默认是4
.symbol(AAChartSymbolType.Circle)//曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
.fillColor(AAColor.White)//点的填充色(用来设置折线连接点的填充色)
.lineWidth(3)//外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
.lineColor("")//外沿线的颜色(用来设置折线连接点的轮廓描边颜色,当值为空字符串时,默认取数据点或数据列的颜色)
));
AAYAxis yAxis1 = new AAYAxis()
.visible(true)
.lineWidth(1)
.tickPositions(new Object[]{0, 50, 100, 150, 200})
.labels(new AALabels()
.enabled(true)
.style(new AAStyle()
.color("DodgerBlue"))
.formatter("function () {\n" +
" let yValue = this.value;\n" +
" if (yValue >= 200) {\n" +
" return \"极佳\";\n" +
" } else if (yValue >= 150 && yValue < 200) {\n" +
" return \"非常棒\";\n" +
" } else if (yValue >= 100 && yValue < 150) {\n" +
" return \"相当棒\";\n" +
" } else if (yValue >= 50 && yValue < 100) {\n" +
" return \"还不错\";\n" +
" } else {\n" +
" return \"一般\";\n" +
" }\n" +
" }"))
.gridLineWidth(0)
.title(new AATitle()
.text("中文")
.style(AAStyle.style("DodgerBlue", 14, AAChartFontWeightType.Bold)));
AAYAxis yAxis2 = new AAYAxis()
.visible(true)
.lineWidth(1)
.tickPositions(new Object[]{0, 50, 100, 150, 200})
.labels(new AALabels()
.enabled(true)
.style(new AAStyle()
.color(AAColor.Red))
.formatter("function () {\n" +
" let yValue = this.value;\n" +
" if (yValue >= 200) {\n" +
" return \"Awesome\";\n" +
" } else if (yValue >= 150 && yValue < 200) {\n" +
" return \"Great\";\n" +
" } else if (yValue >= 100 && yValue < 150) {\n" +
" return \"Very Good\";\n" +
" } else if (yValue >= 50 && yValue < 100) {\n" +
" return \"Not Bad\";\n" +
" } else {\n" +
" return \"Just So So\";\n" +
" }\n" +
" }"))
.gridLineWidth(0)
.title(new AATitle()
.text("ENGLISH")
.style(AAStyle.style(AAColor.Red, 14, AAChartFontWeightType.Bold)))
.opposite(true);
AATooltip aaTooltip = new AATooltip()
.enabled(true)
.shared(true);
AASeriesElement[] seriesArr = {
new AASeriesElement()
.name("2020")
.type(AAChartType.Spline)
.lineWidth(7)
.color(AAGradientColor.DeepSea)
.borderRadius(4)
.yAxis(1)
.data(new Object[]{
0, 71.5, 106.4, 129.2, 144.0, 176.0,
135.6, 148.5, 216.4, 194.1, 95.6, 54.4
}),
new AASeriesElement()
.name("2021")
.type(AAChartType.Spline)
.lineWidth(7)
.color(AAGradientColor.Sanguine)
.yAxis(0)
.data(new Object[]{
135.6, 148.5, 216.4, 194.1, 95.6, 54.4,
0, 71.5, 106.4, 129.2, 144.0, 176.0
})
};
AAOptions aaOptions = new AAOptions()
.chart(aaChart)
.title(aaTitle)
.plotOptions(aaPlotOptions)
.xAxis(aaXAxis)
.yAxisArray(new AAYAxis[]{yAxis1, yAxis2})
.tooltip(aaTooltip)
.series(seriesArr);
return aaOptions;
}
//https://github.com/AAChartModel/AAChartKit/issues/1324
public static AAOptions configureTheAxesLabelsFormattersOfDoubleYAxesChart2() {
AAChart aaChart = new AAChart()
.backgroundColor(AAColor.White);
AATitle aaTitle = new AATitle()
.text("");
AAXAxis aaXAxis = new AAXAxis()
.visible(true)
.min(0)
.categories(new String[]{
"Java", "Swift", "Python", "Ruby", "PHP", "Go","C",
"C#", "C++", "Perl", "R", "MATLAB", "SQL"
});
AAPlotOptions aaPlotOptions = new AAPlotOptions()
.series(new AASeries()
.marker(new AAMarker()
.radius(7)//曲线连接点半径,默认是4
.symbol(AAChartSymbolType.Circle)//曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
.fillColor(AAColor.White)//点的填充色(用来设置折线连接点的填充色)
.lineWidth(3)//外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
.lineColor("")//外沿线的颜色(用来设置折线连接点的轮廓描边颜色,当值为空字符串时,默认取数据点或数据列的颜色)
));
AAYAxis yAxis1 = new AAYAxis()
.visible(true)
.lineWidth(1)
.tickPositions(new Object[]{0, 50, 100, 150, 200})
.labels(new AALabels()
.enabled(true)
.style(new AAStyle()
.color("DodgerBlue"))
.formatter("function () {\n" +
" var yValue = this.value;\n" +
" var formattedYValue = (yValue / 1000).toFixed(3) + '千';\n" +
" return formattedYValue;\n" +
" }"))
.gridLineWidth(0)
.title(new AATitle()
.text("以「千」为单位")
.style(AAStyle.style("DodgerBlue", 14, AAChartFontWeightType.Bold)));
AAYAxis yAxis2 = new AAYAxis()
.visible(true)
.lineWidth(1)
.tickPositions(new Object[]{0, 50, 100, 150, 200})
.labels(new AALabels()
.enabled(true)
.style(new AAStyle()
.color(AAColor.Red))
.formatter("function () {\n" +
" var yValue = this.value;\n" +
" var formattedYValue = (yValue / 10000).toFixed(4) + '万';\n" +
" return formattedYValue;\n" +
" }"))
.gridLineWidth(0)
.title(new AATitle()
.text("以『万』为单位")
.style(AAStyle.style(AAColor.Red, 14, AAChartFontWeightType.Bold)))
.opposite(true);
AATooltip aaTooltip = new AATooltip()
.enabled(true)
.shared(true);
AASeriesElement[] seriesArr = {
new AASeriesElement()
.name("2020")
.type(AAChartType.Spline)
.lineWidth(7)
.color(AAGradientColor.DeepSea)
.borderRadius(4)
.yAxis(1)
.data(new Object[]{
0, 71.5, 106.4, 129.2, 144.0, 176.0,
135.6, 148.5, 216.4, 194.1, 95.6, 54.4
}),
new AASeriesElement()
.name("2021")
.type(AAChartType.Spline)
.lineWidth(7)
.color(AAGradientColor.Sanguine)
.yAxis(0)
.data(new Object[]{
135.6, 148.5, 216.4, 194.1, 95.6, 54.4,
0, 71.5, 106.4, 129.2, 144.0, 176.0
})
};
AAOptions aaOptions = new AAOptions()
.chart(aaChart)
.title(aaTitle)
.plotOptions(aaPlotOptions)
.xAxis(aaXAxis)
.yAxisArray(new AAYAxis[]{yAxis1, yAxis2})
.tooltip(aaTooltip)
.series(seriesArr);
return aaOptions;
}
//https://github.com/AAChartModel/AAChartKit/issues/1324
//https://github.com/AAChartModel/AAChartKit/issues/1330
public static AAOptions configureTheAxesLabelsFormattersOfDoubleYAxesChart3() {
AAChart aaChart = new AAChart()
.backgroundColor(AAColor.White);
AATitle aaTitle = new AATitle()
.text("");
AAXAxis aaXAxis = new AAXAxis()
.visible(true)
.min(0)
.categories(new String[]{
"Java", "Swift", "Python", "Ruby", "PHP", "Go","C",
"C#", "C++", "Perl", "R", "MATLAB", "SQL"
});
AAPlotOptions aaPlotOptions = new AAPlotOptions()
.series(new AASeries()
.marker(new AAMarker()
.radius(7)//曲线连接点半径,默认是4
.symbol(AAChartSymbolType.Circle)//曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
.fillColor(AAColor.White)//点的填充色(用来设置折线连接点的填充色)
.lineWidth(3)//外沿线的宽度(用来设置折线连接点的轮廓描边的宽度)
.lineColor("")//外沿线的颜色(用来设置折线连接点的轮廓描边颜色,当值为空字符串时,默认取数据点或数据列的颜色)
));
AAYAxis yAxis1 = new AAYAxis()
.visible(true)
.lineWidth(1)
.tickPositions(new Object[]{0, 50, 100, 150, 200})
.labels(new AALabels()
.enabled(true)
.style(new AAStyle()
.color("DodgerBlue"))
.formatter("function () {\n" +
" var yValue = this.value;\n" +
" var unitStr = \"\";\n" +
" if (yValue == 0) {\n" +
" unitStr = \"\";\n" +
" }\n" +
" var formattedYValue = (yValue / 1000).toFixed(3) + unitStr;\n" +
" return formattedYValue;\n" +
" }"))//Y轴文字数值为 0 的时候, 不显示单位
.gridLineWidth(0)
.title(new AATitle()
.text("以「千」为单位")
.style(AAStyle.style("DodgerBlue", 14, AAChartFontWeightType.Bold)));
AAYAxis yAxis2 = new AAYAxis()
.visible(true)
.lineWidth(1)
.tickPositions(new Object[]{0, 50, 100, 150, 200})
.labels(new AALabels()
.enabled(true)
.style(new AAStyle()
.color(AAColor.Red))
.formatter("function () {\n" +
" var yValue = this.value;\n" +
" var unitStr = \"\";\n" +
" if (yValue == 0) {\n" +
" unitStr = \"\";\n" +
" }\n" +
" var formattedYValue = (yValue / 10000).toFixed(4) + unitStr;\n" +
" return formattedYValue;\n" +
" }"))//Y轴文字数值为 0 的时候, 不显示单位
.gridLineWidth(0)
.title(new AATitle()
.text("以『万』为单位")
.style(AAStyle.style(AAColor.Red, 14, AAChartFontWeightType.Bold)))
.opposite(true)
;
AATooltip aaTooltip = new AATooltip()
.enabled(true)
.shared(true);
AASeriesElement[] seriesArr = {
new AASeriesElement()
.name("2020")
.type(AAChartType.Spline)
.lineWidth(7)
.color(AAGradientColor.DeepSea)
.borderRadius(4)
.yAxis(1)
.data(new Object[]{
0, 71.5, 106.4, 129.2, 144.0, 176.0,
135.6, 148.5, 216.4, 194.1, 95.6, 54.4
}),
new AASeriesElement()
.name("2021")
.type(AAChartType.Spline)
.lineWidth(7)
.color(AAGradientColor.Sanguine)
.yAxis(0)
.data(new Object[]{
135.6, 148.5, 216.4, 194.1, 95.6, 54.4,
0, 71.5, 106.4, 129.2, 144.0, 176.0
})
};
AAOptions aaOptions = new AAOptions()
.chart(aaChart)
.title(aaTitle)
.plotOptions(aaPlotOptions)
.xAxis(aaXAxis)
.yAxisArray(new AAYAxis[]{yAxis1, yAxis2})
.tooltip(aaTooltip)
.series(seriesArr);
return aaOptions;
}
//https://github.com/AAChartModel/AAChartKit/issues/1217
public static AAOptions customColumnChartXAxisLabelsTextByInterceptTheFirstFourCharacters() {
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Bar)//图表类型
.title("春江花月夜")//图表主标题
.subtitle("张若虚")//图表副标题
// .yAxisGridLineStyle([AALineStyle styleWithWidth:0})//y轴横向分割线宽度(为0即是隐藏分割线)
.xAxisReversed(true)
// .xAxisLabelsStyle(AAStyle.style(AAColor.Black))
.legendEnabled(false)
.categories(new String[]{
"春江潮水连海平", "海上明月共潮生",
"滟滟随波千万里", "何处春江无月明",
"江流宛转绕芳甸", "月照花林皆似霰",
"空里流霜不觉飞", "汀上白沙看不见",
"江天一色无纤尘", "皎皎空中孤月轮",
"江畔何人初见月", "江月何年初照人",
"人生代代无穷已", "江月年年望相似",
"不知江月待何人", "但见长江送流水",
"白云一片去悠悠", "青枫浦上不胜愁",
"谁家今夜扁舟子", "何处相思明月楼",
"可怜楼上月裴回", "应照离人妆镜台",
"玉户帘中卷不去", "捣衣砧上拂还来",
"此时相望不相闻", "愿逐月华流照君",
"鸿雁长飞光不度", "鱼龙潜跃水成文",
"昨夜闲潭梦落花", "可怜春半不还家",
"江水流春去欲尽", "江潭落月复西斜",
"斜月沉沉藏海雾", "碣石潇湘无限路",
"不知乘月几人归", "落月摇情满江树",
})
.series(new AASeriesElement[]{
new AASeriesElement()
.lineWidth(1.5)
.color(AAGradientColor.DeepSea)
.name("2018")
.data(new Object[]{
1.51, 3.7, 0.94, 1.44, 1.6, 1.63, 1.56, 1.91, 2.45, 3.87, 3.24, 4.90, 4.61, 4.10,
4.17, 3.85, 4.17, 3.46, 3.46, 3.55, 3.50, 4.13, 2.58, 2.28,1.51, 2.7, 0.94, 1.44,
3.6, 1.63, 1.56, 1.91, 2.45, 3.87, 3.24, 4.90,
})
});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.xAxis.labels
.formatter("function () {\n" +
" let xAxisCategory = this.value;\n" +
" if (xAxisCategory.length > 4) {\n" +
" return xAxisCategory.substr(0, 4);\n" +
" } else {\n" +
" return xAxisCategory;\n" +
" }\n" +
" }");
;
return aaOptions;
}
//https://github.com/AAChartModel/AAChartKit/issues/852 自定义蜘蛛🕷图样式
public static AAOptions customSpiderChartStyle() {
String[] categoryArr = {
"周转天数(天)",
"订单满足率",
"订单履约时效",
"动销率",
"畅销商品缺货率",
"高库存金额占比",
"不动销金额占比",
"停采金额占比",
};
// String categoryJSArrStr = {categoryArr aa_toJSArray];
//
// String xAxisLabelsFormatter ={String stringWithFormat:(AAJSFunc(function () {
// return %[this.value];
// })),categoryJSArrStr];
String categoryJSArrStr = javaScriptArrayStringWithJavaArray(categoryArr);
String xAxisLabelsFormatter = String.format("function () {\n" +
" return %s[this.value];\n" +
" }", categoryJSArrStr);
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Line)//图表类型
.title("健康体检表")//图表主标题
.colorsTheme(new String[]{"#fe117c","#ffc069",})//设置主体颜色数组
.yAxisLineWidth(0)
// .yAxisGridLineStyle([AALineStyle styleWithWidth:0})
// .yAxisTickPositions([0, 5, 10, 15, 20, 25, 30, 35})
.markerRadius(5)
.markerSymbol(AAChartSymbolType.Circle)
.polar(true)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("本月得分")
.data(new Object[]{7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5,}),
new AASeriesElement()
.name("上月得分")
.data(new Object[]{0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, }),
});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.chart
.marginLeft(80)
.marginRight(80);
aaOptions.xAxis
.lineWidth(0)//避免多边形外环之外有额外套了一层无用的外环
.labels.style(AAStyle.style(AAColor.Black))
.formatter(xAxisLabelsFormatter);
aaOptions.yAxis
.gridLineInterpolation("polygon")//设置蜘蛛网🕸图表的网线为多边形
.labels.style(AAStyle.style(AAColor.Black));
//设定图例项的CSS样式。只支持有关文本的CSS样式设定。
// /默认是:{
// "color": "#333333",
// "cursor": "pointer",
// "fontSize": "12px",
// "fontWeight": "bold"
// }
// /
AAItemStyle aaItemStyle = new AAItemStyle()
.color(AAColor.Gray)//字体颜色
.cursor("pointer")//(在移动端这个属性没什么意义,其实不用设置)指定鼠标滑过数据列时鼠标的形状。当绑定了数据列点击事件时,可以将此参数设置为 "pointer",用来提醒用户改数据列是可以点击的。
.fontSize(14)//字体大小
.fontWeight(AAChartFontWeightType.Thin);//字体为细体字
aaOptions.legend
.enabled(true)
.align(AAChartAlignType.Center)//设置图例位于水平方向上的右侧
.layout(AAChartLayoutType.Horizontal)//设置图例排列方式为垂直排布
.verticalAlign(AAChartVerticalAlignType.Top)//设置图例位于竖直方向上的顶部
.itemStyle(aaItemStyle);
return aaOptions;
}
// Refer to the issue https://github.com/AAChartModel/AAChartKit/issues/589
public static AAOptions customizeEveryDataLabelSinglelyByDataLabelsFormatter() {
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Areaspline)//图表类型
.dataLabelsEnabled(true)
.tooltipEnabled(false)
.colorsTheme(new Object[]{AAGradientColor.FizzyPeach})
.markerRadius(0)
.legendEnabled(false)
.categories(new String[]{"美国🇺🇸","欧洲🇪🇺","中国🇨🇳","日本🇯🇵","韩国🇰🇷","越南🇻🇳","中国香港🇭🇰",})
.series(new AASeriesElement[]{
new AASeriesElement()
.data(new Object[]{7.0, 6.9, 2.5, 14.5, 18.2, 21.5, 5.2}),
});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.yAxis.gridLineDashStyle = AAChartLineDashStyleType.LongDash;//设置Y轴的网格线样式为 AAChartLineDashStyleType.LongDash
String[] unitArr ={"美元", "欧元", "人民币", "日元", "韩元", "越南盾", "港币", };
String unitJSArrStr = javaScriptArrayStringWithJavaArray(unitArr);
String dataLabelsFormatter = String.format("function () {\n" +
" return this.y + %s[this.point.index]; \n" + //单组 series 图表, 获取选中的点的索引是 this.point.index ,多组并且共享提示框,则是this.points[0].index
" }", unitJSArrStr);
AADataLabels aaDatalabels = aaOptions.plotOptions.series.dataLabels;
aaDatalabels
.style(AAStyle.style(AAColor.Red, 10, AAChartFontWeightType.Bold, "1px 1px contrast"))
.formatter(dataLabelsFormatter)
.backgroundColor(AAColor.White)// white color
.borderColor(AAColor.Red)// red color
.borderRadius(1.5)
.borderWidth(1.3)
.x(3).y(-20)
.verticalAlign(AAChartVerticalAlignType.Middle);
return aaOptions;
}
// Refer to GitHub issue: https://github.com/AAChartModel/AAChartKit/issues/938
// Refer to online chart sample: https://www.highcharts.com/demo/column-comparison
public static AAOptions customXAxisLabelsBeImages() {
String[] nameArr = {
"South Korea",
"Japan",
"Australia",
"Germany",
"Russia",
"China",
"Great Britain",
"United States"
};
String[] colorArr = {
AARgba(201, 36, 39, 1.f),
AARgba(201, 36, 39, 1.f),
AARgba(0, 82, 180, 1.f),
AARgba(0, 0, 0, 1.f),
AARgba(240, 240, 240, 1.f),
AARgba(255, 217, 68, 1.f),
AARgba(0, 82, 180, 1.f),
AARgba(215, 0, 38, 1.f)
};
String[] imageLinkFlagArr = {
"197582",
"197604",
"197507",
"197571",
"197408",
"197375",
"197374",
"197484"
};
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Column)
.title("Custom X Axis Labels Be Images")
.subtitle("use HTML")
.categories(nameArr)
.colorsTheme(colorArr)
.borderRadius(5)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("AD 2020")
.data(new Object[]{9.0, 9.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5})
.colorByPoint(true)
.borderRadiusTopLeft("50%")
.borderRadiusTopRight("50%")
});
String imageLinkFlagJSArrStr = javaScriptArrayStringWithJavaArray(imageLinkFlagArr);
String xLabelsFormatter = String.format("function () {\n" +
" let imageFlag = %s[this.pos];\n" +
" let imageLink = \"\";\n" +
" return imageLink;\n" +
" }", imageLinkFlagJSArrStr);
// https://api.highcharts.com.cn/highcharts#xAxis.labels.formatter
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.xAxis.labels
.useHTML(true)
.formatter(xLabelsFormatter);
aaOptions.plotOptions.column.groupPadding(0.005f);
// /Custom tooltip style/
// String tooltipFormatter ={String stringWithFormat:(AAJSFunc(function () {
// let imageFlag = %[this.point.index];
// let imageLink = "
// ";
// return imageLink
// + " 🌕 🌖 🌗 🌘 🌑 🌒 🌓 🌔
// "
// + " Support JavaScript Function Just Right Now !!!
// "
// + " The Gold Price For 2020 "
// + this.x
// + " Is "
// + this.y
// + " Dollars ";
// })),imageLinkFlagJSArrStr];
String tooltipFormatter = String.format("function () {\n" +
" let imageFlag = %s[this.point.index];\n" +
" let imageLink = \"<span><img src=\\\"https://image.flaticon.com/icons/svg/197/\" + imageFlag + \".svg\\\" style=\\\"width: 30px; height: 30px;\\\"/><br></span>\";\n" +
" return imageLink\n" +
" + \" \uD83C\uDF15 \uD83C\uDF16 \uD83C\uDF17 \uD83C\uDF18 \uD83C\uDF11 \uD83C\uDF12 \uD83C\uDF13 \uD83C\uDF14 <br/> \"\n" +
" + \" Support JavaScript Function Just Right Now !!! <br/> \"\n" +
" + \" The Gold Price For <b>2020 \"\n" +
" + this.x\n" +
" + \" </b> Is <b> \"\n" +
" + this.y\n" +
" + \" </b> Dollars \";\n" +
" }", imageLinkFlagJSArrStr);
aaOptions.tooltip
.shared(false)
.useHTML(true)
.formatter(tooltipFormatter);
return aaOptions;
}
private static String javaScriptArrayStringWithJavaArray(Object[] javaArray) {
StringBuilder originalJsArrStr = new StringBuilder();
for (Object element : javaArray) {
originalJsArrStr.append("'").append(element.toString()).append("',");
}
return "[" + originalJsArrStr + "]";
}
}
@@ -0,0 +1,208 @@
package com.example.anan.AAChartCore.ChartsDemo.chartcomposer;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartAlignType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartLayoutType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartStackingType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartVerticalAlignType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartZoomType;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAHover;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAPoint;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAPointEvents;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AASeriesEvents;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAStates;
import com.github.AAChartModel.AAChartCore.AATools.AAColor;
public class JSFunctionForAALegendComposer {
public static AAOptions disableLegendClickEventForNormalChart() {
AASeriesElement element1 = new AASeriesElement()
.name("Predefined symbol")
.data(new Object[]{0.45, 0.43, 0.50, 0.55, 0.58, 0.62, 0.83, 0.39, 0.56, 0.67, 0.50, 0.34, 0.50, 0.67, 0.58, 0.29, 0.46, 0.23, 0.47, 0.46, 0.38, 0.56, 0.48, 0.36});
AASeriesElement element2 = new AASeriesElement()
.name("Image symbol")
.data(new Object[]{0.38, 0.31, 0.32, 0.32, 0.64, 0.66, 0.86, 0.47, 0.52, 0.75, 0.52, 0.56, 0.54, 0.60, 0.46, 0.63, 0.54, 0.51, 0.58, 0.64, 0.60, 0.45, 0.36, 0.67});
AASeriesElement element3 = new AASeriesElement()
.name("Base64 symbol (*)")
.data(new Object[]{0.46, 0.32, 0.53, 0.58, 0.86, 0.68, 0.85, 0.73, 0.69, 0.71, 0.91, 0.74, 0.60, 0.50, 0.39, 0.67, 0.55, 0.49, 0.65, 0.45, 0.64, 0.47, 0.63, 0.64});
AASeriesElement element4 = new AASeriesElement()
.name("Custom symbol")
.data(new Object[]{0.60, 0.51, 0.52, 0.53, 0.64, 0.84, 0.65, 0.68, 0.63, 0.47, 0.72, 0.60, 0.65, 0.74, 0.66, 0.65, 0.71, 0.59, 0.65, 0.77, 0.52, 0.53, 0.58, 0.53});
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Areaspline)
.title("CUSTOM LEGEND STYLE")
.subtitle("LEGEND ON THE TOP_RIGHT SIDE WITH VERTICAL STYLE")
.subtitleAlign(AAChartAlignType.Left)
.markerRadius(0)
.backgroundColor(AAColor.White)
.dataLabelsEnabled(false)
.yAxisGridLineWidth(0)
.yAxisTitle("percent values")
.zoomType(AAChartZoomType.X)
.stacking(AAChartStackingType.Normal)
.colorsTheme(new String[]{"mediumspringgreen", "deepskyblue", "red", "sandybrown"})
.series(new AASeriesElement[]{element1, element2, element3, element4});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.legend
.enabled(true)
.verticalAlign(AAChartVerticalAlignType.Top)//设置图例位于水平方向上的右侧
.layout(AAChartLayoutType.Vertical)//设置图例排列方式为垂直排布
.align(AAChartAlignType.Right)//设置图例位于竖直方向上的顶部
;
//禁用图例点击事件
aaOptions.plotOptions.series.events = new AASeriesEvents()
.legendItemClick("function() { " +
"return false; " +
"}");
return aaOptions;
}
// //https://github.com/AAChartModel/AAChartKit-Swift/issues/391
// //https://github.com/AAChartModel/AAChartKit-Swift/issues/393
public static AAOptions disableLegendClickEventForPieChart() {
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Pie)
.backgroundColor(AAColor.White)
.title("LANGUAGE MARKET SHARES JANUARY,2020 TO MAY")
.subtitle("virtual data")
.dataLabelsEnabled(true)//是否直接显示扇形图数据
.yAxisTitle("")
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Language market shares")
.innerSize("20%")//内部圆环半径大小占比(内部圆环半径/扇形图半径),
.allowPointSelect(true)
.states(new AAStates()
.hover(new AAHover()
.enabled(false)//禁用点击区块之后出现的半透明遮罩层
))
.data(new Object[][]{
{"Java", 67},
{"Swift", 999},
{"Python", 83},
{"OC", 11},
{"Go", 30},
})
});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.legend.labelFormat("{name} {percentage:.2f}%");
//禁用饼图图例点击事件
aaOptions.plotOptions.series
.point(new AAPoint()
.events(new AAPointEvents()
.legendItemClick("" +
"function() { " +
"return false; " +
"}")));
return aaOptions;
}
//https://bbs.hcharts.cn/article-109-1.html
//图表自带的图例点击事件是:
//点击某个显示/隐藏的图例,该图例对应的serie就隐藏/显示。
//个人觉得不合理,正常来说,有多条折线(或其他类型的图表),点击某个图例是想只看该图例对应的数据;
//于是修改了图例点击事件。
//
//实现的效果是(以折线图为例)
//1. 当某条折线隐藏时,点击该折线的图例 --> 该折线显示;
//2. 当全部折线都显示时,点击某个图例 --> 该图例对应的折线显示,其他折线均隐藏;
//3. 当只有一条折线显示时,点击该折线的图例 --> 全部折线均显示;
//4. 其他情况,按默认处理:
//显示 --> 隐藏;
//隐藏 --> 显示;
//Customized legendItemClick Event online: http://code.hcharts.cn/rencht/hhhhLv/share
public static AAOptions customLegendItemClickEvent() {
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Column)
.stacking(AAChartStackingType.Normal)
.colorsTheme(new String[]{"#fe117c","#ffc069","#06caf4","#7dffc0"})//设置主题颜色数组
.markerRadius(0)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("2017")
.data(new Object[]{7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6}),
new AASeriesElement()
.name("2018")
.data(new Object[]{0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5}),
new AASeriesElement()
.name("2019")
.data(new Object[]{0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0}),
new AASeriesElement()
.name("2020")
.data(new Object[]{3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8}),
});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.legend
.enabled(true)
.align(AAChartAlignType.Right)//设置图例位于水平方向上的右侧
.layout(AAChartLayoutType.Vertical)//设置图例排列方式为垂直排布
.verticalAlign(AAChartVerticalAlignType.Top);//设置图例位于竖直方向上的顶部
//自定义图例点击事件
aaOptions.plotOptions.series.events = new AASeriesEvents()
.legendItemClick("function(event) {\n" +
" function getVisibleMode(series, serieName) {\n" +
" var allVisible = true;\n" +
" var allHidden = true;\n" +
" for (var i = 0; i < series.length; i++) {\n" +
" if (series[i].name == serieName)\n" +
" continue;\n" +
" allVisible &= series[i].visible;\n" +
" allHidden &= (!series[i].visible);\n" +
" }\n" +
" if (allVisible && !allHidden)\n" +
" return 'all-visible';\n" +
" if (allHidden && !allVisible)\n" +
" return 'all-hidden';\n" +
" return 'other-cases';\n" +
" }\n" +
" \n" +
" var series = this.chart.series;\n" +
" var mode = getVisibleMode(series, this.name);\n" +
" var enableDefault = false;\n" +
" if (!this.visible) {\n" +
" enableDefault = true;\n" +
" }\n" +
" else if (mode == 'all-visible') {\n" +
" var seriesLength = series.length;\n" +
" for (var i = 0; i < seriesLength; i++) {\n" +
" var serie = series[i];\n" +
" serie.hide();\n" +
" }\n" +
" this.show();\n" +
" }\n" +
" else if (mode == 'all-hidden') {\n" +
" var seriesLength = series.length;\n" +
" for (var i = 0; i < seriesLength; i++) {\n" +
" var serie = series[i];\n" +
" serie.show();\n" +
" }\n" +
" }\n" +
" else {\n" +
" enableDefault = true;\n" +
" }\n" +
" return enableDefault;\n" +
" }");
return aaOptions;
}
}
@@ -0,0 +1,262 @@
package com.example.anan.AAChartCore.ChartsDemo.chartcomposer;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartAnimationType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartFontWeightType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartLineDashStyleType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartStackingType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartVerticalAlignType;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAAnimation;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAChart;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AADataLabels;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAHover;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AALabels;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAOptions;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAPlotOptions;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAPoint;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAPointEvents;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AASelect;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AASeries;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAStates;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAStyle;
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;
import com.github.AAChartModel.AAChartCore.AATools.AAGradientColor;
import com.github.AAChartModel.AAChartCore.AATools.AALinearGradientDirection;
import java.util.Map;
public class JSFunctionForAAOptionsComposer {
//https://github.com/AAChartModel/AAChartKit/issues/780
public static AAOptions customDoubleXAxesChart() {
Map<String, Object> gradientColorDic1 = AAGradientColor.linearGradient(
AALinearGradientDirection.ToTop,
"#7052f4",
"#00b0ff"//颜色字符串设置支持十六进制类型和 rgba 类型
);
Map<String, Object> gradientColorDic2 = AAGradientColor.linearGradient(
AALinearGradientDirection.ToTop,
"#EF71FF",
"#4740C8"//颜色字符串设置支持十六进制类型和 rgba 类型
);
AAChart aaChart = new AAChart()
.type(AAChartType.Bar);
AATitle aaTitle = new AATitle()
.text("2015 年德国人口金字塔")
.style(new AAStyle()
.color("#000000")
.fontSize(12.0));
String[] aaCategories = new String[]{"0-4", "5-9", "10-14", "15-19",
"20-24", "25-29", "30-34", "35-39", "40-44",
"45-49", "50-54", "55-59", "60-64", "65-69",
"70-74", "75-79", "80-84", "85-89", "90-94",
"95-99", "100 + "};
AAXAxis aaXAxis1 = new AAXAxis()
.reversed(true)
.categories(aaCategories)
.labels(new AALabels()
.step(1))
;
AAXAxis aaXAxis2 = new AAXAxis()
.reversed(true)
.opposite(true)
.categories(aaCategories)
.linkedTo(0)
.labels(new AALabels()
.step(1));
AAYAxis aaYAxis = new AAYAxis()
.gridLineWidth(0)// Y 轴网格线宽度
.title(new AATitle()
.text(""))//Y 轴标题
.labels(new AALabels()
.formatter("function () {\n" +
" return (Math.abs(this.value) / 1000000) + 'M';\n" +
"}"))
.min(-4000000)
.max(4000000);
AAPlotOptions aaPlotOptions = new AAPlotOptions()
.series(new AASeries()
.animation(new AAAnimation()
.duration(800)
.easing(AAChartAnimationType.Bounce)
)
.stacking(AAChartStackingType.Normal));
AATooltip aaTooltip = new AATooltip()
.enabled(true)
.shared(false)
.formatter("function () {\n" +
" return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' +\n" +
" '人口: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);\n" +
"}");
AASeriesElement aaSeriesElement1 = new AASeriesElement()
.name("Men")
.color(gradientColorDic1)
.data(new Object[]{-1746181, -1884428, -2089758, -2222362, -2537431, -2507081, -2443179,
-2664537, -3556505, -3680231, -3143062, -2721122, -2229181, -2227768,
-2176300, -1329968, -836804, -354784, -90569, -28367, -3878});
AASeriesElement aaSeriesElement2 = new AASeriesElement()
.name("Women")
.color(gradientColorDic2)
.data(new Object[]{1656154, 1787564, 1981671, 2108575, 2403438, 2366003, 2301402, 2519874,
3360596, 3493473, 3050775, 2759560, 2304444, 2426504, 2568938, 1785638,
1447162, 1005011, 330870, 130632, 21208});
return new AAOptions()
.chart(aaChart)
.title(aaTitle)
.xAxisArray(new AAXAxis[]{aaXAxis1,aaXAxis2})
.yAxis(aaYAxis)
.plotOptions(aaPlotOptions)
.tooltip(aaTooltip)
.series(new Object[]{aaSeriesElement1,aaSeriesElement2});
}
//https://github.com/AAChartModel/AAChartKit/issues/967
public static AAOptions disableColumnChartUnselectEventEffectBySeriesPointEventClickFunction() {
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Bar)
.title("Custom Bar Chart select color")
.yAxisReversed(true)
.xAxisReversed(true)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("ElementOne")
.data(new Object[]{211,183,157,133,111,91,73,57,43,31,21,13,7,3})
.allowPointSelect(true)
.states(new AAStates()
.hover(new AAHover()
.color(AAColor.Yellow))
.select(new AASelect()
.color(AAColor.Red))
)
});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
AAPoint aaPoint = new AAPoint()
.events(new AAPointEvents()
.click("function () {\n" +
" if (this.selected == true) {\n" +
" this.selected = false;\n" +
" }\n" +
" return;\n" +
" }"));
aaOptions.plotOptions.series
.point(aaPoint);
return aaOptions;
}
// Refer to the issue https://github.com/AAChartModel/AAChartKit/issues/589
public static AAOptions customizeEveryDataLabelSinglelyByDataLabelsFormatter() {
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Areaspline)//图表类型
.dataLabelsEnabled(true)
.tooltipEnabled(false)
.colorsTheme(new Object[]{AAGradientColor.FizzyPeach})
.markerRadius(0)
.legendEnabled(false)
.categories(new String[]{"美国🇺🇸","欧洲🇪🇺","中国🇨🇳","日本🇯🇵","韩国🇰🇷","越南🇻🇳","中国香港🇭🇰",})
.series(new AASeriesElement[]{
new AASeriesElement()
.data(new Object[]{7.0, 6.9, 2.5, 14.5, 18.2, 21.5, 5.2}),
});
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.yAxis.gridLineDashStyle = AAChartLineDashStyleType.LongDash;//设置Y轴的网格线样式为 AAChartLineDashStyleType.LongDash
String[] unitArr ={"美元", "欧元", "人民币", "日元", "韩元", "越南盾", "港币", };
String unitJSArrStr = javaScriptArrayStringWithJavaArray(unitArr);
String dataLabelsFormatter = String.format("function () {\n" +
" return this.y + %s[this.point.index]; \n" + //单组 series 图表, 获取选中的点的索引是 this.point.index ,多组并且共享提示框,则是this.points[0].index
" }", unitJSArrStr);
AADataLabels aaDatalabels = aaOptions.plotOptions.series.dataLabels;
aaDatalabels
.style(AAStyle.style(AAColor.Red, 10, AAChartFontWeightType.Bold, "1px 1px contrast"))
.formatter(dataLabelsFormatter)
.backgroundColor(AAColor.White)// white color
.borderColor(AAColor.Red)// red color
.borderRadius(1.5)
.borderWidth(1.3)
.x(3).y(-20)
.verticalAlign(AAChartVerticalAlignType.Middle);
return aaOptions;
}
//https://github.com/AAChartModel/AAChartKit-Swift/issues/404
public static AAOptions configureColorfulDataLabelsForPieChart() {
AAOptions aaOptions = new AAOptions()
.title(new AATitle()
.text("Colorful DataLabels For Pie Chart"))
.colors(new Object[]{
"#0c9674", "#7dffc0", "#ff3333", "#facd32", "#ffffa0",
"#EA007B", "#fe117c", "#ffc069", "#06caf4", "#7dffc0"
})
.series(new AASeriesElement[]{
new AASeriesElement()
.type(AAChartType.Pie)
.name("语言热度值")
.innerSize("20%")//内部圆环半径大小占比
.borderWidth(0)//描边的宽度
.allowPointSelect(true)//是否允许在点击数据点标记(扇形图点击选中的块发生位移)
.states(new AAStates()
.hover(new AAHover()
.enabled(false)))//禁用点击区块之后出现的半透明遮罩层
.dataLabels(new AADataLabels()
.allowOverlap(true)//允许字符重叠
.useHTML(true)
.formatter("function () {\n" +
" const point = this.point;\n" +
" return '<span style=\\\"color: ' + point.color + '\\\">' +\n" +
" point.name + ': ' + point.y + '%</span>';\n" +
" }"))
.data(new Object[][]{
{"Firefox", 3336.2},
{"IE", 26.8},
{"Chrome", 666.8},
{"Safari", 88.5},
{"Opera", 46.0},
{"Others", 223.0},
{"Firefox", 3336.2},
{"IE", 26.8},
{"Chrome", 666.8},
{"Safari", 88.5},
{"Opera", 46.0},
{"Others", 223.0},
})
});
return aaOptions;
}
private static String javaScriptArrayStringWithJavaArray(Object[] javaArray) {
StringBuilder originalJsArrStr = new StringBuilder();
for (Object element : javaArray) {
originalJsArrStr.append("'").append(element.toString()).append("',");
}
return "[" + originalJsArrStr + "]";
}
}
@@ -0,0 +1,814 @@
package com.example.anan.AAChartCore.ChartsDemo.chartcomposer;
import static com.github.AAChartModel.AAChartCore.AATools.AAColor.AARgba;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartFontWeightType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartLineDashStyleType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartStackingType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolStyleType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AADataElement;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AADataLabels;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAMarker;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAPie;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAStyle;
import com.github.AAChartModel.AAChartCore.AATools.AAColor;
import com.github.AAChartModel.AAChartCore.AATools.AAGradientColor;
import com.github.AAChartModel.AAChartCore.AATools.AALinearGradientDirection;
public class MixedChartComposer {
public static AAChartModel arearangeMixedLine() {
AASeriesElement[] aaSeriesArr = {
new AASeriesElement()
.name("Temperature")
.color("#1E90FF")
.type(AAChartType.Line)
.data(new Object[][] {
{12464064, 21.5},
{12464928, 22.1},
{12465792, 23},
{12466656, 23.8},
{12467520, 21.4},
{12468384, 21.3},
{12469248, 18.3},
{12470112, 15.4},
{12470976, 16.4},
{12471840, 17.7},
{12472704, 17.5},
{12473568, 17.6},
{12474432, 17.7},
{12475296, 16.8},
{12476160, 17.7},
{12477024, 16.3},
{12477888, 17.8},
{12478752, 18.1},
{12479616, 17.2},
{12480480, 14.4},
{12481344, 13.7},
{12482208, 15.7},
{12483072, 14.6},
{12483936, 15.3},
{12484800, 15.3},
{12485664, 15.8},
{12486528, 15.2},
{12487392, 14.8},
{12488256, 14.4},
{12489120, 15},
{12489984, 13.6}
})
.zIndex(1)
,
new AASeriesElement()
.name("Range")
.color("#1E90FF")
.type(AAChartType.Arearange)
.lineWidth(0)
.fillOpacity(0.3)
.data(new Object[][] {
{12464064, 14.3, 27.7},
{12464928, 14.5, 27.8},
{12465792, 15.5, 29.6},
{12466656, 16.7, 30.7},
{12467520, 16.5, 25.0},
{12468384, 17.8, 25.7},
{12469248, 13.5, 24.8},
{12470112, 10.5, 21.4},
{12470976, 9.2, 23.8},
{12471840, 11.6, 21.8},
{12472704, 10.7, 23.7},
{12473568, 11.0, 23.3},
{12474432, 11.6, 23.7},
{12475296, 11.8, 20.7},
{12476160, 12.6, 22.4},
{12477024, 13.6, 19.6},
{12477888, 11.4, 22.6},
{12478752, 13.2, 25.0},
{12479616, 14.2, 21.6},
{12480480, 13.1, 17.1},
{12481344, 12.2, 15.5},
{12482208, 12.0, 20.8},
{12483072, 12.0, 17.1},
{12483936, 12.7, 18.3},
{12484800, 12.4, 19.4},
{12485664, 12.6, 19.9},
{12486528, 11.9, 20.2},
{12487392, 11.0, 19.3},
{12488256, 10.8, 17.8},
{12489120, 11.8, 18.5},
{12489984, 10.8, 16.1}
})
.zIndex(0)
};
return new AAChartModel()
.title("LANGUAGE MARKET SHARES JANUARY,2020 TO MAY")
.subtitle("virtual data")
.series(aaSeriesArr);
}
public static AAChartModel columnrangeMixedLine() {
AASeriesElement[] aaSeriesArr = {
new AASeriesElement()
.name("Temperature")
.type(AAChartType.Columnrange)
.data(new Object[][] {
{(-9.7), 9.4},
{(-8.7), 6.5},
{(-3.5), 9.4},
{(-1.4),19.9},
{0.0 , 22.6},
{2.9 , 29.5},
{9.2 , 30.7},
{7.3 , 26.5},
{4.4 , 18.0},
{(-3.1),11.4},
{(-5.2),10.4},
{(-9.9),16.8}
}),
new AASeriesElement()
.name("Tokyo")
.data(new Object[] {7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6}),
new AASeriesElement()
.name("New York")
.data(new Object[] {0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5}),
new AASeriesElement()
.name("Berlin")
.data(new Object[] {0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0}),
new AASeriesElement()
.name("London")
.data(new Object[] {3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8})
,
};
return new AAChartModel()
.colorsTheme(new Object[] {
"#1e90ff","#EA007B", "#49C1B6", "#FDC20A", "#F78320", "#068E81",})//主题颜色数组
.chartType(AAChartType.Line)
.dataLabelsEnabled(false)
.markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)
.series(aaSeriesArr);
}
public static AAChartModel stackingColumnMixedLine() {
AASeriesElement[] aaSeriesArr = {
new AASeriesElement()
.name("新用户")
.data(new Object[] {82.89,67.54,62.07,59.43,67.02,67.09,35.66,71.78,81.61,78.85,79.12,72.30})
.dataLabels(
new AADataLabels()
.enabled(true)
.style(new AAStyle()
.color(AAColor.Red)
.fontSize(11)
)
)
,
new AASeriesElement()
.name("老用户")
.data(new Object[] {198.66,330.81,151.95,160.12,222.56,229.05,128.53,250.91,224.47,473.99,126.85,260.50})
.dataLabels(
new AADataLabels()
.enabled(true)
.style(new AAStyle()
.color("#000000")
.fontSize(11)
)
),
new AASeriesElement()
.name("总量")
.type(AAChartType.Line)
.data(new Object[] {281.55,398.35,214.02,219.55,289.57,296.14,164.18,322.69,306.08,552.84,205.97,332.79})
.dataLabels(
new AADataLabels()
.enabled(true)
.style(new AAStyle()
.color("#000000")
.fontSize(15)
.fontWeight(AAChartFontWeightType.Bold)
)
)
,
};
return new AAChartModel()
.title("16年1月-16年11月充值客单分析")//图形标题
.subtitle("BY MICVS")//图形副标题
.chartType(AAChartType.Column)
.stacking(AAChartStackingType.Normal)
.legendEnabled(true)
.colorsTheme(new Object[] {
AAGradientColor.OceanBlue,
AAGradientColor.Sanguine,
AAGradientColor.LusciousLime,
})
.series(aaSeriesArr);
}
public static AAChartModel dashStyleTypeMixed() {
AASeriesElement[] aaSeriesData = {
new AASeriesElement()
.name("SolidLine")
.lineWidth(3)
.data(new Object[] {50, 320, 230, 370, 230, 400,320}),
new AASeriesElement()
.name("Dash")
.lineWidth(3)
.dashStyle(AAChartLineDashStyleType.Dash)
.data(new Object[] {50, 320, 230, 370, 230, 400,320}),
new AASeriesElement()
.name("DashDot")
.lineWidth(3)
.dashStyle(AAChartLineDashStyleType.DashDot)
.data(new Object[] {50, 320, 230, 370, 230, 400,320}),
new AASeriesElement()
.name("LongDash")
.lineWidth(3)
.dashStyle(AAChartLineDashStyleType.LongDash)
.data(new Object[] {50, 320, 230, 370, 230, 400,320}),
new AASeriesElement()
.name("LongDashDot")
.lineWidth(3)
.dashStyle(AAChartLineDashStyleType.LongDashDot)
.data(new Object[] {50, 320, 230, 370, 230, 400,320})
,
};
return new AAChartModel()
.chartType(AAChartType.Spline)//图形类型
.dataLabelsEnabled(false)//是否显示数字
.stacking(AAChartStackingType.Normal)
.markerRadius(0)
.series(aaSeriesData);
}
public static AAChartModel negativeColorMixed() {
AASeriesElement[] aaSeriesData = {
new AASeriesElement()
.name("Column")
.type(AAChartType.Column)
.data(new Object[] {
-6.4, -5.2, -3.0, 0.2, 2.3, 5.5, 8.4, 8.3, 5.1, 0.9, -1.1, -4.0,
-6.4, -5.2, -3.0, 0.2, 2.3, 5.5, 8.4, 8.3, 5.1, 0.9, -1.1, -4.0,
-6.4, -5.2, -3.0, 0.2, 2.3, 5.5, 8.4, 8.3, 5.1, 0.9, -1.1, -4.0,})
.color("#0088FF")
.negativeColor("#FF0000")
.threshold(4)//default:0
,
};
return new AAChartModel()
.dataLabelsEnabled(false)//是否显示数字
.series(aaSeriesData);
}
public static AAChartModel scatterMixedLine() {
Object[][] scatterDataArr = {
{0.067732, 3.176513},
{0.42781, 3.816464},
{0.995731, 4.550095},
{0.738336, 4.256571},
{0.981083, 4.560815},
{0.526171, 3.929515},
{0.378887, 3.52617},
{0.033859, 3.156393},
{0.132791, 3.110301},
{0.138306, 3.149813},
{0.247809, 3.476346},
{0.64827, 4.119688},
{0.731209, 4.282233},
{0.236833, 3.486582},
{0.969788, 4.655492},
{0.607492, 3.965162},
{0.358622, 3.5149},
{0.147846, 3.125947},
{0.63782, 4.094115},
{0.230372, 3.476039},
{0.070237, 3.21061},
{0.067154, 3.190612},
{0.925577, 4.631504},
{0.717733, 4.29589},
{0.015371, 3.085028},
{0.33507, 3.44808},
{0.040486, 3.16744},
{0.212575, 3.364266},
{0.617218, 3.993482},
{0.541196, 3.891471},
{0.045353, 3.143259},
{0.126762, 3.114204},
{0.556486, 3.851484},
{0.901144, 4.621899},
{0.958476, 4.580768},
{0.274561, 3.620992},
{0.394396, 3.580501},
{0.87248, 4.618706},
{0.409932, 3.676867},
{0.908969, 4.641845},
{0.166819, 3.175939},
{0.665016, 4.26498},
{0.263727, 3.558448},
{0.231214, 3.436632},
{0.552928, 3.831052},
{0.047744, 3.182853},
{0.365746, 3.498906},
{0.495002, 3.946833},
{0.493466, 3.900583},
{0.792101, 4.238522},
{0.76966, 4.23308},
{0.251821, 3.521557},
{0.181951, 3.203344},
{0.808177, 4.278105},
{0.334116, 3.555705},
{0.33863, 3.502661},
{0.452584, 3.859776},
{0.69477, 4.275956},
{0.590902, 3.916191},
{0.307928, 3.587961},
{0.148364, 3.183004},
{0.70218, 4.225236},
{0.721544, 4.231083},
{0.666886, 4.240544},
{0.124931, 3.222372},
{0.618286, 4.021445},
{0.381086, 3.567479},
{0.385643, 3.56258},
{0.777175, 4.262059},
{0.116089, 3.208813},
{0.115487, 3.169825},
{0.66351, 4.193949},
{0.254884, 3.491678},
{0.993888, 4.533306},
{0.295434, 3.550108},
{0.952523, 4.636427},
{0.307047, 3.557078},
{0.277261, 3.552874},
{0.279101, 3.494159},
{0.175724, 3.206828},
{0.156383, 3.195266},
{0.733165, 4.221292},
{0.848142, 4.413372},
{0.771184, 4.184347},
{0.429492, 3.742878},
{0.162176, 3.201878},
{0.917064, 4.648964},
{0.315044, 3.510117},
{0.201473, 3.274434},
{0.297038, 3.579622},
{0.336647, 3.489244},
{0.666109, 4.237386},
{0.583888, 3.913749},
{0.085031, 3.22899},
{0.687006, 4.286286},
{0.949655, 4.628614},
{0.189912, 3.239536},
{0.844027, 4.457997},
{0.333288, 3.513384},
{0.427035, 3.729674},
{0.466369, 3.834274},
{0.550659, 3.811155},
{0.278213, 3.598316},
{0.918769, 4.692514},
{0.886555, 4.604859},
{0.569488, 3.864912},
{0.066379, 3.184236},
{0.335751, 3.500796},
{0.426863, 3.743365},
{0.395746, 3.622905},
{0.694221, 4.310796},
{0.27276, 3.583357},
{0.503495, 3.901852},
{0.067119, 3.233521},
{0.038326, 3.105266},
{0.599122, 3.865544},
{0.947054, 4.628625},
{0.671279, 4.231213},
{0.434811, 3.791149},
{0.509381, 3.968271},
{0.749442, 4.25391},
{0.058014, 3.19471},
{0.482978, 3.996503},
{0.466776, 3.904358},
{0.357767, 3.503976},
{0.949123, 4.557545},
{0.41732, 3.699876},
{0.920461, 4.613614},
{0.156433, 3.140401},
{0.656662, 4.206717},
{0.616418, 3.969524},
{0.853428, 4.476096},
{0.133295, 3.136528},
{0.693007, 4.279071},
{0.178449, 3.200603},
{0.199526, 3.299012},
{0.073224, 3.209873},
{0.286515, 3.632942},
{0.182026, 3.248361},
{0.621523, 3.995783},
{0.344584, 3.563262},
{0.398556, 3.649712},
{0.480369, 3.951845},
{0.15335, 3.145031},
{0.171846, 3.181577},
{0.867082, 4.637087},
{0.223855, 3.404964},
{0.528301, 3.873188},
{0.890192, 4.633648},
{0.106352, 3.154768},
{0.917886, 4.623637},
{0.014855, 3.078132},
{0.567682, 3.913596},
{0.068854, 3.221817},
{0.603535, 3.938071},
{0.53205, 3.880822},
{0.651362, 4.176436},
{0.901225, 4.648161},
{0.204337, 3.332312},
{0.696081, 4.240614},
{0.963924, 4.532224},
{0.98139, 4.557105},
{0.987911, 4.610072},
{0.990947, 4.636569},
{0.736021, 4.229813},
{0.253574, 3.50086},
{0.674722, 4.245514},
{0.939368, 4.605182},
{0.235419, 3.45434},
{0.110521, 3.180775},
{0.218023, 3.38082},
{0.869778, 4.56502},
{0.19683, 3.279973},
{0.958178, 4.554241},
{0.972673, 4.63352},
{0.745797, 4.281037},
{0.445674, 3.844426},
{0.470557, 3.891601},
{0.549236, 3.849728},
{0.335691, 3.492215},
{0.884739, 4.592374},
{0.918916, 4.632025},
{0.441815, 3.75675},
{0.116598, 3.133555},
{0.359274, 3.567919},
{0.814811, 4.363382},
{0.387125, 3.560165},
{0.982243, 4.564305},
{0.78088, 4.215055},
{0.652565, 4.174999},
{0.87003, 4.58664},
{0.604755, 3.960008},
{0.255212, 3.529963},
{0.730546, 4.213412},
{0.493829, 3.908685},
{0.257017, 3.585821},
{0.833735, 4.374394},
{0.070095, 3.213817},
{0.52707, 3.952681},
{0.116163, 3.129283}
};
Object[] lineDataArr = new Object[][] {
{0.014, 3.078},
{0.969, 4.655},
};
return new AAChartModel()
.dataLabelsEnabled(false)//是否显示数字
.chartType(AAChartType.Scatter)
.markerSymbolStyle(AAChartSymbolStyleType.InnerBlank)
.markerSymbol(AAChartSymbolType.Circle)
.markerRadius(8)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Scatter")
.data(scatterDataArr)
.color("#0088FF")
,
new AASeriesElement()
.name("线性回归线")
.type(AAChartType.Line)
.data(lineDataArr)
.color("#FF0000")
,
});
}
public static AAChartModel negativeColorMixedBubble() {
Object[][] dataArr = {
{0,0,5},{0,1,1},{0,2,0},{0,3,0},{0,4,0},{0,5,0},{0,6,0},{0,7,0},{0,8,0},{0,9,0},
{0,10,0},{0,11,2},{0,12,4},{0,13,1},{0,14,1},{0,15,3},{0,16,4},{0,17,6},{0,18,4},
{0,19,4},{0,20,3},{0,21,3},{0,22,2},{0,23,5},{1,0,7},{1,1,0},{1,2,0},{1,3,0},
{1,4,0},{1,5,0},{1,6,0},{1,7,0},{1,8,0},{1,9,0},{1,10,5},{1,11,2},{1,12,2},
{1,13,6},{1,14,9},{1,15,11},{1,16,6},{1,17,7},{1,18,8},{1,19,12},{1,20,5},{1,21,5},
{1,22,7},{1,23,2},{2,0,1},{2,1,1},{2,2,0},{2,3,0},{2,4,0},{2,5,0},{2,6,0},{2,7,0},
{2,8,0},{2,9,0},{2,10,3},{2,11,2},{2,12,1},{2,13,9},{2,14,8},{2,15,10},{2,16,6},
{2,17,5},{2,18,5},{2,19,5},{2,20,7},{2,21,4},{2,22,2},{2,23,4},{3,0,7},{3,1,3},
{3,2,0},{3,3,0},{3,4,0},{3,5,0},{3,6,0},{3,7,0},{3,8,1},{3,9,0},{3,10,5},{3,11,4},
{3,12,7},{3,13,14},{3,14,13},{3,15,12},{3,16,9},{3,17,5},{3,18,5},{3,19,10},
{3,20,6},{3,21,4},{3,22,4},{3,23,1},{4,0,1},{4,1,3},{4,2,0},{4,3,0},{4,4,0},
{4,5,1},{4,6,0},{4,7,0},{4,8,0},{4,9,2},{4,10,4},{4,11,4},{4,12,2},{4,13,4},
{4,14,4},{4,15,14},{4,16,12},{4,17,1},{4,18,8},{4,19,5},{4,20,3},{4,21,7},{4,22,3},
{4,23,0},{5,0,2},{5,1,1},{5,2,0},{5,3,3},{5,4,0},{5,5,0},{5,6,0},{5,7,0},{5,8,2},
{5,9,0},{5,10,4},{5,11,1},{5,12,5},{5,13,10},{5,14,5},{5,15,7},{5,16,11},{5,17,6},
{5,18,0},{5,19,5},{5,20,3},{5,21,4},{5,22,2},{5,23,0},{6,0,1},{6,1,0},{6,2,0},
{6,3,0},{6,4,0},{6,5,0},{6,6,0},{6,7,0},{6,8,0},{6,9,0},{6,10,1},{6,11,0},{6,12,2},
{6,13,1},{6,14,3},{6,15,4},{6,16,0},{6,17,0},{6,18,0},{6,19,0},{6,20,1},{6,21,2},
{6,22,2},{6,23,6}
};
return new AAChartModel()
.categories(new String[] {
"Saturday", "Friday", "Thursday","Wednesday", "Tuesday", "Monday", "Sunday"
})
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Bubble")
.type(AAChartType.Bubble)
.data(dataArr)
.color("#0088FF")
.negativeColor("#FF0000")
.threshold(4)//default:0
,
});
}
public static AAChartModel polygonMixedScatter() {
Object[][] goalDataArr = {
{153, 42}, {149, 46}, {149, 55},
{152, 60}, {159, 70}, {170, 77},
{180, 70}, {180, 60}, {173, 52},
{166, 45}
};
Object[][] trueDataArr = {
{161.2, 51.6}, {167.5, 59.0}, {159.5, 49.2}, {157.0, 63.0}, {155.8, 53.6},
{170.0, 59.0}, {159.1, 47.6}, {166.0, 69.8}, {176.2, 66.8}, {160.2, 75.2},
{172.5, 55.2}, {170.9, 54.2}, {172.9, 62.5}, {153.4, 42.0}, {160.0, 50.0},
{147.2, 49.8}, {168.2, 49.2}, {175.0, 73.2}, {157.0, 47.8}, {167.6, 68.8},
{159.5, 50.6}, {175.0, 82.5}, {166.8, 57.2}, {176.5, 87.8}, {170.2, 72.8},
{174.0, 54.5}, {173.0, 59.8}, {179.9, 67.3}, {170.5, 67.8}, {160.0, 47.0},
{154.4, 46.2}, {162.0, 55.0}, {176.5, 83.0}, {160.0, 54.4}, {152.0, 45.8},
{162.1, 53.6}, {170.0, 73.2}, {160.2, 52.1}, {161.3, 67.9}, {166.4, 56.6},
{168.9, 62.3}, {163.8, 58.5}, {167.6, 54.5}, {160.0, 50.2}, {161.3, 60.3},
{167.6, 58.3}, {165.1, 56.2}, {160.0, 50.2}, {170.0, 72.9}, {157.5, 59.8},
{167.6, 61.0}, {160.7, 69.1}, {163.2, 55.9}, {152.4, 46.5}, {157.5, 54.3},
{168.3, 54.8}, {180.3, 60.7}, {165.5, 60.0}, {165.0, 62.0}, {164.5, 60.3},
{156.0, 52.7}, {160.0, 74.3}, {163.0, 62.0}, {165.7, 73.1}, {161.0, 80.0},
{162.0, 54.7}, {166.0, 53.2}, {174.0, 75.7}, {172.7, 61.1}, {167.6, 55.7},
{151.1, 48.7}, {164.5, 52.3}, {163.5, 50.0}, {152.0, 59.3}, {169.0, 62.5},
{164.0, 55.7}, {161.2, 54.8}, {155.0, 45.9}, {170.0, 70.6}, {176.2, 67.2},
{170.0, 69.4}, {162.5, 58.2}, {170.3, 64.8}, {164.1, 71.6}, {169.5, 52.8},
{163.2, 59.8}, {154.5, 49.0}, {159.8, 50.0}, {173.2, 69.2}, {170.0, 55.9},
{161.4, 63.4}, {169.0, 58.2}, {166.2, 58.6}, {159.4, 45.7}, {162.5, 52.2},
{159.0, 48.6}, {162.8, 57.8}, {159.0, 55.6}, {179.8, 66.8}, {162.9, 59.4},
{161.0, 53.6}, {151.1, 73.2}, {168.2, 53.4}, {168.9, 69.0}, {173.2, 58.4},
{171.8, 56.2}, {178.0, 70.6}, {164.3, 59.8}, {163.0, 72.0}, {168.5, 65.2},
{166.8, 56.6}, {172.7, 105 }, {163.5, 51.8}, {169.4, 63.4}, {167.8, 59.0},
{159.5, 47.6}, {167.6, 63.0}, {161.2, 55.2}, {160.0, 45.0}, {163.2, 54.0},
{162.2, 50.2}, {161.3, 60.2}, {149.5, 44.8}, {157.5, 58.8}, {163.2, 56.4},
{172.7, 62.0}, {155.0, 49.2}, {156.5, 67.2}, {164.0, 53.8}, {160.9, 54.4},
{162.8, 58.0}, {167.0, 59.8}, {160.0, 54.8}, {160.0, 43.2}, {168.9, 60.5},
{158.2, 46.4}, {156.0, 64.4}, {160.0, 48.8}, {167.1, 62.2}, {158.0, 55.5},
{167.6, 57.8}, {156.0, 54.6}, {162.1, 59.2}, {173.4, 52.7}, {159.8, 53.2},
{170.5, 64.5}, {159.2, 51.8}, {157.5, 56.0}, {161.3, 63.6}, {162.6, 63.2},
{160.0, 59.5}, {168.9, 56.8}, {165.1, 64.1}, {162.6, 50.0}, {165.1, 72.3},
{166.4, 55.0}, {160.0, 55.9}, {152.4, 60.4}, {170.2, 69.1}, {162.6, 84.5},
{170.2, 55.9}, {158.8, 55.5}, {172.7, 69.5}, {167.6, 76.4}, {162.6, 61.4},
{167.6, 65.9}, {156.2, 58.6}, {175.2, 66.8}, {172.1, 56.6}, {162.6, 58.6},
{160.0, 55.9}, {165.1, 59.1}, {182.9, 81.8}, {166.4, 70.7}, {165.1, 56.8},
{177.8, 60.0}, {165.1, 58.2}, {175.3, 72.7}, {154.9, 54.1}, {158.8, 49.1},
{172.7, 75.9}, {168.9, 55.0}, {161.3, 57.3}, {167.6, 55.0}, {165.1, 65.5},
{175.3, 65.5}, {157.5, 48.6}, {163.8, 58.6}, {167.6, 63.6}, {165.1, 55.2},
{165.1, 62.7}, {168.9, 56.6}, {162.6, 53.9}, {164.5, 63.2}, {176.5, 73.6},
{168.9, 62.0}, {175.3, 63.6}, {159.4, 53.2}, {160.0, 53.4}, {170.2, 55.0},
{162.6, 70.5}, {167.6, 54.5}, {162.6, 54.5}, {160.7, 55.9}, {160.0, 59.0},
{157.5, 63.6}, {162.6, 54.5}, {152.4, 47.3}, {170.2, 67.7}, {165.1, 80.9},
{172.7, 70.5}, {165.1, 60.9}, {170.2, 63.6}, {170.2, 54.5}, {170.2, 59.1},
{161.3, 70.5}, {167.6, 52.7}, {167.6, 62.7}, {165.1, 86.3}, {162.6, 66.4},
{152.4, 67.3}, {168.9, 63.0}, {170.2, 73.6}, {175.2, 62.3}, {175.2, 57.7},
{160.0, 55.4}, {165.1, 104 }, {174.0, 55.5}, {170.2, 77.3}, {160.0, 80.5},
{167.6, 64.5}, {167.6, 72.3}, {167.6, 61.4}, {154.9, 58.2}, {162.6, 81.8},
{175.3, 63.6}, {171.4, 53.4}, {157.5, 54.5}, {165.1, 53.6}, {160.0, 60.0},
{174.0, 73.6}, {162.6, 61.4}, {174.0, 55.5}, {162.6, 63.6}, {161.3, 60.9},
{156.2, 60.0}, {149.9, 46.8}, {169.5, 57.3}, {160.0, 64.1}, {175.3, 63.6},
{169.5, 67.3}, {160.0, 75.5}, {172.7, 68.2}, {162.6, 61.4}, {157.5, 76.8},
{176.5, 71.8}, {164.4, 55.5}, {160.7, 48.6}, {174.0, 66.4}, {163.8, 67.3}
};
return new AAChartModel()
.series(new AASeriesElement[]{
new AASeriesElement()
.name("目标")
.type(AAChartType.Polygon)
.data(goalDataArr)
.color("rgba(119, 152, 191, 0.5)")
,
new AASeriesElement()
.name("实际值")
.type(AAChartType.Scatter)
.data(trueDataArr)
.color("#ff0000")
,
});
}
public static AAChartModel polarChartMixed() {
return new AAChartModel()
.chartType(AAChartType.Column)
.polar(true)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Column")
.type(AAChartType.Column)
.data(new Object[] {8, 7, 6, 5, 4, 3, 2, 1}),
new AASeriesElement()
.name("Line")
.type(AAChartType.Line)
.data(new Object[] {1, 2, 3, 4, 5, 6, 7, 8}),
new AASeriesElement()
.name("Area")
.type(AAChartType.Area)
.data(new Object[] {1, 8, 2, 7, 3, 6, 4, 5})
,
});
}
public static AAChartModel configurePieMixedLineMixedColumnChart() {
AASeriesElement columnElement1 = new AASeriesElement()
.name("Anna")
.type(AAChartType.Column)
.data(new Object[]{ 3, 2, 1, 3, 4});
AASeriesElement columnElement2 = new AASeriesElement()
.name("Babara")
.type(AAChartType.Column)
.data(new Object[]{2, 3, 5, 7, 6});
AASeriesElement columnElement3 = new AASeriesElement()
.name("Coco")
.type(AAChartType.Column)
.data(new Object[]{4, 3, 3, 9, 0});
AASeriesElement lineElement = new AASeriesElement()
.name("average value")
.type(AAChartType.Line)
.data(new Object[]{3, 2.67, 3, 6.33, 3.33})
.marker(new AAMarker()
.fillColor("#1E90FF")
.lineWidth(2.0)
.lineColor(AAColor.White)
);
AAPie pieElement = new AAPie()
.type(AAChartType.Pie)
.center(new Object[]{ 100,80})
.size(100)
.showInLegend(true)
.dataLabels(
new AADataLabels()
.enabled(false))
.data(new AADataElement[]{
new AADataElement()
.name("Ada")
.y(13.0)
.color(AAGradientColor.OceanBlue)
,
new AADataElement()
.name("Bob")
.y(13.0)
.color(AAGradientColor.Sanguine)
,
new AADataElement()
.name("Coco")
.y(13.0)
.color(AAGradientColor.PurpleLake)
});
return new AAChartModel()
.stacking(AAChartStackingType.Normal)
.colorsTheme(new Object[]{
"#fe117c", "#ffc069", "#06caf4", "#7dffc0"
})
.dataLabelsEnabled(false)
.series(new Object[]{
columnElement1,
columnElement2,
columnElement3,
lineElement,
pieElement,
});
}
public static AAChartModel configureNegativeColorMixedAreasplineChart() {
return new AAChartModel()
.chartType(AAChartType.Areaspline)
.legendEnabled(false)
.dataLabelsEnabled(false)
.markerRadius(5)
.markerSymbolStyle(AAChartSymbolStyleType.InnerBlank)
.yAxisGridLineWidth(0)
.series(new AASeriesElement[]{
new AASeriesElement()
.name("Column")
.data(new Object[]{
+7.0, +6.9, +2.5, +14.5, +18.2, +21.5, +5.2, +26.5, +23.3, +45.3, +13.9, +9.6,
-7.0, -6.9, -2.5, -14.5, -18.2, -21.5, -5.2, -26.5, -23.3, -45.3, -13.9, -9.6,
})
.lineWidth(5)
.color(AARgba(30, 144, 255, 1.0f))
.negativeColor(AARgba(255, 0, 0, 1.0f))
.fillColor(AAGradientColor.linearGradient(
AALinearGradientDirection.ToTop,
new Object[][]{
{0.0, AARgba(30, 144, 255, 0.0f)},//颜色字符串设置支持十六进制类型和 rgba 类型
{0.5, AARgba(30, 144, 255, 0.0f)},
{1.0, AARgba(30, 144, 255, 0.6f)},}
))
.negativeFillColor(AAGradientColor.linearGradient(
AALinearGradientDirection.ToTop,
new Object[][]{
{0.0, AARgba(255, 0, 0, 0.6f)},//颜色字符串设置支持十六进制类型和 rgba 类型
{0.5, AARgba(255, 0, 0, 0.0f)},
{1.0, AARgba(255, 0, 0, 0.0f)},
}))
.threshold(0)//default:0
});
}
public static AAChartModel configureAerasplinerangeMixedColumnrangeMixedLineChart() {
return new AAChartModel()
.chartType(AAChartType.Line)
.dataLabelsEnabled(true)
.markerSymbol(AAChartSymbolType.Circle)
.markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)
.borderRadius(10)
.categories(new String[]{
"流水线",
"机器加工",
"冲床",
"模具工",
"机器加工",
"仓库",
"维修工",
"质检员",
})
.series(new Object[]{
new AASeriesElement()
.name("工资变化曲线")
.type(AAChartType.Areasplinerange)
.data(new Object[][]{
{3800, 5500},//流水线
{4000, 6500},//机器加工
{4000, 6800},//冲床
{4000, 7500},//模具工
{4200, 9000},//机器加工
{3800, 6800},//仓库
{5500, 7500},//维修工
{5000, 7200},//质检员
})
,
new AASeriesElement()
.name("工资变化棱形")
.color(AAGradientColor.OceanBlue)
.type(AAChartType.Columnrange)
.data(new Object[][]{
{3800, 5500},//流水线
{4000, 6500},//机器加工
{4000, 6800},//冲床
{4000, 7500},//模具工
{4200, 9000},//机器加工
{3800, 6800},//仓库
{5500, 7500},//维修工
{5000, 7200},//质检员
})
,
new AASeriesElement()
.name("八月份均值")
.lineWidth(8)
.data(new Object[]{
4000,//流水线
4400,//机器加工
4600,//冲床
5200,//模具工
5800,//机器加工
5000,//仓库
5500,//维修工
5000,//质检员
})
,
new AASeriesElement()
.name("九月份均值")
.lineWidth(8)
.data(new Object[]{
3868,//流水线
4084,//机器加工
4260,//冲床
4586,//模具工
5518,//机器加工
5483,//仓库
4962,//维修工
5821,//质检员
})
,
});
}
}
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.AdditionalContent.AdvancedUpdatingFeatureActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,235 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.anan.AAChartCore.ChartsDemo.MainContent.BasicChartActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#4b2b7f"
android:orientation="vertical">
<RadioGroup
android:id="@+id/stackingTypeRadioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/noStackingRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="noStacking"
android:textColor="@color/lightGray" />
<RadioButton
android:id="@+id/normalStackingRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="normalStacking"
android:textColor="@color/lightGray" />
<RadioButton
android:id="@+id/percentStackingRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="percentStacking"
android:textColor="@color/lightGray" />
</RadioGroup>
<RadioGroup
android:id="@+id/cornerStyleTypeRadioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/squareCornersRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="squareCorners"
android:textColor="@color/lightGray" />
<RadioButton
android:id="@+id/roundedCornersRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="roundedCorners"
android:textColor="@color/lightGray" />
<RadioButton
android:id="@+id/wedgeCornersRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="wedge"
android:textColor="@color/lightGray" />
</RadioGroup>
<RadioGroup
android:id="@+id/markerSymbolTypeRadioGroup"
android:layout_width="match_parent"
android:layout_height="38dp"
android:orientation="horizontal">
<RadioButton
android:id="@+id/circleSymbolRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="⬤⬤"
android:textColor="@color/lightGray"
android:textSize="22dp" />
<RadioButton
android:id="@+id/squareSymbolRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="■■"
android:textColor="@color/lightGray"
android:textSize="22dp" />
<RadioButton
android:id="@+id/diamondSymbolRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="◆◆"
android:textColor="@color/lightGray"
android:textSize="22dp" />
<RadioButton
android:id="@+id/triangleSymbolRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="▲▲"
android:textColor="@color/lightGray"
android:textSize="22dp" />
<RadioButton
android:id="@+id/triangleDownSymbolRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="▼▼"
android:textColor="@color/lightGray"
android:textSize="22dp" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Switch
android:id="@+id/xReversedSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Switch
android:id="@+id/yReversedSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Switch
android:id="@+id/xInvertedSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Switch
android:id="@+id/polarSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Switch
android:id="@+id/dataShowSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Switch
android:id="@+id/markerHideSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="xReversed"
android:textColor="@color/lightGray" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="yReversed"
android:textColor="@color/lightGray" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="xInverted"
android:textColor="@color/lightGray" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="polar"
android:textColor="@color/lightGray" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="dataShow"
android:textColor="@color/lightGray" />
<TextView
android:id="@+id/markerHideTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="markerHide"
android:textColor="@color/lightGray" />
</LinearLayout>
</LinearLayout>
<com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView
android:id="@+id/AAChartView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.MainContent.CustomStyleChartActivity">
<include
layout="@layout/content_special_chart"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.AdditionalContent.JSFunctionForAATooltipActivity">
<include layout="@layout/content_special_chart" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.AdditionalContent.DoubleChartsLinkedWorkActivity">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="1dp"
android:layout_marginLeft="1dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="1dp"
android:layout_marginRight="1dp"
android:layout_marginBottom="1dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView
android:id="@+id/AAChartView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView
android:id="@+id/AAChartView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.DrawChartWithAAOptionsActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_special_chart" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.anan.AAChartCore.ChartsDemo.AdditionalContent.EvaluateJSStringFunctionActivity">
<include layout="@layout/content_special_chart" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.AdditionalContent.HideOrShowChartSeriesActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/content_common_chart"
android:layout_width="match_parent"
android:layout_height="500dp" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/stackingTypeRadioGroup"
android:orientation="horizontal">
<RadioButton
android:id="@+id/hide1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="hide 1" />
<RadioButton
android:id="@+id/hide2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="hide 2" />
<RadioButton
android:id="@+id/hide3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="hide 3" />
<RadioButton
android:id="@+id/hide4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="hide 4"
/>
</RadioGroup>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="38dp"
android:id="@+id/markerSymbolTypeRadioGroup"
android:orientation="horizontal">
<RadioButton
android:id="@+id/show1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="show 1" />
<RadioButton
android:id="@+id/show2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="show 2" />
<RadioButton
android:id="@+id/show3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="show 3" />
<RadioButton
android:id="@+id/show4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="show 4" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Switch
android:id="@+id/switch2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Switch
android:id="@+id/switch3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Switch
android:id="@+id/switch4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Switch
android:id="@+id/switch5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="seriesHidden" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="yReversed" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="xInverted" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="polarization" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="dataShow" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.AdditionalContent.JSFunctionForAAChartEventsActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.anan.AAChartCore.ChartsDemo.MainContent.MainActivity">
<ExpandableListView
android:id="@+id/exlist_lol"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:childDivider="#D5D5D5" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.MainContent.MainContent.MixedChartActivity">
<include
layout="@layout/content_common_chart"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.AdditionalContent.OnlyRefreshChartDataActivity">
<include
layout="@layout/content_special_chart"
tools:layout_editor_absoluteX="-16dp"
tools:layout_editor_absoluteY="-151dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.AdditionalContent.ScrollableChartActivity">
<com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView
android:id="@+id/AAChartView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.AdditionalContent.ScrollingUpdateDataActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.anan.AAChartCore.ChartsDemo.MainContent.MainContent.SpecialChartActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_special_chart" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChartsDemo.AdditionalContent.UpdateChartBackgroundColorActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.anan.AAChartCore.ChartsDemo.MainContent.MainContent.CommonChartActivity"
tools:showIn="@layout/activity_basic_chart">
<com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView
android:id="@+id/AAChartView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.anan.AAChartCore.ChartsDemo.MainContent.MainContent.SpecialChartActivity"
tools:showIn="@layout/activity_special_chart">
<com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView
android:id="@+id/AAChartView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="@+id/tv_group_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:gravity="center_vertical"
android:paddingLeft="30dp"
android:text="AP"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="@+id/tv_colorful_index"
android:layout_width="48dp"
android:layout_height="match_parent"
android:gravity="center_vertical|center"
android:text="◉"
android:textSize="20dp"></TextView>
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:focusable="false"
android:gravity="center_vertical|left"
android:text="图表名称"
android:textColor="#123456"
android:textSize="18sp" />
</LinearLayout>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="white">#FFFFFF</color>
<color name="lightGray">#cccccc</color>
</resources>
@@ -0,0 +1,3 @@
<resources>
<dimen name="fab_margin">16dp</dimen>
</resources>
@@ -0,0 +1,5 @@
<resources>
<string name="app_name">AAChartCore</string>
<string name="title_activity_common_chart">CommonChartActivity</string>
<string name="title_activity_special_chart">SpecialChartActivity</string>
</resources>
@@ -0,0 +1,20 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
@@ -0,0 +1,17 @@
package com.example.anan.AAChartCore;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}