コード例 #1
0
        /// <summary>
        /// Ends the segment.
        /// </summary>
        /// <param name="atIndex">At index.</param>
        /// <param name="location">The location.</param>
        public override void EndSegment(int atIndex, CorePoint location)
        {
            var splitter = Splitters[ActiveSplitters - 1];

            var animSpeed = Model.Chart.View.AnimationsSpeed;
            var noAnim = Model.Chart.View.DisableAnimations;

            if (splitter.IsNew)
            {
                splitter.Right.Point = new Point(0, location.Y);
            }

            var areaLimit = 0d;
            if (!double.IsNaN(AreaLimit))
                areaLimit = ChartFunctions.ToDrawMargin(AreaLimit, AxisOrientation.X, Model.Chart, ScalesXAt);
            var uw = Model.Chart.AxisY[ScalesYAt].EvaluatesUnitWidth
                ? ChartFunctions.GetUnitWidth(AxisOrientation.Y, Model.Chart, ScalesYAt) / 2
                : 0;
            location.Y += uw;

            Figure.Segments.Remove(splitter.Right);
            if (noAnim)
                splitter.Right.Point = new Point(areaLimit, location.Y);
            else
                splitter.Right.BeginAnimation(LineSegment.PointProperty,
                    new PointAnimation(new Point(areaLimit, location.Y), animSpeed));
            Figure.Segments.Insert(atIndex, splitter.Right);

            splitter.IsNew = false;
        }
コード例 #2
0
        public override void Update()
        {
            var heatSeries = (IHeatSeriesView)View;

            var uw = new CorePoint(
                0 * ChartFunctions.GetUnitWidth(AxisOrientation.X, Chart, View.ScalesXAt) / 2,
                -ChartFunctions.GetUnitWidth(AxisOrientation.Y, Chart, View.ScalesYAt));

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            var wd = CurrentXAxis.MaxLimit - CurrentXAxis.MinLimit == 0
                ? double.MaxValue
                : CurrentXAxis.MaxLimit - CurrentXAxis.MinLimit;
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            var hd = CurrentYAxis.MaxLimit - CurrentYAxis.MinLimit == 0
                ? double.MaxValue
                : CurrentYAxis.MaxLimit - CurrentYAxis.MinLimit;
            var w = Chart.DrawMargin.Width / wd;
            var h = Chart.DrawMargin.Height / hd;

            //lets force the gradients to always have an 'interpol-able' model

            if (!heatSeries.Stops.Any())
                throw new LiveChartsException("There is no a valid gradient to create a heat series.");

            var correctedGradients = heatSeries.Stops.Select(x => new CoreGradientStop
            {
                Color = x.Color,
                Offset = x.Offset < 0 ? 0 : (x.Offset > 1 ? 1 : x.Offset)
            }).ToList();
            var min = correctedGradients[0];
            min.Offset = 0;
            correctedGradients.Insert(0, min);
            var max = correctedGradients[correctedGradients.Count - 1];
            max.Offset = 1;
            correctedGradients.Add(max);

            foreach (var chartPoint in View.ActualValues.Points)
            {
                chartPoint.ChartLocation = ChartFunctions.ToDrawMargin(
                    chartPoint, View.ScalesXAt, View.ScalesYAt, Chart) + uw;

                chartPoint.SeriesView = View;

                chartPoint.View = View.GetPointView(chartPoint.View, chartPoint,
                    View.DataLabels ? View.LabelPoint(chartPoint) : null);

                var heatView = (IHeatPointView)chartPoint.View;

                heatView.ColorComponents = ColorInterpolation(correctedGradients,
                    chartPoint.Weight / Chart.Value3CoreLimit.Max);

                heatView.Width = w;
                heatView.Height = h;

                chartPoint.View.DrawOrMove(null, chartPoint, 0, Chart);
            }
        }
