Skip to content
Naresh Nichani
Naresh Nichani asked on May 18, 2017 1:08 AM

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

Sign In to post a reply

Replies

  • 0
    Michael Germann
    Michael Germann answered on Jan 23, 2017 11:28 PM

    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?

    • 0
      Naresh Nichani
      Naresh Nichani answered on Jan 24, 2017 10:19 AM

      Hi,

      Thanks.

      First can let me know or point me to an article on the differences between UltraChart and UltraDataChart. Which is the better one to use? 

      I tried the following code – 

      Control series1_TooltipContentUpdating(object sender, ChartTooltipContentEventArgs e)
      {

      Control ctl = e.CurrentContent;

      if (ctl != null && e.DataContext.Item != null)
      {
         ctl.SuspendLayout();
         SetControlText(ctl, e.DataContext.Item);
         ctl.ResumeLayout();
      }
      return ctl;

      }

      private void SetControlText(Control ctl, object item)
      {
      foreach (Control ctl1 in ctl.Controls)
      {
      Control ctl2 = ctl1;
      if (ctl2.Text.Equals(string.Format("{0}:",_yFieldName)))
      {
      ctl2.Text = ctl2.Text.Replace(_yFieldName, _yFieldDisplayName);
      }
      SetControlText(ctl2, item);
      }
      }

      This seems to find the text and replace it. However the label displayed is blurry on the screen.

      Regards,

      Naresh

      D-Tools Inc.

      • 0
        Michael Germann
        Michael Germann answered on Jan 26, 2017 1:07 AM

        Hi Naresh,

            The UltraChart is our original chart that we initially created roughly in 2005. It does have a few features such as 3D charts, that the UltraDataChart does not have, it currently also has a slightly better level of customization, but we will no longer be doing new development for it. The UltraDataChart is our latest chart, it was built with cross platform design in mind, the same chart look and feel, and API design in Windows Forms, WPF, jQuery, Xamarin, IOS and Android. We are also continuely developing for it, so if there is a feature or something that you do want, that we don't already have, the UltraDataChart is the one we will likely implement it in.

        As to the blurry or flashing, you want to assign a value to the tag, and confirm that the tag is not the same, so you don't constantly update it. But in testing it myself it looks like we are constantly setting the label as well for the default tool tip so this looks like it will not work. You will need to create a custom Tooltip from scratch to get the behavior that you are looking for. You are encouraged to submit this as a feature request on our product ideas page here: ideas.infragistics.com, many of our new features are pulled from ideas suggested on this site.

        Let me know if this helps,

      • 0
        Naresh Nichani
        Naresh Nichani answered on Jan 31, 2017 11:23 AM

        Hi,

        Thanks.

        On a different topic I create my X-Axis as follows.

        CategoryXAxis xAxis = new CategoryXAxis
        {
        Label = xFieldEnumName,
        LabelFontSize = 10,
        LabelsVisible = true,
        Interval = 1,
        //LabelExtent = 90,
        //LabelAngle = 0,
        DataSource = dt,
        Title = xField.DisplayName,
        LabelLocation = AxisLabelsLocation.OutsideBottom

        };

        The Labels are visible below the axis as expected. However really long labels get cut off on a column chart. I would like to see more of the label. Is there a wrap function? I tried a LabelAngle = 320 – however that takes too much space at times.

      • 0
        Michael Germann
        Michael Germann answered on Feb 1, 2017 12:08 AM

        Hi Naresh,

           There is no auto-wrap feature, but there are two solutions that you may want to look into. One is for the Axis you can set the LabelMargin property, and give yourself more room to display the labels. Additionally I am not sure if you are already using the FormatLabel event. But you can always embed a LineFeed in the label string. Something like this:

        xAxis.FormatLabel += XAxis_FormatLabel;

        private static string XAxis_FormatLabel(AxisLabelInfo info)
        {
            return string.Format("{0}\n{1:00}\n{2:00}", info.DateValue.Year, info.DateValue.Month, info.DateValue.Day);
        }

        Let me know if either of those help with your issue,

    • 0
      tuoc le
      tuoc le answered on May 18, 2017 1:08 AM

      Hello Mike,

      Do you have this code in .Net VB?

      Thanks,

      Tuoc.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Naresh Nichani
Favorites
0
Replies
6
Created On
May 18, 2017
Last Post
9 years, 5 months ago

Suggested Discussions

Created by

Created on

May 18, 2017 1:08 AM

Last activity on

May 18, 2017 1:08 AM