An An 5 months ago
parent
commit
c0ba8fbd42

+ 8 - 12
charts/src/main/assets/AAChartView.js

@@ -73,18 +73,14 @@ function configureChartTouchEvent(aaPlotOptions) {
 }
 
 function onlyRefreshTheChartDataWithSeries(receivedSeries, animation) {
-    var receivedSeriesArr = JSON.parse(receivedSeries);
-    var seriesArrLength = receivedSeriesArr.length;
-    for (var i = 0; i < seriesArrLength; i++) {
-        var receivedSeriesElementData = receivedSeriesArr[i].data;
-        // 获取series
-        var seriesElement = aaGlobalChart.series[i];
-        // 执行只刷新数据的函数
-        seriesElement.setData(receivedSeriesElementData, false);
-    }
-
-    var animationBool = (animation == "true") ? true:false;
-    aaGlobalChart.redraw(animationBool);
+    let receivedSeriesArr = JSON.parse(receivedSeries);
+    let animationBool = (animation === "true");
+
+    aaGlobalChart.update({
+            series: receivedSeriesArr
+        },
+        true, false, animationBool
+    );
 }
 
 function updateChart(optionsStr, redraw) {

+ 5 - 2
sample/src/main/java/com/github/aachartmodel/aainfographics/demo/additionalcontent/DoubleChartsLinkedWorkActivity.kt

@@ -93,13 +93,15 @@ class DoubleChartsLinkedWorkActivity : AppCompatActivity(),
             .setDataLabelsEnabled(false)
             .setBorderRadius(4F)
             .setLegendEnabled(false)
+            .setColorsTheme(gradientColorArr)
             .setTouchEventEnabled(true)
             .setSeries(
                 AASeriesElement()
                     .name("")
                     .data(arrayOf(149.9, 154, 106.4, 129.2, 144.0, 154, 135.6, 154, 154, 154, 95.6, 54.4))
+                    .colorByPoint(true)
                     //里面最大值是154
-                    .color(AAGradientColor.linearGradient("rgba(242,82,70,0.2)","rgba(242,82,70,1.0)"))   //柱状图渐变色
+//                    .color(AAGradientColor.linearGradient("rgba(242,82,70,0.2)","rgba(242,82,70,1.0)"))   //柱状图渐变色
                     .borderWidth(2F)
                     .dataLabels(
                         AADataLabels().enabled(true).verticalAlign(AAChartVerticalAlignType.Middle)
@@ -208,7 +210,8 @@ class DoubleChartsLinkedWorkActivity : AppCompatActivity(),
             aaChartView2?.aa_updateXAxisCategories(configureXAxisCategoresDataArray(), false)
 
             aaChartView2?.aa_onlyRefreshTheChartDataWithChartOptionsSeriesArray(
-                aaSeriesElementsArr
+                aaSeriesElementsArr,
+                false
             )
         }
     }