コード例 #3
0
        /// <summary>
        /// Converts a chart values pair to pixels
        /// </summary>
        /// <param name="chart">Target chart</param>
        /// <param name="chartPoint">point in screen</param>
        /// <param name="axisX">axis x index</param>
        /// <param name="axisY">axis y index</param>
        /// <returns></returns>
        public static Point ConvertToPixels(this Chart chart, Point chartPoint, int axisX = 0, int axisY = 0)
        {
            if (chart.Model == null || chart.AxisX.Any(x => x.Model == null)) return new Point();

            var uw = new CorePoint(
                chart.AxisX[axisX].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart.Model, axisX) / 2
                    : 0,
                chart.AxisY[axisY].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.Y, chart.Model, axisY) / 2
                    : 0);

            return new Point(
                ChartFunctions.ToPlotArea(chartPoint.X, AxisOrientation.X, chart.Model, axisX) + uw.X,
                ChartFunctions.ToPlotArea(chartPoint.Y, AxisOrientation.Y, chart.Model, axisY) + uw.Y);
        }
コード例 #4
0
        public override void Update()
        {
            var bubbleSeries = (IBubbleSeriesView) View;

            var p1 = new CorePoint();
            var p2 = new CorePoint();

            p1.X = Chart.Value3CoreLimit.Max;
            p1.Y = bubbleSeries.MaxBubbleDiameter;

            p2.X = Chart.Value3CoreLimit.Min;
            p2.Y = bubbleSeries.MinBubbleDiameter;

            var deltaX = p2.X - p1.X;
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            var m = (p2.Y - p1.Y) / (deltaX == 0 ? double.MinValue : deltaX);

            var uw = new CorePoint(
                    CurrentXAxis.EvaluatesUnitWidth
                        ? ChartFunctions.GetUnitWidth(AxisOrientation.X, Chart, View.ScalesXAt) / 2
                        : 0,
                    CurrentYAxis.EvaluatesUnitWidth
                        ? ChartFunctions.GetUnitWidth(AxisOrientation.Y, Chart, View.ScalesYAt) / 2
                        : 0);

            foreach (var chartPoint in View.ActualValues.Points)
            {
                chartPoint.ChartLocation = ChartFunctions.ToDrawMargin(
                    chartPoint, View.ScalesXAt, View.ScalesYAt, Chart) + uw;

                chartPoint.SeriesView = View;

                chartPoint.View = View.GetPointView(chartPoint.View, chartPoint,
                    View.DataLabels ? View.LabelPoint(chartPoint) : null);

                var bubbleView = (IBubblePointView) chartPoint.View;

                bubbleView.Diameter = m*(chartPoint.Weight - p1.X) + p1.Y;

                chartPoint.View.DrawOrMove(null, chartPoint, 0, Chart);
            }
        }
コード例 #5
0
ファイル: Chart.cs プロジェクト: beto-rodriguez/Live-Charts
        /// <summary>
        /// Shows the legend.
        /// </summary>
        /// <param name="at">At.</param>
        public void ShowLegend(CorePoint at)
        {
            if (ChartLegend == null) return;

            if (ChartLegend.Parent == null)
            {
                AddToView(ChartLegend);
                Canvas.SetLeft(ChartLegend, 0d);
                Canvas.SetTop(ChartLegend, 0d);
            }

            ChartLegend.Visibility = Visibility.Visible;

            Canvas.SetLeft(ChartLegend, at.X);
            Canvas.SetTop(ChartLegend, at.Y);
        }
コード例 #6
0
ファイル: Chart.cs プロジェクト: beto-rodriguez/Live-Charts
        private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
        {
            if (Zoom == ZoomingOptions.None) return;

            var p = e.GetCurrentPoint(this);

            var corePoint = new CorePoint(p.Position.X, p.Position.Y);

            e.Handled = true;

            if (p.Properties.MouseWheelDelta > 0)
                Model.ZoomIn(corePoint);
            else
                Model.ZoomOut(corePoint);
        }
