Autoscaling problem with multiple series
Autoscaling problem with multiple series
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
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:
I hope will helps.
Thanks,
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);
}
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Autoscaling problem with multiple series
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
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