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

TeeChart for Javascript for the HTML5 Canvas
Post Reply
vishwa
Newbie
Newbie
Posts: 33
Joined: Mon Oct 15, 2007 12:00 am

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

Post by vishwa » Tue Jul 10, 2018 4:19 am

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.

Yeray
Site Admin
Site Admin
Posts: 8737
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Fri Jul 13, 2018 8:55 am

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;
  }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

vishwa
Newbie
Newbie
Posts: 33
Joined: Mon Oct 15, 2007 12:00 am

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

Post by vishwa » Wed Jul 18, 2018 10:50 am

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;
  }

Yeray
Site Admin
Site Admin
Posts: 8737
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Fri Jul 20, 2018 9:43 am

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));
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

vishwa
Newbie
Newbie
Posts: 33
Joined: Mon Oct 15, 2007 12:00 am

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

Post by vishwa » Tue Jul 24, 2018 4:16 am

Thanks, it is working fine now.

Post Reply