|
Find coordinates of textbox after scrolling or zooming |
Posted by Roger on Aug-22-2013 03:15 |
|
Hi
Please find attached Chard.docx file with some screen-shots.
I have created a rubberband box routine, with handles that allows the user to enter text
and move the resultant textbox about and position the text box anywhere on a xychart
chart. See doc. If the user scrolls or zooms the xychart chart the textbox remains in the
correct position (as though attached to the xychart line data). So far - all ok.
Language: vb.net, .net 4, VS 2010
I'm using the Layer.addCustomDataLabel method to control the position of the text box
when scrolling/zooming. The rubberbox uses different routines via winChartViewer_Paint
that coordinates the moving and dragging.
My problem is this: when I scroll or zoom the chart the rubberband remains in the same
postion. I need to be able to
calculate the screen coordinates of the Layer.addCustomDataLabel text box after scolling
to give the x, y coords to the rubberband routine so that the rubberband box overlays
the scrolled Chart Director tetbox after scrolling. See pic #2 whch shows the (incorrect)
result after scrolling.
I hope I have explained this ok! I hope you can help.
cheers
Roger
|
Re: Find coordinates of textbox after scrolling or zooming |
Posted by Roger on Aug-22-2013 21:13 |
|
Hi
Figured it out!
_dragRect.X = layer.getXCoor(Chart.CTime(_DataDateIndex))
_dragRect.Y = chartd.getYCoor(_yDataValue)
_dragRect = rubber band variables
cheers
Roger |
Re: Find coordinates of textbox after scrolling or zooming |
Posted by Roger on Aug-22-2013 22:57 |
|
oops!
Thought it worked, but doesn't. Spoke too soon. Sorry.
Over to support!
Roger |
Re: Find coordinates of textbox after scrolling or zooming |
Posted by Peter Kwan on Aug-23-2013 00:46 |
|
Hi Roger,
I assume your chart is an XYChart using a real date/time axis (that is, your chart is not a
FinanceChart object, and your code is using Layer.setXData to supply the date/time x-
coordinates for each data point to ChartDirector). In this case, the code should be:
_dragRect.X = chartd.getXCoor(Chart.CTime(myXDateTimeArray(dataItem)))
_dragRect.Y = chartd.getYCoor(myYDataArray(dataItem))
In the above, the dataItem is the same dataItem you use in the addCustomDataLabel
method call. The returned x and y coordinates is the position of the data point associated
with the custom data label.
Note that the getXCoor and getYCoor can only be used after the chart is drawn, or after
you have set the chart to the WinChartViewer.
Hope this can help.
Regards
Peter Kwan |
Re: Find coordinates of textbox after scrolling or zooming |
Posted by Roger on Aug-23-2013 02:54 |
|
Hi Peter
Thanks for the help.
x coordinate code worked good, but had to add "+ t.getTopY" to get y coord of the
textbox:
_dragRect.Y = chartd.getYCoor(viewPortDataSeries(i)) + t.getTopY
where t = ChartDirector.TextBox, i is the dataitem as per your answer.
Thanks again. Rubberband text-box now working with scrolling/zooming, dragging and re-
sizing.
Roger |
|