public override uint GetBestScale(double xAxisMax, double yAxisMax) { var xTop = Center.X + Radius; var xBottom = Center.X - Radius; var yLeft = Center.Y - Radius; var yRight = Center.X + Radius; uint scale = 1; if (xTop > xAxisMax) { scale = GraphMathUtilities.CalculateScale(GraphAxis.X, xTop, xAxisMax, yAxisMax); } if (xBottom < (-1 * xAxisMax)) { scale = GraphMathUtilities.CalculateScale(GraphAxis.X, xBottom, xAxisMax, yAxisMax); } if (yRight > yAxisMax) { scale = GraphMathUtilities.CalculateScale(GraphAxis.Y, yRight, xAxisMax, yAxisMax); } if (yLeft < (-1 * yAxisMax)) { scale = GraphMathUtilities.CalculateScale(GraphAxis.Y, yLeft, xAxisMax, yAxisMax); } return(scale); }
public override uint GetBestScale(double xAxisMax, double yAxisMax) { var pointsX = Points.OrderByDescending(p => p.Value.X); var pointsY = Points.OrderByDescending(p => p.Value.Y); var xMax = pointsX.First().Value.X; var yMax = pointsY.First().Value.Y; var xMin = pointsX.Last().Value.X; var yMin = pointsY.Last().Value.Y; uint scale = 1; if (xMax > yMax) { scale = GraphMathUtilities.CalculateScale(GraphAxis.X, xMax, xAxisMax, yAxisMax); } if (yMax > xMax) { scale = GraphMathUtilities.CalculateScale(GraphAxis.Y, yMax, xAxisMax, yAxisMax); } if (xMin < yMin) { scale = GraphMathUtilities.CalculateScale(GraphAxis.X, xMin, xAxisMax, yAxisMax); } if (yMin < xMin) { scale = GraphMathUtilities.CalculateScale(GraphAxis.Y, yMin, xAxisMax, yAxisMax); } return(scale); }
private List <UIElement> GetLinePaths(LineGraph lineGraph, GraphParams graphParams) { var result = new List <UIElement>(); for (int i = 0; i < lineGraph.Points.Count - 1; i++) { var lineGeometry = new LineGeometry { StartPoint = GraphMathUtilities.TransformToCanvasCoords(graphParams, lineGraph.Points.ElementAt(i).Value), EndPoint = GraphMathUtilities.TransformToCanvasCoords(graphParams, lineGraph.Points.ElementAt(i + 1).Value) }; var linePath = new Path { Stroke = new SolidColorBrush(lineGraph.Color), Fill = new SolidColorBrush(lineGraph.Color), StrokeThickness = 2, Data = lineGeometry }; if (lineGraph.LineType != LinePattern.Solid) { linePath.StrokeDashArray = GraphMappingUtilities.GetLinePattern(lineGraph.LineType); } result.Add(linePath); } return(result); }
private UIElement GetCirclePath(CircleGraph circleGraph, GraphParams graphParams) { var circleGeometry = new EllipseGeometry { Center = GraphMathUtilities.TransformToCanvasCoords(graphParams, circleGraph.Center), RadiusX = circleGraph.Radius, RadiusY = circleGraph.Radius }; var pathGeometry = PathGeometry.CreateFromGeometry(circleGeometry); var path = new Path { Stroke = new SolidColorBrush(circleGraph.Color), StrokeThickness = 2, Data = pathGeometry }; if (circleGraph.Filled) { path.Fill = new SolidColorBrush(circleGraph.Color); } if (circleGraph.LineType != LinePattern.Solid) { path.StrokeDashArray = GraphMappingUtilities.GetLinePattern(circleGraph.LineType); } return(path); }
private UIElement GetComplexShapePath(ComplexShape complexShape, GraphParams graphParams) { var points = complexShape.Points.Select(p => GraphMathUtilities.TransformToCanvasCoords(graphParams, p.Value)); var polygon = new Polygon { Stroke = new SolidColorBrush(complexShape.Color), StrokeThickness = 2 }; var myPointCollection = new PointCollection(points); polygon.Points = myPointCollection; if (complexShape.Filled) { polygon.Fill = new SolidColorBrush(complexShape.Color); } if (complexShape.LineType != LinePattern.Solid) { polygon.StrokeDashArray = GraphMappingUtilities.GetLinePattern(complexShape.LineType); } return(polygon); }