You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2018/04/27 08:36:04 UTC

[incubator-echarts] branch master updated: Fix stack on time axis.

This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/master by this push:
     new 752a288  Fix stack on time axis.
     new 332b086  Merge branch 'master' of https://github.com/apache/incubator-echarts
752a288 is described below

commit 752a288d7d6f3d8fc9628268a9286318311a54e3
Author: sushuang <su...@gmail.com>
AuthorDate: Fri Apr 27 16:35:27 2018 +0800

    Fix stack on time axis.
---
 src/data/helper/dataStackHelper.js |   8 +-
 test/area-stack.html               | 162 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 168 insertions(+), 2 deletions(-)

diff --git a/src/data/helper/dataStackHelper.js b/src/data/helper/dataStackHelper.js
index e470edc..d0c9145 100644
--- a/src/data/helper/dataStackHelper.js
+++ b/src/data/helper/dataStackHelper.js
@@ -72,10 +72,16 @@ export function enableDataStack(seriesModel, dimensionInfoList, opt) {
         }
     });
 
+    if (stackedDimInfo && !byIndex && !stackedByDimInfo) {
+        // Compatible with previous design, value axis (time axis) only stack by index.
+        // It may make sense if the user provides elaborately constructed data.
+        byIndex = true;
+    }
+
     // Add stack dimension, they can be both calculated by coordinate system in `unionExtent`.
     // That put stack logic in List is for using conveniently in echarts extensions, but it
     // might not be a good way.
-    if (stackedDimInfo && (byIndex || stackedByDimInfo)) {
+    if (stackedDimInfo) {
         // Use a weird name that not duplicated with other names.
         stackResultDimension = '__\0ecstackresult';
         stackedOverDimension = '__\0ecstackedover';
diff --git a/test/area-stack.html b/test/area-stack.html
index bfef3a1..7d2b9ab 100644
--- a/test/area-stack.html
+++ b/test/area-stack.html
@@ -19,7 +19,7 @@
 
         <div id="main0"></div>
         <div id="main1"></div>
-
+        <div id="main2"></div>
 
 
 
@@ -400,5 +400,165 @@
         </script>
 
 
+
+
+
+
+
+
+
+
+        <script>
+
+            var chart;
+            var myChart;
+            var option;
+
+            require(['echarts'], function (echarts) {
+
+                var data = [
+                    [["2016-10-4",44],["2016-10-5",54],["2016-10-6",47],["2016-10-7",37],["2016-10-8",36],["2016-10-9",30],["2016-10-10",20],["2016-10-11",21],["2016-10-12",29]],
+                    [["2016-10-4",28],["2016-10-5",38],["2016-10-6",44],["2016-10-7",40],["2016-10-8",42],["2016-10-9",39],["2016-10-10",46],["2016-10-11",50],["2016-10-12",46]]
+                ];
+
+                var option = {
+                    legend: {
+                    },
+                    tooltip: {
+                        triggerOn: 'none',
+                        position: function (pt) {
+                            return [pt[0], 130];
+                        }
+                    },
+                    toolbox: {
+                        left: 'center',
+                        itemSize: 25,
+                        top: 55,
+                        feature: {
+                            dataZoom: {
+                                yAxisIndex: 'none'
+                            },
+                            restore: {}
+                        }
+                    },
+                    xAxis: {
+                        type: 'time',
+                        axisPointer: {
+                            value: '2016-10-7',
+                            snap: true,
+                            lineStyle: {
+                                color: '#004E52',
+                                opacity: 0.5,
+                                width: 2
+                            },
+                            label: {
+                                show: true,
+                                formatter: function (params) {
+                                    return echarts.format.formatTime('yyyy-MM-dd', params.value);
+                                },
+                                backgroundColor: '#004E52'
+                            },
+                            handle: {
+                                show: true,
+                                color: '#004E52'
+                            }
+                        },
+                        splitLine: {
+                            show: false
+                        }
+                    },
+                    yAxis: {
+                        type: 'value',
+                        axisTick: {
+                            inside: true
+                        },
+                        splitLine: {
+                            show: false
+                        },
+                        axisLabel: {
+                            inside: true,
+                            formatter: '{value}\n'
+                        },
+                        z: 10
+                    },
+                    grid: {
+                        top: 110,
+                        left: 15,
+                        right: 15,
+                        height: 160
+                    },
+                    dataZoom: [{
+                        type: 'inside',
+                        throttle: 50
+                    }],
+                    series: [
+                        {
+                            name:'line1',
+                            type:'line',
+                            smooth: true,
+                            symbol: 'circle',
+                            symbolSize: 5,
+                            sampling: 'average',
+                            itemStyle: {
+                                normal: {
+                                    color: '#8ec6ad'
+                                }
+                            },
+                            stack: 'a',
+                            areaStyle: {
+                                normal: {
+                                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+                                        offset: 0,
+                                        color: '#8ec6ad'
+                                    }, {
+                                        offset: 1,
+                                        color: '#ffe'
+                                    }])
+                                }
+                            },
+                            data: data[0]
+                        },
+                        {
+                            name:'line2',
+                            type:'line',
+                            smooth:true,
+                            stack: 'a',
+                            symbol: 'circle',
+                            symbolSize: 5,
+                            sampling: 'average',
+                            itemStyle: {
+                                normal: {
+                                    color: '#d68262'
+                                }
+                            },
+                            areaStyle: {
+                                normal: {
+                                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+                                        offset: 0,
+                                        color: '#d68262'
+                                    }, {
+                                        offset: 1,
+                                        color: '#ffe'
+                                    }])
+                                }
+                            },
+                            data: data[1]
+                        }
+
+                    ]
+                };
+
+                testHelper.create(echarts, 'main2', {
+                    title: 'Stack on time axis (byIndex)',
+                    option: option
+                });
+            });
+
+        </script>
+
+
+
+
+
     </body>
 </html>
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
sushuang@apache.org.

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org