コード例 #7
0
        /// <summary>
        /// Starts the segment.
        /// </summary>
        /// <param name="atIndex">At index.</param>
        /// <param name="location">The location.</param>
        public virtual void StartSegment(int atIndex, CorePoint location)
        {
            if (Splitters.Count <= ActiveSplitters)
                Splitters.Add(new LineSegmentSplitter {IsNew = true});

            var splitter = Splitters[ActiveSplitters];
            splitter.SplitterCollectorIndex = SplittersCollector;

            ActiveSplitters++;
            var animSpeed = Model.Chart.View.AnimationsSpeed;
            var noAnim = Model.Chart.View.DisableAnimations;

            if (atIndex != 0)
            {
                Figure.Segments.Remove(splitter.Bottom);

                if (splitter.IsNew)
                {
                    splitter.Bottom.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
                    splitter.Left.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
                }

                if (noAnim)
                    splitter.Bottom.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
                else
                    splitter.Bottom.BeginAnimation(LineSegment.PointProperty,
                        new PointAnimation(new Point(location.X, Model.Chart.DrawMargin.Height), animSpeed));
                Figure.Segments.Insert(atIndex, splitter.Bottom);

                Figure.Segments.Remove(splitter.Left);
                if (noAnim)
                    splitter.Left.Point = location.AsPoint();
                else
                    splitter.Left.BeginAnimation(LineSegment.PointProperty,
                        new PointAnimation(location.AsPoint(), animSpeed));
                Figure.Segments.Insert(atIndex + 1, splitter.Left);

                return;
            }

            if (splitter.IsNew)
            {
                splitter.Bottom.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
                splitter.Left.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
            }

            Figure.Segments.Remove(splitter.Left);
            if (Model.Chart.View.DisableAnimations)
                splitter.Left.Point = location.AsPoint();
            else
                splitter.Left.BeginAnimation(LineSegment.PointProperty,
                    new PointAnimation(location.AsPoint(), animSpeed));
            Figure.Segments.Insert(atIndex, splitter.Left);
        }
コード例 #8
0
ファイル: Chart.cs プロジェクト: beto-rodriguez/Live-Charts
        private void MouseWheelOnRoll(object sender, MouseWheelEventArgs e)
        {
            if (Zoom == ZoomingOptions.None) return;

            var p = e.GetPosition(this);

            var corePoint = new CorePoint(p.X, p.Y);

            e.Handled = true;

            if (e.Delta > 0)
                Model.ZoomIn(corePoint);
            else
                Model.ZoomOut(corePoint);
        }
コード例 #9
0
        /// <summary>
        /// Adds the or move.
        /// </summary>
        /// <param name="chart">The chart.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// </exception>
        public void AddOrMove(ChartCore chart)
        {
            if (chart == null || UIElement == null) return;
            if (!chart.AreComponentsLoaded) return;

            if (UIElement.Parent == null)
            {
                chart.View.AddToDrawMargin(UIElement);
                Panel.SetZIndex(UIElement, 1000);
            }

            var coordinate = new CorePoint(ChartFunctions.ToDrawMargin(X, AxisOrientation.X, chart, AxisX),
                ChartFunctions.ToDrawMargin(Y, AxisOrientation.Y, chart.View.Model, AxisY));

            var wpfChart = (CartesianChart) chart.View;

            var uw = new CorePoint(
                wpfChart.AxisX[AxisX].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart, AxisX)/2
                    : 0,
                wpfChart.AxisY[AxisY].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.Y, chart, AxisY)/2
                    : 0);

            coordinate += uw;

            UIElement.UpdateLayout();

            switch (VerticalAlignment)
            {
                case VerticalAlignment.Top:
                    coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight);
                    break;
                case VerticalAlignment.Center:
                    coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight / 2);
                    break;
                case VerticalAlignment.Bottom:
                    coordinate = new CorePoint(coordinate.X, coordinate.Y);
                    break;
                case VerticalAlignment.Stretch:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            switch (HorizontalAlignment)
            {
                case HorizontalAlignment.Left:
                    coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth, coordinate.Y);
                    break;
                case HorizontalAlignment.Center:
                    coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth / 2, coordinate.Y);
                    break;
                case HorizontalAlignment.Right:
                    coordinate = new CorePoint(coordinate.X, coordinate.Y);
                    break;
                case HorizontalAlignment.Stretch:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            if (chart.View.DisableAnimations)
            {
                Canvas.SetLeft(UIElement, coordinate.X);
                Canvas.SetTop(UIElement, coordinate.Y);
            }
            else
            {
                if (double.IsNaN(Canvas.GetLeft(UIElement)))
                {
                    Canvas.SetLeft(UIElement, coordinate.X);
                    Canvas.SetTop(UIElement, coordinate.Y);
                }
                UIElement.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(coordinate.X, wpfChart.AnimationsSpeed));
                UIElement.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(coordinate.Y, wpfChart.AnimationsSpeed));
            }

            _owner = chart;
        }
