void AddLabels(Graphics g)
{
float xOffset = ChartArea.Width / 30f;
float yOffset = ChartArea.Height / 30f;
CGSize labelFontSize = g.MeasureString ("A", LabelFont);
CGSize titleFontSize = g.MeasureString ("A", TitleFont);
// Add horizontal axis label:
var aBrush = new SolidBrush (LabelFontColor);
CGSize stringSize = g.MeasureString (XLabel, LabelFont);
g.DrawString (XLabel, LabelFont, aBrush, new PointF (form1.PlotPanel.Left + form1.PlotPanel.Width / 2 - (int)stringSize.Width / 2, ChartArea.Bottom - (int)yOffset - (int)labelFontSize.Height));
// Add y-axis label:
var sFormat = new StringFormat ();
sFormat.Alignment = StringAlignment.Center;
stringSize = g.MeasureString (YLabel, LabelFont);
// Save the state of the current Graphics object
GraphicsState gState = g.Save ();
g.TranslateTransform (ChartArea.X + xOffset, (float)(ChartArea.Y +
yOffset + titleFontSize.Height +
yOffset / 3 + form1.PlotPanel.Height / 2));
g.RotateTransform (-90);
g.DrawString (YLabel, LabelFont, aBrush, 0, 0, sFormat);
// Restore it:
g.Restore (gState);
// Add title:
aBrush = new SolidBrush (TitleFontColor);
stringSize = g.MeasureString (Title, TitleFont);
if (Title.ToUpper () != "NO TITLE")
g.DrawString (Title, TitleFont, aBrush, new PointF (form1.PlotPanel.Left + form1.PlotPanel.Width / 2 -
(int)stringSize.Width / 2, ChartArea.Top + (int)yOffset));
aBrush.Dispose ();
}