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 2022/01/22 17:52:55 UTC

[echarts] branch fix-heatmap-gap created (now a0d50ce)

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

wangzx pushed a change to branch fix-heatmap-gap
in repository https://gitbox.apache.org/repos/asf/echarts.git.


      at a0d50ce  fix(heatmap): add 0.5px to avoid the gaps when dpr is not an integer.

This branch includes the following new commits:

     new a0d50ce  fix(heatmap): add 0.5px to avoid the gaps when dpr is not an integer.

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: fix(heatmap): add 0.5px to avoid the gaps when dpr is not an integer.

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

wangzx pushed a commit to branch fix-heatmap-gap
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit a0d50cec4fb26ac53fb8267ffafc0b6419eba01d
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Sun Jan 23 01:49:08 2022 +0800

    fix(heatmap): add 0.5px to avoid the gaps when dpr is not an integer.
---
 src/chart/heatmap/HeatmapView.ts | 10 ++++++----
 test/heatmap-gap-bug.html        |  6 +++++-
 test/heatmap-large.html          |  8 ++++++--
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/chart/heatmap/HeatmapView.ts b/src/chart/heatmap/HeatmapView.ts
index 253fe50..11258d6 100644
--- a/src/chart/heatmap/HeatmapView.ts
+++ b/src/chart/heatmap/HeatmapView.ts
@@ -247,10 +247,12 @@ class HeatmapView extends ChartView {
 
                 rect = new graphic.Rect({
                     shape: {
-                        x: Math.floor(Math.round(point[0]) - width / 2),
-                        y: Math.floor(Math.round(point[1]) - height / 2),
-                        width: Math.ceil(width),
-                        height: Math.ceil(height)
+                        x: point[0] - width / 2,
+                        y: point[1] - height / 2,
+                        // gaps usually appear when dpr is not an integer
+                        // add 0.5px to avoid the gaps
+                        width: width + .5,
+                        height: height + .5
                     },
                     style
                 });
diff --git a/test/heatmap-gap-bug.html b/test/heatmap-gap-bug.html
index a6793b0..1fd6b73 100644
--- a/test/heatmap-gap-bug.html
+++ b/test/heatmap-gap-bug.html
@@ -97,7 +97,11 @@ under the License.
             </div>
         </div>
         <script>
-
+            // gap usually appears when dpr is not an integer
+            Object.defineProperty(window, 'devicePixelRatio', {
+                value: 2.5,
+                writable: false
+            });
             require([
                 'echarts'
             ], function (echarts) {
diff --git a/test/heatmap-large.html b/test/heatmap-large.html
index d0be16b..9271ad2 100644
--- a/test/heatmap-large.html
+++ b/test/heatmap-large.html
@@ -36,7 +36,11 @@ under the License.
         </style>
         <div id="main"></div>
         <script>
-
+            // gap usually appears when dpr is not an integer
+            Object.defineProperty(window, 'devicePixelRatio', {
+                value: 2.5,
+                writable: false
+            });
             require([
                 'echarts'
             ], function (echarts) {
@@ -111,4 +115,4 @@ under the License.
 
         </script>
     </body>
-</html>
\ No newline at end of file
+</html>

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