Page 1 of 1
Autoscaling problem with multiple series
Posted: Fri Nov 22, 2013 6:51 pm
by 8121878
I created a chart with six fastline series and only the first series controls the y-axis (left axis) scaling. Is there a way to have the chart auto-scale based on data from all the series?
Re: Autoscaling problem with multiple series
Posted: Mon Nov 25, 2013 10:45 am
by 10050769
Hello Charlesw,
I think you can find the Minimum and Maximum of all series and using SetMinMax define the Minimum and Maxium of the series and have scale based in all the series. You can do something as next:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
for (int i = 0; i < 6; i++)
{
tChart1.Aspect.View3D = false;
new FastLine(tChart1.Chart);
tChart1[i].FillSampleValues(100);
}
SetAxisLeftMinAndMaxSeries();
button1.Click += button1_Click;
}
void button1_Click(object sender, EventArgs e)
{
tChart1.ShowEditor();
}
private void SetAxisLeftMinAndMaxSeries()
{
double Min,Max;
Min = 0;
Max=0;
for(int i=0; i<tChart1.Series.Count-1; ++i)
{
Min = tChart1[i].YValues.Minimum;
Max = tChart1[i].YValues.Maximum;
if (Math.Min(tChart1[i].YValues.Minimum, tChart1[i + 1].YValues.Minimum)<Min)
{
Min = Math.Min(tChart1[i].YValues.Minimum, tChart1[i + 1].YValues.Minimum);
}
if (Max< Math.Max(tChart1[i].YValues.Maximum, tChart1[i + 1].YValues.Maximum))
{
Max = Math.Max(tChart1[i].YValues.Maximum, tChart1[i + 1].YValues.Maximum);
}
}
tChart1.Axes.Left.SetMinMax(Min, Max);
}
I hope will helps.
Thanks,
Re: Autoscaling problem with multiple series
Posted: Mon Nov 25, 2013 4:24 pm
by 8121878
Sandra,
Thanks very much for your reply, it was very helpful.
Your implied response was that auto-scaling multiple series in the same chart is not supported at design time but must be customer-coded. So I wrote an auto-scaling, run-time algorithm, based on your suggestion, and that worked.
It also fixed the chart crashing when any other series than the first was selected. I should mention that the user can select any combination of the six series to display; all six are not always displayed.
Thank you for your time,
Alex Specker--using CharlesW login