Ejemplo n.º 1
0
 double ICartesianSeries.GetMinX(AxisCore axis)
 {
     var f = AxisLimits.SeparatorMin(axis);
     return CurrentYAxis.MinLimit >= 0 && CurrentYAxis.MaxLimit > 0
         ? (f >= 0 ? f : 0)
         : f;
 }
Ejemplo n.º 2
0
 double ICartesianSeries.GetMaxY(AxisCore axis)
 {
     var f = AxisLimits.SeparatorMax(axis);
     return CurrentYAxis.BotLimit < 0 && CurrentYAxis.TopLimit <= 0
         ? (f >= 0 ? f : 0)
         : f;
 }
Ejemplo n.º 3
0
        private static void SetAxisLimits(AxisCore ax, IList <ISeriesView> series, AxisOrientation orientation)
        {
            var first  = new CoreLimit();
            var firstR = 0d;

            if (series.Count > 0)
            {
                first = orientation == AxisOrientation.X
                    ? series[0].Values.GetTracker(series[0]).XLimit
                    : series[0].Values.GetTracker(series[0]).YLimit;
                var view = series[0] as IAreaPoint;
                firstR = view != null?view.GetPointDiameter() : 0;
            }

            //                     [ max, min, pointRadius ]
            var boundries = new[] { first.Max, first.Min, firstR };

            for (var index = 1; index < series.Count; index++)
            {
                var seriesView = series[index];
                var tracker    = seriesView.Values.GetTracker(seriesView);
                var limit      = orientation == AxisOrientation.X ? tracker.XLimit : tracker.YLimit;
                var view       = seriesView as IAreaPoint;
                var radius     = view != null?view.GetPointDiameter() : 0;

                if (limit.Max > boundries[0])
                {
                    boundries[0] = limit.Max;
                }
                if (limit.Min < boundries[1])
                {
                    boundries[1] = limit.Min;
                }
                if (radius > boundries[2])
                {
                    boundries[2] = radius;
                }
            }

            ax.TopSeriesLimit = boundries[0];
            ax.BotSeriesLimit = boundries[1];

            ax.TopLimit = double.IsNaN(ax.MaxValue) ? boundries[0] : ax.MaxValue;
            ax.BotLimit = double.IsNaN(ax.MinValue) ? boundries[1] : ax.MinValue;

            ax.MaxPointRadius = boundries[2];
        }
        /// <summary>
        /// Updates the label.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;
            TextBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                                                TextBlock.DesiredSize.Width, TextBlock.DesiredSize.Height, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform {
                Angle = transform.LabelAngle
            }
                : null;

            LabelModel = transform;

            return(transform);
        }
