How to customize the Chart Title in WinForms Chart control?
In WinForms Chart control, the chart title can be customized both at design time and runtime. At design time, you can modify the title using the Properties window by accessing the Title property under the ChartControl object. At runtime, the title can be programmatically adjusted to change its text, color, and position. Additionally, you can enable or disable the chart title as needed using Visible property.
The following code snippets demonstrate how to apply chart title customizations at runtime.
this.chartControl1 = new ChartControl();
. . .
// Specifying Chart Title
this.chartControl1.Title.Text = "My Chart";
this.chartControl1.Title.Alignment = ChartAlignment.Center;
this.chartControl1.Title.Position = ChartDock.Bottom;
this.chartControl1.Title.Visible = true;
// Specifying Color
this.chartControl1.Title.BackColor = Color.Lavender;
this.chartControl1.Title.ForeColor = Color.Green;
this.chartControl1.Title.Font = new Font("Arial", 14.0f);
Me.ChartControl1 = New ChartControl()
. . .
' Specifying Chart Title
Me.ChartControl1.Title.Text = "My Chart"
Me.ChartControl1.Title.Alignment = ChartAlignment.Center
Me.ChartControl1.Title.Position = ChartDock.Bottom
Me.ChartControl1.Title.Visible = True
' Specifying Color
Me.ChartControl1.Title.BackColor = Color.Lavender
Me.ChartControl1.Title.ForeColor = Color.Green
Me.ChartControl1.Title.Font = New Font("Arial", 14.0F)
To display the border of the title, the ShowBorder property is used. The border's forecolor, dash style, and width can also be modified.
// Specifying Border Properties
this.chartControl1.Title.ShowBorder = true;
this.chartControl1.Title.Border.ForeColor = Color.Red;
this.chartControl1.Title.Border.DashStyle = DashStyle.Dot;
this.chartControl1.Title.Border.Width = 2f;
' Specifying Border Properties
Me.ChartControl1.Title.ShowBorder = True
Me.ChartControl1.Title.Border.ForeColor = Color.Red
Me.ChartControl1.Title.Border.DashStyle = DashStyle.Dot
Me.ChartControl1.Title.Border.Width = 2.0FOutput
Conclusion
I hope you enjoyed learning about how to customize the Chart Title in WinForms Chart control.
You can refer to our WinForms Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our WinForms Chart examples to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our Winforms Chart and other Winforms components.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!