Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1401
Custom Tooltip for legend
posted

I plotted composite chart with multiple layers. I created a legend object and added to the ultrachart.Composite.Legends.Add(....).

What ever the layer I created I added the same to this legend object.

Now when I place the mouse over any of the legend item, it should show in a tool tip with some explanation.

This explanation text is different for different legend item entry.

In the FillSceneGraph event, I did as follows:

int row = 0; 

foreach
(Primitive p in e.SceneGraph)

{

if (p.Path != null && p.Path.ToLower().IndexOf("legend") != -1)

{

if (p.Row >= row)

{

Text textPrimitive = e.SceneGraph[e.SceneGraph.IndexOf(p)-1] as Text; //Index0f(p) is legend symboul

//and immediate before (IndexOf(p-1)) is its corresponding text

if (null != currentMousePoint)

{

Infragistics.Win.ToolTip  toolTip = new Infragistics.Win.ToolTip(ultrachart1); 

//currentMousePoint was a private field which was assigned in the mouse move event of the ultrachart 

if (currentMousePoint.X >= textPrimitive.bounds.Left && currentMousePoint.X <= textPrimitive.bounds.Right &&

currentMousePoint.Y >= textPrimitive.bounds.Top && currentMousePoint.Y <= textPrimitive.bounds.Bottom)

{

toolTip.ToolTipText =
"testToolTip";

toolTip.Show();

}

else

{

if(null != toolTip)

{

toolTip.Hide();

}

}

}

}

I cant assign cappabilities of this text to Pcaps.HitTest and Pcaps.ToolTip and changing the ultrachart1.ToolTips.formatstring = "<ITEM_LABEL>"

as I already used a custom tooltip for the ultrachart to customize the the chart data being showed. If I do so it was showing the same tooltip

for the series data and legends as well. This was a disaster.

Now the problem I have been facing is:

This custom tooltip was working only if there is one entry in the legends item (say only one layer with one XYSeries). I want this cutom tooltip I created for every legend item in the legends box of this composite chart with multiple layers and multiple XYSeries.

I could not loop over through all the legend items text in the FillSceneGraphEvent. Else my work would be easy. But not able to loop through those legend texts

How to this. Any idea? Or else any easy way you suggest to bypass this tricky procedure

 

Parents
No Data
Reply
  • 28496
    Offline posted

     you couldn't loopthrough the legend Text primitives in FillSceneGraph?  why not?  don't they show up in e.SceneGraph where p.Path contains "Legend" ?

     the one other approach i can think of is using FillSceneGraph to overlay Box primitives on top of the Texts, and make them clickable using

    mybox.Layer = e.ChartCore.GetChartLayer();

    mybox.Row = mybox.Column = 0;

    mybox.Caps = PCaps.HitTest | PCaps.ToolTip;

    mybox.Chart = this.ultraChart1.ChartType;

     

    (this way the custom Box primitives will show tooltips and raise the DataItemOver/ChartDataClicked events)

Children