You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/05/18 02:46:23 UTC

[echarts] branch fix-map-small-region created (now 1120b9d)

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

shenyi pushed a change to branch fix-map-small-region
in repository https://gitbox.apache.org/repos/asf/echarts.git.


      at 1120b9d  test: add map test for optimizing small regions.

This branch includes the following new commits:

     new 1120b9d  test: add map test for optimizing small regions.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


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


[echarts] 01/01: test: add map test for optimizing small regions.

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch fix-map-small-region
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 1120b9d8ee0e0ee13af5b2f6781cfbc6ecc19f3d
Author: pissang <bm...@gmail.com>
AuthorDate: Tue May 18 10:45:31 2021 +0800

    test: add map test for optimizing small regions.
    
    update zrender version
---
 package-lock.json                 |   6 +-
 package.json                      |   2 +-
 src/coord/geo/fix/nanhai.ts       |  10 ++-
 test/data/map/json/china-new.json |   1 +
 test/map-china.html               | 125 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 139 insertions(+), 5 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 3115dfa..65b0f4e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10974,9 +10974,9 @@
       }
     },
     "zrender": {
-      "version": "npm:zrender-nightly@5.1.1-dev.20210512",
-      "resolved": "https://registry.npmjs.org/zrender-nightly/-/zrender-nightly-5.1.1-dev.20210512.tgz",
-      "integrity": "sha512-4Vk0QSncG7CSNr4T2EZts+jmgkZkAaFbf03nXJYzLIUVagqa0OcnoVyj6Sg3is7YiYpoqHi0oj0cAEN36Q8IjQ==",
+      "version": "npm:zrender-nightly@5.1.1-dev.20210518",
+      "resolved": "https://registry.npmjs.org/zrender-nightly/-/zrender-nightly-5.1.1-dev.20210515.tgz",
+      "integrity": "sha512-b5ukUUmK6fRhbm6ecT/KuBN8mzKZhMEu0iOwEgeK/xIzvLPwMAdbkYf8Y5PH2zJvFN9jV/IFv6YxjOFOyqNQZQ==",
       "requires": {
         "tslib": "2.0.3"
       }
diff --git a/package.json b/package.json
index 8eaf3a9..ba20fe2 100644
--- a/package.json
+++ b/package.json
@@ -63,7 +63,7 @@
   },
   "dependencies": {
     "tslib": "2.0.3",
-    "zrender": "npm:zrender-nightly@^5.1.1-dev.20210512"
+    "zrender": "npm:zrender-nightly@^5.1.1-dev.20210518"
   },
   "devDependencies": {
     "@babel/code-frame": "7.10.4",
diff --git a/src/coord/geo/fix/nanhai.ts b/src/coord/geo/fix/nanhai.ts
index e1dd612..971bc57 100644
--- a/src/coord/geo/fix/nanhai.ts
+++ b/src/coord/geo/fix/nanhai.ts
@@ -23,6 +23,7 @@ import * as zrUtil from 'zrender/src/core/util';
 import { GeoJSONRegion } from '../Region';
 
 const geoCoord = [126, 25];
+const nanhaiName = '南海诸岛';
 
 const points = [
     [[0, 3.5], [7, 11.2], [15, 11.9], [30, 7], [42, 0.7], [52, 0.7],
@@ -53,8 +54,15 @@ for (let i = 0; i < points.length; i++) {
 
 export default function fixNanhai(mapType: string, regions: GeoJSONRegion[]) {
     if (mapType === 'china') {
+        for (let i = 0; i < regions.length; i++) {
+            // Already exists.
+            if (regions[i].name === nanhaiName) {
+                return;
+            }
+        }
+
         regions.push(new GeoJSONRegion(
-            '南海诸岛',
+            nanhaiName,
             zrUtil.map(points, function (exterior) {
                 return {
                     type: 'polygon',
diff --git a/test/data/map/json/china-new.json b/test/data/map/json/china-new.json
new file mode 100644
index 0000000..ada90de
--- /dev/null
+++ b/test/data/map/json/china-new.json
@@ -0,0 +1 @@
+{"type":"FeatureCollection","features":[{"type":"Feature","id":"710000","properties":{"id":"710000","cp":[121.509062,24.044332],"name":"台湾","childNum":6},"geometry":{"type":"MultiPolygon","coordinates":[["@@°Ü¯Û"],["@@ƛĴÕƊÉɼģºðʀ\\ƎsÆNŌÔĚäœnÜƤɊĂǀĆĴžĤNJŨxĚĮǂƺòƌ‚–âÔ®ĮXŦţƸZûЋƕƑGđ¨ĭMó·ęcëƝɉlÝƯֹÅŃ^Ó·śŃNjƏďíåɛGɉ™¿@ăƑŽ¥ĘWǬÏĶŁâ"],["@@\\p|WoYG¿¥I†j@¢"],["@@…¡‰@ˆV^RqˆBbAŒnTXeRz¤Lž«³I"],["@@ÆEE—„kWqë @œ"],["@@fced"],["@@„¯ɜÄèaì¯ØǓIġĽ"],["@@çûĖ롖hòř "],["@@Ձ@BQ@GH}Ho_}eƒQ…RqèùZɖ¡Ā•ÐÙhߦYC|@NA [...]
\ No newline at end of file
diff --git a/test/map-china.html b/test/map-china.html
new file mode 100644
index 0000000..76878b4
--- /dev/null
+++ b/test/map-china.html
@@ -0,0 +1,125 @@
+<!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/simpleRequire.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>
+        </style>
+
+
+
+        <div id="main0"></div>
+        <div id="main1"></div>
+
+
+
+
+
+
+        <script>
+        require([
+            'echarts',
+            'map/json/china-new.json'
+        ], function (echarts, chinaJson) {
+            var option;
+            echarts.registerMap('china', chinaJson)
+
+            option = {
+                series: {
+                    type: 'map',
+                    map: 'china'
+                }
+            };
+
+            var chart = testHelper.create(echarts, 'main0', {
+                title: [
+                    'Can still draw small islands on a small container',
+                ],
+                height: 200,
+                option: option
+            });
+        });
+        </script>
+
+
+        <script>
+        require([
+            'echarts',
+            'map/json/china-new.json'
+        ], function (echarts, chinaJson) {
+            var option;
+            echarts.registerMap('china', chinaJson)
+
+            option = {
+                series: {
+                    type: 'map',
+                    map: 'china',
+                    itemStyle: {
+                        areaColor: '#fff'
+                    },
+                    data: [{
+                        name: '广西',
+                        itemStyle: {
+                            areaColor: '#ddd'
+                        }
+                    }, {
+                        name: '广东',
+                        itemStyle: {
+                            areaColor: '#aaa'
+                        }
+                    }, {
+                        name: '海南',
+                        itemStyle: {
+                            areaColor: '#bbb'
+                        }
+                    }, {
+                        name: '台湾',
+                        itemStyle: {
+                            areaColor: '#ccc'
+                        }
+                    }]
+                }
+            };
+
+            var chart = testHelper.create(echarts, 'main1', {
+                title: [
+                    'Colors are correct on specifed areas',
+                ],
+                option: option
+            });
+        });
+        </script>
+
+
+    </body>
+</html>
+

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