VisActor / VChart

VChart, more than just a cross-platform charting library, but also an expressive data storyteller.
https://www.visactor.io/vchart
MIT License
1.01k stars 72 forks source link

[Bug] markPoint itemLine's symbol render sometimes work not as expected #3455

Open kkxxkk2019 opened 15 hours ago

kkxxkk2019 commented 15 hours ago

Version

lastest

Link to Minimal Reproduction

none

Steps to Reproduce

const spec = {
  "direction": "vertical",
  "type": "common",
  "color": [
    "#00295C",
    "#2568BD",
    "#9F9F9F",
    "#C5C5C5",
    "#00B0F0",
    "#4BCFFF",
    "#C2C2C2",
    "#D7D7D7"
  ],
  "series": [
    {
      "direction": "vertical",
      "type": "scatter",
      "stack": false,
      "_editor_spec_size": [
        5,
        50
      ],
      "label": {
        "visible": true,
        "position": "top",
        "style": {
          "lineHeight": "100%",
          "fontSize": 16,
          "fontWeight": "bold"
        },
        "overlap": {
          "strategy": []
        },
        "smartInvert": true,
        "formatConfig": {
          "content": "text"
        },
        "interactive": true
      },
      "point": {
        "style": {}
      },
      "invalidType": "ignore",
      "_editor_spec_text_field": "date",
      "xField": "a",
      "yField": "b",
      "dataId": "0",
      "id": "series-0"
    }
  ],
  "legends": {
    "id": "legend-discrete",
    "visible": false,
    "autoPage": false,
    "position": "start",
    "interactive": false,
    "item": {
      "label": {
        "style": {
          "fill": "#1F2329",
          "fontSize": 16
        }
      }
    },
    "_originalVisible": true
  },
  "axes": [
    {
      "label": {
        "autoLimit": false,
        "style": {
          "fill": "#1F2329",
          "fontSize": 16
        },
        "formatConfig": {}
      },
      "domainLine": {
        "visible": true,
        "style": {
          "stroke": "#000000"
        }
      },
      "tick": {
        "visible": true,
        "style": {
          "stroke": "#000000"
        }
      },
      "grid": {
        "visible": false,
        "style": {
          "stroke": "#bbbfc4"
        }
      },
      "autoIndent": false,
      "maxWidth": null,
      "maxHeight": null,
      "orient": "left",
      "id": "axis-left",
      "type": "linear",
      "zero": false
    },
    {
      "label": {
        "autoLimit": false,
        "style": {
          "fill": "#1F2329",
          "fontSize": 16
        },
        "formatConfig": {}
      },
      "domainLine": {
        "visible": true,
        "style": {
          "stroke": "#000000"
        }
      },
      "tick": {
        "visible": true,
        "style": {
          "stroke": "#000000"
        }
      },
      "grid": {
        "visible": false,
        "style": {
          "stroke": "#bbbfc4"
        }
      },
      "autoIndent": false,
      "maxWidth": null,
      "maxHeight": null,
      "orient": "bottom",
      "id": "axis-bottom",
      "type": "linear",
      "zero": false,
      "paddingInner": [
        0.6737160120845922,
        0
      ],
      "paddingOuter": [
        0.6737160120845922,
        0
      ]
    }
  ],
  "data": [
    {
      "id": "0",
      "sourceKey": "total",
      "specField": {
        "_editor_dimension_field": {
          "type": "dimension",
          "order": 0
        },
        "_editor_type_field": {
          "type": "series",
          "order": 0
        },
        "_editor_value_field": {
          "type": "value",
          "order": 0
        }
      },
      "values": [
        {
          "date": "x1",
          "a": 20,
          "b": 20
        },
        {
          "date": "x2",
          "a": 23,
          "b": 24
        },
        {
          "date": "x3",
          "a": 26,
          "b": 29
        }
      ]
    }
  ],
  "markArea": [],
  "markLine": [],
  "markPoint": [
    {
      "itemLine": {
        "decorativeLine": {
          "visible": false
        },
        "startSymbol": {
          "size": 10,
          "visible": true,
          "style": {
            "fill": "#000",
            "stroke": "#000",
            "lineWidth": 0,
            "color": "#000",
            "fillOpacity": 0.3
          },
          "originSymbolType": "solidArrow",
          "symbolType": "M -1 1.5 L 0 0 L 1 1.5 Z",
          "refX": 0
        },
        "endSymbol": {
          "style": {
            "fill": false,
            "stroke": "#000",
            "lineWidth": 1,
            "color": "#000"
          },
          "visible": false,
          "size": 10,
          "originSymbolType": "arrow",
          "symbolType": "<svg><path d=\"M -1 1 L 0 0 L 1 1\"/></svg>",
          "refX": -5
        },
        "line": {
          "style": {
            "stroke": "#000",
            "pickStrokeBuffer": 5
          }
        },
        "type": "type-po",
        "arcRatio": 0.02
      },
      "itemContent": {
        "offsetY": -78.4375,
        "offsetX": 126.34765625,
        "type": "text",
        "autoRotate": false,
        "confine": false,
        "position": "middle",
        "text": {
          "text": [
            "箭头没有对齐数据点"
          ],
          "containerTextAlign": "center",
          "padding": 4,
          "style": {
            "fontSize": 16,
            "fill": "#000"
          },
          "labelBackground": {
            "visible": false,
            "style": {
              "lineWidth": 1,
              "stroke": "#000"
            }
          }
        },
        "refX": 0,
        "refY": 0
      },
      "id": "cb0bdec8-3406-4774-8071-4b9cae1f9855",
      "name": "mark-point",
      "interactive": true,
      "position": {
        "x": "56.744706003289465%",
        "y": "5.859375%"
      },
      "regionRelative": true,
      "targetSymbol": {
        "visible": true,
        "style": {
          "size": 10,
          "fill": "#000",
          "lineWidth": 0
        },
        "offset": 0
      },
      "zIndex": 520
    },
    {
      "itemLine": {
        "decorativeLine": {
          "visible": false
        },
        "startSymbol": {
          "size": 50,
          "visible": true,
          "style": {
            "fill": false,
            "stroke": "#f54a45",
            "lineWidth": 1,
            "color": "#f54a45"
          },
          "originSymbolType": "arrow",
          "symbolType": "<svg><path d=\"M -1 1 L 0 0 L 1 1\"/></svg>",
          "refX": 0
        },
        "endSymbol": {
          "style": {
            "fill": false,
            "stroke": "#f54a45",
            "lineWidth": 1,
            "color": "#f54a45"
          },
          "visible": false,
          "size": 10,
          "originSymbolType": "arrow",
          "symbolType": "<svg><path d=\"M -1 1 L 0 0 L 1 1\"/></svg>",
          "refX": 0
        },
        "line": {
          "style": {
            "stroke": "#f54a45",
            "pickStrokeBuffer": 5,
            "lineWidth": 4,
            "lineDash": [
              0,
              0
            ]
          }
        },
        "type": "type-arc",
        "arcRatio": 0.02,
        "visible": true
      },
      "itemContent": {
        "offsetY": -53.15234375,
        "offsetX": -1.05078125,
        "type": "text",
        "autoRotate": false,
        "confine": false,
        "position": "middle",
        "text": {
          "text": [
            "箭头没有对齐数据点"
          ],
          "containerTextAlign": "center",
          "padding": 4,
          "style": {
            "fontSize": 16,
            "fill": "#000"
          },
          "labelBackground": {
            "visible": false,
            "style": {
              "lineWidth": 4,
              "stroke": "#f54a45",
              "lineDash": [
                0,
                0
              ]
            }
          }
        },
        "refX": 0,
        "refY": 0
      },
      "id": "4feb0db9-d48e-4639-abe2-fbf77794b5a0",
      "name": "mark-point",
      "interactive": true,
      "position": {
        "x": "20.932488692434212%",
        "y": "60.89043674698795%"
      },
      "regionRelative": true,
      "targetSymbol": {
        "visible": true,
        "style": {
          "size": 10,
          "fill": "#f54a45",
          "lineWidth": 0,
          "stroke": "#f54a45"
        },
        "offset": 4
      },
      "zIndex": 520
    },
    {
      "itemLine": {
        "decorativeLine": {
          "visible": false
        },
        "startSymbol": {
          "size": 10,
          "visible": true,
          "style": {
            "fill": "#000",
            "stroke": "#000",
            "lineWidth": 0,
            "color": "#000",
            "fillOpacity": 0.3

          },
          "originSymbolType": "solidArrow",
          "symbolType": "M -1 1.5 L 0 0 L 1 1.5 Z",
          "refX": 0
        },
        "endSymbol": {
          "style": {
            "fill": false,
            "stroke": "#000",
            "lineWidth": 1,
            "color": "#000"
          },
          "visible": false,
          "size": 10,
          "originSymbolType": "arrow",
          "symbolType": "<svg><path d=\"M -1 1 L 0 0 L 1 1\"/></svg>",
          "refX": -5
        },
        "line": {
          "style": {
            "stroke": "#000",
            "pickStrokeBuffer": 5
          }
        },
        "type": "type-op",
        "arcRatio": 0.02
      },
      "itemContent": {
        "offsetY": -42.01953125,
        "offsetX": 131.6328125,
        "type": "text",
        "autoRotate": false,
        "confine": false,
        "position": "middle",
        "text": {
          "text": [
            "箭头没有对齐数据点"
          ],
          "containerTextAlign": "center",
          "padding": 4,
          "style": {
            "fontSize": 16,
            "fill": "#000"
          },
          "labelBackground": {
            "visible": false,
            "style": {
              "lineWidth": 1,
              "stroke": "#000"
            }
          }
        },
        "refX": 0,
        "refY": 0
      },
      "id": "c275a3bd-d798-4896-9b3f-a1af2820361b",
      "name": "mark-point",
      "interactive": true,
      "position": {
        "x": "47.58493523848684%",
        "y": "36.24341114457831%"
      },
      "regionRelative": true,
      "targetSymbol": {
        "visible": true,
        "style": {
          "size": 10,
          "fill": "#000",
          "lineWidth": 0
        },
        "offset": 0
      },
      "zIndex": 520
    },
    {
      "id": "23eb184a-7fe8-42ad-b955-71c362baaab8",
      "name": "mark-point",
      "interactive": true,
      "position": {
        "x": "22.201377467105264%",
        "y": "12.70590173192771%"
      },
      "regionRelative": true,
      "itemContent": {
        "offsetX": -160.43359375,
        "offsetY": 20.83203125,
        "type": "text",
        "autoRotate": false,
        "confine": false,
        "position": "middle",
        "text": {
          "text": [
            "弧线两端在某些角度下有尖角",
            "设置了 lineCap 也无用"
          ],
          "containerTextAlign": "center",
          "padding": 4,
          "style": {
            "fontSize": 16,
            "fill": "#000"
          },
          "labelBackground": {
            "visible": false,
            "style": {
              "lineWidth": 3,
              "stroke": "#f54a45",
              "lineDash": [
                0,
                0
              ]
            }
          }
        },
        "refX": 0,
        "refY": 0
      },
      "itemLine": {
        "type": "type-arc",
        "arcRatio": 0.02,
        "startSymbol": {
          "visible": true,
          "size": 50,
          "originSymbolType": "arrow",
          "style": {
            "fill": false,
            "stroke": "#f54a45",
            "lineWidth": 1,
            "color": "#f54a45"
          },
          "symbolType": "<svg><path d=\"M -1 1 L 0 0 L 1 1\"/></svg>",
          "refX": 0
        },
        "endSymbol": {
          "visible": false,
          "size": 10,
          "originSymbolType": "arrow",
          "style": {
            "fill": false,
            "stroke": "#f54a45",
            "lineWidth": 1,
            "color": "#f54a45"
          },
          "symbolType": "<svg><path d=\"M -1 1 L 0 0 L 1 1\"/></svg>",
          "refX": 0
        },
        "line": {
          "style": {
            "stroke": "#f54a45",
            "pickStrokeBuffer": 5,
            "lineWidth": 3,
            "lineDash": [
              0,
              0
            ]
          }
        },
        "decorativeLine": {
          "visible": false
        },
        "visible": true
      },
      "targetSymbol": {
        "visible": true,
        "style": {
          "size": 10,
          "fill": "#f54a45",
          "lineWidth": 0,
          "stroke": "#f54a45"
        },
        "offset": 4
      },
      "zIndex": 520
    },
    {
      "itemLine": {
        "decorativeLine": {
          "visible": false
        },
        "startSymbol": {
          "size": 10,
          "visible": true,
          "style": {
            "fill": "#000",
            "stroke": "#000",
            "lineWidth": 0,
            "color": "#000",
            "fillOpacity": 0.3
          },
          "originSymbolType": "solidArrow",
          "symbolType": "M -1 1.5 L 0 0 L 1 1.5 Z",
          "refX": 0
        },
        "endSymbol": {
          "style": {
            "fill": false,
            "stroke": "#000",
            "lineWidth": 1,
            "color": "#000"
          },
          "visible": false,
          "size": 10,
          "originSymbolType": "arrow",
          "symbolType": "<svg><path d=\"M -1 1 L 0 0 L 1 1\"/></svg>",
          "refX": -5
        },
        "line": {
          "style": {
            "stroke": "#000",
            "pickStrokeBuffer": 5
          }
        },
        "type": "type-do",
        "arcRatio": 0.02
      },
      "itemContent": {
        "offsetY": -11.496307825890426,
        "offsetX": 132.09329041129422,
        "type": "text",
        "autoRotate": false,
        "confine": false,
        "position": "middle",
        "text": {
          "text": "请输入标注文本",
          "containerTextAlign": "center",
          "padding": 4,
          "style": {
            "fontSize": 16,
            "fill": "#000"
          },
          "labelBackground": {
            "visible": false,
            "style": {
              "lineWidth": 1,
              "stroke": "#000"
            }
          }
        },
        "refX": 0,
        "refY": 0
      },
      "id": "0e1f2977-ec56-4b29-9ace-34a04870ff95",
      "name": "mark-point",
      "interactive": true,
      "position": {
        "x": "60.96705386513158%",
        "y": "69.02061370481928%"
      },
      "regionRelative": true,
      "targetSymbol": {
        "visible": true,
        "style": {
          "size": 10,
          "fill": "#000",
          "lineWidth": 0
        },
        "offset": 0
      },
      "zIndex": 520
    }
  ],
  padding: 100
};

const vchart = new VChart(spec, { dom: CONTAINER_ID });
vchart.renderSync();

// Just for the convenience of console debugging, DO NOT COPY!
window['vchart'] = vchart;

Current Behavior

image

Expected Behavior

  1. 弧线两端削平
  2. symbol 对齐数据点

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

bugserver case:

kkxxkk2019 commented 15 hours ago

bugserver case: https://bugserver.cn.goofy.app/case?product=chartspace4&fileid=67404b343a9fee00b29bd946