Esempio n. 1
0
        /// <summary>
        /// Reset data serial to row default styles.
        /// </summary>
        protected virtual void ResetDataSerialStyles()
        {
            var ds = this.dataSource;

            if (ds == null)
            {
                return;
            }

            int dataSerialCount = this.dataSource.SerialCount;

            if (this.dataSource == null || dataSerialCount <= 0)
            {
                this.serialStyles.Clear();
            }

            while (this.serialStyles.Count < dataSerialCount)
            {
                this.serialStyles.Add(new DataSerialStyle(this)
                {
                    FillColor = ChartUtility.GetDefaultDataSerialFillColor(this.serialStyles.Count),
                    LineColor = ChartUtility.GetDefaultDataSerialFillColor(this.serialStyles.Count),
                    LineWidth = 2f,
                });
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Reset data serial to row default styles.
        /// </summary>
        protected virtual void ResetDataSerialStyles()
        {
            if (DataSource == null)
            {
                return;
            }

            // Allocate styles in such way that derived classes can opt to use them for categories instead
            int dataSerialCount = Math.Max(DataSource.SerialCount, DataSource.CategoryCount);

            if (dataSerialCount <= 0)
            {
                serialStyles.Clear();
            }

            while (serialStyles.Count < dataSerialCount)
            {
                serialStyles.Add(new DataSerialStyle(this)
                {
                    FillColor = ChartUtility.GetDefaultDataSerialFillColor(serialStyles.Count),
                    LineColor = ChartUtility.GetDefaultDataSerialFillColor(serialStyles.Count),
                    LineWidth = 2f,
                });
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Update specified axis information.
        /// </summary>
        /// <param name="ai">Axis information set.</param>
        /// <param name="minData">Minimum value scanned from data range.</param>
        /// <param name="maxData">Maximum value scanned from data range.</param>
        protected virtual void UpdateAxisInfo(AxisDataInfo ai, double minData, double maxData)
        {
            var clientRect = this.PlotViewContainer;

            double range = maxData - minData;

            ai.Levels = (int)Math.Ceiling(clientRect.Height / 30f);

            // when clientRect is zero, nothing to do
            if (double.IsNaN(ai.Levels))
            {
                return;
            }

            if (minData == maxData)
            {
                if (maxData == 0)
                {
                    maxData = ai.Levels;
                }
                else
                {
                    minData = 0;
                }
            }

            int    scaler;
            double stride = ChartUtility.CalcLevelStride(minData, maxData, ai.Levels, out scaler);

            ai.Scaler = scaler;

            double m;

            if (!ai.AutoMinimum)
            {
                if (this.AxisOriginToZero(minData, maxData, range))
                {
                    ai.Minimum = 0;
                }
                else
                {
                    m = minData % stride;
                    if (m == 0)
                    {
                        if (minData == 0)
                        {
                            ai.Minimum = minData;
                        }
                        else
                        {
                            ai.Minimum = minData - stride;
                        }
                    }
                    else
                    {
                        if (minData < 0)
                        {
                            ai.Minimum = minData - stride - m;
                        }
                        else
                        {
                            ai.Minimum = minData - m;
                        }
                    }
                }
            }

            if (!ai.AutoMaximum)
            {
                m = maxData % stride;
                if (m == 0)
                {
                    ai.Maximum = maxData + stride;
                }
                else
                {
                    ai.Maximum = maxData - m + stride;
                }
            }

            ai.Levels = (int)Math.Round((ai.Maximum - ai.Minimum) / stride);

            ai.LargeStride = stride;
        }
Esempio n. 4
0
        /// <summary>
        /// Update specified axis information.
        /// </summary>
        /// <param name="ai">Axis information set.</param>
        /// <param name="minData">Minimum value scanned from data range.</param>
        /// <param name="maxData">Maximum value scanned from data range.</param>
        protected virtual void UpdateAxisInfo(AxisDataInfo ai, double minData, double maxData)
        {
            var clientRect = this.PlotViewContainer;

            double range = maxData - minData;

            var isTransposed = HorizontalAxisInfoView.Orientation == AxisOrientation.Vertical;

            ai.Levels = (int)Math.Ceiling((isTransposed ? clientRect.Width : clientRect.Height) / 30f);

            // when clientRect is zero, nothing to do
            if (double.IsNaN(ai.Levels))
            {
                return;
            }

            if (minData == maxData)
            {
                if (maxData == 0)
                {
                    maxData = ai.Levels;
                }
                else
                {
                    minData = 0;
                }
            }

            int    scaler;
            double stride   = ChartUtility.CalcLevelStride(minData, maxData, ai.Levels, out scaler);
            double nearzero = stride / 1E9;

            ai.Scaler = scaler;

            double m;

            if (!ai.AutoMinimum)
            {
                if (this.AxisOriginToZero(minData, maxData, range))
                {
                    ai.Minimum = 0;
                }
                else
                {
                    m = minData % stride;
                    if (Math.Abs(m) < nearzero)
                    {
                        ai.Minimum = minData;
                    }
                    else
                    {
                        if (minData < 0)
                        {
                            ai.Minimum = minData - stride - m;
                        }
                        else
                        {
                            ai.Minimum = minData - m;
                        }
                    }
                }
            }

            if (!ai.AutoMaximum)
            {
                m = maxData % stride;
                if (Math.Abs(m) < nearzero)
                {
                    ai.Maximum = maxData;
                }
                else
                {
                    ai.Maximum = maxData - m + stride;
                }
            }

            ai.Levels = (int)Math.Round((ai.Maximum - ai.Minimum) / stride);

            ai.LargeStride = stride;
        }