Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
230
Request for dashed line
posted

Currenlty I had made dashed line using the following code but in case points are less or inclined line it is not drawing correctly how to fix up the code ?:

public getDashedMarker(): any {
    let style = { outline: "#8B5BB1", fill: "white", text: "black" };
    const size = 10;

    return {
      measure: function (measureInfo: DataTemplateMeasureInfo) {
        const context = measureInfo.context;
        const height = context.measureText("M").width;
        const width = context.measureText("0.00").width;
        measureInfo.width = width;
        measureInfo.height = height + 8;
      },
      render: function (renderInfo: DataTemplateRenderInfo) {
        let ctx = renderInfo.context;
        let x = renderInfo.xPosition;
        let y = renderInfo.yPosition;

        if (renderInfo.isHitTestRender) {
          ctx.fillStyle = renderInfo.data.actualItemBrush.fill;

          let width = renderInfo.availableWidth;
          let height = renderInfo.availableHeight;

          ctx.fillRect(x, y, renderInfo.availableWidth, renderInfo.availableHeight);
          return;
        }


        const dataItem = renderInfo.data.item;
        if (dataItem === null) return;


        let xOffset = 2;
        let yOffset = 0;
        ctx.fillText("", x - (xOffset), y - (yOffset));
        ctx.strokeStyle = "rgb(161, 167, 179)";
        ctx.fillStyle = "white";
        ctx.beginPath();
        ctx.lineTo(x, y);
        ctx.lineTo(x + 8, y);
        ctx.stroke();
        ctx.fill();

      }