You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by de...@apache.org on 2018/12/19 12:54:51 UTC

[incubator-echarts] branch master updated: fix(markLine): fix subPixel in markLine #9598

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

deqingli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/master by this push:
     new ddee8a4  fix(markLine): fix subPixel in markLine #9598
ddee8a4 is described below

commit ddee8a404ab91127266e17a3148fbaea2d1612b5
Author: deqingli <an...@gmail.com>
AuthorDate: Wed Dec 19 20:53:53 2018 +0800

    fix(markLine): fix subPixel in markLine #9598
---
 src/chart/helper/Line.js | 39 ++++++++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/chart/helper/Line.js b/src/chart/helper/Line.js
index 726061c..e5f3cfc 100644
--- a/src/chart/helper/Line.js
+++ b/src/chart/helper/Line.js
@@ -58,22 +58,33 @@ function createSymbol(name, lineData, idx) {
     return symbolPath;
 }
 
-function createLine(points) {
+function createLine(points, lineWidth) {
     var line = new LinePath({
         name: 'line'
     });
-    setLinePoints(line.shape, points);
+    setLinePoints(line.shape, points, lineWidth);
     return line;
 }
 
-function setLinePoints(targetShape, points) {
-    var p1 = points[0];
-    var p2 = points[1];
+function setLinePoints(targetShape, points, lineWidth) {
+    var subPixelParam = graphic.subPixelOptimizeLine({
+        shape: {
+            x1: points[0][0],
+            y1: points[0][1],
+            x2: points[1][0],
+            y2: points[1][1]
+        },
+        style: {
+            lineWidth: lineWidth
+        }
+    });
+
+    var shape = subPixelParam.shape;
     var cp1 = points[2];
-    targetShape.x1 = p1[0];
-    targetShape.y1 = p1[1];
-    targetShape.x2 = p2[0];
-    targetShape.y2 = p2[1];
+    targetShape.x1 = shape.x1;
+    targetShape.y1 = shape.y1;
+    targetShape.x2 = shape.x2;
+    targetShape.y2 = shape.y2;
     targetShape.percent = 1;
 
     if (cp1) {
@@ -206,8 +217,8 @@ lineProto.beforeUpdate = updateSymbolAndLabelBeforeLineUpdate;
 lineProto._createLine = function (lineData, idx, seriesScope) {
     var seriesModel = lineData.hostModel;
     var linePoints = lineData.getItemLayout(idx);
-
-    var line = createLine(linePoints);
+    var lineStyle = seriesScope && seriesScope.lineStyle;
+    var line = createLine(linePoints, lineStyle.lineWidth);
     line.shape.percent = 0;
     graphic.initProps(line, {
         shape: {
@@ -242,7 +253,9 @@ lineProto.updateData = function (lineData, idx, seriesScope) {
     var target = {
         shape: {}
     };
-    setLinePoints(target.shape, linePoints);
+    var lineStyle = seriesScope && seriesScope.lineStyle;
+
+    setLinePoints(target.shape, linePoints, lineStyle.lineWidth);
     graphic.updateProps(line, target, seriesModel, idx);
 
     zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
@@ -394,7 +407,7 @@ lineProto.updateLayout = function (lineData, idx) {
 
 lineProto.setLinePoints = function (points) {
     var linePath = this.childOfName('line');
-    setLinePoints(linePath.shape, points);
+    setLinePoints(linePath.shape, points, linePath.style.lineWidth);
     linePath.dirty();
 };
 


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