I have a polar chart I created by chart control in my WinForms app. X axis type is Distance, Y axis type is Azimuth.
My problem is that I cannot set X,Y initial points i.e (0,0) at center, it always appears at different place. Just as shown in figure 1
As you see in the above figures, Azimuth value is Zero at 270 and 360 at 90, and Distance is 0 at 180 and 100 at 0. Here is the code I used to create polar chart.
public PolarChart()
{
this.WindowState = FormWindowState.Maximized;
InitializeComponent();
Series s0 = new Series("PolarChart");
s0.Color = Color.Gray;
s0.ChartType = SeriesChartType.Polar;
s0.Points.AddXY(0, 0);
chart1.Series.Add(s0);
chart1.Series[0]["PolarDrawingStyle"] = "line";
chart1.ChartAreas[0].AxisX.Minimum = 0;
chart1.ChartAreas[0].AxisX.Maximum = 360;
chart1.ChartAreas[0].AxisX.Interval = 30;
chart1.ChartAreas[0].AxisY.Minimum = 0;
chart1.ChartAreas[0].AxisY.Maximum = 100;
chart1.ChartAreas[0].AxisY.Interval = 10;
}
private void btnDisplay_Click(object sender, EventArgs e)
{
TextFieldParser reader = new TextFieldParser("LFPoints.txt");
reader.Delimiters = new string[] { "," };
reader.HasFieldsEnclosedInQuotes = true;
string[] read = reader.ReadFields();
try
{
Series S2 = new Series("Plot");
S2.ChartType = SeriesChartType.Polar;
S2.BorderColor = Color.Red;
if (read != null)
if (read.Length != 0)
{
foreach (string other in read)
{
ComputeDistanceAngle(other, Base);
S2.Points.AddXY(Azimuth, Distance);
}
chart1.Series.Add(S2);
chart1.Series["LFPlot"]["PolarDrawingStyle"] = "marker";
}
else
{
MessageBox.Show("No Graph to Plot");
}
else
MessageBox.Show("No Graph to Plot");
}
catch (Exception)
{
}
}
private void chart1_MouseMove(object sender, MouseEventArgs e)
{
var pos = e.Location;
if (prevPosition.HasValue && pos == prevPosition.Value)
return;
tooltip.RemoveAll();
prevPosition = pos;
var results = chart1.HitTest(pos.X, pos.Y, false,
ChartElementType.PlottingArea);
foreach (var result in results)
{
if (result.ChartElementType == ChartElementType.PlottingArea)
{
var xVal = result.ChartArea.AxisX.PixelPositionToValue(pos.X);
var yVal = result.ChartArea.AxisY.PixelPositionToValue(pos.Y);
tooltip.Show("Azimuth = " + xVal + "\n"+" Distance = " + yVal, this.chart1,
pos.X, pos.Y - 15);
}
}
}
After I tried a lot I came to know about "Crossing" property.
chart1.ChartAreas[0].AxisX.Crossing = 90;
chart1.ChartAreas[0].AxisY.Crossing = 0;
But I didn't get what i need. So please help me to plot the points in polar chart with X and Y points starting from center. Here is the link which exactly how I need my polar chart. enter link description here
I am using Visual Studio 2010.