You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2021/01/02 13:06:58 UTC

[incubator-echarts] 03/05: test(symbol): add test case for symbol clip.

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

wangzx pushed a commit to branch feat/symbol-clip
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit efb329e4a1aafd06beccb3cf4865fe34c7941cba
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Sat Jan 2 20:58:54 2021 +0800

    test(symbol): add test case for symbol clip.
---
 test/symbol-clip.html | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 162 insertions(+)

diff --git a/test/symbol-clip.html b/test/symbol-clip.html
new file mode 100644
index 0000000..9b99525
--- /dev/null
+++ b/test/symbol-clip.html
@@ -0,0 +1,162 @@
+<!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" />
+        <style>
+            #main0 {
+                height: calc(100% - 120px);
+            }
+            .test-title-inner {
+                text-align: center;
+            }
+            .test-chart-block-left, .test-chart {
+                height: 100%;
+            }
+        </style>
+    </head>
+    <body>
+
+
+        <div id="main0"></div>
+
+
+        <script>
+        require(['echarts'], function (echarts) {
+            var CLIP_PATHS = [
+                'NO CLIPPING', // for test
+                'circle(50px at 50 50)',
+                'ellipse(20px 20px at 50% 50%);',
+                'inset(10% 20% 30% 10% round 100%);',
+                'rect(25% 3% 10% 5% round 0%);',
+                'rect(25% round 0%);',
+                'path(M215,100.3c97.8-32.6,90.5-71.9,336-77.6 c92.4-2.1,98.1,81.6,121.8,116.4c101.7,149.9,53.5,155.9,14.7,178c-96.4,54.9,5.4,269-257,115.1c-57-33.5-203,46.3-263.7,20.1c-33.5-14.5-132.5-45.5-95-111.1C125.9,246.6,98.6,139.1,215,100.3z)',
+                'path(M680.96 494.933H573.44l20.48-141.653c0-5.12-3.413-8.533-6.827-10.24h-1.706c-1.707 0-5.12 1.707-6.827 3.413L404.48 549.547c-3.413 3.413-1.707 8.533 1.707 11.946 1.706 1.707 3.413 1.707 5.12 1.707h109.226l-20.48 141.653c0 5.12 3.414 8.534 6.827 10.24h1.707c1.706 0 5.12-1.706 6.826-3.413l174.08-203.093c3.414-3.414 1.707-8.534-1.706-11.947-3.414-1.707-5.12-1.707-6.827-1.707z)',
+                'path(\'M0.5,1 C0.5,1,0,0.7,0,0.3 A0.25,0.25,1,1,1,0.5,0.3 A0.25,0.25,1,1,1,1,0.3 C1,0.7,0.5,1,0.5,1 Z\')',
+                'path(M348.16 276.48c-7.68 15.36-20.48 25.6-33.28 25.6L120.32 332.8c-74.24 12.8-102.4 104.96-51.2 161.28l138.24 140.8c10.24 12.8 15.36 28.16 12.8 40.96L189.44 870.4c-12.8 76.8 66.56 135.68 130.56 99.84l171.52-92.16c12.8-7.68 28.16-7.68 40.96 0l171.52 92.16c64 35.84 143.36-20.48 130.56-99.84l-33.28-197.12c-2.56-15.36 2.56-30.72 12.8-43.52l138.24-138.24c53.76-56.32 23.04-148.48-48.64-161.28l-192-28.16c-15.36-2.56-28.16-12.8-33.28-25.6l-84.48-181.76c-33.28-71.68-128-71.68-16 [...]
+                'path(M126.153,71.798c0,35.275-30.128,31.452-65.403,31.452S0.411,107.073,0.411,71.798S34,0.927,63.282,0.927             C92,0.927,126.153,36.523,126.153,71.798z)',
+                'path(M971.464704 668.658688 968.998912 651.020288 965.843968 633.814016 963.337216 624.9728 960.917504 615.569408 957.71648 606.598144 954.430464 596.612096 950.668288 587.208704 946.562048 577.545216 939.254784 561.765376 932.769792 547.8656 926.285824 535.437312 920.62208 523.848704 914.138112 513.301504 909.382656 503.616512 899.309568 489.15456 886.64064 469.894144 883.70176 465.138688 882.707456 463.107072 882.707456 461.50656 884.825088 455.000064 887.763968 449.20 [...]
+                'path(M331.428571 263.428571q0-23.428571-14.285714-37.714285t-37.714286-14.285715q-24.571429 0-43.428571 14.571429T217.142857 263.428571q0 22.285714 18.857143 36.857143t43.428571 14.571429q23.428571 0 37.714286-14t14.285714-37.428572z m424.571429 289.714286q0-16-14.571429-28.571428t-37.428571-12.571429q-15.428571 0-28.285714 12.857143T662.857143 553.142857q0 16 12.857143 28.857143t28.285714 12.857143q22.857143 0 37.428571-12.571429t14.571429-29.142857z m-134.857143-289.71 [...]
+                'path(M210.410732 410.339412H68.474355a68.421137 68.421137 0 0 0-68.182617 74.128577l39.866898 476.801278a68.438174 68.438174 0 0 0 68.182617 62.730733h102.069479a34.210568 34.210568 0 0 0 34.210568-34.210568V444.567017a34.227605 34.227605 0 0 0-34.210568-34.227605zM953.792071 410.339412H647.583632C752.941279 19.98456 574.340986 0 574.340986 0c-75.781179 0-60.07294 60.004792-65.763343 69.971516 0 144.883801-116.380673 265.881539-172.90989 316.107015a67.875948 67.875948 0  [...]
+                'path(M673.92 175.04l-64 11.2-14.08-78.72 64-11.2zM864 486.72l75.2 27.2 20.8-60.16-75.2-27.2zM919.68 224l-41.28-48.32-61.12 51.52 40.96 48.96z m-232.64 196.16A256 256 0 0 0 192 490.88 192 192 0 0 0 256 864h384a224 224 0 0 0 47.04-442.88z m34.88-40.32a268.16 268.16 0 0 1 105.28 62.4A158.08 158.08 0 0 0 838.4 384a160 160 0 0 0-241.28-136.96 306.56 306.56 0 0 1 124.8 133.76z)',
+                'polygon(50% 30%, 100% 0%, 70% 50%, 100% 100%, 50% 70%, 0% 100%, 30% 50%, 0% 0%);',
+                'polygon(50% 0%, 60% 40%, 100% 50%, 50% 100%, 40% 60%, 0% 50%)',
+                'polygon(50% 2.4%, 34.5% 33.8%, 0% 38.8%, 25% 63.1%, 19.1% 97.6%, 50% 81.3%, 80.9% 97.6%, 75% 63.1%, 100% 38.8%, 65.5% 33.8%);',
+                'polygon(30% 31%, 20% 84%, 83% 83%, 93% 42%, 90% 18%, 58% 13%, 5% 14%, 13% 50%);',
+                'polygon(0% 0%, 100% 0%, 100% 75%, 75% 75%, 75% 100%, 50% 75%, 0% 75%);',
+                'polygon(40% 0%, 40% 20%, 100% 20%, 100% 80%, 40% 80%, 40% 100%, 0% 50%);',
+                'polygon(20% 0%, 0% 20%, 30% 50%, 0% 80%, 20% 100%, 50% 70%, 80% 100%, 100% 80%, 70% 50%, 100% 20%, 80% 0%, 50% 30%);',
+                'polygon(50% 0%, 80% 10%, 100% 35%, 100% 70%, 80% 90%, 50% 100%, 20% 90%, 0% 70%, 0% 35%, 20% 10%);',
+                'polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);'
+            ];
+
+            var symbolSize = 100;
+            var dpr = window.devicePixelRatio || 1;
+
+            var option = {
+                textStyle: {
+                    fontFamily: 'PingFang SC'
+                },
+                title: {
+                    text: 'Various Clipping of Symbol'
+                },
+                xAxis: {
+                    type: 'category'
+                },
+                yAxis: {
+                    type: 'value'
+                },
+                grid: {
+                    top: '10%',
+                    left: '5%',
+                    right: '5%',
+                    bottom: '10%'
+                },
+                toolbox: {
+                    feature: {
+                        saveAsImage: {}
+                    }
+                },
+                dataZoom: [
+                    {
+                        show: true,
+                        realtime: true,
+                        xAxisIndex: [0, 1]
+                    },
+                    {
+                        type: 'inside',
+                        realtime: true,
+                        xAxisIndex: [0, 1]
+                    }
+                ],
+                series: [{
+                    type: 'line',
+                    symbolSize: symbolSize,
+                    symbol: function(rawValue, params) {
+                        return 'image://https://picsum.photos/' + symbolSize * dpr/* + '?_=' + params.dataIndex;*/
+                    },
+                    // symbolRotate: function(rawValue, params) {
+                    //     return ~~rawValue[1] % 360;
+                    // },
+                    symbolClip: function(rawValue, params) {
+                        return CLIP_PATHS[params.dataIndex % CLIP_PATHS.length];
+                    },
+                    label: {
+                        show: true,
+                        formatter: function (params) {
+                            var clip = CLIP_PATHS[params.dataIndex % CLIP_PATHS.length];
+                            var idx = clip.indexOf('(');
+                            return clip.slice(0, idx === -1 ? undefined : idx)/* + '('+ (~~params.value[1] % 360) +'°)'*/;
+                        }
+                    },
+                    data: (function() {
+                        var data = [];
+                        while (data.length < CLIP_PATHS.length) {
+                            data.push([data.length, ~~ (Math.random() * 2000)]);
+                        }
+                        return data;
+                    })()
+                }]
+            };
+
+            var chart = testHelper.create(echarts, 'main0', {
+                title: [
+                    'Various Clipping of Symbol',
+                    `The supported currently rules are '**inset**'、'**rect**'、'**circle**'、'**ellipse**'、'**polygon**'、'**path**'`,
+                    'https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path'
+                ],
+                option: option
+            });
+        });
+        </script>
+
+    </body>
+</html>
+


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