I have tried many things such as setting Right to Left
or messing with the IsReversed
property for ChartArea
but no go. Any advice?
If you want to reverse the x-axis all you need to do is
private void button1_Click(object sender, EventArgs e)
{
ChartArea CA = chart1.ChartAreas[0];
CA.AxisX.IsReversed = true;
}
Before and after:
If you want to keep the y-axis to the left use this:
private void button2_Click(object sender, EventArgs e)
{
ChartArea CA = chart1.ChartAreas[0];
CA.AxisY2.Enabled = AxisEnabled.True;
CA.AxisY.Enabled = AxisEnabled.False;
CA.AxisX.IsReversed = true;
}
If, as you comment, you simply want to add DataPoints
to the left, you can do so like this:
Series S = chart1.Series[0];
DataPoint dp = new DataPoint(dp.XValue, dp.YValues[0]);
S.Points.Insert(0, dp);
This may be a little slower, but it will work just as well as Adding
them at the end. You may want to have a look at this post, where DataPoints
are inserted at various spots in the Points
collection..
Note the Points
is often accessed like an array but really is of type DataPointCollection so adding and removing and many other operations are readily available.
One common use is removing Points from the left to create a 'moving' chart like an oscillograph..