コード例 #10
0
        public override void Update()
        {
            var points = View.ActualValues.Points.ToList();
            var segmentPosition = 0;

            var lineView = View as ILineSeriesView;
            if (lineView == null) return;

            var smoothness = lineView.LineSmoothness;
            smoothness = smoothness > 1 ? 1 : (smoothness < 0 ? 0 : smoothness);

            foreach (var segment in points.SplitEachNaN())
            {
                var p0 = segment.Count > 0
                    ? ChartFunctions.ToDrawMargin(segment[0], View.ScalesXAt, View.ScalesYAt, Chart)
                    : new CorePoint(0, 0);
                var p1 = segment.Count > 0
                    ? ChartFunctions.ToDrawMargin(segment[0], View.ScalesXAt, View.ScalesYAt, Chart)
                    : p0;
                var p2 = segment.Count > 1
                    ? ChartFunctions.ToDrawMargin(segment[1], View.ScalesXAt, View.ScalesYAt, Chart)
                    : p1;
                var p3 = segment.Count > 2
                    ? ChartFunctions.ToDrawMargin(segment[2], View.ScalesXAt, View.ScalesYAt, Chart)
                    : p2;

                var uw = new CorePoint(
                    CurrentXAxis.EvaluatesUnitWidth
                        ? ChartFunctions.GetUnitWidth(AxisOrientation.X, Chart, View.ScalesXAt)/2
                        : 0,
                    CurrentYAxis.EvaluatesUnitWidth
                        ? ChartFunctions.GetUnitWidth(AxisOrientation.Y, Chart, View.ScalesYAt)/2
                        : 0);

                if (SeriesOrientation == SeriesOrientation.Horizontal)
                {
                    p0 += uw;
                    p1 += uw;
                    p2 += uw;
                    p3 += uw;
                }
                else
                {
                    p0 = new CorePoint(p0.X + uw.X, p0.Y - uw.Y);
                    p1 = new CorePoint(p1.X + uw.X, p1.Y - uw.Y);
                    p2 = new CorePoint(p2.X + uw.X, p2.Y - uw.Y);
                    p3 = new CorePoint(p3.X + uw.X, p3.Y - uw.Y);
                }

                lineView.StartSegment(segmentPosition, p1);
                segmentPosition += segmentPosition == 0 ? 1 : 2;

                ChartPoint previousDrawn = null;

                for (var index = 0; index < segment.Count; index++)
                {
                    var chartPoint = segment[index];

                    chartPoint.ChartLocation = p1;

                    chartPoint.SeriesView = View;

                    var xc1 = (p0.X + p1.X)/2.0;
                    var yc1 = (p0.Y + p1.Y)/2.0;
                    var xc2 = (p1.X + p2.X)/2.0;
                    var yc2 = (p1.Y + p2.Y)/2.0;
                    var xc3 = (p2.X + p3.X)/2.0;
                    var yc3 = (p2.Y + p3.Y)/2.0;

                    var len1 = Math.Sqrt((p1.X - p0.X)*(p1.X - p0.X) + (p1.Y - p0.Y)*(p1.Y - p0.Y));
                    var len2 = Math.Sqrt((p2.X - p1.X)*(p2.X - p1.X) + (p2.Y - p1.Y)*(p2.Y - p1.Y));
                    var len3 = Math.Sqrt((p3.X - p2.X)*(p3.X - p2.X) + (p3.Y - p2.Y)*(p3.Y - p2.Y));

                    var k1 = len1/(len1 + len2);
                    var k2 = len2/(len2 + len3);

                    if (double.IsNaN(k1)) k1 = 0d;
                    if (double.IsNaN(k2)) k2 = 0d;

                    var xm1 = xc1 + (xc2 - xc1)*k1;
                    var ym1 = yc1 + (yc2 - yc1)*k1;
                    var xm2 = xc2 + (xc3 - xc2)*k2;
                    var ym2 = yc2 + (yc3 - yc2)*k2;

                    var c1X = xm1 + (xc2 - xm1)*smoothness + p1.X - xm1;
                    var c1Y = ym1 + (yc2 - ym1)*smoothness + p1.Y - ym1;
                    var c2X = xm2 + (xc2 - xm2)*smoothness + p2.X - xm2;
                    var c2Y = ym2 + (yc2 - ym2)*smoothness + p2.Y - ym2;

                    chartPoint.View = View.GetPointView(chartPoint.View, chartPoint,
                        View.DataLabels ? View.LabelPoint(chartPoint) : null);

                    var bezierView = chartPoint.View as IBezierPointView;
                    if (bezierView == null) continue;

                    bezierView.Data = index == segment.Count - 1
                        ? new BezierData(new CorePoint(p1.X, p1.Y))
                        : new BezierData
                        {
                            Point1 = index == 0 ? new CorePoint(p1.X, p1.Y) : new CorePoint(c1X, c1Y),
                            Point2 = new CorePoint(c2X, c2Y),
                            Point3 = new CorePoint(p2.X, p2.Y)
                        };

                    chartPoint.View.DrawOrMove(previousDrawn, chartPoint, segmentPosition, Chart);
                    segmentPosition++;

                    previousDrawn = chartPoint.View.IsNew
                        ? previousDrawn
                        : chartPoint;

                    p0 = new CorePoint(p1);
                    p1 = new CorePoint(p2);
                    p2 = new CorePoint(p3);
                    p3 = segment.Count > index + 3
                        ? ChartFunctions.ToDrawMargin(segment[index + 3], View.ScalesXAt, View.ScalesYAt, Chart)
                        : p2;

                    if (SeriesOrientation == SeriesOrientation.Horizontal)
                    {
                        p3 += uw;
                    }
                    else
                    {
                        p3 = new CorePoint(p3.X + uw.X, p3.Y - uw.Y);
                    }
                }
                lineView.EndSegment(segmentPosition, p1);
                segmentPosition++;
            }
        }
