/// <summary> /// Method for drawing the X axis into the canvas. /// </summary> private void createXaxis() { // Make the X axis. GeometryGroup xaxis_geom = new GeometryGroup(); //Create a straight horizontal line xaxis_geom.Children.Add(new LineGeometry( new Point(xminCanvas, window.graphCanvas.Height - yminCanvas), new Point(window.graphCanvas.Width, window.graphCanvas.Height - yminCanvas))); int count = 0; //Iterate through and add | markings to this line. for (double x = xminCanvas; x <= xmaxCanvas; x += step) { string label = NumRounder.RoundToSignificantDigits(Xlabels[count], 4); DrawText(x + 6, window.graphCanvas.Height - (yminCanvas - 6), label, true, true); //Add | per each step. xaxis_geom.Children.Add(new LineGeometry( new Point(x, window.graphCanvas.Height - yminCanvas - HEIGHT_OF_POINT_MARKERS / 2), new Point(x, window.graphCanvas.Height - yminCanvas + HEIGHT_OF_POINT_MARKERS / 2))); count++; } //add the variable name to the axis. //equation is to make the label center aligned DrawText(MARGIN + (AXIS_LENGTH / 2) - (((plotFunc.X.Length - 1.0) * 8.0) / 2.0), window.graphCanvas.Height - 30, plotFunc.X, false, false); //Then style the X axis. Path xaxis_path = new Path(); xaxis_path.StrokeThickness = 1; xaxis_path.Stroke = Brushes.White; xaxis_path.Data = xaxis_geom; //Add it to the graphCanvas. window.graphCanvas.Children.Add(xaxis_path); }
/// <summary> /// Method for drawing the Y axis into the canvas. /// </summary> private void createYaxis() { // Make the Y ayis. GeometryGroup yaxis_geom = new GeometryGroup(); //Create a vertical line yaxis_geom.Children.Add(new LineGeometry( new Point(xminCanvas, window.graphCanvas.Height - yminCanvas), new Point(xminCanvas, 0))); int count = 0; //Iterate through and add | markings to this line. for (double y = yminCanvas; y <= ymaxCanvas; y += step) { string stringRep = NumRounder.RoundToSignificantDigits(Ylabels[count], 4); DrawText((MARGIN - 8) - (stringRep.Length * 7), window.graphCanvas.Height - y - 6, stringRep, false, false); //Add | per each step yaxis_geom.Children.Add(new LineGeometry( new Point(xminCanvas - HEIGHT_OF_POINT_MARKERS / 2, window.graphCanvas.Height - y), new Point(xminCanvas + HEIGHT_OF_POINT_MARKERS / 2, window.graphCanvas.Height - y))); count++; } //add the variable name to the axis. DrawText(10, AXIS_LENGTH / 2 + (((plotFunc.Y.Length - 1.0) * 8.0) / 2.0), plotFunc.Y, true, false); //Then style the Y axis Path yaxis_path = new Path(); yaxis_path.StrokeThickness = 1; yaxis_path.Stroke = Brushes.White; yaxis_path.Data = yaxis_geom; //Add it to the graph canvas window.graphCanvas.Children.Add(yaxis_path); }