vb.net - MS Charting Annotations refuse to align to mouse position -


can tell me why below happening please? red line signifies annotation should positioned (along x axis), it's rendered right on left edge... did few searches in google , so, , found answer implies pixelpositiontovalue(mouse.x) sort it, using ends same.

enter image description here

private sub assignnewdowntime()     dim sstr string = inputbox("please enter downtime reason")     dim annot new charting.rectangleannotation()      annot.cliptochartarea = "chart1"     annot.backcolor = color.darkred     annot.forecolor = color.white     annot.allowmoving = true     annot.allowanchormoving = false     annot.allowselecting = false     annot.ismultiline = false     annot.allowtextediting = false     annot.issizealwaysrelative = false     annot.x = chart1.chartareas(0).axisx.pixelpositiontovalue(startmousepoint.x)     annot.y = 10     annot.width = 25      annot.text = sstr & " /x: " & annot.x & "y:" & annot.y      chart1.annotations.add(annot)     chart1.invalidate() end sub 

gah! happens... pull hair out hours, post on , within 5 minutes i've fixed it. anyway, future generations may pull hair out, here's solution:

annotations x , y aren't set of chart, whereas chart range 0.0 1.0, annotations default range 0 100. nightmare! there couple of ways around this, chose:

annot.axisx = chart1.chartareas(0).axisx

which sets x axis of annotation mimic of chart. values , limits correct. did worked instantly. can of course set axisy of annotation well, beware in charting y bottom top. more information can found here: http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.annotation(v=vs.110).aspx - (which wish i'd read first...):

annotations commonly used comment or elaborate on chart elements such data points. annotations can used draw custom shapes. default, annotations positioned using relative coordinates, (0,0) representing top-left corner, , (100,100) representing bottom-right corner of chart image. possible switch relative coordinate system system uses axis values. axis coordinate system, x , y, represent position of top-left corner of annotation, set using x axis , y axis values, instead of values range 0-100. there 2 ways use axis values when specify position , size of annotation: set axisx, axisy or both of these annotation properties axisx , axisy property values of chartarea object. use anchordatapoint property anchor annotation data point. in case, positioning automatically calculated. annotations derived annotation class, can used set attributes common annotation objects, such color, position, anchoring , forth.

anyway, hope helps folk out.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -