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
1615
IGStackedSeriesDataSource with dynamic number of columns
posted

Hi, 

A while ago we implemented a dynamic stacked data source helper (with your help). 

Yesterday we updated our code to 14.1 and the code stopped working because  IGStackedSeriesDataSource no longer has GetPoint and  UpdatePointAtIndex methods. 

It's ridiculous that new version changes are not backward compatible and break the signature of the code. 

Please advice on how to fix this. The code for our dynamic stacked data source class is shown below. Worked perfectly until this update. 


public class DynamicStackFragment : IGStackedFragmentSeries
    {
        public int Index { get; set; }
    }

    public class DynamicStackedDataSource : IGStackedSeriesDataSource
    {
        //This structure is the array of custom objects, from which the fragments will be extracted.
        [Export ("Data")]
        NSObject[] Data { get; set; }
        //Determines the property name of the items in the data array to be used for labels.
        [Export ("LabelPath")]
        string LabelPath { get; set; }
        //Determines the property name of the items in the data array to be used for stack values.
        [Export ("ValuesPath")]
        string ValuesPath { get; set; }

        public DynamicStackedDataSource ()
        {
        }

        public DynamicStackedDataSource (NSObject[] data, string labelPath, string valuesPath)
        {
            Data = data;  
            LabelPath = labelPath;
            ValuesPath = valuesPath;
        }

        public override int NumberOfFragments (IGStackedSeriesBase series)
        {
            return this.Data.Length;
        }

        public override int NumberOfPointsInFragment (IGStackedFragmentSeries fragment, IGStackedSeriesBase series)
        {
            DynamicStackFragment df = fragment as DynamicStackFragment;
            DataModel model = this.Data [df.Index] as DataModel;
            return (int)model.Points.Count;
        }

        public override IGStackedFragmentSeries GetFragment (IGStackedSeriesBase series, int index)
        {
            DynamicStackFragment fragment = new DynamicStackFragment ();
            DataModel item = (DataModel)this.Data [index];
            fragment.Name = item.Name;
            fragment.Title = item.Title;
            fragment.ValueProperty = item.Title;
            fragment.Index = index;
            return fragment;
        }

        //FIX IT
        public  IGCategoryPoint GetPoint (IGStackedSeriesBase series, int index, IGStackedFragmentSeries fragment)
        {
            //NSString label; 
            DynamicStackFragment df = fragment as DynamicStackFragment;
            DataModel item = (DataModel)Data [df.Index];

            DatePoint datepoint = item.Points.GetItem<DatePoint> (index);
        
            IGCategoryPoint point = new IGCategoryPoint (datepoint.Value.DoubleValue, datepoint.Date.ToString ("MMM-yy"));
            return point;
        }
        //FIX IT
        public  IGCategoryPoint UpdatePointAtIndex (IGStackedSeriesBase series, int index, IGStackedFragmentSeries fragment)
        {
            IGCategoryPoint newPoint = GetPoint (series, index, fragment);

            NSObject sourceItem = new NSObject (series.DataPoints.ValueAt ((uint)index));

            if (sourceItem != null && sourceItem.GetType () == typeof(NSDictionary)) {
                NSNumber value = new NSNumber (newPoint.Value);
                string label = newPoint.Label;

                sourceItem.SetValueForKey (value, new NSString (fragment.ValueProperty));
                sourceItem.SetValueForKey (new NSString (label), new NSString ("label"));
            }

            return newPoint;
        }
    }

Parents Reply Children
No Data