/// <summary>
        /// Changes the category to the specified type. If a prefab is specified it will be maintained for this catgeory and type. if a prefab is not specified then either the previously specified prefab is used or the default prefab.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="category">the category</param>
        /// <param name="Prefab">a prefab for the catgeory or null</param>
        public void ChangeCategory <T>(string category, T prefab = null) where T : ScrollableAxisChart
        {
            BaseScrollableCategoryData baseData;

            if (mData.TryGetValue(category, out baseData) == false)  // category does not exist
            {
                Debug.LogWarning(String.Format("Category named {0} does not exist", category));
                return;
            }

            CategoryData data = baseData as CategoryData;

            if (data == null)   // invalid data , should never happen
            {
                Debug.LogWarning(String.Format("Category named {0} is invalid", category));
                return;
            }

            CategoryChartView view = null;

            bool hasView = data.CategoryViews.TryGetValue(typeof(T).FullName, out view); // find the view in the data

            if (prefab != null || hasView == false)                                      //create a new catgeory view if it doesn't exist, if the prefab is not null then create a new catgeory view anyway.
            {
                CategoryChartView tmpView = CreateCategoryView(typeof(T), prefab);
                if (tmpView != null)
                {
                    if (hasView)
                    {
                        mParent.RealaseChart(view.mObject);     // if there was a previous view and the prefab is not null , release the old view
                        view.mObject = tmpView.mObject;         // and assign the new one to the current view
                    }
                    else
                    {
                        view = tmpView;                                   // if this is a new category view then assign it
                        data.CategoryViews.Add(typeof(T).FullName, view); // and add it to the category data object
                    }

                    view.IsPrefabed = prefab != null;
                }
            }

            if (view == null)  // T is an invalid chart type , This could happen when using canvas chart type for non canvas mixed series chart or vice versa
            {
                Debug.LogWarning("Invalid chart type, no category added");
                return;
            }

            CategoryChartView current = data.getCurrent();

            if (current != null && current != view)  // if the current view is not also the new one , deactivate it
            {
                mParent.DeactivateChart(current.mObject);
            }

            data.Selected = typeof(T);             // set the selected type

            mParent.ReactivateChart(view.mObject); // make sure the new view is activated
        }
        CategoryChartView CreateCategoryView(Type t, ScrollableAxisChart prefab)
        {
            var chart = mParent.CreateCategoryView(t, prefab);

            if (chart == null)
            {
                return(null);
            }
            var cat = chart.ScrollableData.GetDefaultCategory();
            CategoryChartView view = new CategoryChartView();

            view.mCategory = cat;
            view.Filter    = null;
            view.mObject   = chart;
            view.mType     = t;
            return(view);
        }
        /// <summary>
        /// Adds a new category with the specified depth. If a prefab is specified it will be used instead of the deafult one for type T
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="category"></param>
        /// <param name="depth"></param>
        /// /// <param name="filter"></param>
        /// <param name="prefab">a prefab for the selected type , or null to use the default prefab </param>
        public void AddCategory <T>(string category, float depth, CategoryFilter filter = null, T prefab = null) where T : ScrollableAxisChart
        {
            if (mData.ContainsKey(category))
            {
                Debug.LogWarning(String.Format("A category named {0} already exists", category));
                return;
            }
            CategoryData data = new CategoryData();

            data.Depth    = depth;
            data.Selected = typeof(T);
            CategoryChartView view = CreateCategoryView(typeof(T), prefab);

            if (view == null)
            {
                Debug.LogWarning("Invalid chart type, no category added");
                return;
            }
            view.Filter = filter;
            data.CategoryViews.Add(typeof(T).FullName, view);
            mData.Add(category, data);
        }