コード例 #11
0
        private static byte InterpolateColorComponent(byte fromComponent, byte toComponent,
            double fromOffset, double toOffset, double value)
        {
            var p1 = new CorePoint(fromOffset, fromComponent);
            var p2 = new CorePoint(toOffset, toComponent);

            var deltaX = p2.X - p1.X;
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            var m = (p2.Y - p1.Y) / (deltaX == 0 ? double.MinValue : deltaX);

            return (byte)(m * (value - p1.X) + p1.Y);
        }
コード例 #12
0
        /// <summary>
        /// Adds the or move.
        /// </summary>
        /// <param name="chart">The chart.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// </exception>
        public void AddOrMove(ChartCore chart)
        {
            if (chart?.AxisX == null || chart?.AxisY == null || UIElement == null) return;
            if (UIElement.Parent == null)
            {
                chart.View.AddToDrawMargin(UIElement);
                Canvas.SetZIndex(UIElement, 1000);
            }

            var coordinate = new CorePoint(ChartFunctions.ToDrawMargin(X, AxisOrientation.X, chart, AxisX),
                ChartFunctions.ToDrawMargin(Y, AxisOrientation.Y, chart, AxisY));

            var uwpChart = (CartesianChart) chart.View;

            var uw = new CorePoint(
                uwpChart.AxisX[AxisX].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart, AxisX)/2
                    : 0,
                uwpChart.AxisY[AxisY].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.Y, chart, AxisY)/2
                    : 0);

            coordinate += uw;

            UIElement.UpdateLayout();

            switch (VerticalAlignment)
            {
                case VerticalAlignment.Top:
                    coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight);
                    break;
                case VerticalAlignment.Center:
                    coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight / 2);
                    break;
                case VerticalAlignment.Bottom:
                    coordinate = new CorePoint(coordinate.X, coordinate.Y);
                    break;
                case VerticalAlignment.Stretch:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            switch (HorizontalAlignment)
            {
                case HorizontalAlignment.Left:
                    coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth, coordinate.Y);
                    break;
                case HorizontalAlignment.Center:
                    coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth / 2, coordinate.Y);
                    break;
                case HorizontalAlignment.Right:
                    coordinate = new CorePoint(coordinate.X, coordinate.Y);
                    break;
                case HorizontalAlignment.Stretch:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            if (chart.View.DisableAnimations)
            {
                Canvas.SetLeft(UIElement, coordinate.X);
                Canvas.SetTop(UIElement, coordinate.Y);
            }
            else
            {
                if (double.IsNaN(Canvas.GetLeft(UIElement)))
                {
                    Canvas.SetLeft(UIElement, coordinate.X);
                    Canvas.SetTop(UIElement, coordinate.Y);
                }

                var x = AnimationsHelper.CreateDouble(coordinate.X, uwpChart.AnimationsSpeed, "(Canvas.Left)");
                var y = AnimationsHelper.CreateDouble(coordinate.Y, uwpChart.AnimationsSpeed, "(Canvas.Top)");
                AnimationsHelper.CreateStoryBoardAndBegin(UIElement, x, y);
            }
            _owner = chart;
        }
