예제 #1
0
        /// <inheritdoc/>
        protected override AxisScale OnSuggestYScale()
        {
            TextScale scale = new TextScale(-0.5, 0.5);

            scale.Labels.Add(new TextLabel(0, Title));
            return(scale);
        }
예제 #2
0
        /// <summary>
        /// Suggests a scale for the base axis (independent values).
        /// </summary>
        /// <returns>
        /// A suitable <see cref="TextScale"/> with ticks between the text labels.
        /// </returns>
        public AxisScale SuggestBaseScale()
        {
            if (Data == null || Data.Count == 0)
            {
                return(null);
            }

            CultureInfo culture     = ChartHelper.GetCulture(this);
            Orientation orientation = EffectiveOrientation;

            if (Data.Count == 1)
            {
                DataPoint data      = Data[0];
                double    value     = (orientation == Orientation.Vertical) ? data.X : data.Y;
                TextScale textScale = new TextScale(value - 0.5, value + 0.5);
                textScale.Labels.Add(new TextLabel(value, value.ToString(culture), null));
                textScale.TicksBetweenLabels = true;
                return(textScale);
            }
            else
            {
                DataPoint dataN       = Data[0];
                DataPoint dataNPlus1  = Data[1];
                DataPoint dataNMinus2 = Data[Data.Count - 2];
                DataPoint dataNMinus1 = Data[Data.Count - 1];
                double    valueN;
                double    valueNPlus1;
                double    valueNMinus2;
                double    valueNMinus1;
                if (orientation == Orientation.Vertical)
                {
                    valueN       = dataN.X;
                    valueNPlus1  = dataNPlus1.X;
                    valueNMinus2 = dataNMinus2.X;
                    valueNMinus1 = dataNMinus1.X;
                }
                else
                {
                    valueN       = dataN.Y;
                    valueNPlus1  = dataNPlus1.Y;
                    valueNMinus2 = dataNMinus2.Y;
                    valueNMinus1 = dataNMinus1.Y;
                }

                double    min       = valueN - (valueNPlus1 - valueN) / 2;
                double    max       = valueNMinus1 + (valueNMinus1 - valueNMinus2) / 2;
                TextScale textScale = new TextScale(min, max)
                {
                    TicksBetweenLabels = true
                };
                for (int i = 0; i < Data.Count; i++)
                {
                    DataPoint data  = Data[i];
                    double    value = (orientation == Orientation.Vertical) ? data.X : data.Y;
                    textScale.Labels.Add(new TextLabel(value, value.ToString(culture), null));
                }
                return(textScale);
            }
        }
예제 #3
0
        private static IList <TextLabel> GetLabels(Axis axis)
        {
            AxisScale         scale     = axis.Scale;
            IList <TextLabel> labels    = null;
            TextScale         textScale = scale as TextScale;

            if (textScale != null)
            {
                labels = (textScale).Labels;
            }

            return(labels);
        }
예제 #4
0
 /// <inheritdoc/>
 protected override AxisScale OnSuggestYScale()
 {
     TextScale scale = new TextScale(-0.5, 0.5);
     scale.Labels.Add(new TextLabel(0, Title));
     return scale;
 }
예제 #5
0
        /// <summary>
        /// Suggests a scale for the base axis (independent values).
        /// </summary>
        /// <returns>
        /// A suitable <see cref="TextScale"/> with ticks between the text labels.
        /// </returns>
        public AxisScale SuggestBaseScale()
        {
            if (Data == null || Data.Count == 0)
                return null;

            CultureInfo culture = ChartHelper.GetCulture(this);
            Orientation orientation = EffectiveOrientation;
            if (Data.Count == 1)
            {
                DataPoint data = Data[0];
                double value = (orientation == Orientation.Vertical) ? data.X : data.Y;
                TextScale textScale = new TextScale(value - 0.5, value + 0.5);
                textScale.Labels.Add(new TextLabel(value, value.ToString(culture), null));
                textScale.TicksBetweenLabels = true;
                return textScale;
            }
            else
            {
                DataPoint dataN = Data[0];
                DataPoint dataNPlus1 = Data[1];
                DataPoint dataNMinus2 = Data[Data.Count - 2];
                DataPoint dataNMinus1 = Data[Data.Count - 1];
                double valueN;
                double valueNPlus1;
                double valueNMinus2;
                double valueNMinus1;
                if (orientation == Orientation.Vertical)
                {
                    valueN = dataN.X;
                    valueNPlus1 = dataNPlus1.X;
                    valueNMinus2 = dataNMinus2.X;
                    valueNMinus1 = dataNMinus1.X;
                }
                else
                {
                    valueN = dataN.Y;
                    valueNPlus1 = dataNPlus1.Y;
                    valueNMinus2 = dataNMinus2.Y;
                    valueNMinus1 = dataNMinus1.Y;
                }

                double min = valueN - (valueNPlus1 - valueN) / 2;
                double max = valueNMinus1 + (valueNMinus1 - valueNMinus2) / 2;
                TextScale textScale = new TextScale(min, max)
                {
                    TicksBetweenLabels = true
                };
                for (int i = 0; i < Data.Count; i++)
                {
                    DataPoint data = Data[i];
                    double value = (orientation == Orientation.Vertical) ? data.X : data.Y;
                    textScale.Labels.Add(new TextLabel(value, value.ToString(culture), null));
                }
                return textScale;
            }
        }