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 2021/02/19 13:53:20 UTC

[echarts] 01/01: This code has been modified in 8c2267d45 (see #11854) and merge into next branch in dd3d83cc4, but in 58dc3f701 the merge was not correct enough (it cause the drillDownIcon displayed repeatedly in some case). So fix it according to 8c2267d45. And add the missing test case.

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

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

commit 2a49feb09737c44e7a6d7677880a03ab0961e6d7
Author: 100pah <su...@gmail.com>
AuthorDate: Fri Feb 19 21:52:13 2021 +0800

    This code has been modified in 8c2267d45 (see #11854) and merge into next branch in dd3d83cc4,
    but in 58dc3f701 the merge was not correct enough (it cause the drillDownIcon displayed repeatedly in some case).
    So fix it according to 8c2267d45. And add the missing test case.
---
 src/chart/treemap/TreemapView.ts |  13 +-
 test/treemap-action.html         | 416 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 418 insertions(+), 11 deletions(-)

diff --git a/src/chart/treemap/TreemapView.ts b/src/chart/treemap/TreemapView.ts
index 81e78c7..d784c81 100644
--- a/src/chart/treemap/TreemapView.ts
+++ b/src/chart/treemap/TreemapView.ts
@@ -959,16 +959,7 @@ function renderNode(
             upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL
         );
 
-        let text = retrieve(
-            seriesModel.getFormattedLabel(
-                thisNode.dataIndex, 'normal', null, null, normalLabelModel.get('formatter')
-            ),
-            convertOptionIdName(nodeModel.get('name'), null)
-        );
-        if (!upperLabelRect && thisLayout.isLeafRoot) {
-            const iconChar = seriesModel.get('drillDownIcon', true);
-            text = iconChar ? iconChar + ' ' + text : text;
-        }
+        const defaultText = convertOptionIdName(nodeModel.get('name'), null);
 
         const isShow = normalLabelModel.getShallow('show');
 
@@ -976,7 +967,7 @@ function renderNode(
             rectEl,
             getLabelStatesModels(nodeModel, upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL),
             {
-                defaultText: isShow ? text : null,
+                defaultText: isShow ? defaultText : null,
                 inheritColor: visualColor,
                 defaultOpacity: visualOpacity,
                 labelFetcher: seriesModel,
diff --git a/test/treemap-action.html b/test/treemap-action.html
new file mode 100755
index 0000000..1b33110
--- /dev/null
+++ b/test/treemap-action.html
@@ -0,0 +1,416 @@
+<!DOCTYPE html>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+<html>
+    <head>
+        <meta charset="utf-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1" />
+        <script src="lib/esl.js"></script>
+        <script src="lib/config.js"></script>
+        <script src="lib/jquery.min.js"></script>
+        <script src="lib/facePrint.js"></script>
+        <script src="lib/testHelper.js"></script>
+        <!-- <script src="ut/lib/canteen.js"></script> -->
+        <link rel="stylesheet" href="lib/reset.css" />
+    </head>
+    <body>
+        <style>
+            .test-title {
+                background: #146402;
+                color: #fff;
+            }
+        </style>
+
+
+        <div id="main0"></div>
+        <div id="main1"></div>
+        <div id="main2"></div>
+
+
+
+
+
+        <script>
+
+            var option;
+
+            require([
+                'echarts'/*, 'map/js/china' */
+            ], function (echarts) {
+
+                var option = {
+                    series: [
+                        {
+                            name:'矩形树图',
+                            type:'treemap',
+                            roam: false,
+                            emphasis: {
+                                itemStyle: {
+                                    borderColor: 'red'
+                                }
+                            },
+                            levels: [
+                                {
+                                    itemStyle: {
+                                        borderWidth: 0,
+                                        gapWidth: 30,
+                                        borderColor: '#999'
+                                    },
+                                },
+                                {
+                                    itemStyle: {
+                                        borderWidth: 15,
+                                        gapWidth: 40,
+                                        borderColor: '#333'
+                                    }
+                                },
+                                {
+                                    itemStyle: {
+                                        borderWidth: 10,
+                                        borderColor: '#555570'
+                                    }
+                                }
+                            ],
+                            data:[
+                                {
+                                    name: '三星',
+                                    value: 6,
+                                },
+                                {
+                                    name: '小米',
+                                    value: 4,
+                                    children: [
+                                        {
+                                            name: '小米0',
+                                            value: 10,
+                                            children: [
+                                                {
+                                                    itemStyle: {
+                                                        color: 'orange'
+                                                    },
+                                                    name: '小尺',
+                                                    value: 400
+                                                },
+                                                {
+                                                    name: '小寸',
+                                                    value: 200
+                                                },
+                                                {
+                                                    name: '小光年',
+                                                    value: 100
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            name: '小米1',
+                                            value: 4
+                                        },
+                                        {
+                                            name: '小米2',
+                                            value: 4
+                                        }
+                                    ]
+                                },
+                                {
+                                    name: '中兴',
+                                    value: 1
+                                }
+                            ]
+                        }
+                    ]
+                };
+
+                var chart = testHelper.create(echarts, 'main0', {
+                    option: option,
+                    title: [
+                        'click to dispatchAction hightlight dataIndex 2',
+                        'broder color become **red**'
+                    ],
+                    buttons: [{
+                        text: 'highlight dataIndex: 2',
+                        onclick: function () {
+                            chart.dispatchAction({
+                                type: 'highlight',
+                                seriesIndex: 0,
+                                dataIndex: 2
+                            });
+                        }
+                    }]
+                });
+            });
+
+        </script>
+
+
+
+
+
+
+
+        <script>
+
+            var option;
+
+            require([
+                'echarts'/*, 'map/js/china' */
+            ], function (echarts) {
+
+                var option = {
+                    series: [
+                        {
+                            type:'treemap',
+                            roam: false,
+                            label: {
+                                formatter: function (params) {
+                                    console.log('incb', params.name);
+                                    return params.name;
+                                }
+                            },
+                            emphasis: {
+                                itemStyle: {
+                                    borderColor: 'red'
+                                },
+                                label: {
+                                    formatter: function (params) {
+                                        return 'SERIES ' + params.name;
+                                    }
+                                }
+                            },
+                            levels: [{
+                                itemStyle: {
+                                    borderWidth: 0,
+                                    gapWidth: 30,
+                                    borderColor: '#999'
+                                },
+                                emphasis: {
+                                    label: {
+                                        formatter: function (params) {
+                                            return 'LEVEL0 ' + params.name;
+                                        }
+                                    }
+                                }
+                            }, {
+                                itemStyle: {
+                                    borderWidth: 15,
+                                    gapWidth: 40,
+                                    borderColor: '#333'
+                                },
+                                emphasis: {
+                                    label: {
+                                        formatter: function (params) {
+                                            return 'LEVEL1 ' + params.name;
+                                        }
+                                    }
+                                }
+                            }, {
+                                itemStyle: {
+                                    borderWidth: 10,
+                                    borderColor: '#555570'
+                                },
+                                emphasis: {
+                                    label: {
+                                        formatter: function (params) {
+                                            return 'LEVEL2 ' + params.name;
+                                        }
+                                    }
+                                }
+                            }],
+                            data:[{
+                                name: '三星',
+                                value: 6,
+                            }, {
+                                name: '小米',
+                                value: 4,
+                                children: [{
+                                    name: '小米0',
+                                    value: 10,
+                                    children: [{
+                                        itemStyle: {
+                                            color: 'orange'
+                                        },
+                                        emphasis: {
+                                            label: {
+                                                formatter: function (params) {
+                                                    return 'ITEM ' + params.name;
+                                                }
+                                            }
+                                        },
+                                        name: '小尺',
+                                        value: 400
+                                    }, {
+                                        name: '小寸',
+                                        value: 200
+                                    }, {
+                                        name: '小光年',
+                                        value: 100
+                                    }]
+                                }, {
+                                    name: '小米1',
+                                    value: 4
+                                }, {
+                                    name: '小米2',
+                                    value: 4
+                                }]
+                            }, {
+                                name: '中兴',
+                                value: 1
+                            }]
+                        }
+                    ]
+                };
+
+                var chart = testHelper.create(echarts, 'main1', {
+                    option: option,
+                    height: 600,
+                    title: [
+                        'hover the rect, the label should be added with a prefix (SERIES/LEVELX/ITEM)'
+                    ]
+                });
+            });
+
+        </script>
+
+
+
+
+
+
+
+
+
+
+
+        <script>
+
+            var option;
+
+            require([
+                'echarts'/*, 'map/js/china' */
+            ], function (echarts) {
+
+                var option = {
+                    series: [
+                        {
+                            name: 'Phone or length',
+                            type:'treemap',
+                            roam: false,
+                            leafDepth: 2,
+                            label: {
+                                formatter: function (params) {
+                                    console.log('incb', params.name);
+                                    return params.name;
+                                }
+                            },
+                            upperLabel: {
+                                show: true,
+                                height: 30,
+                                color: 'green'
+                            },
+                            emphasis: {
+                                itemStyle: {
+                                    borderColor: 'red'
+                                },
+                                label: {
+                                    formatter: function (params) {
+                                        return 'LABEL ' + params.name;
+                                    }
+                                },
+                                upperLabel: {
+                                    formatter: function (params) {
+                                        return 'UPPERLABEL ' + params.name;
+                                    }
+                                }
+                            },
+                            levels: [{
+                                itemStyle: {
+                                    borderWidth: 0,
+                                    gapWidth: 30,
+                                    borderColor: '#999'
+                                }
+                            }, {
+                                itemStyle: {
+                                    borderWidth: 15,
+                                    gapWidth: 40,
+                                    borderColor: '#333'
+                                }
+                            }, {
+                                itemStyle: {
+                                    borderWidth: 10,
+                                    borderColor: '#555570'
+                                }
+                            }],
+                            data:[{
+                                name: '三星',
+                                value: 6,
+                            }, {
+                                name: '小米',
+                                value: 4,
+                                children: [{
+                                    name: '小米0',
+                                    value: 10,
+                                    children: [{
+                                        itemStyle: {
+                                            color: 'orange'
+                                        },
+                                        name: '小尺',
+                                        value: 400
+                                    }, {
+                                        name: '小寸',
+                                        value: 200
+                                    }, {
+                                        name: '小光年',
+                                        value: 100
+                                    }]
+                                }, {
+                                    name: '小米1',
+                                    value: 4
+                                }, {
+                                    name: '小米2',
+                                    value: 4
+                                }]
+                            }, {
+                                name: '中兴',
+                                value: 1
+                            }]
+                        }
+                    ]
+                };
+
+                var chart = testHelper.create(echarts, 'main2', {
+                    option: option,
+                    height: 600,
+                    title: [
+                        'hover the rect:',
+                        '**label** should be added with a prefix "LABEL"',
+                        '**upper label** should be added with a prefix "UPPERLABEL"',
+                        '**drill down icon** should remain'
+                    ]
+                });
+            });
+
+        </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