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
227
Ultra chart : On mousemove the customized Legend Tooltip is not worked on scrollbar is enabled (enablescrollbar = true)
posted

Hi,

I have tried to provide a tool tip in legend area on mouse move event and it was created in the fillscenegraph event.

Also, the selection of the chart type is "Line Chart" and the application platform is .Net Framework 3.5 & Infragistics version is 2009.1

Below code is used to customize the legend area,

private Primitive LastPrimitive { get; set; }
    void UltraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
    {
        PrimitiveCollection primitivesToAdd = new PrimitiveCollection();
        foreach (Primitive p in e.SceneGraph)
        {
            if (p.Path != null && p.Path.Contains("Legend"))
            {
               p.Layer = e.ChartCore.GetChartLayer();
                if (p is Box)
                {
                    this.LastPrimitive = p;
               
                }
                else if (p is Text)
                {
                    Text t = (Text)p;
                    p.Row = 0;
                    p.Column = 0;
                    p.Value = this.LastPrimitive.Value;
                    Box newBox = new Box(t.bounds);
                    newBox.PE.FillOpacity = newBox.PE.StrokeOpacity = 0;
                    newBox.Row = p.Row;
                    newBox.Column = p.Column;
                    newBox.Chart = p.Chart;
                    newBox.Layer = p.Layer;
                    newBox.Value = p.Value;
                    newBox.Caps = PCaps.HitTest | PCaps.Skin | PCaps.Tooltip;
                    primitivesToAdd.Add(newBox);
                }
            }
        }
        e.SceneGraph.AddRange(primitivesToAdd.ToArray());
    }

When the mouse moves on legend area, the tool tip displays without issues and if the scrollbar is disabled.

But, the same is not displaying on while setting the property EnableScrollbar = true.

Please assist us to overcome from this issue.


Thanks in advance and hope will wait for the quick response.


Best regards,

Rithanya


 


Parents
  • 53790
    posted

    Hello Rithanya,

    There are differenet approaches to solve this task. One possible approach could be if you are using FillSceneGraph and MouseMove events. For example:

    private void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
    {
        legendItems.Clear();
        foreach (Primitive p in e.SceneGraph)
        {
            if (p is Box && p.Path != null && p.Path.ToLower().IndexOf("legend") != -1 && p.Row != -1 && p.Column != -1)
            {
                legendItems.Add(p as Box);
            }
        }
    }

    private void ultraChart1_MouseMove(object sender, MouseEventArgs e)
    {
        if (legendItems.Where(p => p.rect.X < e.Location.X && e.Location.X < p.rect.X + p.rect.Width && p.rect.Y < e.Location.Y && p.rect.Y + p.rect.Height > e.Location.Y).Count() > 0)
        {
            Box it = legendItems.Where(p => p.rect.X < e.Location.X && e.Location.X < p.rect.X + p.rect.Width && p.rect.Y < e.Location.Y && p.rect.Y + p.rect.Height > e.Location.Y).First();
            if (it != null)
            {
                int index = legendItems.IndexOf(it);
                Graphics gr = ultraChart1.CreateGraphics();
                gr.DrawRectangle(new Pen(Brushes.Black), new Rectangle(it.rect.X + 9, it.rect.Y - 11, 22, 16));
                gr.FillRectangle(Brushes.WhiteSmoke, new Rectangle(it.rect.X + 10, it.rect.Y - 10, 20, 15));
                gr.DrawString(dt.Rows[index].Field<Decimal>(1).ToString(), new System.Drawing.Font("Ariel", 8F), Brushes.Black, new PointF(it.rect.X + 10, it.rect.Y - 10));
            }
        }
        else
        {
            ultraChart1.Refresh();
        }
    }

    Please take a look at the attached sample and video file for more details. Let me know if you have any questions.

    Regards

Reply Children