Ejemplo n.º 1
0
        /// <summary>
        /// Converts from chart values to chart control size.
        /// </summary>
        /// <param name="value">value to scale</param>
        /// <param name="source">axis orientation to scale value at</param>
        /// <param name="chart">chart model to scale value at</param>
        /// <param name="axis">axis model instance</param>
        /// <returns></returns>
        public static double ToPlotArea(double value, AxisOrientation source, ChartCore chart, AxisCore axis)
        {
            var p1 = new CorePoint();
            var p2 = new CorePoint();

            if (source == AxisOrientation.Y)
            {
                p1.X = axis.TopLimit;
                p1.Y = chart.DrawMargin.Top;

                p2.X = axis.BotLimit;
                p2.Y = chart.DrawMargin.Top + chart.DrawMargin.Height;
            }
            else
            {
                p1.X = axis.TopLimit;
                p1.Y = chart.DrawMargin.Width + chart.DrawMargin.Left;

                p2.X = axis.BotLimit;
                p2.Y = chart.DrawMargin.Left;
            }

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

            return(m * (value - p1.X) + p1.Y);
        }
Ejemplo n.º 2
0
        public double FromPreviousAxisState(double value, AxisTags source, ChartCore chart)
        {
            if (LastAxisMax == null)
            {
                return(0);
            }

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

            if (source == AxisTags.Y)
            {
                p1.X = LastAxisMax ?? 0;
                p1.Y = LastPlotArea.Top;

                p2.X = LastAxisMin ?? 0;
                p2.Y = LastPlotArea.Top + LastPlotArea.Height;
            }
            else
            {
                p1.X = LastAxisMax ?? 0;
                p1.Y = LastPlotArea.Width + LastPlotArea.Left;

                p2.X = LastAxisMin ?? 0;
                p2.Y = LastPlotArea.Left;
            }

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

            return(d);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts from chart control size to chart values.
        /// </summary>
        /// <param name="value">value to scale</param>
        /// <param name="source">axis orientation to scale value at</param>
        /// <param name="chart">chart model to scale value at</param>
        /// <param name="axis">axis index in collection of chart.axis</param>
        /// <returns></returns>
        public static double FromPlotArea(double value, AxisOrientation source, ChartCore chart, int axis = 0)
        {
            var p1 = new CorePoint();
            var p2 = new CorePoint();

            if (source == AxisOrientation.Y)
            {
                p1.X = chart.AxisY[axis].MaxLimit;
                p1.Y = chart.DrawMargin.Top;

                p2.X = chart.AxisY[axis].MinLimit;
                p2.Y = chart.DrawMargin.Top + chart.DrawMargin.Height;
            }
            else
            {
                p1.X = chart.AxisX[axis].MaxLimit;
                p1.Y = chart.DrawMargin.Width + chart.DrawMargin.Left;

                p2.X = chart.AxisX[axis].MinLimit;
                p2.Y = chart.DrawMargin.Left;
            }

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

            return((value + m * p1.X - p1.Y) / m);
        }
Ejemplo n.º 4
0
        internal double FromPreviousState(double value, AxisTags source, ChartCore chart)
        {
            if (LastAxisMax == null) return 0;

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

            if (source == AxisTags.Y)
            {
                p1.X = LastAxisMax ?? 0;
                p1.Y = LastPlotArea.Top;

                p2.X = LastAxisMin ?? 0;
                p2.Y = LastPlotArea.Top + LastPlotArea.Height;
            }
            else
            {
                p1.X = LastAxisMax ?? 0;
                p1.Y = LastPlotArea.Width + LastPlotArea.Left;

                p2.X = LastAxisMin ?? 0;
                p2.Y = LastPlotArea.Left;
            }

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

            return d;
        }
Ejemplo n.º 5
0
 public CorePoint(CorePoint point) : this()
 {
     X = point.X;
     Y = point.Y;
 }
Ejemplo n.º 6
0
 public BezierData(CorePoint point)
 {
     Point1 = point;
     Point2 = point;
     Point3 = point;
 }
Ejemplo n.º 7
0
 public static CorePoint ToPlotArea(CorePoint point, ChartCore chart, int axis = 0)
 {
     return(new CorePoint(
                ToPlotArea(point.X, AxisTags.X, chart, axis),
                ToPlotArea(point.Y, AxisTags.Y, chart, axis)));
 }
Ejemplo n.º 8
0
 public BezierData(CorePoint point)
 {
     Point1 = point;
     Point2 = point;
     Point3 = point;
 }
Ejemplo n.º 9
0
 public CorePoint(CorePoint point)
     : this()
 {
     X = point.X;
     Y = point.Y;
 }