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. Image for the cookie policy date
close icon

how do I get polar chart to be in degrees instead of radians?

I can't find any options on the PrimaryXAxis that will allow degrees instead of radians for the min max range, and for values added to the series.


6 Replies

BT Byron Tate September 5, 2008 12:56 AM UTC


>I can't find any options on the PrimaryXAxis that will allow degrees instead of radians for the min max range, and for values added to the series.


Also, a series point at 0 degrees shows up at the top axis, but the right axis is labeled zero, the top axis is labeled 1.57 (90 degrees). So the axis labels seem to be 90 degrees off.



MA Manohari Syncfusion Team September 8, 2008 05:55 AM UTC

Hi Byron,

We regret for the delayed response. Please find our responses to your queries below.

1) It is posssible to display the Labels in degree by handling the ChartAxis.FormatLabel event. Please refer to the following sample code.

Sample Code:

void PrimaryXAxis_FormatLabel(object sender, ChartFormatAxisLabelEventArgs e)
{
double rad = e.Value;
double deg = rad * 360 / (2 * Math.PI);
if (deg != 360)
{

e.Label = deg.ToString();
}
else
{
e.Label = "";
}
e.Handled = true;
}


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

http://websamples.syncfusion.com/samples/Chart.Windows/F76405/Sample1.htm

2) We regret to inform you that currently we do not have support to reverse the ChartAxis labels in Polar ChartType ( to display axis values in Clock Wise ). However we have created a feature request in this regard and have forwarded it to our Development team. I will get back to you regarding the time line for implementing this feature on or before September 12th 2008.

Kindly let us know if you have any queries. Thanks for your patience.

Regards,
Manohari.R



BT Byron Tate September 8, 2008 11:05 PM UTC

Thanks for the info re: printing degrees as labels in the polar plot.

As for the other problem, I don't want to reverse the ChartAxis labels in Polar ChartType. What I see is that when I specify 0 radians for the x value, the y point is positioned along the vertical axis, not the horizontal axis. The horizontal axis is labeled 0. This looks like a bug.


>Hi Byron,

We regret for the delayed response. Please find our responses to your queries below.

1) It is posssible to display the Labels in degree by handling the ChartAxis.FormatLabel event. Please refer to the following sample code.

Sample Code:

void PrimaryXAxis_FormatLabel(object sender, ChartFormatAxisLabelEventArgs e)
{
double rad = e.Value;
double deg = rad * 360 / (2 * Math.PI);
if (deg != 360)
{

e.Label = deg.ToString();
}
else
{
e.Label = "";
}
e.Handled = true;
}


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

http://websamples.syncfusion.com/samples/Chart.Windows/F76405/Sample1.htm

2) We regret to inform you that currently we do not have support to reverse the ChartAxis labels in Polar ChartType ( to display axis values in Clock Wise ). However we have created a feature request in this regard and have forwarded it to our Development team. I will get back to you regarding the time line for implementing this feature on or before September 12th 2008.

Kindly let us know if you have any queries. Thanks for your patience.

Regards,
Manohari.R





BT Byron Tate September 9, 2008 11:06 PM UTC

I have version 6.1.0.34. I notice your sample was built using 6.3.0.30.

I downloaded the source project from the link on the example page. When I run it, I get strange radian values in the PrimaryXAxis_FormatLabel method, and the X axis labels are drawn the same as with PrimaryXAxis_FormatLabel removed as the event handler. axis labels are 0, 1.57, 3.14, 4.71, 6.28



MA Manohari Syncfusion Team September 16, 2008 10:01 AM UTC

Hi Byron,

We regret very much for the inconvinience caused. I have modified the sample to run in version 6.1.0.34.It is possible to format the Labels to display in degrees in version 6.1.0.34 using the ChartFormatAxisLabel event as given below.

Sample code:

void chartControl1_ChartFormatAxisLabel(object sender, ChartFormatAxisLabelEventArgs e)
{
if (e.AxisOrientation == ChartOrientation.Horizontal)
{
double rad = e.Value;
double deg = rad * 360 / (2 * Math.PI);
if (deg != 360)
{

e.Label = deg.ToString();
}
else
{
e.Label = "";
}

}
e.Handled = true;
}

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

http://websamples.syncfusion.com/samples/Chart.Windows/F76405/Sample2.htm

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

Regards,
Manohari.R



MA Manohari Syncfusion Team September 16, 2008 11:07 AM UTC

Hi Byron,

Please find Our response to your Query regarding YAxis Labels along the the horizontal axis.

It is possible to place the YAxis Labels along the the horizontal axis by drawing Custom Axis labels along the Horizontal Axis And hiding the existing Y Axis labels. Please refer to the sample code below.

Sample Code:

this.chartControl1.PrimaryYAxis.ForeColor = Color.Transparent; // To hide actual Y Axis Labels
this.chartControl1.ChartAreaPaint += new PaintEventHandler(chartControl1_ChartAreaPaint);
}

void chartControl1_ChartAreaPaint(object sender, PaintEventArgs e)
{
double min = this.chartControl1.PrimaryYAxis.Range.Min;
double Interval = this.chartControl1.PrimaryYAxis.Range.Interval;
double nInterval = this.chartControl1.PrimaryYAxis.Range.NumberOfIntervals;
float pntX = this.chartControl1.PrimaryYAxis.Rect.Right;
float pntX1 = this.chartControl1.PrimaryYAxis.GetCoordinateFromValue(min + Interval);
float pntY = this.chartControl1.PrimaryYAxis.Rect.Bottom;
float PntXDelta = pntX1 - pntY;
for (int i = 0; i <= nInterval; i++)
{
string str = (min + i * Interval).ToString();
SizeF sz = e.Graphics.MeasureString(str, this.Font);
e.Graphics.DrawString(str, this.Font, new SolidBrush(Color.Black), new PointF(pntX - (PntXDelta * i), pntY)); // Draws custom labels


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

http://websamples.syncfusion.com/samples/Chart.Windows/F76405/Sample3.htm

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

Regards,
Manohari.R



Loader.
Live Chat Icon For mobile
Up arrow icon