コード例 #13
0
        /// <summary>
        /// Ends the segment.
        /// </summary>
        /// <param name="atIndex">At index.</param>
        /// <param name="location">The location.</param>
        public virtual void EndSegment(int atIndex, CorePoint location)
        {
            var splitter = Splitters[ActiveSplitters - 1];

            var animSpeed = Model.Chart.View.AnimationsSpeed;
            var noAnim = Model.Chart.View.DisableAnimations;

            var areaLimit = Model.Chart.DrawMargin.Height;
            if (!double.IsNaN(AreaLimit))
                areaLimit = ChartFunctions.ToDrawMargin(AreaLimit, AxisOrientation.Y, Model.Chart, ScalesYAt);
            var uw = Model.Chart.AxisX[ScalesXAt].EvaluatesUnitWidth
                ? ChartFunctions.GetUnitWidth(AxisOrientation.X, Model.Chart, ScalesXAt) / 2
                : 0;
            location.X -= uw;

            if (splitter.IsNew)
            {
                splitter.Right.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
            }

            Figure.Segments.Remove(splitter.Right);
            if (noAnim)
                splitter.Right.Point = new Point(location.X, areaLimit);
            else
                splitter.Right.BeginPointAnimation(nameof(LineSegment.Point), new Point(location.X, areaLimit), animSpeed);
            Figure.Segments.Insert(atIndex, splitter.Right);

            splitter.IsNew = false;
        }
