Exemplo n.º 1
0
        private void InsertVerticalPoint(ChartTransform.ChartCartesianTransformer cartesianTransformer, int index,
                                         IList <double> values)
        {
            bool   bullBearFlag  = false;
            double highValues    = yHiChartVals[index];
            double lowValues     = yLoChartVals[index];
            var    alignedValues = AlignHiLoSegment(yOpenChartVals[index], yCloseChartVals[index], highValues, lowValues);

            highValues = alignedValues[0];
            lowValues  = alignedValues[1];
            Point hiPoint, loPoint, startopenpoint, startclosepoint, endopenpoint, endclosepoint;

            GetPoints(cartesianTransformer, index, out hiPoint, out loPoint, out startopenpoint,
                      out endopenpoint, out startclosepoint, out endclosepoint, highValues, lowValues);
            xValues.Insert(0, ((float)hiPoint.Y));
            yHiValues.Insert(0, (float)hiPoint.X);
            yLoValues.Insert(0, (float)loPoint.X);
            yOpenStartValues.Insert(0, (float)startopenpoint.X);
            yOpenEndValues.Insert(0, (float)endopenpoint.Y);
            yCloseValues.Insert(0, (float)endclosepoint.X);
            yCloseEndValues.Insert(0, (float)endclosepoint.Y);
            if (index == 0 || (Series as FastHiLoOpenCloseBitmapSeries).ComparisonMode == FinancialPrice.None)
            {
                bullBearFlag = yOpenChartVals[index] <= yCloseChartVals[index];
            }
            else
            {
                bullBearFlag = values[index] >= values[index - 1];
            }
            isBull.Insert(0, bullBearFlag);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Updates the segments based on its data point value. This method is not
 /// intended to be called explicitly outside the Chart but it can be overridden by
 /// any derived class.
 /// </summary>
 /// <param name="transformer">Represents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>
 public override void Update(IChartTransformer transformer)
 {
     if (transformer != null)
     {
         ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
         double xStart         = cartesianTransformer.XAxis.VisibleRange.Start;
         double xEnd           = cartesianTransformer.XAxis.VisibleRange.End;
         double xBase          = cartesianTransformer.XAxis.IsLogarithmic ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase : 1;
         bool   xIsLogarithmic = cartesianTransformer.XAxis.IsLogarithmic;
         double edgeValue      = xIsLogarithmic ? Math.Log(xVal, xBase) : xVal;
         if (edgeValue >= xStart && edgeValue <= xEnd && ((!double.IsNaN(highValue) && !double.IsNaN(lowValue)) || Series.ShowEmptyPoints))
         {
             Point hipoint = transformer.TransformToVisible(xVal, highValue);
             Point lopoint = transformer.TransformToVisible(xVal, lowValue);
             segLine.X1 = hipoint.X;
             segLine.Y1 = hipoint.Y;
             segLine.X2 = lopoint.X;
             segLine.Y2 = lopoint.Y;
         }
         else
         {
             segLine.ClearUIValues();
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Updates the segments based on its data point value. This method is not
 /// intended to be called explicitly outside the Chart but it can be overriden by
 /// any derived class.
 /// </summary>
 /// <param name="transformer">Reresents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>
 public override void Update(IChartTransformer transformer)
 {
     bitmap = fastHiLoOpenCloseSeries.Area.GetFastRenderSurface();
     if (transformer != null && fastHiLoOpenCloseSeries.DataCount > 0)
     {
         ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
         xValues.Clear();
         yHiValues.Clear();
         yLoValues.Clear();
         yOpenStartValues.Clear();
         yOpenEndValues.Clear();
         yCloseValues.Clear();
         yCloseEndValues.Clear();
         isBull.Clear();
         x_isInversed = cartesianTransformer.XAxis.IsInversed;
         y_isInversed = cartesianTransformer.YAxis.IsInversed;
         sbsInfo      = (fastHiLoOpenCloseSeries as ChartSeriesBase).GetSideBySideInfo(fastHiLoOpenCloseSeries as ChartSeriesBase);
         center       = sbsInfo.Median;
         Left         = sbsInfo.Start;
         Right        = sbsInfo.End;
         //Removed the screen point calculation methods and added the Transform to Visible method.
         CalculatePoint(cartesianTransformer);
         UpdateVisual(true);
     }
 }
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overridden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Represents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>
        public override void Update(IChartTransformer transformer)
        {
            bitmap = fastCandleBitmapSeries.Area.GetFastRenderSurface();
            if (transformer != null && fastCandleBitmapSeries.DataCount > 0)
            {
                ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;

                count = (int)(Math.Ceiling(xEnd));
                count = (int)Math.Min(count, xChartVals.Count);

                x_isInversed = cartesianTransformer.XAxis.IsInversed;
                y_isInversed = cartesianTransformer.YAxis.IsInversed;
                xStart       = cartesianTransformer.XAxis.VisibleRange.Start;
                xEnd         = cartesianTransformer.XAxis.VisibleRange.End;
                yStart       = cartesianTransformer.YAxis.VisibleRange.Start;
                yEnd         = cartesianTransformer.YAxis.VisibleRange.End;
                if (fastCandleBitmapSeries.IsActualTransposed)
                {
                    ySize   = cartesianTransformer.YAxis.RenderedRect.Width;
                    xSize   = cartesianTransformer.XAxis.RenderedRect.Height;
                    yOffset = cartesianTransformer.YAxis.RenderedRect.Left - fastCandleBitmapSeries.Area.SeriesClipRect.Left;
                    xOffset = cartesianTransformer.XAxis.RenderedRect.Top - fastCandleBitmapSeries.Area.SeriesClipRect.Top;
                }
                else
                {
                    ySize   = cartesianTransformer.YAxis.RenderedRect.Height;
                    xSize   = cartesianTransformer.XAxis.RenderedRect.Width;
                    yOffset = cartesianTransformer.YAxis.RenderedRect.Top - fastCandleBitmapSeries.Area.SeriesClipRect.Top;
                    xOffset = cartesianTransformer.XAxis.RenderedRect.Left - fastCandleBitmapSeries.Area.SeriesClipRect.Left;
                }

                if (x_isInversed)
                {
                    double temp = xStart;
                    xStart = xEnd;
                    xEnd   = temp;
                }

                if (y_isInversed)
                {
                    double temp = yStart;
                    yStart = yEnd;
                    yEnd   = temp;
                }
                isHollow.Clear();
                isBull.Clear();
                xValues.Clear();
                x1Values.Clear();
                x2Values.Clear();
                openValue.Clear();
                closeValue.Clear();
                highValue.Clear();
                highValue1.Clear();
                lowValue.Clear();
                lowValue1.Clear();
                //Removed the screen point calculation methods and added the point to value method.
                CalculatePoints(cartesianTransformer);
                UpdateVisual();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overridden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Represents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>
        public override void Update(IChartTransformer transformer)
        {
            bitmap = fastBarSeries.Area.GetFastRenderSurface();
            if (transformer != null && fastBarSeries.DataCount != 0)
            {
                ChartTransform.ChartCartesianTransformer cartesianTransformer =
                    transformer as ChartTransform.ChartCartesianTransformer;
                bool isLogarithmic = cartesianTransformer.XAxis.IsLogarithmic ||
                                     cartesianTransformer.YAxis.IsLogarithmic;
                x_isInversed = cartesianTransformer.XAxis.IsInversed;
                y_isInversed = cartesianTransformer.YAxis.IsInversed;

                xStart = cartesianTransformer.XAxis.VisibleRange.Start;
                xEnd   = cartesianTransformer.XAxis.VisibleRange.End;

                yStart = cartesianTransformer.YAxis.VisibleRange.Start;
                yEnd   = cartesianTransformer.YAxis.VisibleRange.End;


                width  = cartesianTransformer.XAxis.RenderedRect.Height;
                height = cartesianTransformer.YAxis.RenderedRect.Width;

                // WPF-14441 - Calculating Bar Position for the Series
                left = fastBarSeries.Area.SeriesClipRect.Right - cartesianTransformer.YAxis.RenderedRect.Right;
                top  = fastBarSeries.Area.SeriesClipRect.Bottom - cartesianTransformer.XAxis.RenderedRect.Bottom;

                availableSize = new Size(width, height);
                if (x_isInversed)
                {
                    double temp = xStart;
                    xStart = xEnd;
                    xEnd   = temp;
                }

                if (y_isInversed)
                {
                    double temp = yStart;
                    yStart = yEnd;
                    yEnd   = temp;
                }

                x1Values.Clear();
                x2Values.Clear();
                y1Values.Clear();
                y2Values.Clear();
                //Removed the screen point calculation methods and added the point to value method.
                if (!isLogarithmic)
                {
                    CalculatePoints(cartesianTransformer);
                }
                else
                {
                    CalculateLogPoints(cartesianTransformer);
                }
                UpdateVisual();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overriden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Reresents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>

        public override void Update(IChartTransformer transformer)
        {
            if (transformer != null)
            {
                if (isSegmentUpdated)
                {
                    Series.SeriesRootPanel.Clip = null;
                }
                ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
                double xBase          = cartesianTransformer.XAxis.IsLogarithmic ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase : 1;
                bool   xIsLogarithmic = cartesianTransformer.XAxis.IsLogarithmic;
                double xStart         = cartesianTransformer.XAxis.VisibleRange.Start;
                double xEnd           = cartesianTransformer.XAxis.VisibleRange.End;
                double left           = xIsLogarithmic ? Math.Log(Point1.X, xBase) : Point1.X;
                double right          = xIsLogarithmic ? Math.Log(Point4.X, xBase) : Point4.X;

                if ((left <= xEnd && right >= xStart))
                {
                    PathFigure    figure      = new PathFigure();
                    BezierSegment bezierSeg   = new BezierSegment();
                    PathGeometry  segGeometry = new PathGeometry();

                    P1 = figure.StartPoint = transformer.TransformToVisible(Point1.X, Point1.Y);
                    Q1 = bezierSeg.Point1 = transformer.TransformToVisible(Point2.X, Point2.Y);
                    Q2 = bezierSeg.Point2 = transformer.TransformToVisible(Point3.X, Point3.Y);
                    P2 = bezierSeg.Point3 = transformer.TransformToVisible(Point4.X, Point4.Y);
                    figure.Segments.Add(bezierSeg);
                    segGeometry.Figures = new PathFigureCollection()
                    {
                        figure
                    };

                    var path = this.segPath;
                    if (path != null)
                    {
                        path.Data = segGeometry;
                    }
                    else
                    {
                        Data = segGeometry;
                    }
                }
                else
                {
                    if (segPath != null)
                    {
                        this.segPath.Data = null;
                    }
                    else if (Data != null)
                    {
                        Data = null;
                    }
                }
                isSegmentUpdated = true;
            }
        }
Exemplo n.º 7
0
        private void InsertDataPoint(ChartTransform.ChartCartesianTransformer cartesianTransformer, int index)
        {
            double x1Val = 0, x2Val = 0, y2Val = 0, y1Val = 0;

            GetPoints(index, out x1Val, out x2Val, out y1Val, out y2Val);
            x1Values.Insert(0, (float)(top + availableSize.Width * cartesianTransformer.XAxis.ValueToCoefficientCalc(x1Val)));
            x2Values.Insert(0, (float)(top + availableSize.Width * cartesianTransformer.XAxis.ValueToCoefficientCalc(x2Val)));
            y1Values.Insert(0, (float)(left + availableSize.Height * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y1Val))));
            y2Values.Insert(0, (float)(left + availableSize.Height * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y2Val))));
        }
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overridden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Represents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>
        public override void Update(IChartTransformer transformer)
        {
            bitmap = fastRangeAreaBitmapSeries.Area.GetFastRenderSurface();
            if (transformer != null && fastRangeAreaBitmapSeries.DataCount > 0)
            {
                ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;

                // Removed the screen point calculation methods and added the point to value method.
                CalculatePoints(cartesianTransformer);
                UpdateVisual();
            }
        }
 /// <summary>
 /// Updates the segments based on its data point value. This method is not
 /// intended to be called explicitly outside the Chart but it can be overriden by
 /// any derived class.
 /// </summary>
 /// <param name="transformer"></param>
 public override void Update(IChartTransformer transformer)
 {
     bitmap = fastSeries.Area.GetFastRenderSurface();
     if (transformer != null && fastSeries.DataCount > 0)
     {
         ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
         xValues.Clear();
         yValues.Clear(); //WPF-14440 In seconday axis scrolling not apply for FastStepLineBitmapSeries
         //Removed the existing screen point calculation methods and added the TransformVisible method.
         CalculatePoints(cartesianTransformer);
         UpdateVisual();
     }
 }
Exemplo n.º 10
0
        private void CalculatePonts(ChartTransform.ChartCartesianTransformer cartesianTransformer)
        {
            int cnt = xChartVals.Count - 1;

            Points = new PointCollection();
            for (int i = 0; i <= cnt; i++)
            {
                double xVal  = xChartVals[i];
                double yVal  = yChartVals[i];
                Point  point = cartesianTransformer.TransformToVisible(xVal, yVal);
                Points.Add(point);
            }
        }
Exemplo n.º 11
0
        private void InsertDataPoint(ChartTransform.ChartCartesianTransformer cartesianTransformer, int index)
        {
            double x1Val = 0, x2Val = 0, y2Val = 0, y1Val = 0;

            GetXYPoints(index, out x1Val, out x2Val, out y1Val, out y2Val);
            Point tlpoint = cartesianTransformer.TransformToVisible(x1Val, y1Val);
            Point rbpoint = cartesianTransformer.TransformToVisible(x2Val, y2Val);

            x1Values.Insert(0, ((float)tlpoint.X));
            x2Values.Insert(0, ((float)rbpoint.X));
            y1Values.Insert(0, ((float)tlpoint.Y));
            y2Values.Insert(0, ((float)rbpoint.Y));
            actualIndexes.Insert(0, index);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Transforms for non logarithmic axis
        /// </summary>
        /// <param name="cartesianTransformer"></param>
        void TransformToScreenCoInLog(ChartTransform.ChartCartesianTransformer cartesianTransformer)
        {
            double xBase = cartesianTransformer.XAxis.IsLogarithmic ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase : 1;
            double yBase = cartesianTransformer.YAxis.IsLogarithmic ? (cartesianTransformer.YAxis as LogarithmicAxis).LogarithmicBase : 1;

            if (!fastSeries.IsActualTransposed)
            {
                TransformToScreenCoInLogHorizontal(xBase, yBase);
            }
            else
            {
                TransformToScreenCoInLogVertical(xBase, yBase);
            }
        }
Exemplo n.º 13
0
 private void GetHiLoPoints(ChartTransform.ChartCartesianTransformer cartesianTransformer, int index,
                            out Point hipoint, out Point lopoint)
 {
     if (fastHiloSeries.IsIndexed)
     {
         hipoint = cartesianTransformer.TransformToVisible(index, yHiChartVals[index]);
         lopoint = cartesianTransformer.TransformToVisible(index, yLoChartVals[index]);
     }
     else
     {
         hipoint = cartesianTransformer.TransformToVisible(xChartVals[index], yHiChartVals[index]);
         lopoint = cartesianTransformer.TransformToVisible(xChartVals[index], yLoChartVals[index]);
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Updates the segments based on its data point value. This method is not
 /// intended to be called explicitly outside the Chart but it can be overriden by
 /// any derived class.
 /// </summary>
 /// <param name="transformer">Reresents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>
 public override void Update(IChartTransformer transformer)
 {
     bitmap = fastHiloSeries.Area.GetFastRenderSurface();
     if (transformer != null && fastHiloSeries.DataCount > 0)
     {
         ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
         xValues.Clear();
         yHiValues.Clear();
         yLoValues.Clear();
         x_isInversed = cartesianTransformer.XAxis.IsInversed;
         y_isInversed = cartesianTransformer.YAxis.IsInversed;
         //Removed the screen point calculation methods and added the point to value method.
         CalculatePoints(cartesianTransformer);
         UpdateVisual(true);
     }
 }
        private void InsertDataPoint(ChartTransform.ChartCartesianTransformer cartesianTransformer, int index)
        {
            double xValue, yValue;

            GetXYValue(index, out xValue, out yValue);
            Point point = cartesianTransformer.TransformToVisible(xValue, yValue);

            if (!fastSeries.IsActualTransposed)
            {
                xValues.Insert(0, point.X);
                yValues.Insert(0, point.Y);
            }
            else
            {
                xValues.Insert(0, point.Y);
                yValues.Insert(0, point.X);
            }
        }
Exemplo n.º 16
0
        private void InsertDataPoint(ChartTransform.ChartCartesianTransformer cartesianTransformer, int index)
        {
            Point hipoint, lopoint;

            GetHiLoPoints(cartesianTransformer, index, out hipoint, out lopoint);
            if (!fastHiloSeries.IsActualTransposed)
            {
                xValues.Insert(0, (float)hipoint.X);
                yHiValues.Insert(0, (float)hipoint.Y);
                yLoValues.Insert(0, (float)lopoint.Y);
            }
            else
            {
                xValues.Insert(0, (float)hipoint.Y);
                yHiValues.Insert(0, (float)hipoint.X);
                yLoValues.Insert(0, (float)lopoint.X);
            }
        }
Exemplo n.º 17
0
        private void InsertDataPoint(ChartTransform.ChartCartesianTransformer cartesianTransformer,
                                     Thickness areaBorderThickness, int index)
        {
            double xValue, yValue;

            GetXYValue(index, out xValue, out yValue);
            Point point = cartesianTransformer.TransformToVisible(xValue, yValue);

            if (!fastSeries.IsTransposed)
            {
                xValues.Insert(0, (point.X - areaBorderThickness.Left));
                yValues.Insert(0, (point.Y - areaBorderThickness.Top));
            }
            else
            {
                xValues.Insert(0, (point.Y - areaBorderThickness.Left));
                yValues.Insert(0, (point.X - areaBorderThickness.Top));
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overriden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Reresents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>
        public override void Update(IChartTransformer transformer)
        {
            bitmap = fastColumnSeries.Area.GetFastRenderSurface();
            if (transformer != null && fastColumnSeries.DataCount != 0)
            {
                ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
                x_isInversed = cartesianTransformer.XAxis.IsInversed;
                y_isInversed = cartesianTransformer.YAxis.IsInversed;

                x1Values.Clear();
                x2Values.Clear();
                y1Values.Clear();
                y2Values.Clear();
                actualIndexes.Clear();
                //Removed the existing screen point calculation methods and added the TransformVisible method.
                CalculatePoints(cartesianTransformer);
                UpdateVisual(true);
            }
        }
Exemplo n.º 19
0
        private void CalculateLogPoints(ChartTransform.ChartCartesianTransformer cartesianTransformer)
        {
            double xBase = cartesianTransformer.XAxis.IsLogarithmic
                ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase
                : 1;
            double yBase = cartesianTransformer.YAxis.IsLogarithmic
                ? (cartesianTransformer.YAxis as LogarithmicAxis).LogarithmicBase
                : 1;
            float x1Value = 0, x2Value = 0, y1Value = 0, y2Value = 0;

            for (int i = 0; i < this.Series.DataCount; i++)
            {
                double logx1 = xBase == 1 ? x1ChartVals[i] : Math.Log(x1ChartVals[i], xBase);
                double logx2 = xBase == 1 ? x2ChartVals[i] : Math.Log(x2ChartVals[i], xBase);
                double logy1 = yBase == 1 ? y1ChartVals[i] : Math.Log(y1ChartVals[i], yBase);
                double logy2 = yBase == 1 ? y2ChartVals[i] : Math.Log(y2ChartVals[i], yBase);

                double x1Val = x_isInversed ? logx2 < xEnd ? xEnd : logx2 : logx1 < xStart ? xStart : logx1;
                double x2Val = x_isInversed ? logx1 > xStart ? xStart : logx1 : logx2 > xEnd ? xEnd : logx2;

                double y1Val = y_isInversed
                    ? logy2 > yStart ? yStart : logy2 <yEnd?yEnd : logy2
                                                       : logy1> yEnd ? yEnd : logy1 < yStart ? yStart : logy1;

                double y2Val = y_isInversed
                    ? logy1 <yEnd?yEnd : logy1> yStart ? yStart : logy1
                    : logy2 <yStart?yStart : logy2> yEnd ? yEnd : logy2;
                x1Value = (float)(top + (availableSize.Width) * cartesianTransformer.XAxis.ValueToCoefficientCalc(x1Val));
                x2Value = (float)(top + (availableSize.Width) * cartesianTransformer.XAxis.ValueToCoefficientCalc(x2Val));
                y1Value =
                    (float)
                    (left + (availableSize.Height) * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y1Val)));
                y2Value =
                    (float)
                    (left + (availableSize.Height) * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y2Val)));
                x1Values.Add(x1Value);
                x2Values.Add(x2Value);
                y1Values.Add(y1Value);
                y2Values.Add(y2Value);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overriden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Reresents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>

        public override void Update(IChartTransformer transformer)
        {
            if (transformer != null)
            {
                ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
                double xBase          = cartesianTransformer.XAxis.IsLogarithmic ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase : 1;
                bool   xIsLogarithmic = cartesianTransformer.XAxis.IsLogarithmic;
                double xStart         = cartesianTransformer.XAxis.VisibleRange.Start;
                double xEnd           = cartesianTransformer.XAxis.VisibleRange.End;
                double pos            = xIsLogarithmic ? Math.Log(xPos, xBase) : xPos;

                if (pos >= xStart && pos <= xEnd && (!double.IsNaN(yPos) || Series.ShowEmptyPoints))
                {
                    Point point1 = transformer.TransformToVisible(xPos, yPos);

                    if (ellipseSegment != null)
                    {
                        ellipseSegment.Visibility = Visibility.Visible;
                        ellipseSegment.Height     = ellipseSegment.Width = 2 * this.segmentRadius;
                        ellipseSegment.SetValue(Canvas.LeftProperty, point1.X - this.segmentRadius);
                        ellipseSegment.SetValue(Canvas.TopProperty, point1.Y - this.segmentRadius);
                    }
                    else
                    {
                        control.Visibility = Visibility.Visible;
                        RectX = point1.X - this.segmentRadius;
                        RectY = point1.Y - this.segmentRadius;
                        Size  = SegmentRadius = 2 * this.segmentRadius;
                    }
                }
                else if (customTemplate == null)
                {
                    ellipseSegment.Visibility = Visibility.Collapsed;
                }
                else
                {
                    control.Visibility = Visibility.Collapsed;
                }
            }
        }
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overriden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Reresents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>

        public override void Update(IChartTransformer transformer)
        {
            if (Length == 0)
            {
                base.Update(transformer);
            }
            else
            if (transformer != null && fastSeries.DataCount > 1)
            {
                ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
                bool isLogarithmic = cartesianTransformer.XAxis.IsLogarithmic || cartesianTransformer.YAxis.IsLogarithmic;
                if (!isLogarithmic)
                {
                    TransformToScreenCo(cartesianTransformer);
                }
                else
                {
                    TransformToScreenCoInLog(cartesianTransformer);
                }

                UpdateVisual(true);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overridden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Represents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>
        public override void Update(IChartTransformer transformer)
        {
            if (transformer != null)
            {
                ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
                double xBase          = cartesianTransformer.XAxis.IsLogarithmic ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase : 1;
                bool   xIsLogarithmic = cartesianTransformer.XAxis.IsLogarithmic;
                double left           = xIsLogarithmic ? Math.Log(Left, xBase) : Left;
                double right          = xIsLogarithmic ? Math.Log(Right, xBase) : Right;
                double xStart         = Math.Floor(cartesianTransformer.XAxis.VisibleRange.Start);
                double xEnd           = Math.Ceiling(cartesianTransformer.XAxis.VisibleRange.End);

                if (!double.IsNaN(Top) && !double.IsNaN(Bottom) &&
                    (left <= xEnd && right >= xStart))
                {
                    //Calculate the rect for segment rendering.
                    rect = CalculateSegmentRect(transformer);
                    segmentCanvas.Visibility = Visibility.Visible;

                    if (WaterfallRectSegment != null)
                    {
                        WaterfallRectSegment.SetValue(Canvas.LeftProperty, rect.X);
                        WaterfallRectSegment.SetValue(Canvas.TopProperty, rect.Y);
                        WaterfallRectSegment.Visibility = Visibility.Visible;
                        Width  = WaterfallRectSegment.Width = rect.Width;
                        Height = WaterfallRectSegment.Height = rect.Height;

                        //set position for connector line.
                        UpdateConnectorLine(transformer);
                    }
                }
                else
                {
                    segmentCanvas.Visibility = Visibility.Collapsed;
                }
            }
        }
Exemplo n.º 23
0
 private void GetPoints(ChartTransform.ChartCartesianTransformer cartesianTransformer, int index,
                        out Point hiPoint, out Point loPoint, out Point startopenpoint,
                        out Point endopenpoint, out Point startclosepoint, out Point endclosepoint,
                        double highValues, double lowValues)
 {
     if (fastHiLoOpenCloseSeries.IsIndexed)
     {
         hiPoint         = cartesianTransformer.TransformToVisible(index + center, highValues);
         loPoint         = cartesianTransformer.TransformToVisible(xChartVals[index] + center, lowValues);
         startopenpoint  = cartesianTransformer.TransformToVisible(xChartVals[index] + center, yOpenChartVals[index]);
         endopenpoint    = cartesianTransformer.TransformToVisible(xChartVals[index] + Left, yOpenChartVals[index]);
         startclosepoint = cartesianTransformer.TransformToVisible(index + center, yCloseChartVals[index]);
         endclosepoint   = cartesianTransformer.TransformToVisible(index + Right, yCloseChartVals[index]);
     }
     else
     {
         hiPoint         = cartesianTransformer.TransformToVisible(xChartVals[index] + center, highValues);
         loPoint         = cartesianTransformer.TransformToVisible(xChartVals[index] + center, lowValues);
         startopenpoint  = cartesianTransformer.TransformToVisible(xChartVals[index] + center, yOpenChartVals[index]);
         endopenpoint    = cartesianTransformer.TransformToVisible(xChartVals[index] + Left, yOpenChartVals[index]);
         startclosepoint = cartesianTransformer.TransformToVisible(xChartVals[index] + center, yCloseChartVals[index]);
         endclosepoint   = cartesianTransformer.TransformToVisible(xChartVals[index] + Right, yCloseChartVals[index]);
     }
 }
Exemplo n.º 24
0
        private void CalculatePoints(ChartTransform.ChartCartesianTransformer cartesianTransformer)
        {
            ChartAxis xAxis = cartesianTransformer.XAxis;

            if (this.Series.IsIndexed)
            {
                var isGrouping = (Series.ActualXAxis is CategoryAxis) &&
                                 (Series.ActualXAxis as CategoryAxis).IsIndexed;
                int start = 0, end = 0;
                if (!isGrouping)
                {
                    start = 0;
                    end   = x1ChartVals.Count - 1;
                }
                else
                {
                    start = (int)Math.Floor(xAxis.VisibleRange.Start);
                    end   = (int)Math.Ceiling(xAxis.VisibleRange.End);
                    end   = end > y1ChartVals.Count - 1 ? y1ChartVals.Count - 1 : end;
                }
                start = start < 0 ? 0 : start;
                for (int i = start; i <= end; i++)
                {
                    AddDataPoint(cartesianTransformer, i);
                }
                startIndex = start;
            }
            else if (this.Series.isLinearData)
            {
                double start = xAxis.VisibleRange.Start;
                double end   = xAxis.VisibleRange.End;
                int    i     = 0;
                int    count = x1ChartVals.Count - 1;
                startIndex = 0;
                for (i = 1; i < count; i++)
                {
                    double xValue = x1ChartVals[i];
                    if (xValue >= start && xValue <= end)
                    {
                        AddDataPoint(cartesianTransformer, i);
                    }
                    else if (xValue < start)
                    {
                        startIndex = i;
                    }
                    else if (xValue > end)
                    {
                        AddDataPoint(cartesianTransformer, i);
                        break;
                    }
                }
                InsertDataPoint(cartesianTransformer, startIndex);
                if (i == count)
                {
                    AddDataPoint(cartesianTransformer, count);
                }
            }
            else
            {
                startIndex = 0;
                for (int i = 0; i < this.Series.DataCount; i++)
                {
                    AddDataPoint(cartesianTransformer, i);
                }
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Updates the box and whisker segment based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overridden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Represents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>
        public override void Update(IChartTransformer transformer)
        {
            if (double.IsNaN(Minimum) && double.IsNaN(LowerQuartile) && double.IsNaN(Median) && double.IsNaN(UppperQuartile) && double.IsNaN(Maximum))
            {
                return;
            }

            ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
            double xStart         = Math.Floor(cartesianTransformer.XAxis.VisibleRange.Start);
            double xEnd           = Math.Ceiling(cartesianTransformer.XAxis.VisibleRange.End);
            double xBase          = cartesianTransformer.XAxis.IsLogarithmic ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase : 1;
            bool   xIsLogarithmic = cartesianTransformer.XAxis.IsLogarithmic;
            double left           = xIsLogarithmic ? Math.Log(Left, xBase) : Left;
            double right          = xIsLogarithmic ? Math.Log(Right, xBase) : Right;

            if ((left <= xEnd && right >= xStart))
            {
                lowerQuartileLine.Visibility = Visibility.Visible;
                upperQuartileLine.Visibility = Visibility.Visible;
                medianLine.Visibility        = Visibility.Visible;
                minimumLine.Visibility       = Visibility.Visible;
                maximumLine.Visibility       = Visibility.Visible;
                rectangle.Visibility         = Visibility.Visible;

                Point minimumPoint       = transformer.TransformToVisible(Center, Minimum);
                Point lowerQuartilePoint = transformer.TransformToVisible(Center, LowerQuartile);
                Point medianPoint        = transformer.TransformToVisible(Center, Median);
                Point upperQuartilePoint = transformer.TransformToVisible(Center, UppperQuartile);
                Point maximumPoint       = transformer.TransformToVisible(Center, Maximum);

                var tlPoint = transformer.TransformToVisible(Left, UppperQuartile);
                var brPoint = transformer.TransformToVisible(Right, LowerQuartile);

                double spacing = (Series as ISegmentSpacing).SegmentSpacing;
                rect = new Rect(tlPoint, brPoint);

                if (Series.IsActualTransposed)
                {
                    if (spacing > 0 && spacing <= 1)
                    {
                        rect.Y      = (Series as ISegmentSpacing).CalculateSegmentSpacing(spacing, rect.Bottom, rect.Top);
                        rect.Height = (1 - spacing) * rect.Height;
                    }

                    var percentHeight      = rect.Height / 2 * WhiskerWidth;
                    var centerLinePosition = rect.Y + rect.Height / 2;
                    var topPercentWidth    = centerLinePosition - percentHeight;
                    var bottomPercentWidth = centerLinePosition + percentHeight;

                    this.medianLine.X1 = medianPoint.X;
                    this.medianLine.X2 = medianPoint.X;
                    this.medianLine.Y1 = rect.Top;
                    this.medianLine.Y2 = rect.Bottom;

                    this.maximumLine.X1 = maximumPoint.X;
                    this.maximumLine.Y1 = topPercentWidth;
                    this.maximumLine.X2 = maximumPoint.X;
                    this.maximumLine.Y2 = bottomPercentWidth;

                    this.minimumLine.X1 = minimumPoint.X;
                    this.minimumLine.Y1 = topPercentWidth;
                    this.minimumLine.X2 = minimumPoint.X;
                    this.minimumLine.Y2 = bottomPercentWidth;
                }
                else
                {
                    if (spacing > 0 && spacing <= 1)
                    {
                        rect.X     = (Series as ISegmentSpacing).CalculateSegmentSpacing(spacing, rect.Right, rect.Left);
                        rect.Width = (1 - spacing) * rect.Width;
                    }

                    var percentWidth       = rect.Width / 2 * WhiskerWidth;
                    var centerLinePosition = rect.X + rect.Width / 2;
                    var leftPercentWidth   = centerLinePosition - percentWidth;
                    var rightPercentWidth  = centerLinePosition + percentWidth;

                    this.medianLine.X1 = rect.Left;
                    this.medianLine.X2 = rect.Right;
                    this.medianLine.Y1 = medianPoint.Y;
                    this.medianLine.Y2 = medianPoint.Y;

                    this.maximumLine.X1 = leftPercentWidth;
                    this.maximumLine.Y1 = maximumPoint.Y;
                    this.maximumLine.X2 = rightPercentWidth;
                    this.maximumLine.Y2 = maximumPoint.Y;

                    this.minimumLine.X1 = leftPercentWidth;
                    this.minimumLine.Y1 = minimumPoint.Y;
                    this.minimumLine.X2 = rightPercentWidth;
                    this.minimumLine.Y2 = minimumPoint.Y;
                }

                rectangle.Width  = rect.Width;
                rectangle.Height = rect.Height;
                rectangle.SetValue(Canvas.LeftProperty, rect.X);
                rectangle.SetValue(Canvas.TopProperty, rect.Y);

                this.lowerQuartileLine.X1 = minimumPoint.X;
                this.lowerQuartileLine.X2 = lowerQuartilePoint.X;
                this.lowerQuartileLine.Y1 = minimumPoint.Y;
                this.lowerQuartileLine.Y2 = lowerQuartilePoint.Y;

                this.upperQuartileLine.X1 = upperQuartilePoint.X;
                this.upperQuartileLine.X2 = maximumPoint.X;
                this.upperQuartileLine.Y1 = upperQuartilePoint.Y;
                this.upperQuartileLine.Y2 = maximumPoint.Y;

                UpdateMeanSymbol(cartesianTransformer, (Series as BoxAndWhiskerSeries).ShowMedian);
            }
            else
            {
                medianLine.Visibility        = Visibility.Collapsed;
                minimumLine.Visibility       = Visibility.Collapsed;
                maximumLine.Visibility       = Visibility.Collapsed;
                lowerQuartileLine.Visibility = Visibility.Collapsed;
                upperQuartileLine.Visibility = Visibility.Collapsed;
                rectangle.Visibility         = Visibility.Collapsed;
                averagePath.Visibility       = Visibility.Collapsed;
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overridden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Represents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>

        public override void Update(IChartTransformer transformer)
        {
            if (transformer != null)
            {
                ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
                double xBase          = cartesianTransformer.XAxis.IsLogarithmic ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase : 1;
                bool   xIsLogarithmic = cartesianTransformer.XAxis.IsLogarithmic;
                double left           = xIsLogarithmic ? Math.Log(Left, xBase) : Left;
                double right          = xIsLogarithmic ? Math.Log(Right, xBase) : Right;
                double xStart         = Math.Floor(cartesianTransformer.XAxis.VisibleRange.Start);
                double xEnd           = Math.Ceiling(cartesianTransformer.XAxis.VisibleRange.End);

                if (!double.IsNaN(Top) && !double.IsNaN(Bottom) &&
                    (left <= xEnd && right >= xStart) &&
                    (!double.IsNaN(YData) || Series.ShowEmptyPoints))
                {
                    double spacing = (Series is HistogramSeries) ? 0.0 : (Series as ISegmentSpacing).SegmentSpacing;
                    Point  tlpoint = transformer.TransformToVisible(Left, Top);
                    Point  rbpoint = transformer.TransformToVisible(Right, Bottom);
                    rect = new Rect(tlpoint, rbpoint);

                    if (spacing > 0.0 && spacing <= 1)
                    {
                        if (Series.IsActualTransposed == true)
                        {
                            double leftpos = (Series as ISegmentSpacing).CalculateSegmentSpacing(spacing,
                                                                                                 rect.Bottom, rect.Top);
                            rect.Y = leftpos;
                            Height = rect.Height = (1 - spacing) * rect.Height;
                        }

                        else
                        {
                            double leftpos = (Series as ISegmentSpacing).CalculateSegmentSpacing(spacing, rect.Right,
                                                                                                 rect.Left);
                            rect.X = leftpos;
                            Width  = rect.Width = (1 - spacing) * rect.Width;
                        }
                    }
                    if (RectSegment != null)
                    {
                        RectSegment.SetValue(Canvas.LeftProperty, rect.X);
                        RectSegment.SetValue(Canvas.TopProperty, rect.Y);
                        RectSegment.Visibility = Visibility.Visible;
                        Width  = RectSegment.Width = rect.Width;
                        Height = RectSegment.Height = rect.Height;
                    }
                    else
                    {
                        control.Visibility = Visibility.Visible;
                        RectX  = rect.X;
                        RectY  = rect.Y;
                        Width  = rect.Width;
                        Height = rect.Height;
                    }
                }
                else if (customTemplate == null)
                {
                    RectSegment.Visibility = Visibility.Collapsed;
                }
                else
                {
                    control.Visibility = Visibility.Collapsed;
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// This method used to gets the selected data point segment pixel positions
        /// </summary>
        internal void GenerateBarPixels()
        {
            WriteableBitmap bmp = Area.fastRenderSurface;

            ChartTransform.ChartCartesianTransformer cartesianTransformer = CreateTransformer(
                new Size(
                    Area.SeriesClipRect.Width,
                    Area.SeriesClipRect.Height),
                true) as ChartTransform.ChartCartesianTransformer;

            DoubleRange sbsInfo = this.GetSideBySideInfo(this);

            float x1Value = 0, x2Value = 0, y1Value = 0, y2Value = 0;

            double x1 = dataPoint.XData + sbsInfo.Start;
            double x2 = dataPoint.XData + sbsInfo.End;
            double y1 = dataPoint.YData;
            double y2 = ActualXAxis != null ? ActualXAxis.Origin : 0;

            double xStart = cartesianTransformer.XAxis.VisibleRange.Start;
            double xEnd   = cartesianTransformer.XAxis.VisibleRange.End;

            double yStart = cartesianTransformer.YAxis.VisibleRange.Start;
            double yEnd   = cartesianTransformer.YAxis.VisibleRange.End;

            double width  = cartesianTransformer.XAxis.RenderedRect.Height;
            double height = cartesianTransformer.YAxis.RenderedRect.Width;

            // WPF-14441 - Calculating Bar Position for the Series
            double left = Area.SeriesClipRect.Right - cartesianTransformer.YAxis.RenderedRect.Right;
            double top  = Area.SeriesClipRect.Bottom - cartesianTransformer.XAxis.RenderedRect.Bottom;

            Size availableSize = new Size(width, height);
            bool isLogarithmic = cartesianTransformer.XAxis.IsLogarithmic || cartesianTransformer.YAxis.IsLogarithmic;

            if (ActualXAxis.IsInversed)
            {
                double temp = xStart;
                xStart = xEnd;
                xEnd   = temp;
            }

            if (ActualYAxis.IsInversed)
            {
                double temp = yStart;
                yStart = yEnd;
                yEnd   = temp;
            }

            if (!isLogarithmic)
            {
                double x1Val = ActualXAxis.IsInversed
                          ? x2 < xEnd ? xEnd : x2
                          : x1 < xStart ? xStart : x1;
                double x2Val = ActualXAxis.IsInversed
                                   ? x1 > xStart ? xStart : x1
                                   : x2 > xEnd ? xEnd : x2;

                double y1Val = ActualYAxis.IsInversed
                                   ? y2 > yStart ? yStart : y2 <yEnd?yEnd : y2
                                                                : y1> yEnd ? yEnd : y1 < yStart ? yStart : y1;
                double y2Val = ActualYAxis.IsInversed
                                   ? y1 <yEnd?yEnd : y1> yStart ? yStart : y1
                                   : y2 <yStart?yStart : y2> yEnd ? yEnd : y2;
                x1Value = (float)(top + (availableSize.Width) * cartesianTransformer.XAxis.ValueToCoefficientCalc(x1Val));
                x2Value = (float)(top + (availableSize.Width) * cartesianTransformer.XAxis.ValueToCoefficientCalc(x2Val));
                y1Value = (float)(left + (availableSize.Height) * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y1Val)));
                y2Value = (float)(left + (availableSize.Height) * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y2Val)));
            }
            else
            {
                double xBase = cartesianTransformer.XAxis.IsLogarithmic ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase : 1;
                double yBase = cartesianTransformer.YAxis.IsLogarithmic ? (cartesianTransformer.YAxis as LogarithmicAxis).LogarithmicBase : 1;

                double logx1 = xBase == 1 ? x1 : Math.Log(x1, xBase);
                double logx2 = xBase == 1 ? x2 : Math.Log(x2, xBase);
                double logy1 = yBase == 1 ? y1 : Math.Log(y1, yBase);
                double logy2 = yBase == 1 ? y2 : Math.Log(y2, yBase);

                double x1Val = ActualXAxis.IsInversed ? logx2 < xEnd ? xEnd : logx2 : logx1 < xStart ? xStart : logx1;
                double x2Val = ActualXAxis.IsInversed ? logx1 > xStart ? xStart : logx1 : logx2 > xEnd ? xEnd : logx2;

                double y1Val = ActualYAxis.IsInversed
                                   ? logy2 > yStart ? yStart : logy2 <yEnd?yEnd : logy2
                                                                      : logy1> yEnd ? yEnd : logy1 < yStart ? yStart : logy1;

                double y2Val = ActualYAxis.IsInversed
                                   ? logy1 <yEnd?yEnd : logy1> yStart ? yStart : logy1
                                   : logy2 <yStart?yStart : logy2> yEnd ? yEnd : logy2;
                x1Value = (float)(top + (availableSize.Width) * cartesianTransformer.XAxis.ValueToCoefficientCalc(x1Val));
                x2Value = (float)(top + (availableSize.Width) * cartesianTransformer.XAxis.ValueToCoefficientCalc(x2Val));
                y1Value = (float)(left + (availableSize.Height) * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y1Val)));
                y2Value = (float)(left + (availableSize.Height) * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y2Val)));
            }

            double _x1 = x1Value;
            double _x2 = x2Value;
            double _y1 = y1 > 0 ? y1Value : y2Value;
            double _y2 = y1 > 0 ? y2Value : y1Value;

            var spacingSegment = this as ISegmentSpacing;

            if (spacingSegment != null)
            {
                double spacing = spacingSegment.SegmentSpacing;
                if (spacing > 0 && spacing <= 1)
                {
                    double leftpos  = spacingSegment.CalculateSegmentSpacing(spacing, _x2, _x1);
                    double rightpos = spacingSegment.CalculateSegmentSpacing(spacing, _x1, _x2);
                    _x1 = (float)(leftpos);
                    _x2 = (float)(rightpos);
                }
            }

            double diff = _x2 - _x1;

            width  = (int)Area.SeriesClipRect.Width;
            height = (int)Area.SeriesClipRect.Height;

            selectedSegmentPixels.Clear();

            if (_y1 < _y2)
            {
                selectedSegmentPixels = bmp.GetRectangle((int)width, (int)height, (int)(width - _y2), (int)(height - _x1 - diff), (int)(width - _y1), (int)(height - _x1), selectedSegmentPixels);
            }
            else
            {
                selectedSegmentPixels = bmp.GetRectangle((int)width, (int)height, (int)(width - y1), (int)(height - x1 - diff), (int)(width - y2), (int)(height - x1), selectedSegmentPixels);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overriden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Reresents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>

        public override void Update(IChartTransformer transformer)
        {
            ChartTransform.ChartCartesianTransformer cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer;
            double xStart         = Math.Floor(cartesianTransformer.XAxis.VisibleRange.Start);
            double xEnd           = Math.Ceiling(cartesianTransformer.XAxis.VisibleRange.End);
            double xBase          = cartesianTransformer.XAxis.IsLogarithmic ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase : 1;
            bool   xIsLogarithmic = cartesianTransformer.XAxis.IsLogarithmic;
            double left           = xIsLogarithmic ? Math.Log(cdpBottomLeft.X, xBase) : cdpBottomLeft.X;
            double right          = xIsLogarithmic ? Math.Log(cdpRightTop.X, xBase) : cdpRightTop.X;

            if ((left <= xEnd && right >= xStart) || Series.ShowEmptyPoints)
            {
                double spacing = (Series as ISegmentSpacing).SegmentSpacing;
                columnSegment.Visibility = Visibility.Visible;
                hiLoLine.Visibility      = Visibility.Visible;
                hiLoLine1.Visibility     = Visibility.Visible;
                openCloseLine.Visibility = Visibility.Visible;
                Point blpoint = transformer.TransformToVisible(cdpBottomLeft.X, cdpBottomLeft.Y);
                Point trpoint = transformer.TransformToVisible(cdpRightTop.X, cdpRightTop.Y);
                rect = new Rect(blpoint, trpoint);
                if (spacing > 0 && spacing <= 1)
                {
                    if (Series.IsActualTransposed)
                    {
                        rect.Y = (Series as ISegmentSpacing).CalculateSegmentSpacing(spacing, rect.Bottom, rect.Top);
                        columnSegment.Height = rect.Height = (1 - spacing) * rect.Height;
                    }
                    else
                    {
                        rect.X = (Series as ISegmentSpacing).CalculateSegmentSpacing(spacing, rect.Right, rect.Left);
                        columnSegment.Width = rect.Width = (1 - spacing) * rect.Width;
                    }
                }
                if (cdpBottomLeft.Y == cdpRightTop.Y)
                {
                    if (!double.IsNaN(cdpBottomLeft.Y) && !double.IsNaN(cdpRightTop.Y))
                    {
                        columnSegment.Visibility = Visibility.Collapsed;
                        this.openCloseLine.X1    = rect.Left;
                        this.openCloseLine.Y1    = rect.Top;
                        this.openCloseLine.X2    = rect.Right;
                        this.openCloseLine.Y2    = rect.Bottom;
                    }
                    else
                    {
                        openCloseLine.Visibility = Visibility.Collapsed;
                        openCloseLine.ClearUIValues();
                    }
                }
                else if (!double.IsNaN(cdpBottomLeft.Y) && !double.IsNaN(cdpRightTop.Y))
                {
                    openCloseLine.Visibility = Visibility.Collapsed;
                    columnSegment.SetValue(Canvas.LeftProperty, rect.X);
                    columnSegment.SetValue(Canvas.TopProperty, rect.Y);
                    columnSegment.Width  = rect.Width;
                    columnSegment.Height = rect.Height;
                }
                else
                {
                    columnSegment.Visibility = Visibility.Collapsed;
                    columnSegment.ClearUIValues();
                }
                Point point1 = transformer.TransformToVisible(this.hiPoint.X, this.hiPoint.Y);
                Point point2 = transformer.TransformToVisible(this.hiPoint1.X, this.hiPoint1.Y);
                Point point3 = transformer.TransformToVisible(this.loPoint.X, this.loPoint.Y);
                Point point4 = transformer.TransformToVisible(this.loPoint1.X, this.loPoint1.Y);
                if (!double.IsNaN(point1.Y) && !double.IsNaN(point2.Y) && !double.IsNaN(point1.X) && !double.IsNaN(point2.X) && !double.IsNaN(point3.Y) && !double.IsNaN(point4.Y) && !double.IsNaN(point3.X) && !double.IsNaN(point4.X))
                {
                    this.hiLoLine.X1  = point1.X;
                    this.hiLoLine.X2  = point2.X;
                    this.hiLoLine.Y1  = point1.Y;
                    this.hiLoLine.Y2  = point2.Y;
                    this.hiLoLine1.X1 = point3.X;
                    this.hiLoLine1.X2 = point4.X;
                    this.hiLoLine1.Y1 = point3.Y;
                    this.hiLoLine1.Y2 = point4.Y;
                    if (rect.Contains(point1))
                    {
                        this.hiLoLine.Visibility = Visibility.Collapsed;
                    }
                    if (rect.Contains(point3))
                    {
                        this.hiLoLine1.Visibility = Visibility.Collapsed;
                    }
                }
                else
                {
                    hiLoLine.Visibility = Visibility.Collapsed;
                    hiLoLine.ClearUIValues();
                    hiLoLine1.Visibility = Visibility.Collapsed;
                    hiLoLine1.ClearUIValues();
                }
            }
            else
            {
                columnSegment.ClearUIValues();
                hiLoLine.ClearUIValues();
                hiLoLine1.ClearUIValues();
                openCloseLine.ClearUIValues();
                columnSegment.Visibility = Visibility.Collapsed;
                hiLoLine.Visibility      = Visibility.Collapsed;
                hiLoLine1.Visibility     = Visibility.Collapsed;
                openCloseLine.Visibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// This method is used to gets the selected data point segment pixel positions
        /// </summary>
        internal void GenerateStackingBarPixels()
        {
            WriteableBitmap bmp = Area.fastRenderSurface;

            ChartTransform.ChartCartesianTransformer cartesianTransformer = CreateTransformer(
                new Size(
                    Area.SeriesClipRect.Width,
                    Area.SeriesClipRect.Height),
                true) as ChartTransform.ChartCartesianTransformer;

            bool isLogarithmic = cartesianTransformer.XAxis.IsLogarithmic || cartesianTransformer.YAxis.IsLogarithmic;
            bool x_isInversed  = cartesianTransformer.XAxis.IsInversed;
            bool y_isInversed  = cartesianTransformer.YAxis.IsInversed;

            double        x1ChartVal, x2ChartVal, y1ChartVal, y2ChartVal;
            double        xStart, xEnd, yStart, yEnd, width, height, left, top;
            int           i       = dataPoint.Index;
            DoubleRange   sbsInfo = this.GetSideBySideInfo(this);
            List <double> xValues = (ActualXValues is List <double>) ? ActualXValues as List <double> : GetXValues();

            if (!this.IsIndexed)
            {
                x1ChartVal = xValues[i] + sbsInfo.Start;
                x2ChartVal = xValues[i] + sbsInfo.End;
                y1ChartVal = YRangeEndValues[i];
                y2ChartVal = YRangeStartValues[i];
            }
            else
            {
                x1ChartVal = i + sbsInfo.Start;
                x2ChartVal = i + sbsInfo.End;
                y1ChartVal = YRangeEndValues[i];
                y2ChartVal = YRangeStartValues[i];
            }

            xStart = cartesianTransformer.XAxis.VisibleRange.Start;
            xEnd   = cartesianTransformer.XAxis.VisibleRange.End;

            yStart = cartesianTransformer.YAxis.VisibleRange.Start;
            yEnd   = cartesianTransformer.YAxis.VisibleRange.End;

            width  = cartesianTransformer.XAxis.RenderedRect.Height;
            height = cartesianTransformer.YAxis.RenderedRect.Width;

            // WPF-14441 - Calculating Bar Position for the Series
            left = Area.SeriesClipRect.Right - cartesianTransformer.YAxis.RenderedRect.Right;
            top  = Area.SeriesClipRect.Bottom - cartesianTransformer.XAxis.RenderedRect.Bottom;

            Size availableSize = new Size(width, height);

            if (x_isInversed)
            {
                double temp = xStart;
                xStart = xEnd;
                xEnd   = temp;
            }

            if (y_isInversed)
            {
                double temp = yStart;
                yStart = yEnd;
                yEnd   = temp;
            }

            float x1Value = 0, x2Value = 0, y1Value = 0, y2Value = 0;

            // Removed the screen point calculation methods and added the point to value method.
            if (!isLogarithmic)
            {
                double x1Val = x_isInversed
                                   ? x2ChartVal < xEnd ? xEnd : x2ChartVal
                                   : x1ChartVal < xStart ? xStart : x1ChartVal;
                double x2Val = x_isInversed
                                   ? x1ChartVal > xStart ? xStart : x1ChartVal
                                   : x2ChartVal > xEnd ? xEnd : x2ChartVal;

                double y1Val = y_isInversed
                                   ? y2ChartVal > yStart ? yStart : y2ChartVal <yEnd?yEnd : y2ChartVal
                                                                                : y1ChartVal> yEnd ? yEnd : y1ChartVal < yStart ? yStart : y1ChartVal;
                double y2Val = y_isInversed
                                   ? y1ChartVal <yEnd?yEnd : y1ChartVal> yStart ? yStart : y1ChartVal
                                   : y2ChartVal <yStart?yStart : y2ChartVal> yEnd ? yEnd : y2ChartVal;
                x1Value = (float)(top + (availableSize.Width) * cartesianTransformer.XAxis.ValueToCoefficientCalc(x1Val));
                x2Value = (float)(top + (availableSize.Width) * cartesianTransformer.XAxis.ValueToCoefficientCalc(x2Val));
                y1Value = (float)(left + (availableSize.Height) * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y1Val)));
                y2Value = (float)(left + (availableSize.Height) * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y2Val)));
            }
            else
            {
                double xBase = cartesianTransformer.XAxis.IsLogarithmic ? (cartesianTransformer.XAxis as LogarithmicAxis).LogarithmicBase : 1;
                double yBase = cartesianTransformer.YAxis.IsLogarithmic ? (cartesianTransformer.YAxis as LogarithmicAxis).LogarithmicBase : 1;

                double logx1 = xBase == 1 ? x1ChartVal : Math.Log(x1ChartVal, xBase);
                double logx2 = xBase == 1 ? x2ChartVal : Math.Log(x2ChartVal, xBase);
                double logy1 = yBase == 1 ? y1ChartVal : Math.Log(y1ChartVal, yBase);
                double logy2 = yBase == 1 ? y2ChartVal : Math.Log(y2ChartVal, yBase);

                double x1Val = x_isInversed ? logx2 < xEnd ? xEnd : logx2 : logx1 < xStart ? xStart : logx1;
                double x2Val = x_isInversed ? logx1 > xStart ? xStart : logx1 : logx2 > xEnd ? xEnd : logx2;

                double y1Val = y_isInversed
                                   ? logy2 > yStart ? yStart : logy2 <yEnd?yEnd : logy2
                                                                      : logy1> yEnd ? yEnd : logy1 < yStart ? yStart : logy1;

                double y2Val = y_isInversed
                                   ? logy1 <yEnd?yEnd : logy1> yStart ? yStart : logy1
                                   : logy2 <yStart?yStart : logy2> yEnd ? yEnd : logy2;
                x1Value = (float)(top + (availableSize.Width) * cartesianTransformer.XAxis.ValueToCoefficientCalc(x1Val));
                x2Value = (float)(top + (availableSize.Width) * cartesianTransformer.XAxis.ValueToCoefficientCalc(x2Val));
                y1Value = (float)(left + (availableSize.Height) * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y1Val)));
                y2Value = (float)(left + (availableSize.Height) * (1 - cartesianTransformer.YAxis.ValueToCoefficientCalc(y2Val)));
            }

            float x1 = 0, x2, y1, y2, diff = 0;

            width  = (int)Area.SeriesClipRect.Width;
            height = (int)Area.SeriesClipRect.Height;

            x1 = x1Value;
            x2 = x2Value;
            y1 = y1ChartVal > 0 ? y1Value : y2Value;
            y2 = y1ChartVal > 0 ? y2Value : y1Value;

            var spacingSegment = this as ISegmentSpacing;

            if (spacingSegment != null)
            {
                double spacing = spacingSegment.SegmentSpacing;
                if (spacing > 0 && spacing <= 1)
                {
                    double leftpos  = spacingSegment.CalculateSegmentSpacing(spacing, x1, x2);
                    double rightpos = spacingSegment.CalculateSegmentSpacing(spacing, x2, x1);
                    x2 = (float)leftpos;
                    x1 = (float)rightpos;
                }
            }

            diff = x2 - x1;

            selectedSegmentPixels.Clear();

            if (y1 < y2)
            {
                selectedSegmentPixels = bmp.GetRectangle(
                    (int)width,
                    (int)height,
                    (int)(width - y2),
                    (int)(height - x1 - diff),
                    (int)(width - y1),
                    (int)(height - x1),
                    selectedSegmentPixels);
            }
            else
            {
                selectedSegmentPixels = bmp.GetRectangle(
                    (int)width,
                    (int)height,
                    (int)(width - y1),
                    (int)(height - x1 - diff),
                    (int)(width - y2),
                    (int)(height - x1),
                    selectedSegmentPixels);
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// This method is used to gets the selected data point segment pixel positions
        /// </summary>
        internal void GenerateStackingColumnPixels()
        {
            WriteableBitmap bmp = Area.fastRenderSurface;

            ChartTransform.ChartCartesianTransformer cartesianTransformer = CreateTransformer(
                new Size(
                    Area.SeriesClipRect.Width,
                    Area.SeriesClipRect.Height),
                true) as ChartTransform.ChartCartesianTransformer;

            bool x_isInversed = cartesianTransformer.XAxis.IsInversed;
            bool y_isInversed = cartesianTransformer.YAxis.IsInversed;

            double        x1ChartVal, x2ChartVal, y1ChartVal, y2ChartVal;
            int           i       = dataPoint.Index;
            DoubleRange   sbsInfo = this.GetSideBySideInfo(this);
            List <double> xValues = (ActualXValues is List <double>) ? ActualXValues as List <double> : GetXValues();

            if (!this.IsIndexed)
            {
                x1ChartVal = xValues[i] + sbsInfo.Start;
                x2ChartVal = xValues[i] + sbsInfo.End;
                y1ChartVal = YRangeEndValues[i];
                y2ChartVal = YRangeStartValues[i];
            }
            else
            {
                x1ChartVal = i + sbsInfo.Start;
                x2ChartVal = i + sbsInfo.End;
                y1ChartVal = YRangeEndValues[i];
                y2ChartVal = YRangeStartValues[i];
            }

            double x1Val = x_isInversed
                                  ? x2ChartVal
                                  : x1ChartVal;
            double x2Val = x_isInversed
                               ? x1ChartVal
                               : x2ChartVal;
            double y2Val = y_isInversed
                               ? y1ChartVal
                               : y2ChartVal;
            double y1Val = y_isInversed
                               ? y2ChartVal
                               : y1ChartVal;
            Point tlpoint = cartesianTransformer.TransformToVisible(x1Val, y1Val);
            Point rbpoint = cartesianTransformer.TransformToVisible(x2Val, y2Val);
            float x1Value = ((float)tlpoint.X);
            float x2Value = ((float)rbpoint.X);
            float y1Value = ((float)tlpoint.Y);
            float y2Value = ((float)rbpoint.Y);

            float x1     = 0;
            float x2     = 0;
            float y1     = 0;
            float y2     = 0;
            int   width  = (int)Area.SeriesClipRect.Width;
            int   height = (int)Area.SeriesClipRect.Height;

            selectedSegmentPixels.Clear();

            x1 = x1Value;
            x2 = x2Value;
            y1 = y1ChartVal > 0 ? y1Value : y2Value;
            y2 = y1ChartVal > 0 ? y2Value : y1Value;

            var spacingSegment = this as ISegmentSpacing;

            if (spacingSegment != null)
            {
                double spacing = spacingSegment.SegmentSpacing;
                if (spacing > 0 && spacing <= 1)
                {
                    double leftpos  = spacingSegment.CalculateSegmentSpacing(spacing, x2, x1);
                    double rightpos = spacingSegment.CalculateSegmentSpacing(spacing, x1, x2);
                    x1 = (float)(leftpos);
                    x2 = (float)(rightpos);
                }
            }

            if (y1 < y2)
            {
                selectedSegmentPixels = bmp.GetRectangle(width, height, (int)(x1), (int)y1, (int)x2, (int)y2, selectedSegmentPixels);
            }
            else
            {
                selectedSegmentPixels = bmp.GetRectangle(width, height, (int)(x1), (int)y2, (int)x2, (int)y1, selectedSegmentPixels);
            }
        }