Pashted commented on code in PR #19435:
URL: https://github.com/apache/echarts/pull/19435#discussion_r1436429361


##########
test/pie-itemRadiusScale.html:
##########
@@ -0,0 +1,291 @@
+<!--
+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">
+    <script src="lib/simpleRequire.js"></script>
+    <script src="lib/config.js"></script>
+    <style>
+        body {
+            margin: 0;
+        }
+
+        #main {
+            width:  100%;
+            height: 92%;
+        }
+
+        p {
+            text-align: center;
+        }
+
+        button {
+            padding:    5px 15px;
+            background: lightgray;
+            cursor:     pointer;
+        }
+
+        button:hover {
+            background: transparent;
+        }
+    </style>
+</head>
+<body>
+<p>
+    <button type="button"
+            onclick="selectRandomValues()">
+        Random selection
+    </button>
+</p>
+<div id="main"></div>
+<script>
+    let dataset = {
+        dimensions: ['key', 'value', 'selected'],
+        source: [
+            ['A', 1092, 112],
+            ['B', 768, 499],
+            ['C', 604, 257],
+            ['D', 238, 180]
+        ],
+    };
+
+    function selectRandomValues() {
+        dataset.source.forEach(row => {
+            row[2] = row[1] * Math.random();
+        });
+        chart.setOption({dataset});
+    }
+
+
+    function itemScale(params) {
+        const {data = []} = params;
+        return data[2] / data[1];
+    }
+
+    function itemScaleQuadratic(params) {
+        const {value, encode} = params;
+        const val = value[encode.value?.[0]];
+        const selected = value[encode.value?.[1]];
+        const scale = selected / val;
+        return Math.pow(scale, 1 / 2);
+    }
+
+    function itemScaleCubic(params) {
+        const {value, encode} = params;
+        const val = value[encode.value?.[0]];
+        const selected = value[encode.value?.[1]];
+        const scale = selected / val;
+        return Math.pow(scale, 1 / 3);
+    }
+
+    let chart;
+
+    require([
+        'echarts'
+    ], function (echarts) {
+        chart = echarts.init(document.getElementById('main'), null, {});
+
+        chart.setOption({
+            legend: {
+                itemStyle: {
+                    opacity: 1
+                }
+            },
+            tooltip: {trigger: 'item'},
+            dataset: dataset,
+            title: [
+                createTitle([1, 1], 'default'),
+                createTitle([1, 2], 'extra pie as background'),
+                createTitle([1, 3], 'donut style'),
+                createTitle([2, 1], 'cubic scale'),
+                createTitle([2, 2], 'quadratic scale'),
+                createTitle([2, 3], 'quadratic scale + donut style'),
+            ],
+            series: [
+                /** example #1: scaling based on a simple function */
+                createScaledSeries(
+                    [1, 1],
+                    {},
+                    itemScale
+                ),
+
+                /** example #2: add pie with the same angles,
+                 * but full radius and semitransparent background */
+                createBackgroundSeries([1, 2]),

Review Comment:
   Intuitively, it seems that the background style in the series root will be 
applied to the entire pie. it's not obvious that the function is called on 
every element. If I'm trying to intuitively understand property names, then it 
seems more logical for me to put the style of the elements into itemStyle. Like 
`series-pie.itemStyle.backgroundStyle.color`.
   
   But this entry `series-pie.backgroundStyle.opacity` with a numeric type 
rather than a function seems clear to me. This tells me that transparency will 
work the same on all elements



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to