コード例 #14
0
        /// <summary>
        /// Zooms the out.
        /// </summary>
        /// <param name="pivot">The pivot.</param>
        public void ZoomOut(CorePoint pivot)
        {
            View.HideTooltip();

            pivot = new CorePoint(
                ChartFunctions.FromPlotArea(pivot.X, AxisOrientation.X, this),
                ChartFunctions.FromPlotArea(pivot.Y, AxisOrientation.Y, this));

            var speed = View.ZoomingSpeed < 0.1 ? 0.1 : (View.ZoomingSpeed > 0.95 ? 0.95 : View.ZoomingSpeed);

            if (View.Zoom == ZoomingOptions.X || View.Zoom == ZoomingOptions.Xy)
            {
                foreach (var xi in AxisX)
                {
                    var max = double.IsNaN(xi.MaxValue) ? xi.TopLimit : xi.MaxValue;
                    var min = double.IsNaN(xi.MinValue) ? xi.BotLimit : xi.MinValue;
                    var l = max - min;
                    var rMin = (pivot.X - min) / l;
                    var rMax = 1 - rMin;

                    var target = l*(1/speed);
                    if (target > xi.View.MaxRange) return;
                    var mint = pivot.X - target * rMin;
                    var maxt = pivot.X + target * rMax;
                    xi.View.SetRange(mint, maxt);
                }
            }

            if (View.Zoom == ZoomingOptions.Y || View.Zoom == ZoomingOptions.Xy)
            {
                foreach (var yi in AxisY)
                {
                    var max = double.IsNaN(yi.MaxValue) ? yi.TopLimit : yi.MaxValue;
                    var min = double.IsNaN(yi.MinValue) ? yi.BotLimit : yi.MinValue;
                    var l = max - min;
                    var rMin = (pivot.Y - min) / l;
                    var rMax = 1 - rMin;

                    var target = l * (1 / speed);
                    if (target > yi.View.MaxRange) return;
                    var mint = pivot.Y - target * rMin;
                    var maxt = pivot.Y + target * rMax;
                    yi.View.SetRange(mint, maxt);
                }
            }
        }
コード例 #15
0
        /// <summary>
        /// Places the legend.
        /// </summary>
        /// <param name="drawMargin">The draw margin.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentOutOfRangeException"></exception>
        public CoreRectangle PlaceLegend(CoreRectangle drawMargin)
        {
            var legendSize = View.LoadLegend();

            const int padding = 10;

            switch (View.LegendLocation)
            {
                case LegendLocation.None:
                    View.HideLegend();
                    break;
                case LegendLocation.Top:
                    drawMargin.Top += legendSize.Height;
                    drawMargin.Height -= legendSize.Height;
                    View.ShowLegend(new CorePoint(ControlSize.Width * .5 - legendSize.Width * .5, 0));
                    break;
                case LegendLocation.Bottom:
                    var bot = new CorePoint(ControlSize.Width*.5 - legendSize.Width*.5,
                        ControlSize.Height - legendSize.Height);
                    drawMargin.Height -= legendSize.Height;
                    View.ShowLegend(new CorePoint(bot.X, ControlSize.Height - legendSize.Height));
                    break;
                case LegendLocation.Left:
                    drawMargin.Left = drawMargin.Left + legendSize.Width;
                    View.ShowLegend(new CorePoint(0, ControlSize.Height*.5 - legendSize.Height*.5));
                    break;
                case LegendLocation.Right:
                    drawMargin.Width -= legendSize.Width + padding;
                    View.ShowLegend(new CorePoint(ControlSize.Width - legendSize.Width,
                        ControlSize.Height*.5 - legendSize.Height*.5));
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return drawMargin;
        }
コード例 #16
0
        /// <summary>
        /// Drags the specified delta.
        /// </summary>
        /// <param name="delta">The delta.</param>
        public void Drag(CorePoint delta)
        {
            if (View.Zoom == ZoomingOptions.None) return;

            if (View.Zoom == ZoomingOptions.X || View.Zoom == ZoomingOptions.Xy)
            {
                foreach (var xi in AxisX)
                {
                    xi.View.SetRange((double.IsNaN(xi.MinValue) ? xi.BotLimit : xi.MinValue) + delta.X,
                        (double.IsNaN(xi.MaxValue) ? xi.TopLimit : xi.MaxValue) + delta.X);
                }
            }

            if (View.Zoom == ZoomingOptions.Y || View.Zoom == ZoomingOptions.Xy)
            {
                foreach (var yi in AxisY)
                {
                    yi.View.SetRange((double.IsNaN(yi.MinValue) ? yi.BotLimit : yi.MinValue) + delta.Y,
                        (double.IsNaN(yi.MaxValue) ? yi.TopLimit : yi.MaxValue) + delta.Y);
                }
            }
        }