Page 1 of 1

How to change CursorTool position(both x and y-axis) onClick

Posted: Tue Jul 10, 2018 4:19 am
by 14047022
I'm using ColorGrid for chart creation and i want to change CursorTool position(x-axis and y-axis coordinates) based on click. Can any one help us to achieve this. And is there any way that we can give position values for x-axis and y-axis so the cursortool can be re-arranged to that position. If any one has done already please give us solution.

Re: How to change CursorTool position(both x and y-axis) onClick

Posted: Fri Jul 13, 2018 8:55 am
by yeray
Hello,

You can call the CursortTool mousemove function at the Chart's mousedown event as follows:

Code: Select all

  var t = new Tee.CursorTool(Chart1);
  t.format.stroke.size=2;
  t.format.stroke.fill="#BB0000";
  t.render="layer";
  t.followMouse=false;
  Chart1.tools.add(t);

  Chart1.mousedown=function(event) {
    t.oldFollowMouse = t.followMouse;
    t.followMouse = true;
    var p = new Tee.Point(0, 0);
    t.chart.calcMouse(event, p);
    t.mousemove(p);
    t.followMouse = t.oldFollowMouse;
  }

Re: How to change CursorTool position(both x and y-axis) onClick

Posted: Wed Jul 18, 2018 10:50 am
by 14047022
Hello,

Thank you so much for your reply, it is working fine, only if we add "t.dragging = 0", otherwise it is not working. and how to set x-axis value to zero when chart is loading first time or how to change positions of x and y manually(might be the scenario is another buttons and i want to change x or y position by increment one by one).
Yeray wrote:Hello,

You can call the CursortTool mousemove function at the Chart's mousedown event as follows:

Code: Select all

  var t = new Tee.CursorTool(Chart1);
  t.format.stroke.size=2;
  t.format.stroke.fill="#BB0000";
  t.render="layer";
  t.followMouse=false;
  Chart1.tools.add(t);

  Chart1.mousedown=function(event) {
    t.oldFollowMouse = t.followMouse;
    t.followMouse = true;
    var p = new Tee.Point(0, 0);
    t.chart.calcMouse(event, p);
    t.mousemove(p);
    t.followMouse = t.oldFollowMouse;
  }

Re: How to change CursorTool position(both x and y-axis) onClick

Posted: Fri Jul 20, 2018 9:43 am
by yeray
Hello,

You can manually set a position knowing the pixel coordinates, or calculating them from the axis values. To do this, instead of this:

Code: Select all

  var p = new Tee.Point(0, 0);
  t.chart.calcMouse(event, p);
Do this:

Code: Select all

    var p = new Tee.Point(Chart1.axes.bottom.calc(80), Chart1.axes.left.calc(80));

Re: How to change CursorTool position(both x and y-axis) onClick

Posted: Tue Jul 24, 2018 4:16 am
by 14047022
Thanks, it is working fine now.