Profile Picture

NHitTestResult.DataPointIndex is always 0 unless DataLabelStyle.Visible is true?

Posted By Noah Shipley 12 Years Ago
Author
Message
Noah Shipley
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 3, Visits: 1
I have added custom code to update a tooltip as the user mouses over data points within a series, however the value for DataPointIndex is wrong unless I am also showing data labels, which is ugly and seems like bug.

private void ChartControl_OnMouseMove(object sender, MouseEventArgs e)
{
NHitTestResult hitTest = _ChartControl.HitTest(e.X, e.Y);

if (hitTest.ChartElement == ChartElement.DataPoint)
{
var tip = new SuperToolTip() { AllowHtmlText = DefaultBoolean.True };

if (hitTest.Series.Name != "Line Series" && hitTest.Series.Name != "Point Series")
{
var title = tip.Items.AddTitle(hitTest.Series.Name);
}

//title.Appearance.TextOptions.HAlignment = HorzAlignment.Center;

switch (hitTest.Series.GetSeriesType())
{
//case SeriesType.Line:
// {
// var series = (NLineSeries)hitTest.Series;
// break;
// }

case SeriesType.BoxAndWhiskers:
{
var series = (NBoxAndWhiskersSeries) hitTest.Series;
tip.Items.Add("Index: " + hitTest.DataPointIndex);
tip.Items.AddSeparator();
tip.Items.Add("Low: " + ((double)series.LowerBoxValues[hitTest.DataPointIndex]).ToString(Model.DataFormatString));
tip.Items.Add("High: " + ((double)series.UpperBoxValues[hitTest.DataPointIndex]).ToString(Model.DataFormatString));
tip.Items.Add("Mean: " + ((double)series.AverageValues[hitTest.DataPointIndex]).ToString(Model.DataFormatString));
tip.Items.Add("Median: " + ((double)series.MedianValues[hitTest.DataPointIndex]).ToString(Model.DataFormatString));

break;
}

default:
{
if (hitTest.Series is NSeries)
{
var series = hitTest.Series as NSeries;

tip.Items.Add("Value: " + ((double) series.Values[hitTest.DataPointIndex]).ToString(Model.DataFormatString));
}

break;
}
}

var showArgs = new ToolTipControllerShowEventArgs() { SuperTip = tip };

_ChartControl.Widget.KFrame.ToolTipController.ShowHint(showArgs);
}
else
{
_ChartControl.Widget.KFrame.ToolTipController.HideHint();
}

}




Similar Topics


Reading This Topic