Author |
Topic  |
|
seh-a
USA
14 Posts |
Posted - 22 Aug 2013 : 16:44:10
|
I am implementing a new chart using a template of a successfully implemented MEAN_RANGE_CHART type chart. Code fragments as follows:
numsamplespersubgroup = 3; numdatapointsinview = 20; ... this.InitSPCBatchVariableControlChart(SPCControlChartData.MEAN_RANGE_CHART, numsamplespersubgroup, numdatapointsinview); ... for (i=0; i<20; i++) { getdata(ref samples); this.ChartData.AddNewSampleRecord(batchcounter++, timestamp, samples); // samples is DoubleArray of 2 or 4 elements } .... this.AutoScalePrimaryChartYRange(); this.AutoScaleSecondaryChartYRange(); System.Threading.Thread.Sleep(500); ... this.ChartData.NumRecordsPerChart = total_records == 1 ? 2 : total_records; // total_records = 20 this.RebuildChartUsingCurrentData();
using this code, I get error 'Index was out of range. Must be non-nagative and less than the size of the collection. Parameter name: index' on all the samples that is 4 , not the 2 elements. So, I change numsamplespersubgroup to 4 and that eleminates this error message but I would get error 'Index was outside the bounds of the array' from calling this.AutoScalePrimaryChartYRange(). I am confused. What did I do wrong? |
|
quinncurtis
1586 Posts |
Posted - 23 Aug 2013 : 08:39:08
|
A MEAN_RANGE_CHART requires fixed sample size, i.e. the number of samples in a sub interval. In your setup you specify 3 for numsamplespersubgroup , which is OK.
But in your call to AddNewSampleRecord you say:
// samples is DoubleArray of 2 or 4 elements
Which is incorrect in both cases. If your numsamplespersubgroup is 3, then you must always pass in exactly 3 values in the samples array, and the samples array should be sized to 3. |
 |
|
|
Topic  |
|
|
|