Posted 14 September 2019, 5:42 pm EST
How do you achieve a ToolTipResult from a MouseOverEvent on a specific XAxis item?
Forums Home / ComponentOne / WinForms Edition
Posted by: graham on 14 September 2019, 5:42 pm EST
Posted 14 September 2019, 5:42 pm EST
How do you achieve a ToolTipResult from a MouseOverEvent on a specific XAxis item?
Posted 15 September 2019, 8:30 pm EST
Hi Graham,
As per my understanding, you want to display tooltip whenever mouse hover on the Axis. For this, you have to Enable tooltip on C1Chart and then set the Axis.TooltipText as follows:
c1Chart1.ToolTip.Enabled = true;
c1Chart1.ToolTip.SelectAction = SelectActionEnum.MouseOver;
c1Chart1.ChartArea.AxisY.TooltipText = "X-Axis";
Also, If you want to customize the content displayed in tooltip dynamically then you can handle the C1Chart.ShowTooltip event as follows:
c1Chart1.ShowTooltip += C1Chart1_ShowTooltip;
private void C1Chart1_ShowTooltip(object sender, ShowTooltipEventArgs e)
{
if (sender.Equals(c1Chart1.ChartArea.AxisX))
{
var axis = sender as Axis;
var position = c1Chart1.PointToClient(Control.MousePosition);
double x = 0, y = 0;
c1Chart1.ChartGroups.Group0.CoordToDataCoord(position.X, position.Y, ref x, ref y);
e.TooltipText = DateTime.FromOADate(x).ToShortDateString();
}
}
Please refer to the attached sample (prj_AxisTooltip.zip) for the same. Also, for better understanding, you can refer the “Tooltip” product sample from “Documents\ComponentOne Samples\WinForms\C1Chart\CS\Tooltip”.
Regards,
Basant
prj_AxisTooltip.zip
Posted 15 September 2019, 11:13 pm EST
Please give this to me in VB.Net Syntax.
I do not do C#
Posted 16 September 2019, 3:49 pm EST
Hi Graham,
Sorry for the inconvenience, Please refer to the attached VB sample for doing the same.
Regards,
Basant
prj_AxisTooltip_VB.zip
Posted 16 September 2019, 10:11 pm EST
Thank you Basant.
That’s beautiful.
Of course, I need to modify it for my purposes. Not a big deal.
But, it has taken me about 5 years to get a Data Connected Gantt Chart from this product.
Regards, Graham
Posted 17 September 2019, 3:04 pm EST
Hi Graham,
I am not sure about what was troubling you in the past. However, thanks for the acknowledgment and it’s good to know that now our product meets your requirement.
Regards,
Basant