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
710
Monotouch - Stacked Chart Tooltip
posted

Hi,

can someone help?

i have a stacked chart, and i have a problem when trying to implement the tooltip... in this line:

    string seriesKey = itemlist.Keys.GetValue(0).ToString();
    double pointValue = ((IGCategoryPoint)itemlist.ValueForKey (new NSString (seriesKey))).Value;  <<<<==== This line give me this error:


    Unable to cast object of type 'MonoTouch.Foundation.NSMutableDictionary' to type 'Infragistics.IGCategoryPoint'.


thanks


the code:


        public class MyChartViewDelegate :IGChartViewDelegate
        {
            public override string ResolveLabelForAxis (IGChartView chartView, IGAxis axis, NSObject item)
            {
                if (axis is IGCategoryXAxis) 
                {
                    NSMutableDictionary dm = (NSMutableDictionary)item;
                    return ((NSString)dm["label"]).ToString();
                }

                if (axis is IGNumericYAxis)
                {
                    return (item.ToString());
                }

                return string.Empty;
            }


            public override UIView ResolveTooltipView (IGChartView chartView, NSDictionary itemlist)
            {
                UIView tooltip = new UIView(new RectangleF(0, 0, 100, 30));
                tooltip.BackgroundColor = UIColor.LightGray;
                if (itemlist.Count > 0)
                {
                    string seriesKey = itemlist.Keys.GetValue(0).ToString();
                    double pointValue = ((IGCategoryPoint)itemlist.ValueForKey (new NSString (seriesKey))).Value;
            
                    UILabel valueLabel = new UILabel();
                    valueLabel.BackgroundColor = UIColor.Clear;
                    valueLabel.Text = String.Format("${0:0.00}", pointValue);
                    valueLabel.SizeToFit();
                    valueLabel.Frame = new RectangleF(5, 5, valueLabel.Frame.Size.Width, valueLabel.Frame.Size.Height);
                    tooltip.AddSubview(valueLabel);
                }

                return tooltip;
            }
        }



  • 48586
    Verified Answer
    posted

    Hello, ­­­­­

     

    I am just checking about the progress of this issue. Let me know If you need any further assistance on this  issue?

     

    Thank you for using Infragistics Components.

  • 26458
    Verified Answer
    Offline posted

    Hi, 

    The stacked charts have a slightly different itemlist passed down to ResolveTooltipView. Typically, for non-stacked charts, the itemlist contains an IGDataPoint, but stacked charts have an extra level of depth, so the itemlist is a dictionary of dictionaries. The inner dictionary represents the stacked fragments in a stacked series. In your sample code, after you get the seriesKey, you would get the inner stack dictionary:
    NSDictionary stack = itemList.ValueForKey(seriesKey);

    stack will be a dictionary of series fragment keys and their respective values. For example, if you created a stack series with fields {"value1", "value2"}
    you would use stack.ValueForKey("value1") to get the value for the first fragment, etc.

    Hope this helps you.