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
270
Custom ToolTip
posted

Hi,

On a UltraDataChart I have the ShowDefaultToolTip set to True.

My chart is bound to a IEnumerable and I set the ValueMemberPath for the series to a field called "SummaryColumn1" or "SummaryColumn2".

See below.  [items is an IEnumerable object and sumaryColumnName is the name of the property]

ColumnSeries series1 = new ColumnSeries

{
DataSource = items,
ValueMemberPath = summaryColumnName,
XAxis = xAxis,
YAxis = yAxis,
IsHighlightingEnabled = true,
IsTransitionInEnabled = false,
ShowDefaultTooltip = true,
};

The Tooltip displays fine. However the Tooltip display the property name as "SummaryColumn1". I need to show a custom text like "Total Price" or something - how do I do that?

Regards,

Naresh Nichani

Parents
  • 7695
    Offline posted

    Hi Naresh,

        Currently it is not built into the DataChart to easily modify the DefaultTooltips. You do have the ability through the TooltipContentUpdating event to create your own custom tooltips. How that event works is it gives you the DataContext of the Tooltip, and the CurrentContent control that it is currently showing. Below is a snippet of a simple CustomTooltip:

            Control series_TooltipContentUpdating(object sender, ChartTooltipContentEventArgs e)
            {
                Panel panel = e.CurrentContent as Panel;

                // NOTE: The below check stops the redundant painting of the same tooltip
                if (panel == null || (panel != null && !panel.Tag.Equals(e.DataContext.Item)))
                {
                    panel = new Panel();
                    panel.Tag = e.DataContext.Item; // Needed for the above check to work
                    panel.Size = new Size(300, 80);
                    Color colorItem = e.DataContext.ActualItemBrush.Color.ToColor();
                   
                    Label l1 = new Label() { Text = e.DataContext.Series.GetType().FullName, Width = 290 };
                    l1.Location = new System.Drawing.Point(5, 5);               
                    Label l2 = new Label() { Text = e.DataContext.Series.Name, Width = 290 };
                    l2.Location = new System.Drawing.Point(5, 28);
                    Label l3 = new Label() { Text = e.DataContext.Item.ToString(), Width = 290 };
                    l3.Location = new System.Drawing.Point(5, 51);

                    l2.ForeColor = colorItem;
                    l3.ForeColor = colorItem;
                    panel.Controls.AddRange(new Control[] { l1, l2, l3 });
                    
                }
               
                return panel;
            }


    If you like the style of the DefaultTooltip, this event will fire with the DefaultTooltips enabled. While there is not a built in easy way to update the DefaultTooltip, you can access the control via the e.CurrentContent, and from there search through the UserControl's control structure to find the Label text and update it.

    Let me know if this helps?


Reply Children
No Data