winforms - Windows Forms Chart: Get mouse cursor coordinates in Chart axis scale? -
i have problem following sample:
when click @ place marked '1' on screenshot, can position in pixels mouseclick event in pretty easy way:
private: system::void chart1_mouseclick(system::object^ sender, system::windows::forms::mouseeventargs^ e) { point chartlocationonform = chart1->findform()->pointtoclient(chart1->parent->pointtoscreen(chart1->location)); cursorposx = e->x - chartlocationonform.x; cursorposy = e->y - chartlocationonform.y; }
after printing these values out, position in pixels, position marked '2' equal (0,0).
what after clicking spot in '1' is
x: 40
y: 178.5,
which coordinates inside chart. there civilised way (i mean other considering padding, margins , borders of chart , calculating these coordinates myself)?
one of ideas create sort of invisible cursorx , cursory , use methods, still seems more fancy way solve simple problem real, straight-forward solution. right or really way supposed solve problem?
yep, there civilized way of doing if understand question correctly. can use axis.pixelpositiontovalue method that.
e.g. (in c#)
chart.chartareas[0].axisx.pixelpositiontovalue(pt.x) chart.chartareas[0].axisy.pixelpositiontovalue(pt.y)
Comments
Post a Comment