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

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

commit 21790a840dc6b9aab2523cc1020f3ab2c7fcb50c
Author: 100pah <[email protected]>
AuthorDate: Mon Jun 23 18:57:59 2025 +0800

    fix(logScale): fix the breaking introduced by axisBreak.
---
 src/scale/helper.ts |  10 +--
 test/logScale.html  | 193 ++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 187 insertions(+), 16 deletions(-)

diff --git a/src/scale/helper.ts b/src/scale/helper.ts
index 67cb3c558..31f41945e 100644
--- a/src/scale/helper.ts
+++ b/src/scale/helper.ts
@@ -163,11 +163,13 @@ function scale(
     return val * (extent[1] - extent[0]) + extent[0];
 }
 
-export function logTransform(base: number, extent: number[]): [number, number] 
{
+export function logTransform(base: number, extent: number[], noClampNegative?: 
boolean): [number, number] {
     const loggedBase = Math.log(base);
     return [
-        // log(negative) is NaN, so safe guard here
-        Math.log(Math.max(0, extent[0])) / loggedBase,
-        Math.log(Math.max(0, extent[1])) / loggedBase
+        // log(negative) is NaN, so safe guard here.
+        // PENDING: But even getting a -Infinity still does not make sense in 
extent.
+        //  Just keep it as is, getting a NaN to make some previous cases 
works by coincidence.
+        Math.log(noClampNegative ? extent[0] : Math.max(0, extent[0])) / 
loggedBase,
+        Math.log(noClampNegative ? extent[1] : Math.max(0, extent[1])) / 
loggedBase
     ];
 }
diff --git a/test/logScale.html b/test/logScale.html
index def5bfdfd..5db142b7a 100644
--- a/test/logScale.html
+++ b/test/logScale.html
@@ -21,25 +21,30 @@ under the License.
 <html>
     <head>
         <meta charset='utf-8'>
-        <script src='lib/simpleRequire.js'></script>
-        <script src='lib/config.js'></script>
+        <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="lib/canteen.js"></script> -->
+        <!-- <script src="lib/draggable.js"></script> -->
+        <link rel="stylesheet" href="lib/reset.css" />
     </head>
     <body>
         <style>
-            html, body, #main, #main1 {
-                width: 100%;
-                height: 100%;
-            }
         </style>
-        <div id='main'></div>
-        <div id='main1'></div>
+
+        <!-- <div id='main0'></div>
+        <div id='main1'></div> -->
+        <div id='main2_negative'></div>
+
+
         <script>
 
             require([
                 'echarts'
             ], function (echarts) {
-            var chart = echarts.init(document.getElementById('main'));
-                chart.setOption({
+                var option = {
                     title: {
                         text: '对数轴示例',
                         x: 'center'
@@ -79,18 +84,28 @@ under the License.
                         type: 'line',
                         data: [1, 0.1, 0.01, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 
1e-8]
                     }]
+                };
+
+                var chart = testHelper.create(echarts, 'main0', {
+                    title: [
+                        'log test 1',
+                    ],
+                    option: option,
                 });
+
+
             });
 
         </script>
+
+
         <script>
 
             require([
                 'echarts'
             ], function (echarts) {
-                var chart = echarts.init(document.getElementById('main1'));
                 // See #13154
-                chart.setOption({
+                var option = {
                     xAxis: {
                         type: 'value',
                     },
@@ -109,9 +124,163 @@ under the License.
                             ],
                         },
                     ],
+                };
+
+                var chart = testHelper.create(echarts, 'main1', {
+                    title: [
+                        'log test 2',
+                    ],
+                    option: option,
                 });
+
+
             });
 
         </script>
+
+
+
+        <script>
+
+
+            require([
+                'echarts',
+            ], function (echarts /*, data */) {
+
+                var option = {
+                    backgroundColor: 'rgba(0,0,0,0.1)',
+                    legend: {
+                        top: 3,
+                        backgroundColor: 'rgba(250,0,0,0.4)',
+                        borderRadius: 3,
+                        borderWidth: 2,
+                        borderColor: 'rgba(150,0,0,0.7)'
+                    },
+                    tooltip: {},
+                    xAxis: [
+                        {
+                            id: 0,
+                            name: 'xAxis_0 long name',
+                            nameTextStyle: {
+                                rich: {
+                                    name_big_1: {
+                                        borderWidth: 4,
+                                        borderColor: 'rgba(0,180,0,0.5)',
+                                        backgroundColor: 'rgba(0,150,0,0.5)',
+                                        padding: [10, 20],
+                                        color: '#000',
+                                        fontSize: 20
+                                    }
+                                },
+                                color: '#555'
+                            },
+                            nameMoveOverlap: true,
+                            nameLocation: 'middle',
+                            axisLabel: {
+                                textStyle: {
+                                    rich: {
+                                        label_big_1: {
+                                            borderWidth: 4,
+                                            borderColor: 'rgba(0,180,0,0.5)',
+                                            backgroundColor: 
'rgba(0,150,0,0.5)',
+                                            padding: [10, 20],
+                                            color: '#000',
+                                            fontSize: 20
+                                        }
+                                    },
+                                    color: '#555'
+                                }
+                            },
+                            axisLine: {onZero: false},
+                            position: ['bottom', 'top']
+                        }
+                    ],
+                    yAxis: [
+                        {
+                            id: 0,
+                            name: 'yAxis_0 long name',
+                            type: 'log',
+                            nameTextStyle: {
+                                rich: {
+                                    name_big_1: {
+                                        borderWidth: 4,
+                                        borderColor: 'rgba(0,180,0,0.5)',
+                                        backgroundColor: 'rgba(0,150,0,0.5)',
+                                        padding: [10, 20],
+                                        color: '#000',
+                                        fontSize: 20
+                                    }
+                                },
+                                color: '#555'
+                            },
+                            nameMoveOverlap: true,
+                            nameLocation: 'middle',
+                            axisLabel: {
+                                textStyle: {
+                                    rich: {
+                                        label_big_1: {
+                                            borderWidth: 4,
+                                            borderColor: 'rgba(0,180,0,0.5)',
+                                            backgroundColor: 
'rgba(0,150,0,0.5)',
+                                            padding: [10, 20],
+                                            color: '#000',
+                                            fontSize: 20
+                                        }
+                                    },
+                                    color: '#555'
+                                }
+                            },
+                            axisLine: {onZero: false},
+                            position: ['left', 'right']
+                        }
+                    ],
+                    grid: [
+                        {
+                            left: 100,
+                            right: 10,
+                            top: 30,
+                            bottom: 100,
+                            show: true,
+                            backgroundColor: 'rgba(150,0,0,0.2)'
+                        }
+                    ],
+                    series: [
+                        {
+                            xAxisIndex: 0,
+                            yAxisIndex: 0,
+                            symbolSize: 10,
+                            name: 'series_small_0',
+                            data: [[-50, 12]],
+                            type: 'scatter'
+                        },
+                        {
+                            xAxisIndex: 0,
+                            yAxisIndex: 0,
+                            symbolSize: 10,
+                            name: 'series_big_0',
+                            data: [
+                                [10000000000, -832],
+                                [55555550000, 31133232233]
+                            ],
+                            type: 'scatter'
+                        }
+                    ]
+                };
+
+                var chart = testHelper.create(echarts, 'main2_negative', {
+                    title: [
+                        'Test negative',
+                    ],
+                    option: option,
+                });
+
+            });
+
+
+        </script>
+
+
+
+
     </body>
 </html>
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to