public void RenderPoint(Canvas canvas, DataPoint dataPoint) { RadRect slot = dataPoint.LayoutSlot; Paint paint = this.CreatePaint(dataPoint); canvas.DrawRect((float)slot.GetX(), (float)slot.GetY(), (float)slot.Right, (float)slot.Bottom, paint); paint.Dispose(); }
private void RenderLabel(Canvas canvas, RadRect dataPointSlot, string labelText, StaticLayout textBounds) { // TODO - Rotate the canvas on the center before drawing label //canvas.Rotate(90, (float)canvas.Width / 2, (float)canvas.Height / 2); RectF labelBounds = new RectF(); float height = textBounds.Height + labelPadding * 2; // Calculate the middle of the bar var barY = (float)dataPointSlot.GetY(); var barHeight = canvas.Height - barY; var middlePoint = barHeight / 2; var labelY = canvas.Height - middlePoint; // Calculate left and right padding around the label var barX = (float)dataPointSlot.GetX(); var barRight = (float)dataPointSlot.Right; var barWidth = barRight - barX; var padding = barWidth / 10; // Calculate the Rect bounds var rectLeft = barX + padding; var rectTop = labelY; var rectRight = barRight - padding; var rectBottom = rectTop + height; // Set's the label's position on the Chart's canvas labelBounds.Set(rectLeft, rectTop, rectRight, rectBottom); // Draws Rect's fill and stroke color canvas.DrawRect(labelBounds.Left, labelBounds.Top, labelBounds.Right, labelBounds.Bottom, fillPaint); canvas.DrawRect(labelBounds.Left, labelBounds.Top, labelBounds.Right, labelBounds.Bottom, strokePaint); // Draws the Text on the canvas canvas.DrawText( labelText, (float)dataPointSlot.GetX() + (float)(dataPointSlot.Width / 2.0) - textBounds.GetLineWidth(0) / 2.0f, labelBounds.CenterY() + textBounds.GetLineBottom(0) - textBounds.GetLineBaseline(0), paint); // TODO Undo rotation after drawing label //canvas.Rotate(-90, (float)canvas.Width / 2, (float)canvas.Height / 2); }