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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

text display in graph

Thread ID:





74729 Jun 26,2008 06:54 AM UTC Jun 30,2008 04:40 AM UTC WinForms 1
Tags: Chart
Asked On June 26, 2008 06:54 AM UTC

I am using syncfusion version 5.2. In my column graph i want that the text should be displayed inside the column and at the top of the column.

I am able to display text at only one point either inside or at top....but i want to display text at both points.

Image of what exactly i want is also attached with this message.

I will be very thankful if anyone could help me with this.


Manohari [Syncfusion]
Replied On June 30, 2008 04:40 AM UTC

Hi Prabhjeet,

Thanks for the screenshot. It is possible to display text both inside as well as in the top of the column by handling the ChartAreaPaintEvent Handler as given below:

Sample Code:

void chartControl1_ChartAreaPaint(object sender, PaintEventArgs e)

if (this.checkBox1.Checked)
float y2 = this.chartControl1.PrimaryYAxis.GetCoordinateFromValue(this.chartControl1.PrimaryYAxis.Range.Min);

for (int i = 0; i < this.chartControl1.Series[0].Points.Count; i++)
ChartStyleInfo style = this.chartControl1.Series[0].Styles[i];
string s = String.Format("{0:n0}", this.chartControl1.Series[0].Points[i].YValues[0] / this.totalYValue * 100).ToString() + "%";
SizeF sz = e.Graphics.MeasureString(s, style.GdipFont);
float StartX = this.chartControl1.PrimaryXAxis.GetCoordinateFromValue(this.chartControl1.Series[0].Points[i].X) - sz.Width / 2;
float StartY = this.chartControl1.PrimaryYAxis.GetCoordinateFromValue(this.chartControl1.Series[0].Points[i].YValues[0]);
float MiddleY = y2 - StartY;
e.Graphics.DrawString(s, style.GdipFont, new SolidBrush(Color.Black), new PointF(StartX, StartY + (MiddleY / 2) - sz.Height / 2));


I have attached sample that illustrates the same in this link below.


Kindly let us know if this meets your requirements. Thanks for your patience.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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