Home Forums Chart Support How to make crosshairs scrollable.

How to make crosshairs scrollable.

Viewing 2 posts - 1 through 2 (of 2 total)
  • #61040

    Good day administrator.

    Please I need example on how to make crosshairs scroll up/down, left/right while using canvasjs library.

    #61048

    @chikwado,

    You can use the showAt() method to programmatically move the crosshair along the axis. This method allows you to position the crosshair at any specific value on axisX (or axisY), which can help you achieve the scrolling effect you want. Please find the code-snippet below.

    var xValue = 10, timeoutId;
    function moveCrosshair() {
      
      if (xValue > 90) {
        clearTimeout(timeoutId);
        return;
      }
      chart.axisX[0].crosshair.showAt(xValue);
      xValue += 10;
      timeoutId = setTimeout(moveCrosshair, 500);
    }
    moveCrosshair();

    Please take a look at this JSFiddle for a working example.

    If this does not fulfill your requirements, could you please brief us more about it, so that we can understand your scenario better and help you out?


    Ananya Deka
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.