We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize background and foreground settings in chart?

 

The chart background image can be set either at run-time or at design time.The chart area background image can be changed using the ChartAreaBackImage Property. We can also set any solid color as the backcolor of the chart control as well as ChartArea.

The font face of the text can be chosen from any one of the system supported font faces using the Font property of the ChartStyleInfo class.The font style of the series text can be changed by selecting any one of the different font styles using the FontStyle property of the ChartFontInfo class.

C#

// Settting Image to the Chart

ofd.InitialDirectory = @"..\..\Images";

ofd.Filter = "BackGround files (*.jpg)|*.jpg|All files (*.*)|*.*";

if(DialogResult.OK == ofd.ShowDialog())

{

filename = ofd.FileName;

this.chartControl1.ChartAreaBackImage = new Bitmap(filename);

}

// Setting Chart Background Color

this.chartControl1.ChartInterior = Color.Red;

// Changing font for chart axis

ChartAxis axis = this.chartControl1.PrimaryXAxis;

axis.Font = new Font(Font_Name, 10f, (FontStyle)Enum.Parse(typeof(FontStyle), this.cmb_FontStyle.SelectedItem.ToString(), true));

axis = this.chartControl1.PrimaryYAxis;

VB

' Settting Image to the Chart

Dim ofd As OpenFileDialog = New OpenFileDialog()

ofd.InitialDirectory = "..\..\Images"

ofd.Filter = "BackGround files (*.jpg)|*.jpg|All files (*.*)|*.*"

If DialogResult.OK = ofd.ShowDialog() Then

filename = ofd.FileName

Me.chartControl1.ChartAreaBackImage = New Bitmap(filename)

End If

'Setting BackGroundColor

Me.chartControl1.ChartInterior = Color.Red

' Changing Font for chart axis

Dim axis As ChartAxis = Me.chartControl1.PrimaryXAxis

axis.Font = New System.Drawing.Font(Font_Name, 10.0F, Me.chartControl1.PrimaryXAxis.Font.Style)

axis = Me.chartControl1.PrimaryYAxis

Article ID: Published Date: Last Revised Date: Platform: Control:
63 04/30/2011 07/10/2014 WinForms Chart
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon