Beispiel #1
0
 public PyramidData()
 {
     mDataSource = new ChartSparseDataSource();
     if (mDataSource.Rows.Count == 0)
     {
         mDataSource.Rows.Add(new DataSource.ChartDataRow("Pyramid"));
     }
 }
Beispiel #2
0
        public void OnAfterDeserialize()
        {
            mDataSource = new ChartSparseDataSource();
            mDataSource.SuspendEvents = true;
            mDataSource.Clear();
            if (mCategories == null)
            {
                mCategories = new CategoryData[0];
            }
            if (mGroups == null)
            {
                mGroups = new string[0];
            }
            if (mData == null)
            {
                mData = new DataEntry[0];
            }

            for (int i = 0; i < mCategories.Length; i++)
            {
                AddCategory(mCategories[i].Name, mCategories[i].Materials, mCategories[i].Title, mCategories[i].Text, mCategories[i].Image, mCategories[i].Alpha, mCategories[i].HeightRatio, mCategories[i].LeftSlope, mCategories[i].RightSlope, mCategories[i].PositionBlend, mCategories[i].Scale, mCategories[i].ShiftX, mCategories[i].ShiftY);
            }
            //            for (int i = 0; i < mGroups.Length; i++)
            //                AddGroup(mGroups[i]);
            if (mDataSource.Rows.Count == 0)
            {
                mDataSource.Rows.Add(new DataSource.ChartDataRow("Pyramid"));
            }
            for (int i = 0; i < mData.Length; i++)
            {
                try
                {
                    DataEntry entry = mData[i];
                    mDataSource.SetValue(entry.ColumnName, entry.GroupName, entry.Amount);
                }
                catch (Exception)
                {
                }
            }

            mDataSource.SuspendEvents = false;
        }
        public void OnAfterDeserialize()
        {
            mDataSource = new ChartSparseDataSource();
            mDataSource.SuspendEvents = true;
            mDataSource.Clear();
            if (mCategories == null)
            {
                mCategories = new CategoryData[0];
            }
            if (mGroups == null)
            {
                mGroups = new string[0];
            }
            if (mData == null)
            {
                mData = new DataEntry[0];
            }
            for (int i = 0; i < mCategories.Length; i++)
            {
                AddCategory(mCategories[i].Name, mCategories[i]);
            }
            for (int i = 0; i < mGroups.Length; i++)
            {
                AddGroup(mGroups[i]);
            }

            for (int i = 0; i < mData.Length; i++)
            {
                try
                {
                    DataEntry entry = mData[i];
                    mDataSource.SetValue(entry.ColumnName, entry.GroupName, entry.Amount);
                }
                catch (Exception)
                {
                }
            }

            mDataSource.SuspendEvents = false;
        }
Beispiel #4
0
        void IInternalPieData.OnAfterDeserialize()
        {
            mDataSource = new ChartSparseDataSource();
            mDataSource.SuspendEvents = true;
            mDataSource.Clear();
            if (mCategories == null)
            {
                mCategories = new CategoryData[0];
            }
            if (mGroups == null)
            {
                mGroups = new string[0];
            }
            if (mData == null)
            {
                mData = new DataEntry[0];
            }

            for (int i = 0; i < mCategories.Length; i++)
            {
                AddCategory(mCategories[i].Name, mCategories[i].Materials, mCategories[i].RadiusScale, mCategories[i].DepthScale, mCategories[i].DepthOffset);
            }
            //            for (int i = 0; i < mGroups.Length; i++)
            //                AddGroup(mGroups[i]);
            mDataSource.Rows.Add(new DataSource.ChartDataRow("Pie"));
            for (int i = 0; i < mData.Length; i++)
            {
                try
                {
                    DataEntry entry = mData[i];
                    mDataSource.SetValue(entry.ColumnName, entry.GroupName, entry.Amount);
                }
                catch (Exception)
                {
                }
            }

            mDataSource.SuspendEvents = false;
        }
        /// <summary>
        /// returns the world position for the specified bar value. This can be used to make objects aligned with the bars. The position is at the top of the bar and dependent on it's value
        /// </summary>
        /// <returns>true on success with track position set to the right value. false if the category or group names are wrong</returns>
        public bool GetBarTrackPosition(string category, string group, out Vector3 trackPosition)
        {
            trackPosition = Vector3.zero;
            ChartSparseDataSource data = ((IInternalBarData)DataSource).InternalDataSource;
            int categoryIdx, groupIdx;

            if (data.Columns.TryGetIndexByName(category, out categoryIdx) == false)
            {
                return(false);
            }
            if (data.Rows.TryGetIndexByName(group, out groupIdx) == false)
            {
                return(false);
            }
            BarObject obj;

            if (mBars.TryGetValue(new ChartItemIndex(groupIdx, categoryIdx), out obj) == false)
            {
                return(false);
            }
            trackPosition = GetTopPosition(obj);
            return(true);
        }
        /// <summary>
        /// This method returns the worldspace point for a specified bar and value. This method is different from GetBarTrackPosition because it is not dependent on the bar value. The value is specified as a paramenter
        /// </summary>
        /// <param name="category"></param>
        /// <param name="group"></param>
        /// <param name="value"></param>
        /// <param name="allowOverflow">set this to false in order to clamp the worldspace point to the bounds of the chart. set this to true in order to ingnore the min max value of the chart , </param>
        /// <param name="point">the resulting point in worldspace coordinates</param>
        /// <returns></returns>
        public bool PointToWorldSpace(string category, string group, double value, bool allowOverflow, out Vector3 point)
        {
            point = Vector3.zero;
            ChartSparseDataSource data = ((IInternalBarData)DataSource).InternalDataSource;
            int categoryIdx, groupIdx;

            if (data.Columns.TryGetIndexByName(category, out categoryIdx) == false)
            {
                return(false);
            }
            if (data.Rows.TryGetIndexByName(group, out groupIdx) == false)
            {
                return(false);
            }
            BarObject obj;

            if (mBars.TryGetValue(new ChartItemIndex(groupIdx, categoryIdx), out obj) == false)
            {
                return(false);
            }
            double min = ((IInternalBarData)Data).GetMinValue();
            double max = ((IInternalBarData)Data).GetMaxValue();

            if (min <= max)
            {
                return(false);
            }
            double interp = value / (max - min);

            if (allowOverflow == false)
            {
                interp = Math.Max(0, Math.Min(1, interp));
            }
            point = obj.InnerPosition + obj.SizeDirection * (float)interp;
            return(true);
        }
 public PieData()
 {
     mDataSource = new ChartSparseDataSource();
     mDataSource.Rows.Add(new DataSource.ChartDataRow("Pie"));
 }