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.
Unfortunately, activation email could not send to your email. Please try again.

text display in graph

Thread ID:

Created:

Updated:

Platform:

Replies:

74729 Jun 26,2008 02:54 AM Jun 30,2008 12:40 AM Windows Forms 1
loading
Tags: Chart
abc
Asked On June 26, 2008 02:54 AM

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.





help_13af498f.zip

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

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.

http://websamples.syncfusion.com/samples/Chart.Windows/F74729/Main.htm

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

Regards,
Manohari.R



CONFIRMATION

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.

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.

;