Ejemplo n.º 5
0
        public void UpdateLine(AxisTags source, ChartCore chart, int axisIndex, AxisCore axis)
        {
            var wpfChart = chart.View as Chart;
            var wpfAxis  = axis.View as Axis;

            if (wpfChart == null || wpfAxis == null)
            {
                return;
            }

            switch (Model.State)
            {
            case SeparationState.Remove:
                if (!chart.View.DisableAnimations && !axis.DisableAnimations)
                {
                    MoveFromCurrentAx(wpfChart, source, axisIndex, wpfAxis);
                }
                Remove(wpfChart, wpfAxis);
                break;

            case SeparationState.Keep:
                UnanimatedPlace(wpfChart, source, axisIndex, wpfAxis);
                if (!chart.View.DisableAnimations && !axis.DisableAnimations)
                {
                    MoveFromPreviousAx(wpfChart, source, axisIndex, wpfAxis);
                }
                if (Model.IsNew)
                {
                    FadeIn(wpfChart, wpfAxis);
                }
                break;

            case SeparationState.InitialAdd:
                UnanimatedPlace(wpfChart, source, axisIndex, wpfAxis);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Updates the label.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;

            var formattedText = new FormattedText(
                TextBlock.Text,
                CultureInfo.CurrentUICulture,
                FlowDirection.LeftToRight,
                new Typeface(TextBlock.FontFamily, TextBlock.FontStyle, TextBlock.FontWeight, TextBlock.FontStretch),
                TextBlock.FontSize, Brushes.Black);

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                                                formattedText.Width, formattedText.Height, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform(transform.LabelAngle)
                : null;

            LabelModel = transform;

            return(transform);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     Ases the core element.
        /// </summary>
        /// <param name="chart">The chart.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public virtual AxisCore AsCoreElement(ChartCore chart, AxisOrientation source)
        {
            if (Model == null)
            {
                Model = new AxisCore(this);
            }

            Model.ShowLabels        = ShowLabels;
            Model.Chart             = chart;
            Model.IsMerged          = IsMerged;
            Model.Labels            = Labels;
            Model.LabelFormatter    = LabelFormatter;
            Model.MaxValue          = MaxValue;
            Model.MinValue          = MinValue;
            Model.Title             = Title;
            Model.Position          = Position;
            Model.Separator         = Separator.AsCoreElement(Model, source);
            Model.DisableAnimations = DisableAnimations;
            Model.Sections          = Sections.Select(x => x.AsCoreElement(Model, source)).ToList();

            return(Model);
        }
Ejemplo n.º 8
0
        public void Place(ChartCore chart, AxisCore axis, AxisOrientation direction, int axisIndex,
                          double toLabel, double toLine, double tab)
        {
            if (direction == AxisOrientation.Y)
            {
                Line.X1 = chart.DrawMargin.Left;
                Line.X2 = chart.DrawMargin.Left + chart.DrawMargin.Width;
                Line.Y1 = toLine;
                Line.Y2 = toLine;

                Canvas.SetLeft(TextBlock, tab);
                Canvas.SetTop(TextBlock, toLabel);
            }
            else
            {
                Line.X1 = toLine;
                Line.X2 = toLine;
                Line.Y1 = chart.DrawMargin.Top;
                Line.Y2 = chart.DrawMargin.Top + chart.DrawMargin.Height;

                Canvas.SetLeft(TextBlock, toLabel);
                Canvas.SetTop(TextBlock, tab);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Moves the specified chart.
        /// </summary>
        /// <param name="chart">The chart.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="axisIndex">Index of the axis.</param>
        /// <param name="toLabel">To label.</param>
        /// <param name="toLine">To line.</param>
        /// <param name="tab">The tab.</param>
        public void Move(ChartCore chart, AxisCore axis, AxisOrientation direction, int axisIndex, double toLabel,
                         double toLine, double tab)
        {
            if (direction == AxisOrientation.Y)
            {
                Line.BeginAnimation(Line.X1Property,
                                    new DoubleAnimation(chart.DrawMargin.Left, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.X2Property,
                                    new DoubleAnimation(chart.DrawMargin.Left + chart.DrawMargin.Width, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y1Property,
                                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y2Property,
                                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));

                TextBlock.BeginAnimation(Canvas.TopProperty,
                                         new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
                TextBlock.BeginAnimation(Canvas.LeftProperty,
                                         new DoubleAnimation(tab, chart.View.AnimationsSpeed));
            }
            else
            {
                Line.BeginAnimation(Line.X1Property,
                                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.X2Property,
                                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y1Property,
                                    new DoubleAnimation(chart.DrawMargin.Top, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y2Property,
                                    new DoubleAnimation(chart.DrawMargin.Top + chart.DrawMargin.Height, chart.View.AnimationsSpeed));

                TextBlock.BeginAnimation(Canvas.LeftProperty,
                                         new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
                TextBlock.BeginAnimation(Canvas.TopProperty,
                                         new DoubleAnimation(tab, chart.View.AnimationsSpeed));
            }
        }
Ejemplo n.º 10
0
 double ICartesianSeries.GetMinX(AxisCore axis)
 {
     return((int)(axis.BotLimit / axis.S) * axis.S);
 }
Ejemplo n.º 11
0
 internal static double SeparatorMin(AxisCore axis)
 {
     return(((Math.Floor(axis.BotLimit / axis.S)) - 1.0) * axis.S);
 }
Ejemplo n.º 12
0
 internal static double SeparatorMax(AxisCore axis)
 {
     return((Math.Floor(axis.TopLimit / axis.S) + 1.0) * axis.S);
 }
Ejemplo n.º 13
0
 internal static double UnitRight(AxisCore axis)
 {
     return(Math.Ceiling(axis.TopLimit / axis.Magnitude) * axis.Magnitude + 1);
 }
        /// <summary>
        /// Updates the label.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;
            TextBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                TextBlock.DesiredSize.Width, TextBlock.DesiredSize.Height, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform {  Angle = transform.LabelAngle }
                : null;

            LabelModel = transform;

            return transform;
        }
 double ICartesianSeries.GetMaxY(AxisCore axis)
 {
     return AxisLimits.UnitRight(axis);
 }
        /// <summary>
        /// Moves the specified chart.
        /// </summary>
        /// <param name="chart">The chart.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="axisIndex">Index of the axis.</param>
        /// <param name="toLabel">To label.</param>
        /// <param name="toLine">To line.</param>
        /// <param name="tab">The tab.</param>
        public void Move(ChartCore chart, AxisCore axis, AxisOrientation direction, int axisIndex, double toLabel, double toLine, double tab)
        {
            if (direction == AxisOrientation.Y)
            {
                Line.BeginAnimation(Line.X1Property,
                    new DoubleAnimation(chart.DrawMargin.Left, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.X2Property,
                    new DoubleAnimation(chart.DrawMargin.Left + chart.DrawMargin.Width, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y1Property,
                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y2Property,
                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));

                TextBlock.BeginAnimation(Canvas.TopProperty,
                    new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
                TextBlock.BeginAnimation(Canvas.LeftProperty,
                    new DoubleAnimation(tab, chart.View.AnimationsSpeed));
            }
            else
            {
                Line.BeginAnimation(Line.X1Property,
                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.X2Property,
                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y1Property,
                    new DoubleAnimation(chart.DrawMargin.Top, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y2Property,
                    new DoubleAnimation(chart.DrawMargin.Top + chart.DrawMargin.Height, chart.View.AnimationsSpeed));

                TextBlock.BeginAnimation(Canvas.LeftProperty,
                    new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
                TextBlock.BeginAnimation(Canvas.TopProperty,
                    new DoubleAnimation(tab, chart.View.AnimationsSpeed));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SeparatorConfigurationCore"/> class.
 /// </summary>
 /// <param name="axis">The axis.</param>
 public SeparatorConfigurationCore(AxisCore axis)
 {
     Axis = axis;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Gets the minimum y.
 /// </summary>
 /// <param name="axis">The axis.</param>
 /// <returns></returns>
 public double GetMinY(AxisCore axis)
 {
     return AxisLimits.StretchMin(axis);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Gets the maximum y.
 /// </summary>
 /// <param name="axis">The axis.</param>
 /// <returns></returns>
 public double GetMaxY(AxisCore axis)
 {
     return AxisLimits.StretchMax(axis) + 1;
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Ases the core element.
 /// </summary>
 /// <param name="axis">The axis.</param>
 /// <param name="source">The source.</param>
 /// <returns></returns>
 public SeparatorConfigurationCore AsCoreElement(AxisCore axis, AxisOrientation source)
 {
     AxisOrientation = source;
     return new SeparatorConfigurationCore(axis)
     {
         IsEnabled = IsEnabled,
         Step = Step,
         Source = source
     };
 }
Ejemplo n.º 21
0
 internal static double UnitRight(AxisCore axis)
 {
     return Math.Ceiling(axis.MaxLimit/axis.Magnitude)*axis.Magnitude + 1;
 }
Ejemplo n.º 22
0
 internal static double StretchMin(AxisCore axis)
 {
     return(Math.Floor(axis.MinLimit / axis.Magnitude) * axis.Magnitude);
 }
        /// <summary>
        /// Fades the in.
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="chart">The chart.</param>
        public void FadeIn(AxisCore axis, ChartCore chart)
        {
            if (TextBlock.Visibility != Visibility.Collapsed)
                TextBlock.BeginDoubleAnimation("Opacity", 0, 1, chart.View.AnimationsSpeed);

            if (Line.Visibility != Visibility.Collapsed)
                Line.BeginDoubleAnimation("Opacity", 0, 1, chart.View.AnimationsSpeed);
        }
Ejemplo n.º 24
0
 double ICartesianSeries.GetMaxX(AxisCore axis)
 {
     return(AxisLimits.StretchMax(axis));
 }
Ejemplo n.º 25
0
 double ICartesianSeries.GetMaxY(AxisCore axis)
 {
     return(AxisLimits.SeparatorMaxRounded(axis));
 }
 double ICartesianSeries.GetMaxX(AxisCore axis)
 {
     return AxisLimits.SeparatorMaxRounded(axis);
 }
        /// <summary>
        /// Updates the label.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;

            var formattedText = new FormattedText(
                  TextBlock.Text,
                  CultureInfo.CurrentUICulture,
                  FlowDirection.LeftToRight,
                  new Typeface(TextBlock.FontFamily, TextBlock.FontStyle, TextBlock.FontWeight, TextBlock.FontStretch),
                  TextBlock.FontSize, Brushes.Black);

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                formattedText.Width, formattedText.Height, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform(transform.LabelAngle)
                : null;

            LabelModel = transform;

            return transform;
        }
Ejemplo n.º 28
0
        public LabelEvaluation(double angle, double w, double h, AxisCore axis, AxisOrientation source)
        {
            const double padding = 4;

            ActualWidth  = w;
            ActualHeight = h;

            // for now there is no support for rotated and merged labels.
            // the labels will be rotated but there is no warranty that they are displayed correctly
            if (axis.View.IsMerged)
            {
                Top    = 0;
                Bottom = 0;
                Left   = 0;
                Right  = 0;

                if (source == AxisOrientation.Y)
                {
                    XOffset = padding;
                    YOffset = padding;
                }
                else
                {
                    if (axis.Position == AxisPosition.LeftBottom)
                    {
                        //Bot
                        XOffset = padding;
                        YOffset = -h * 2 - padding;
                    }
                    else
                    {
                        //Top
                        XOffset = padding;
                        YOffset = padding + h * 2;
                    }
                }

                return;
            }

            //OK now lets evaluate the rotation angle...

            // the rotation angle starts from an horizontal line, yes like this text
            // - 0°, | 90°, - 180°, | 270°
            // notice normally rotating a label from 90 to 270° will show the label
            // in a wrong orientation
            // we need to fix that angle

            const double toRadians = Math.PI / 180;

            // 1. width components
            // 2. height components

            WFromW = Math.Abs(Math.Cos(angle * toRadians) * w); // W generated from the width of the label
            WFromH = Math.Abs(Math.Sin(angle * toRadians) * h); // W generated from the height of the label

            HFromW = Math.Abs(Math.Sin(angle * toRadians) * w); // H generated from the width of the label
            HFromH = Math.Abs(Math.Cos(angle * toRadians) * h); // H generated from the height of the label

            LabelAngle = angle % 360;
            if (LabelAngle < 0)
            {
                LabelAngle += 360;
            }
            if (LabelAngle > 90 && LabelAngle < 270)
            {
                LabelAngle = (LabelAngle + 180) % 360;
            }

            //at this points angles should only exist in 1st and 4th quadrant
            //those are the only quadrants that generates readable labels
            //the other 2 quadrants display inverted labels

            var quadrant = ((int)(LabelAngle / 90)) % 4 + 1;

            if (source == AxisOrientation.Y)
            {
                // Y Axis
                if (quadrant == 1)
                {
                    if (axis.Position == AxisPosition.LeftBottom)
                    {
                        // 1, L
                        Top     = HFromW + (HFromH / 2); //space taken from separator to top
                        Bottom  = TakenHeight - Top;     //space taken from separator to bottom
                        XOffset = -WFromW - padding;     //distance from separator to label origin in X
                        YOffset = -Top;                  //distance from separator to label origin in Y
                    }
                    else
                    {
                        // 1, R
                        Bottom  = HFromW + (HFromH / 2);
                        Top     = TakenHeight - Bottom;
                        XOffset = padding + WFromH;
                        YOffset = -Top;
                    }
                }
                else
                {
                    if (axis.Position == AxisPosition.LeftBottom)
                    {
                        // 4, L
                        Bottom  = HFromW + (HFromH / 2);
                        Top     = TakenHeight - Bottom;
                        XOffset = -TakenWidth - padding;
                        YOffset = HFromW - (HFromH / 2);
                    }
                    else
                    {
                        // 4, R
                        Top     = HFromW + (HFromH / 2);
                        Bottom  = TakenHeight - Top;
                        XOffset = padding;
                        YOffset = -Bottom;
                    }
                }
            }
            else
            {
                // X Axis

                //axis x has one exception, if labels rotation equals 0° then the label is centered
                if (Math.Abs(axis.View.LabelsRotation) < .01)
                {
                    Left    = TakenWidth / 2;
                    Right   = Left;
                    XOffset = -Left;
                    YOffset = axis.Position == AxisPosition.LeftBottom
                        ? padding
                        : -padding - TakenHeight;
                }
                else
                {
                    if (quadrant == 1)
                    {
                        if (axis.Position == AxisPosition.LeftBottom)
                        {
                            //1, B
                            Right   = WFromW + (WFromH / 2); //space taken from separator to right
                            Left    = TakenWidth - Right;    //space taken from separator to left
                            XOffset = Left;                  //distance from separator to label origin in X
                            YOffset = padding;               //distance from separator to label origin in Y
                        }
                        else
                        {
                            //1, T
                            Left    = WFromW + (WFromH / 2);
                            Right   = TakenWidth - Left;
                            XOffset = -WFromW;
                            YOffset = -padding - TakenHeight;
                        }
                    }
                    else
                    {
                        if (axis.Position == AxisPosition.LeftBottom)
                        {
                            //4, B
                            Left    = WFromW + (WFromH / 2);
                            Right   = TakenWidth - Left;
                            XOffset = -Left;
                            YOffset = padding + HFromW;
                        }
                        else
                        {
                            //4, T
                            Right   = WFromW + (WFromH / 2);
                            Left    = TakenWidth - Right;
                            XOffset = -Left;
                            YOffset = -HFromH;
                        }
                    }
                }
            }
        }
 double ICartesianSeries.GetMinY(AxisCore axis)
 {
     return AxisLimits.StretchMin(axis);
 }
Ejemplo n.º 30
0
 internal static double StretchMin(AxisCore axis)
 {
     return Math.Floor(axis.MinLimit/axis.Magnitude)*axis.Magnitude;
 }
Ejemplo n.º 31
0
 internal static double StretchMin(AxisCore axis)
 {
     return(axis.BotLimit); //Math.Floor(axis.BotLimit/axis.Magnitude)*axis.Magnitude;
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Ases the core element.
        /// </summary>
        /// <param name="chart">The chart.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public AxisCore AsCoreElement(ChartCore chart, AxisOrientation source)
        {
            if (Model == null) Model = new AxisCore(this);

            Model.ShowLabels = ShowLabels;
            Model.Chart = chart;
            Model.IsMerged = IsMerged;
            Model.Labels = Labels;
            Model.LabelFormatter = LabelFormatter;
            Model.MaxValue = MaxValue;
            Model.MinValue = MinValue;
            Model.Title = Title;
            Model.Position = Position;
            Model.Separator = Separator.AsCoreElement(Model, source);
            Model.DisableAnimations = DisableAnimations;
            Model.Sections = Sections.Select(x => x.AsCoreElement(Model, source)).ToList();

            return Model;
        }
Ejemplo n.º 33
0
 internal static double UnitLeft(AxisCore axis)
 {
     return(Math.Floor(axis.BotLimit / axis.Magnitude) * axis.Magnitude - 1);
 }
Ejemplo n.º 34
0
 double ICartesianSeries.GetMinX(AxisCore axis)
 {
     return AxisLimits.SeparatorMin(axis);
 }
Ejemplo n.º 35
0
 internal static double SeparatorMaxRounded(AxisCore axis)
 {
     return(Math.Round((axis.TopLimit / axis.S) + 1.0, 0) * axis.S);
 }
Ejemplo n.º 36
0
        private void PlaceLabel(string text, AxisCore axis, AxisOrientation source)
        {
            _label.Text = text;

            _label.UpdateLayout();

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                                                _label.Width + 10, _label.Height, axis, source);

            _label.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform {
                Angle = transform.LabelAngle
            }
                : null;

            var toLine = ChartFunctions.ToPlotArea(Value, source, Model.Chart, axis);

            var direction = source == AxisOrientation.X ? 1 : -1;

            toLine += axis.EvaluatesUnitWidth ? direction * ChartFunctions.GetUnitWidth(source, Model.Chart, axis) / 2 : 0;
            var toLabel = toLine + transform.GetOffsetBySource(source);

            var chart = Model.Chart;

            if (axis.IsMerged)
            {
                const double padding = 4;

                if (source == AxisOrientation.Y)
                {
                    if (toLabel + transform.ActualHeight >
                        chart.DrawMargin.Top + chart.DrawMargin.Height)
                    {
                        toLabel -= transform.ActualHeight + padding;
                    }
                }
                else
                {
                    if (toLabel + transform.ActualWidth >
                        chart.DrawMargin.Left + chart.DrawMargin.Width)
                    {
                        toLabel -= transform.ActualWidth + padding;
                    }
                }
            }

            var labelTab = axis.Tab;

            labelTab += transform.GetOffsetBySource(source.Invert());

            if (source == AxisOrientation.Y)
            {
                if (Model.View.DisableAnimations || DisableAnimations)
                {
                    Canvas.SetLeft(_label, labelTab);
                    Canvas.SetTop(_label, toLabel);
                    return;
                }

                _label.BeginDoubleAnimation("Canvas.Top", toLabel, chart.View.AnimationsSpeed);
                _label.BeginDoubleAnimation("Canvas.Left", labelTab, chart.View.AnimationsSpeed);
            }
            else
            {
                if (Model.View.DisableAnimations || DisableAnimations)
                {
                    Canvas.SetLeft(_label, toLabel);
                    Canvas.SetTop(_label, labelTab);
                    return;
                }

                _label.BeginDoubleAnimation("Canvas.Left", toLabel, chart.View.AnimationsSpeed);
                _label.BeginDoubleAnimation("Canvas.Top", labelTab, chart.View.AnimationsSpeed);
            }
        }
Ejemplo n.º 37
0
        private void PlaceLabel(string text, AxisCore axis, AxisOrientation source)
        {
            _label.Text = text;

            var formattedText = new FormattedText(
                _label.Text,
                CultureInfo.CurrentUICulture,
                FlowDirection.LeftToRight,
                new Typeface(_label.FontFamily, _label.FontStyle, _label.FontWeight, _label.FontStretch),
                _label.FontSize, Brushes.Black);

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                                                formattedText.Width + 10, formattedText.Height, axis, source);

            _label.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform(transform.LabelAngle)
                : null;

            var toLine = ChartFunctions.ToPlotArea(Value + SectionOffset + SectionWidth * .5, source, Model.Chart,
                                                   axis);

            var direction = source == AxisOrientation.X ? 1 : -1;

            toLine += axis.EvaluatesUnitWidth ? direction * ChartFunctions.GetUnitWidth(source, Model.Chart, axis) / 2 : 0;
            var toLabel = toLine + transform.GetOffsetBySource(source);

            var chart = Model.Chart;

            if (axis.IsMerged)
            {
                const double padding = 4;

                if (source == AxisOrientation.Y)
                {
                    if (toLabel + transform.ActualHeight >
                        chart.DrawMargin.Top + chart.DrawMargin.Height)
                    {
                        toLabel -= transform.ActualHeight + padding;
                    }
                }
                else
                {
                    if (toLabel + transform.ActualWidth >
                        chart.DrawMargin.Left + chart.DrawMargin.Width)
                    {
                        toLabel -= transform.ActualWidth + padding;
                    }
                }
            }

            var labelTab = axis.Tab;

            labelTab += transform.GetOffsetBySource(source.Invert());

            if (source == AxisOrientation.Y)
            {
                labelTab += 8 * (axis.Position == AxisPosition.LeftBottom ? 1 : -1);

                if (Model.View.DisableAnimations || DisableAnimations)
                {
                    Canvas.SetLeft(_label, labelTab);
                    Canvas.SetTop(_label, toLabel);
                    return;
                }

                _label.BeginAnimation(Canvas.TopProperty,
                                      new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
                _label.BeginAnimation(Canvas.LeftProperty,
                                      new DoubleAnimation(labelTab, chart.View.AnimationsSpeed));
            }
            else
            {
                if (Model.View.DisableAnimations || DisableAnimations)
                {
                    Canvas.SetLeft(_label, toLabel);
                    Canvas.SetTop(_label, labelTab);
                    return;
                }

                _label.BeginAnimation(Canvas.LeftProperty,
                                      new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
                _label.BeginAnimation(Canvas.TopProperty,
                                      new DoubleAnimation(labelTab, chart.View.AnimationsSpeed));
            }
        }
Ejemplo n.º 38
0
 internal static double StretchMax(AxisCore axis)
 {
     return Math.Ceiling(axis.MaxLimit/axis.Magnitude)*axis.Magnitude;
 }
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;
            TextBlock.UpdateLayout();

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                TextBlock.ActualWidth, TextBlock.ActualHeight, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform(transform.LabelAngle)
                : null;

            LabelModel = transform;

            return transform;
        }
Ejemplo n.º 40
0
 double ICartesianSeries.GetMaxX(AxisCore axis)
 {
     return AxisLimits.StretchMax(axis);
 }
Ejemplo n.º 41
0
 double ICartesianSeries.GetMinY(AxisCore axis)
 {
     return(AxisLimits.SeparatorMin(axis));
 }
Ejemplo n.º 42
0
 public double GetMaxY(AxisCore axis)
 {
     return(AxisLimits.StretchMax(axis) + 1);
 }
        /// <summary>
        /// Fades the in.
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="chart">The chart.</param>
        public void FadeIn(AxisCore axis, ChartCore chart)
        {
            if (TextBlock.Visibility != Visibility.Collapsed)
                TextBlock.BeginAnimation(UIElement.OpacityProperty,
                    new DoubleAnimation(0, 1, chart.View.AnimationsSpeed));

            if (Line.Visibility != Visibility.Collapsed)
                Line.BeginAnimation(UIElement.OpacityProperty,
                    new DoubleAnimation(0, 1, chart.View.AnimationsSpeed));
        }
Ejemplo n.º 44
0
 internal static double SeparatorMin(AxisCore axis)
 {
     return (((int) (axis.MinLimit/axis.S)) - 1)*axis.S;
 }
        /// <summary>
        /// Places the specified chart.
        /// </summary>
        /// <param name="chart">The chart.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="axisIndex">Index of the axis.</param>
        /// <param name="toLabel">To label.</param>
        /// <param name="toLine">To line.</param>
        /// <param name="tab">The tab.</param>
        public void Place(ChartCore chart, AxisCore axis, AxisOrientation direction, int axisIndex, 
            double toLabel, double toLine, double tab)
        {
            if (direction == AxisOrientation.Y)
            {
                Line.X1 = chart.DrawMargin.Left;
                Line.X2 = chart.DrawMargin.Left + chart.DrawMargin.Width;
                Line.Y1 = toLine;
                Line.Y2 = toLine;

                Canvas.SetLeft(TextBlock, tab);
                Canvas.SetTop(TextBlock, toLabel);
            }
            else
            {
                Line.X1 = toLine;
                Line.X2 = toLine;
                Line.Y1 = chart.DrawMargin.Top;
                Line.Y2 = chart.DrawMargin.Top + chart.DrawMargin.Height;

                Canvas.SetLeft(TextBlock, toLabel);
                Canvas.SetTop(TextBlock, tab);
            }
        }
Ejemplo n.º 46
0
 double ICartesianSeries.GetMinY(AxisCore axis)
 {
     return(AxisLimits.StretchMin(axis));
 }
Ejemplo n.º 47
0
 internal static double SeparatorMax(AxisCore axis)
 {
     return (((int) (axis.MaxLimit/axis.S)) + 1)*axis.S;
 }
 double ICartesianSeries.GetMaxY(AxisCore axis)
 {
     return double.MinValue;
 }
 double ICartesianSeries.GetMinX(AxisCore axis)
 {
     return double.MaxValue;
 }
Ejemplo n.º 50
0
 internal static double StretchMax(AxisCore axis)
 {
     return(axis.TopLimit); //Math.Ceiling(axis.TopLimit/axis.Magnitude)*axis.Magnitude;
 }
Ejemplo n.º 51
0
 public double GetMinY(AxisCore axis)
 {
     return(AxisLimits.StretchMin(axis));
 }
        /// <summary>
        /// Moves the specified chart.
        /// </summary>
        /// <param name="chart">The chart.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="axisIndex">Index of the axis.</param>
        /// <param name="toLabel">To label.</param>
        /// <param name="toLine">To line.</param>
        /// <param name="tab">The tab.</param>
        public void Move(ChartCore chart, AxisCore axis, AxisOrientation direction, int axisIndex, double toLabel, double toLine, double tab)
        {
            if (direction == AxisOrientation.Y)
            {
                var x1 = AnimationsHelper.CreateDouble(chart.DrawMargin.Left, chart.View.AnimationsSpeed, nameof(Line.X1));
                var x2 = AnimationsHelper.CreateDouble(chart.DrawMargin.Left + chart.DrawMargin.Width, chart.View.AnimationsSpeed, nameof(Line.X2));
                var y1 = AnimationsHelper.CreateDouble(toLine, chart.View.AnimationsSpeed, nameof(Line.Y1));
                var y2 = AnimationsHelper.CreateDouble(toLine, chart.View.AnimationsSpeed, nameof(Line.Y2));

                AnimationsHelper.CreateStoryBoardAndBegin(Line, x1, x2, y1, y2);

                var tb1 = AnimationsHelper.CreateDouble(toLabel, chart.View.AnimationsSpeed, "(Canvas.Top)");
                var tb2 = AnimationsHelper.CreateDouble(tab, chart.View.AnimationsSpeed, "(Canvas.Left)");

                AnimationsHelper.CreateStoryBoardAndBegin(TextBlock, tb1, tb2);
            }
            else
            {
                var x1 = AnimationsHelper.CreateDouble(toLine, chart.View.AnimationsSpeed, nameof(Line.X1));
                var x2 = AnimationsHelper.CreateDouble(toLine, chart.View.AnimationsSpeed, nameof(Line.X2));
                var y1 = AnimationsHelper.CreateDouble(chart.DrawMargin.Top, chart.View.AnimationsSpeed, nameof(Line.Y1));
                var y2 = AnimationsHelper.CreateDouble(chart.DrawMargin.Top + chart.DrawMargin.Height, chart.View.AnimationsSpeed, nameof(Line.Y2));

                AnimationsHelper.CreateStoryBoardAndBegin(Line, x1, x2, y1, y2);

                var tb1 = AnimationsHelper.CreateDouble(toLabel, chart.View.AnimationsSpeed, "(Canvas.Left)");
                var tb2 = AnimationsHelper.CreateDouble(tab, chart.View.AnimationsSpeed, "(Canvas.Top)");

                AnimationsHelper.CreateStoryBoardAndBegin(TextBlock, tb1, tb2);
            }
        }
Ejemplo n.º 53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SeparatorConfigurationCore"/> class.
 /// </summary>
 /// <param name="axis">The axis.</param>
 public SeparatorConfigurationCore(AxisCore axis)
 {
     Axis = axis;
 }
Ejemplo n.º 54
0
 public AxisSectionCore AsCoreElement(AxisCore axis, AxisOrientation source)
 {
     var model = new AxisSectionCore(this, axis.Chart);
     model.View.Model = model;
     return model;
 }
Ejemplo n.º 55
0
 double ICartesianSeries.GetMaxX(AxisCore axis)
 {
     return(double.MinValue);
 }
Ejemplo n.º 56
0
 internal static double SeparatorMax(AxisCore axis)
 {
     return(((int)(axis.TopLimit / axis.S) + 1) * axis.S);
 }
Ejemplo n.º 57
0
 double ICartesianSeries.GetMaxY(AxisCore axis)
 {
     return(AxisLimits.UnitRight(axis));
 }
Ejemplo n.º 58
0
 internal static double SeparatorMin(AxisCore axis)
 {
     return((((int)(axis.BotLimit / axis.S)) - 1) * axis.S);
 }