Reputation: 1068
I have tried many things such as setting Right to Left
or messing with the IsReversed
property for ChartArea
but no go. Any advice?
Sorry for the lack of info, I figured it would be just a switch somewhere in the Chart properties that I was overlooking. Anyways, I am making a custom chart and right now the lines are going from left to right BUT I need it to go in the reverse direction
I guess another way to put it woudl be how do I add points going from right to left?
Upvotes: 2
Views: 4886
Reputation: 54433
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..
Upvotes: 4