/// <summary> /// Draws the point plot using the Drawing Context and x and y axes supplied /// </summary> /// <param name="ctx">The Drawing Context with which to draw.</param> /// <param name="xAxis">The X-Axis to draw against.</param> /// <param name="yAxis">The Y-Axis to draw against.</param> public virtual void Draw(Context ctx, PhysicalAxis xAxis, PhysicalAxis yAxis) { SequenceAdapter data_ = new SequenceAdapter(DataSource, DataMember, OrdinateData, AbscissaData); double leftCutoff_ = xAxis.PhysicalMin.X - marker.Size; double rightCutoff_ = xAxis.PhysicalMax.X + marker.Size; ctx.Save(); ctx.SetColor(marker.LineColor); ctx.SetLineWidth(marker.LineWidth); for (int i = 0; i < data_.Count; ++i) { if (!Double.IsNaN(data_[i].X) && !Double.IsNaN(data_[i].Y)) { Point xPos = xAxis.WorldToPhysical(data_[i].X, false); if (xPos.X < leftCutoff_ || rightCutoff_ < xPos.X) { continue; } Point yPos = yAxis.WorldToPhysical(data_[i].Y, false); marker.Draw(ctx, xPos.X, yPos.Y); if (marker.DropLine) { Point yMin = new Point(data_[i].X, Math.Max(0.0, yAxis.Axis.WorldMin)); Point yStart = yAxis.WorldToPhysical(yMin.Y, false); ctx.MoveTo(xPos.X, yStart.Y); ctx.LineTo(xPos.X, yPos.Y); ctx.Stroke(); } } } ctx.Restore(); }
/// <summary> /// Draws the marker on a plot surface. /// </summary> /// <param name="ctx">The Drawing Context with which to draw</param> /// <param name="xAxis">The X-Axis to draw against.</param> /// <param name="yAxis">The Y-Axis to draw against.</param> public void Draw(Context ctx, PhysicalAxis xAxis, PhysicalAxis yAxis) { Point point = new Point( xAxis.WorldToPhysical(x_, true).X, yAxis.WorldToPhysical(y_, true).Y); marker_.Draw(ctx, point.X, point.Y); }
/// <summary> /// Draws the plot using the Drawing Context and X, Y axes supplied. /// </summary> public override void Draw(Context ctx, PhysicalAxis xAxis, PhysicalAxis yAxis) { SequenceAdapter data = new SequenceAdapter(this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData); TextDataAdapter textData = new TextDataAdapter(this.DataSource, this.DataMember, this.TextData); TextLayout layout = new TextLayout(); layout.Font = Font; ctx.Save(); ctx.SetColor(Colors.Black); for (int i = 0; i < data.Count; ++i) { try { Point p = data[i]; if (!Double.IsNaN(p.X) && !Double.IsNaN(p.Y)) { Point xPos = xAxis.WorldToPhysical(p.X, false); Point yPos = yAxis.WorldToPhysical(p.Y, false); // first plot the marker Marker.Draw(ctx, xPos.X, yPos.Y); // then the label if (textData[i] != "") { layout.Text = textData[i]; Size size = layout.GetSize(); switch (labelTextPosition) { case LabelPositions.Above: p.X = xPos.X - size.Width / 2; p.Y = yPos.Y - size.Height - Marker.Size * 2 / 3; break; case LabelPositions.Below: p.X = xPos.X - size.Width / 2; p.Y = yPos.Y + Marker.Size * 2 / 3; break; case LabelPositions.Left: p.X = xPos.X - size.Width - Marker.Size * 2 / 3; p.Y = yPos.Y - size.Height / 2; break; case LabelPositions.Right: p.X = xPos.X + Marker.Size * 2 / 3; p.Y = yPos.Y - size.Height / 2; break; } ctx.DrawTextLayout(layout, p); } } } catch { throw new XwPlotException("Error in TextPlot.Draw"); } } ctx.Restore(); }