Windows forms:
//...
series.Style.DisplayText = true;
series.Style.Callout.Enable = true;
series.Style.Callout.DisplayTextAndFormat = "custom text";
//...
|
Windows forms:
//...
ChartCustomPoint cp1 = new ChartCustomPoint();
//specify the required text
cp1.Text = "CustomText1";
//specify custom point type as chart coordinates to place the custom text at any location in the chart
cp1.CustomType = ChartCustomPointType.ChartCoordinates;
//specify the coordinates to place the custom label in chart
cp1.XValue = 100;
cp1.YValue = 58;
//customize the custom label
cp1.Color = Color.Red;
cp1.Font.Size = 13;
cp1.Font.FontStyle = FontStyle.Italic;
this.chart.CustomPoints.Add(cp1);
//...
|
private void Form1_Load(object sender, EventArgs e)
{
this.chart.Paint += Chart_Paint;
//...
}
private void Chart_Paint(object sender, PaintEventArgs e)
{
this.DrawString(e.Graphics, 10.0F, 80.0F);
}
public void DrawString(Graphics formGraphics, float x, float y)
{
string drawString = "Custom Text 1";
string drawString2 = "Custom Text 3";
System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
formGraphics.DrawString(drawString2, drawFont, drawBrush, x, y+160,drawFormat);
drawFont.Dispose();
drawBrush.Dispose();
} |