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/09/12 15:54:06 UTC

[incubator-echarts] 01/04: Fix legend highlight bug brought by previous update.

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

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

commit 5fc79255907a3819962de391367c3450f0315e36
Author: sushuang <su...@gmail.com>
AuthorDate: Wed Sep 12 15:30:00 2018 +0800

    Fix legend highlight bug brought by previous update.
---
 src/component/legend/LegendView.js | 25 +++++++------
 test/legend.html                   | 73 +++++++++++++++++++++++++++++++-------
 2 files changed, 75 insertions(+), 23 deletions(-)

diff --git a/src/component/legend/LegendView.js b/src/component/legend/LegendView.js
index 169c16b..acc6ce6 100644
--- a/src/component/legend/LegendView.js
+++ b/src/component/legend/LegendView.js
@@ -166,8 +166,8 @@ export default echarts.extendComponentView({
                 );
 
                 itemGroup.on('click', curry(dispatchSelectAction, name, api))
-                    .on('mouseover', curry(dispatchHighlightAction, seriesModel, null, api, excludeSeriesId))
-                    .on('mouseout', curry(dispatchDownplayAction, seriesModel, null, api, excludeSeriesId));
+                    .on('mouseover', curry(dispatchHighlightAction, seriesModel.name, null, api, excludeSeriesId))
+                    .on('mouseout', curry(dispatchDownplayAction, seriesModel.name, null, api, excludeSeriesId));
 
                 legendDrawnMap.set(name, true);
             }
@@ -199,9 +199,10 @@ export default echarts.extendComponentView({
 
                         // FIXME: consider different series has items with the same name.
                         itemGroup.on('click', curry(dispatchSelectAction, name, api))
-                            // FIXME Should not specify the series name
-                            .on('mouseover', curry(dispatchHighlightAction, seriesModel, name, api, excludeSeriesId))
-                            .on('mouseout', curry(dispatchDownplayAction, seriesModel, name, api, excludeSeriesId));
+                            // Should not specify the series name, consider legend controls
+                            // more than one pie series.
+                            .on('mouseover', curry(dispatchHighlightAction, null, name, api, excludeSeriesId))
+                            .on('mouseout', curry(dispatchDownplayAction, null, name, api, excludeSeriesId));
 
                         legendDrawnMap.set(name, true);
                     }
@@ -211,7 +212,9 @@ export default echarts.extendComponentView({
 
             if (__DEV__) {
                 if (!legendDrawnMap.get(name)) {
-                    console.warn(name + ' series not exists. Legend data should be same with series name or data name.');
+                    console.warn(
+                        name + ' series not exists. Legend data should be same with series name or data name.'
+                    );
                 }
             }
         }, this);
@@ -254,7 +257,7 @@ export default echarts.extendComponentView({
         // PENDING
         if (!itemIcon && symbolType
             // At least show one symbol, can't be all none
-            && ((symbolType !== legendSymbolType) || symbolType == 'none')
+            && ((symbolType !== legendSymbolType) || symbolType === 'none')
         ) {
             var size = itemHeight * 0.8;
             if (symbolType === 'none') {
@@ -361,26 +364,26 @@ function dispatchSelectAction(name, api) {
     });
 }
 
-function dispatchHighlightAction(seriesModel, dataName, api, excludeSeriesId) {
+function dispatchHighlightAction(seriesName, dataName, api, excludeSeriesId) {
     // If element hover will move to a hoverLayer.
     var el = api.getZr().storage.getDisplayList()[0];
     if (!(el && el.useHoverLayer)) {
         api.dispatchAction({
             type: 'highlight',
-            seriesName: seriesModel.name,
+            seriesName: seriesName,
             name: dataName,
             excludeSeriesId: excludeSeriesId
         });
     }
 }
 
-function dispatchDownplayAction(seriesModel, dataName, api, excludeSeriesId) {
+function dispatchDownplayAction(seriesName, dataName, api, excludeSeriesId) {
     // If element hover will move to a hoverLayer.
     var el = api.getZr().storage.getDisplayList()[0];
     if (!(el && el.useHoverLayer)) {
         api.dispatchAction({
             type: 'downplay',
-            seriesName: seriesModel.name,
+            seriesName: seriesName,
             name: dataName,
             excludeSeriesId: excludeSeriesId
         });
diff --git a/test/legend.html b/test/legend.html
index 849ac31..24e6c60 100644
--- a/test/legend.html
+++ b/test/legend.html
@@ -69,8 +69,10 @@ under the License.
 
         <div id="legendHoverLink"></div>
 
+        <div id="multi-pie"></div>
 
         <script>
+
             function makeSeries(seriesCount, categoryCount) {
                 var series = [];
                 var legendData = [];
@@ -812,17 +814,6 @@ under the License.
 
 
 
-
-
-
-
-
-
-
-
-
-
-
         <script>
 
             var chart;
@@ -875,7 +866,7 @@ under the License.
                     ]
                 }
 
-                chart = myChart = testHelper.create(echarts, legendHoverLink, {
+                chart = myChart = testHelper.create(echarts, 'legendHoverLink', {
                     title: 'legendHoverLink is disabled on pie',
                     option: option
                 });
@@ -883,5 +874,63 @@ under the License.
 
         </script>
 
+
+
+
+
+
+
+
+
+
+        <script>
+
+            var chart;
+            var myChart;
+            var option;
+
+            require([
+                'echarts'/*, 'map/js/china' */
+            ], function (echarts) {
+
+                var option = {
+                    tooltip: {
+                    },
+                    legend: {
+                        data: ['a', 'b', 'c']
+                    },
+                    series: [
+                        {
+                            name: 'AAA',
+                            type: 'pie',
+                            center: ['75%', '50%'],
+                            radius: '30%',
+                            data: [
+                                {name: 'a', value: 12},
+                                {name: 'b', value: 34},
+                                {name: 'c', value: 56}
+                            ]
+                        },
+                        {
+                            name: 'BBB',
+                            type: 'pie',
+                            center: ['25%', '50%'],
+                            radius: '30%',
+                            data: [
+                                {name: 'a', value: 12},
+                                {name: 'b', value: 34},
+                                {name: 'c', value: 56}
+                            ]
+                        }
+                    ]
+                }
+
+                chart = myChart = testHelper.create(echarts, 'multi-pie', {
+                    title: 'Hover legend, the segments of BOTH pie should be hightlighted',
+                    option: option
+                });
+            });
+
+        </script>
     </body>
 </html>
\ No newline at end of file


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