注釈ライブラリを使用して注釈を回転させることはできません。postpaint
またはを使用する必要がありprepaint
ます。これは、ペイント後のイベントの使用方法の良い例です。お役に立てれば。以下のリンクからのコードを含めます:
protected void Chart1_PostPaint(object sender, ChartPaintEventArgs e)
{
if (e.ChartElement is Chart)
{
// create text to draw
String TextToDraw;
TextToDraw = "Printed: " + DateTime.Now.ToString("MMM d, yyyy @ h:mm tt");
TextToDraw += " -- Copyright © Steve Wellens";
// get graphics tools
Graphics g = e.ChartGraphics.Graphics;
Font DrawFont = System.Drawing.SystemFonts.CaptionFont;
Brush DrawBrush = Brushes.Black;
// see how big the text will be
int TxtWidth = (int)g.MeasureString(TextToDraw, DrawFont).Width;
int TxtHeight = (int)g.MeasureString(TextToDraw, DrawFont).Height;
// where to draw
int x = 5; // a few pixels from the left border
int y = (int)e.Chart.Height.Value;
y = y - TxtHeight - 5; // a few pixels off the bottom
// draw the string
g.DrawString(TextToDraw, DrawFont, DrawBrush, x, y);
}
}
編集:この例では実際にはテキストが回転しないことに気づきました。このツールを使用する必要があることはわかっているので、テキストを回転させるpostpaintを使用した例を見つけようとします。
編集2:ああ。ここSOで。基本的に、プロパティを使用する必要がありe.Graphics.RotateTransform(270);
ます(その線は270度回転します)。