I am using an UltraDataChart and I would like to draw an outline (box) around the plot area.
I can't find anyway to do this.
Does it require using the Graphics component of the chart to draw a Rectangle, or does it have more to do with the properties of the Axes?
Hello James, There is no border property on the plot area aka. view port rectangle
To work around this you can hook the chart's Paint event and call ControlPaint.DrawBorder. eg.
private void UltraDataChart1_Paint(object sender, PaintEventArgs e) { ControlPaint.DrawBorder(e.Graphics, this.ultraDataChart1.ViewportRect, Color.Red, ButtonBorderStyle.Solid); }
Hello Michael,
I got it to work but had to extend the solution.
I am using the UltraDataChart in a PDF report using the Document engine, When I use the Paint handler in a windows forms app I see the outline - great.
But I didn't see it when I saved the bitmap using UltraDataChart.SaveTo(stream, ImageFormat.Bmp)
So the Paint handler works fine.
In order to save the chart with the outline I had to use the following code:
Bitmap bitmap = new Bitmap(chart.Width, chart.Height); chart.DrawToBitmap(bitmap, chart.Bounds); bitmap.Save(ms, ImageFormat.Bmp);
Image image = new Image(ms);
Now the image is correct and I can add it to the report.
Thanks.
Okay great! Let us know if there is anything else we can assist you with.