Hello,
I am in need of help trying to get the tooltip data from the mouse cursor when the tooltip is not enabled. I noticed that when the tooltip is enabled, the tooltip is set to an object called "ScatterSeriesValueDataContext" which has the X, Y and colorscale properties. But when the tooltip is disabled, the tooltip object is null so I cannot access "ScatterSeriesValueDataContext" anymore.
Is it possible to get the X, Y and colorscale coordinates from the mouse cursor when the tooltip is not enabled? The image below references the data I am trying to get to in code behind. I am trying to get this working with XamDataChart using ScatterAreaSeries
Thank you,
Gabriel
Hello Gabriel,
Thank you for your update on this matter. The PlotAreaMouseLeftButtonUp event is a good event to use in this case if you are looking to get the values on mouse up.
The reason you are getting a different value from UnscaleValue than is in the tooltip is because UnscaleValue is going to be more precise than the tooltip. The reason for this is because the tooltip will be showing the nearest data point in the underlying data source whereas UnscaleValue is the exact pixel location converted to chart coordinates.
Regarding going from an X, Y chart position coordinate to a pixel position, you can use the ScaleValue methods of the axes. This will essentially do the opposite of UnscaleValue as this is meant to go from chart coordinates to screen coordinates.
Please let me know if you have any other questions or concerns on this matter.
Okay so using "XamDataChart.PlotAreaMouseLeftButtonUp" event which passes "PlotAreaMouseButtonEventArgs" which has "PlotAreaPosition", I can use this variable to get me the X and Y coordinates:
var x = this.NumericXAxis.UnscaleValue(plotAreaMouseEventArgs.PlotAreaPosition.X);
var y = this.NumericYAxis.UnscaleValue(plotAreaMouseEventArgs.PlotAreaPosition.Y);
It seems to be working which is great progress thank you but I notice that the tooltip position is not close to the unscaled value. If the tooltip reports X to be -14.5, the unscaled x value is -14.61. That's a big enough difference to concern me. Is there anything I am doing wrong here or is something I am missing.
Also another question related to this. How can I go from an x,y position coordinate to a pixel position coordinate? Pretty much do the opposite of what I am trying to do above with scatter area series
Thank you again,
I have been investigating into the behavior you are looking to achieve in this case, and my best recommendation to you would be to use the UnscaleValue methods on the NumericX and NumericY axis against the current mouse position. For example, you could track this using the MouseMove event on the XamDataChart and then get the mouse position relative to the chart. This would return a Point, which you would then pass Point.X to the NumericXAxis.UnscaleValue and Point.Y to NumericYAxis.UnscaleValue. This would return you the X / Y coordinates as they pertain to the plot area of the chart.
Regarding the color value, you would need to get this from the closest data item to the X / Y coordinates that you get from the UnscaleValue method calls mentioned above. I would again recommend using the mouse position relative to the chart, but this time with the ScatterAreaSeries.GetItem method. This will net you the closest data item to the mouse position, and you can use whichever value you are pointing the ColorMemberPath at, as that is what the value would be. Alternatively, if you know what the formula is to get the color member path in your data item, you could also run the unscaled values retrieved above to get a more accurate “Z” value where your function(X, Y) = Z.