public void setRangeLayoutFor(DataSet dataSet, RangeLayout rangeLayout) { if (dataSet == null) { return; } DataSet newDataSet = DataSetFactory.create(dataSet.getWorksheet(), dataSet.getRange(), dataSet.getName(), rangeLayout, dataSet.getVariableNamesInFirstRowOrColumn()); model.swapDataSets(dataSet, newDataSet); }
public void generateProcessCapability(int LSL, int USL, DataSet dataSet, _Worksheet sheet) { int index = 0; int row = 1; int column = 1; double correctionFactor1, correctionFactor2; double[] averages = new double[dataSet.amountOfVariables()]; double[] Rvalues = new double[dataSet.amountOfVariables()]; double[] averageOfAverages = new double[dataSet.amountOfVariables()]; double[] xChartUpperControlLimit = new double[dataSet.amountOfVariables()]; double[] xChartLowerControlLimit = new double[dataSet.amountOfVariables()]; double[] rChartUpperControlLimit = new double[dataSet.amountOfVariables()]; double[] rChartLowerControlLimit = new double[dataSet.amountOfVariables()]; double[] averageOfRvalues = new double[dataSet.amountOfVariables()]; int[] ArrayIndex = new int[dataSet.amountOfVariables()]; double[] constantC4 = new double[25] { 0.0, 0.7979, 0.8862, 0.9213, 0.9400, 0.9515, 0.9594, 0.9650, 0.9693, 0.9727, 0.9754, 0.9776, 0.9794, 0.9810, 0.9823, 0.9835, 0.9845, 0.9854, 0.9862, 0.9869, 0.9876, 0.9882, 0.9887, 0.9892, 0.9896 }; double[] constantD2 = new double[25] { 0.0, 1.128, 1.693, 2.059, 2.326, 2.534, 2.704, 2.847, 2.970, 3.078, 3.173, 3.258, 3.336, 3.407, 3.472, 3.532, 3.588, 3.640, 3.689, 3.735, 3.778, 3.819, 3.858, 3.895, 3.931 }; sheet.Cells[row, column] = "Index"; sheet.Cells[row, column + 1] = "Observation"; sheet.Cells[row, column + 2] = "Average"; sheet.Cells[row, column + 3] = "Max"; sheet.Cells[row, column + 4] = "Min"; sheet.Cells[row, column + 5] = "R"; for (index = 1; index < dataSet.amountOfVariables(); index++) { row++; sheet.Cells[row, column] = index - 1; sheet.Cells[row, column + 1] = dataSet.getVariables()[index].name; sheet.Cells[row, column + 2] = "=AVERAGE(" + dataSet.getWorksheet().Name + "!" + dataSet.getVariables()[index].Range + ")"; sheet.Cells[row, column + 3] = "=MAX(" + dataSet.getWorksheet().Name + "!" + dataSet.getVariables()[index].Range + ")"; sheet.Cells[row, column + 4] = "=MIN(" + dataSet.getWorksheet().Name + "!" + dataSet.getVariables()[index].Range + ")"; sheet.Cells[row, column + 5] = (double)(sheet.Cells[row, column + 3] as Range).Value - (double)(sheet.Cells[row, column + 4] as Range).Value; ArrayIndex[index - 1] = index; var cellValue = (double)(sheet.Cells[row, column + 2] as Range).Value; if (cellValue < -214682680) { cellValue = 0; // if cellValue is the result of a division by 0, set value to 0 } averages[index - 1] = cellValue; cellValue = (double)(sheet.Cells[row, column + 5] as Range).Value; Rvalues[index - 1] = cellValue; } // create variable to limit amount of subsamples in 1 measurement to 25 int safe; if (dataSet.rangeSize() > 24) { safe = 24; } else { safe = dataSet.rangeSize(); } if (dataSet.getVariableNamesInFirstRowOrColumn()) { correctionFactor1 = constantC4[safe - 1]; correctionFactor2 = constantD2[safe - 1]; } else { correctionFactor1 = constantC4[safe]; } correctionFactor2 = constantD2[safe]; double sigma = Rvalues.Average() / correctionFactor2; double Cp = (USL - LSL) / (6 * sigma); double Cpk = Math.Min((USL - averages.Average()) / (3 * sigma), (averages.Average() - LSL) / (3 * sigma)); row = 1; column = 1; sheet.Cells[row, column + 7] = "LSL"; sheet.Cells[row, column + 8] = "USL"; sheet.Cells[row, column + 9] = "Cp"; sheet.Cells[row, column + 10] = "Cpk"; row++; sheet.Cells[row, column + 7] = LSL; sheet.Cells[row, column + 8] = USL; sheet.Cells[row, column + 9] = Cp; sheet.Cells[row, column + 10] = Cpk; }
public void generateProcessCapability(List <Variable> variables, double LSL, double USL, DataSet dataSet, _Worksheet sheet) { int index = 0; int row = 1; int column = 1; double correctionFactor1, correctionFactor2; double[] averages = new double[dataSet.amountOfVariables()]; double[] Rvalues = new double[dataSet.amountOfVariables()]; double[] averageOfAverages = new double[dataSet.amountOfVariables()]; double[] xChartUpperControlLimit = new double[dataSet.amountOfVariables()]; double[] xChartLowerControlLimit = new double[dataSet.amountOfVariables()]; double[] rChartUpperControlLimit = new double[dataSet.amountOfVariables()]; double[] rChartLowerControlLimit = new double[dataSet.amountOfVariables()]; double[] averageOfRvalues = new double[dataSet.amountOfVariables()]; int[] ArrayIndex = new int[dataSet.amountOfVariables()]; double[] constantC4 = new double[25] { 0.0, 0.7979, 0.8862, 0.9213, 0.9400, 0.9515, 0.9594, 0.9650, 0.9693, 0.9727, 0.9754, 0.9776, 0.9794, 0.9810, 0.9823, 0.9835, 0.9845, 0.9854, 0.9862, 0.9869, 0.9876, 0.9882, 0.9887, 0.9892, 0.9896 }; double[] constantD2 = new double[25] { 0.0, 1.128, 1.693, 2.059, 2.326, 2.534, 2.704, 2.847, 2.970, 3.078, 3.173, 3.258, 3.336, 3.407, 3.472, 3.532, 3.588, 3.640, 3.689, 3.735, 3.778, 3.819, 3.858, 3.895, 3.931 }; sheet.Cells[row, column] = "Index"; sheet.Cells[row, column + 1] = "Observation"; sheet.Cells[row, column + 2] = "Average"; sheet.Cells[row, column + 3] = "STD DEV"; sheet.Cells[row, column + 4] = "Max"; sheet.Cells[row, column + 5] = "Min"; sheet.Cells[row, column + 6] = "R"; sheet.Cells[100, 100] = "=ROWS(" + dataSet.getWorksheet().Name + "!" + variables[0].Range + ")"; int length = Convert.ToInt32((sheet.Cells[100, 100] as Range).Value); sheet.Cells[100, 100] = ""; double temp = 0; List <double> allVals = new List <double>(); double[] all = new double[length * variables.Count]; foreach (Variable var in variables) { string ran = var.Range.ToString(); Array arr = dataSet.getWorksheet().Range[ran].Value; double[] vals = new double[length]; int count = 0; foreach (var item in arr) { temp = Convert.ToDouble(item); vals[count] = temp; count++; } allVals.AddRange(vals); } all = allVals.ToArray(); double totMean = 0; double totStd = 0; for (index = 0; index < variables.Count; index++) { row++; sheet.Cells[row, column] = index; sheet.Cells[row, column + 1] = variables[index].name; sheet.Cells[row, column + 2] = "=AVERAGE(" + dataSet.getWorksheet().Name + "!" + variables[index].Range + ")"; sheet.Cells[row, column + 3] = "=STDEV(" + dataSet.getWorksheet().Name + "!" + variables[index].Range + ")"; sheet.Cells[row, column + 4] = "=MAX(" + dataSet.getWorksheet().Name + "!" + variables[index].Range + ")"; sheet.Cells[row, column + 5] = "=MIN(" + dataSet.getWorksheet().Name + "!" + variables[index].Range + ")"; sheet.Cells[row, column + 6] = (double)(sheet.Cells[row, column + 4] as Range).Value - (double)(sheet.Cells[row, column + 5] as Range).Value; totMean = totMean + Convert.ToDouble((sheet.Cells[row, column + 2] as Range).Value); totStd = totStd + (Convert.ToDouble((sheet.Cells[row, column + 3] as Range).Value)); ArrayIndex[index] = index; var cellValue = (double)(sheet.Cells[row, column + 2] as Range).Value; if (cellValue < -214682680) { cellValue = 0; // if cellValue is the result of a division by 0, set value to 0 } averages[index] = cellValue; cellValue = (double)(sheet.Cells[row, column + 6] as Range).Value; Rvalues[index] = cellValue; } totMean = all.Average(); totStd = sheet.Application.WorksheetFunction.StDev(all); //totMean = totMean / variables.Count; //totStd = totStd / variables.Count; if (dataSet.getVariableNamesInFirstRowOrColumn()) { correctionFactor1 = constantC4[variables.Count - 1]; correctionFactor2 = constantD2[variables.Count - 1]; } else { correctionFactor1 = constantC4[variables.Count]; } correctionFactor2 = constantD2[variables.Count]; System.Diagnostics.Debug.WriteLine(totStd); double sigma = totStd; double Cp = (USL - LSL) / (6 * sigma); double Cpk = Math.Min((USL - totMean) / (3 * sigma), (totMean - LSL) / (3 * sigma)); double Pbelow = sheet.Application.WorksheetFunction.NormDist(LSL, totMean, totStd, true); double Pabove = 1.0 - sheet.Application.WorksheetFunction.NormDist(USL, totMean, totStd, true); row = 1; column = 1; sheet.Cells[row, column + 8] = "LSL"; sheet.Cells[row, column + 9] = "USL"; sheet.Cells[row, column + 10] = "Cp"; sheet.Cells[row, column + 11] = "Cpk"; sheet.Cells[row, column + 12] = "P(below LSL)"; sheet.Cells[row, column + 13] = " Per million"; sheet.Cells[row, column + 14] = "P(above USL)"; sheet.Cells[row, column + 15] = " Per million"; row++; sheet.Cells[row, column + 8] = LSL; sheet.Cells[row, column + 9] = USL; sheet.Cells[row, column + 10] = Cp; sheet.Cells[row, column + 11] = Cpk; sheet.Cells[row, column + 12] = Pbelow; sheet.Cells[row, column + 13] = Pbelow * 1000000; sheet.Cells[row, column + 14] = Pabove; sheet.Cells[row, column + 15] = Pabove * 1000000; }
public void generateXRChart(List <Variable> variables, int startindex, int stopindex, int plotstartindex, int plotstopindex, DataSet dataSet, int offset, _Worksheet sheet) { int counter = 0; int index = 0; int row = 1; int column = 1; double xControlLimitFactor, rControlLimitFactor1, rControlLimitFactor2; double[] averages = new double[dataSet.rangeSize()]; double[] Rvalues = new double[dataSet.rangeSize()]; double[] averageOfAverages = new double[dataSet.rangeSize()]; double[] xChartUpperControlLimit = new double[dataSet.rangeSize()]; //amountOfVariables() double[] xChartLowerControlLimit = new double[dataSet.rangeSize()]; double[] rChartUpperControlLimit = new double[dataSet.rangeSize()]; double[] rChartLowerControlLimit = new double[dataSet.rangeSize()]; double[] averageOfRvalues = new double[dataSet.rangeSize()]; double[] RvaluesInRange = new double[stopindex - startindex]; // +1 double[] averageOfAveragesInRange = new double[stopindex - startindex]; // +1 int[] ArrayIndex = new int[plotstopindex - plotstartindex + 1]; // +1 double[] xChartConstants = new double[25] { 0.0, 1.128, 1.693, 2.059, 2.326, 2.534, 2.704, 2.847, 2.970, 3.078, 3.173, 3.258, 3.336, 3.407, 3.472, 3.532, 3.588, 3.640, 3.689, 3.735, 3.778, 3.819, 3.858, 3.895, 3.931 }; double[] rChartConstants1 = new double[25] { 0, 0, 0, 0, 0, 0, 0.076, 0.136, 0.184, 0.223, 0.256, 0.283, 0.307, 0.328, 0.347, 0.363, 0.378, 0.391, 0.403, 0.415, 0.425, 0.434, 0.443, 0.451, 0.459 }; double[] rChartConstants2 = new double[25] { 0, 3.267, 2.574, 2.282, 2.114, 2.004, 1.924, 1.864, 1.816, 1.777, 1.744, 1.717, 1.693, 1.672, 1.653, 1.637, 1.662, 1.607, 1.597, 1.585, 1.575, 1.566, 1.557, 1.548, 1.541 }; sheet.Cells[row, column] = "Index"; sheet.Cells[row, column + 1] = "Observation"; sheet.Cells[row, column + 2] = "Average"; sheet.Cells[row, column + 3] = "Max"; sheet.Cells[row, column + 4] = "Min"; sheet.Cells[row, column + 5] = "R"; string colLetter = variables[0].Range[1].ToString(); int columnIndex = ColumnLetterToColumnIndex(colLetter); int columnIndex2 = columnIndex + variables.Count - 1; string colLetter2 = ColumnIndexToColumnLetter(columnIndex2); char chstart = variables[0].Range[3]; int start = (int)Char.GetNumericValue(chstart); int final = 0; for (counter = 1; counter <= dataSet.rangeSize(); counter++) //amountOfVariables() { row++; for (index = 0; index < variables.Count; index++) { sheet.Cells[row, column] = counter; if (variables.Count > 1) { sheet.Cells[row, column + 1] = variables[0].name + "-" + variables[variables.Count - 1].name; } else { sheet.Cells[row, column + 1] = variables[index].name; } } int temp = counter; if (dataSet.getVariableNamesInFirstRowOrColumn()) { temp = counter + 1; } sheet.Cells[row, column + 2] = "=AVERAGE(" + dataSet.getWorksheet().Name + "!$" + colLetter + "$" + start + ":$" + colLetter2 + "$" + temp + ")"; sheet.Cells[row, column + 3] = "=MAX(" + dataSet.getWorksheet().Name + "!$" + colLetter + "$" + temp + ":$" + colLetter2 + "$" + temp + ")"; sheet.Cells[row, column + 4] = "=MIN(" + dataSet.getWorksheet().Name + "!$" + colLetter + "$" + temp + ":$" + colLetter2 + "$" + temp + ")"; sheet.Cells[row, column + 5] = (double)(sheet.Cells[row, column + 3] as Range).Value - (double)(sheet.Cells[row, column + 4] as Range).Value; var cellValue = (double)sheet.Cells[row, column + 2].Value; if (cellValue < -214682680) { cellValue = 0; // if cellValue is the result of a division by 0, set value to 0 } averages[counter - 1] = cellValue; cellValue = (double)(sheet.Cells[row, column + 5] as Range).Value; Rvalues[counter - 1] = cellValue; start = start + 1; final = temp; } for (counter = startindex; counter < stopindex; counter++) { RvaluesInRange[counter - startindex] = Rvalues[counter]; averageOfAveragesInRange[counter - startindex] = averages[counter]; } if (dataSet.getVariableNamesInFirstRowOrColumn()) { xControlLimitFactor = xChartConstants[variables.Count - 1]; rControlLimitFactor1 = rChartConstants1[variables.Count - 1]; rControlLimitFactor2 = rChartConstants2[variables.Count - 1]; } else { xControlLimitFactor = xChartConstants[variables.Count]; rControlLimitFactor1 = rChartConstants1[variables.Count]; rControlLimitFactor2 = rChartConstants2[variables.Count]; } for (counter = 0; counter <= final - 2; counter++) { averageOfAverages[counter] = averageOfAveragesInRange.Average(); xChartUpperControlLimit[counter] = averageOfAveragesInRange.Average() + 3.0 * (Rvalues.Average() / (xControlLimitFactor * Math.Sqrt(variables.Count))); xChartLowerControlLimit[counter] = averageOfAveragesInRange.Average() - 3.0 * (Rvalues.Average() / (xControlLimitFactor * Math.Sqrt(variables.Count))); averageOfRvalues[counter] = RvaluesInRange.Average(); rChartUpperControlLimit[counter] = RvaluesInRange.Average() * rControlLimitFactor2; rChartLowerControlLimit[counter] = RvaluesInRange.Average() * rControlLimitFactor1; } // new subsets of arrays for plotting data double[] plotaverages = new double[plotstopindex - plotstartindex + 1]; double[] plotRvalues = new double[plotstopindex - plotstartindex + 1]; double[] plotaverageOfAverages = new double[plotstopindex - plotstartindex + 1]; double[] plotxChartUpperControlLimit = new double[plotstopindex - plotstartindex + 1]; double[] plotxChartLowerControlLimit = new double[plotstopindex - plotstartindex + 1]; double[] plotrChartUpperControlLimit = new double[plotstopindex - plotstartindex + 1]; double[] plotrChartLowerControlLimit = new double[plotstopindex - plotstartindex + 1]; double[] plotaverageOfRvalues = new double[plotstopindex - plotstartindex + 1]; for (int i = plotstartindex; i <= plotstopindex; i++) { ArrayIndex[i - plotstartindex] = i; plotaverages[i - plotstartindex] = averages[i]; plotRvalues[i - plotstartindex] = Rvalues[i]; plotaverageOfAverages[i - plotstartindex] = averageOfAverages[i]; plotxChartUpperControlLimit[i - plotstartindex] = xChartUpperControlLimit[i]; plotxChartLowerControlLimit[i - plotstartindex] = xChartLowerControlLimit[i]; plotrChartUpperControlLimit[i - plotstartindex] = rChartUpperControlLimit[i]; plotrChartLowerControlLimit[i - plotstartindex] = rChartLowerControlLimit[i]; plotaverageOfRvalues[i - plotstartindex] = averageOfRvalues[i]; } var Xcharts = (ChartObjects)sheet.ChartObjects(); var XchartObject = Xcharts.Add(340, 20, 550, 300); var Xchart = XchartObject.Chart; Xchart.ChartType = XlChartType.xlXYScatterLines; Xchart.ChartWizard(Title: "X-Chart " + dataSet.Name, HasLegend: true); var XseriesCollection = (SeriesCollection)Xchart.SeriesCollection(); var avgseries = XseriesCollection.NewSeries(); var avgAvgseries = XseriesCollection.NewSeries(); var UCLseries = XseriesCollection.NewSeries(); var LCLseries = XseriesCollection.NewSeries(); avgseries.Name = ("Observation Averages"); avgAvgseries.Name = ("Center Line"); UCLseries.Name = ("UCL"); LCLseries.Name = ("LCL"); avgseries.Values = plotaverages; avgAvgseries.Values = plotaverageOfAverages; UCLseries.Values = plotxChartUpperControlLimit; LCLseries.Values = plotxChartLowerControlLimit; avgseries.XValues = ArrayIndex; UCLseries.XValues = ArrayIndex; LCLseries.XValues = ArrayIndex; avgAvgseries.XValues = ArrayIndex; var Rcharts = (ChartObjects)sheet.ChartObjects(); var RchartObject = Rcharts.Add(340, 20 + offset, 550, 300); var Rchart = RchartObject.Chart; Rchart.ChartType = XlChartType.xlXYScatterLines; Rchart.ChartWizard(Title: "R-Chart " + dataSet.Name, HasLegend: true); var RseriesCollection = (SeriesCollection)Rchart.SeriesCollection(); var rSeries = RseriesCollection.NewSeries(); var averageRSeries = RseriesCollection.NewSeries(); var UCLSeries = RseriesCollection.NewSeries(); var LCLSeries = RseriesCollection.NewSeries(); rSeries.Name = ("Observation R"); averageRSeries.Name = ("Center Line"); UCLSeries.Name = ("UCL"); LCLSeries.Name = ("LCL"); rSeries.Values = plotRvalues; averageRSeries.Values = plotaverageOfRvalues; UCLSeries.Values = plotrChartUpperControlLimit; LCLSeries.Values = plotrChartLowerControlLimit; rSeries.XValues = ArrayIndex; averageRSeries.XValues = ArrayIndex; UCLSeries.XValues = ArrayIndex; LCLSeries.XValues = ArrayIndex; }
public void generateXRChart(int startindex, int stopindex, int plotstartindex, int plotstopindex, DataSet dataSet, int offset, _Worksheet sheet) { // declaration of variables int index = 0; int row = 1; int column = 1; double xControlLimitFactor, rControlLimitFactor1, rControlLimitFactor2; double[] averages = new double[dataSet.amountOfVariables()]; double[] Rvalues = new double[dataSet.amountOfVariables()]; double[] averageOfAverages = new double[dataSet.amountOfVariables()]; double[] xChartUpperControlLimit = new double[dataSet.amountOfVariables()]; double[] xChartLowerControlLimit = new double[dataSet.amountOfVariables()]; double[] rChartUpperControlLimit = new double[dataSet.amountOfVariables()]; double[] rChartLowerControlLimit = new double[dataSet.amountOfVariables()]; double[] averageOfRvalues = new double[dataSet.amountOfVariables()]; double[] RvaluesInRange = new double[stopindex - startindex + 1]; double[] averageOfAveragesInRange = new double[stopindex - startindex + 1]; int[] ArrayIndex = new int[plotstopindex - plotstartindex + 1]; double[] xChartConstants = new double[25] { 0.0, 1.880, 1.023, 0.729, 0.577, 0.483, 0.419, 0.373, 0.337, 0.308, 0.285, 0.266, 0.249, 0.235, 0.223, 0.212, 0.203, 0.194, 0.187, 0.180, 0.173, 0.167, 0.162, 0.157, 0.153 }; double[] rChartConstants1 = new double[25] { 0, 0, 0, 0, 0, 0, 0.076, 0.136, 0.184, 0.223, 0.256, 0.283, 0.307, 0.328, 0.347, 0.363, 0.378, 0.391, 0.403, 0.415, 0.425, 0.434, 0.443, 0.451, 0.459 }; double[] rChartConstants2 = new double[25] { 0, 3.267, 2.574, 2.282, 2.114, 2.004, 1.924, 1.864, 1.816, 1.777, 1.744, 1.717, 1.693, 1.672, 1.653, 1.637, 1.662, 1.607, 1.597, 1.585, 1.575, 1.566, 1.557, 1.548, 1.541 }; // write labels to sheet sheet.Cells[row, column] = "Index"; sheet.Cells[row, column + 1] = "Observation"; sheet.Cells[row, column + 2] = "Average"; sheet.Cells[row, column + 3] = "Max"; sheet.Cells[row, column + 4] = "Min"; sheet.Cells[row, column + 5] = "R"; // write values to sheet for (index = 1; index < dataSet.amountOfVariables(); index++) { row++; sheet.Cells[row, column] = index - 1; sheet.Cells[row, column + 1] = dataSet.getVariables()[index].name; sheet.Cells[row, column + 2] = "=AVERAGE(" + dataSet.getWorksheet().Name + "!" + dataSet.getVariables()[index].Range + ")"; sheet.Cells[row, column + 3] = "=MAX(" + dataSet.getWorksheet().Name + "!" + dataSet.getVariables()[index].Range + ")"; sheet.Cells[row, column + 4] = "=MIN(" + dataSet.getWorksheet().Name + "!" + dataSet.getVariables()[index].Range + ")"; sheet.Cells[row, column + 5] = (double)(sheet.Cells[row, column + 3] as Range).Value - (double)(sheet.Cells[row, column + 4] as Range).Value; var cellValue = (double)sheet.Cells[row, column + 2].Value; if (cellValue < -214682680) { cellValue = 0; // if cellValue is the result of a division by 0, set value to 0 } averages[index - 1] = cellValue; cellValue = (double)(sheet.Cells[row, column + 5] as Range).Value; Rvalues[index - 1] = cellValue; } // make arrays for calculation within limits for (index = startindex; index <= stopindex; index++) { RvaluesInRange[index - startindex] = Rvalues[index]; averageOfAveragesInRange[index - startindex] = averages[index]; } // create variable to limit amount of subsamples in 1 measurement to 25 int safe; if (dataSet.rangeSize() > 24) { safe = 24; } else { safe = dataSet.rangeSize(); } if (dataSet.getVariableNamesInFirstRowOrColumn()) { xControlLimitFactor = xChartConstants[safe - 1]; rControlLimitFactor1 = rChartConstants1[safe - 1]; rControlLimitFactor2 = rChartConstants2[safe - 1]; } else { xControlLimitFactor = xChartConstants[safe]; } rControlLimitFactor1 = rChartConstants1[safe]; rControlLimitFactor2 = rChartConstants2[safe]; for (index = 0; index < dataSet.amountOfVariables(); index++) { averageOfAverages[index] = averageOfAveragesInRange.Average(); xChartUpperControlLimit[index] = averageOfAveragesInRange.Average() + (xControlLimitFactor * Rvalues.Average()); xChartLowerControlLimit[index] = averageOfAveragesInRange.Average() - (xControlLimitFactor * Rvalues.Average()); averageOfRvalues[index] = RvaluesInRange.Average(); rChartUpperControlLimit[index] = RvaluesInRange.Average() * rControlLimitFactor2; rChartLowerControlLimit[index] = RvaluesInRange.Average() * rControlLimitFactor1; } // new subsets of arrays for plotting data double[] plotaverages = new double[plotstopindex - plotstartindex + 1]; double[] plotRvalues = new double[plotstopindex - plotstartindex + 1]; double[] plotaverageOfAverages = new double[plotstopindex - plotstartindex + 1]; double[] plotxChartUpperControlLimit = new double[plotstopindex - plotstartindex + 1]; double[] plotxChartLowerControlLimit = new double[plotstopindex - plotstartindex + 1]; double[] plotrChartUpperControlLimit = new double[plotstopindex - plotstartindex + 1]; double[] plotrChartLowerControlLimit = new double[plotstopindex - plotstartindex + 1]; double[] plotaverageOfRvalues = new double[plotstopindex - plotstartindex + 1]; for (int i = plotstartindex; i <= plotstopindex; i++) { ArrayIndex[i - plotstartindex] = i; plotaverages[i - plotstartindex] = averages[i]; plotRvalues[i - plotstartindex] = Rvalues[i]; plotaverageOfAverages[i - plotstartindex] = averageOfAverages[i]; plotxChartUpperControlLimit[i - plotstartindex] = xChartUpperControlLimit[i]; plotxChartLowerControlLimit[i - plotstartindex] = xChartLowerControlLimit[i]; plotrChartUpperControlLimit[i - plotstartindex] = rChartUpperControlLimit[i]; plotrChartLowerControlLimit[i - plotstartindex] = rChartLowerControlLimit[i]; plotaverageOfRvalues[i - plotstartindex] = averageOfRvalues[i]; } var Xcharts = (ChartObjects)sheet.ChartObjects(); var XchartObject = Xcharts.Add(340, 20, 550, 300); var Xchart = XchartObject.Chart; Xchart.ChartType = XlChartType.xlXYScatterLines; Xchart.ChartWizard(Title: "X-Chart " + dataSet.Name, HasLegend: true); var XseriesCollection = (SeriesCollection)Xchart.SeriesCollection(); var avgseries = XseriesCollection.NewSeries(); var avgAvgseries = XseriesCollection.NewSeries(); var UCLseries = XseriesCollection.NewSeries(); var LCLseries = XseriesCollection.NewSeries(); avgseries.Name = ("Observation Averages"); avgAvgseries.Name = ("Center Line"); UCLseries.Name = ("UCL"); LCLseries.Name = ("LCL"); avgseries.Values = plotaverages; avgAvgseries.Values = plotaverageOfAverages; UCLseries.Values = plotxChartUpperControlLimit; LCLseries.Values = plotxChartLowerControlLimit; avgseries.XValues = ArrayIndex; UCLseries.XValues = ArrayIndex; LCLseries.XValues = ArrayIndex; avgAvgseries.XValues = ArrayIndex; var Rcharts = (ChartObjects)sheet.ChartObjects(); var RchartObject = Rcharts.Add(340, 20 + offset, 550, 300); var Rchart = RchartObject.Chart; Rchart.ChartType = XlChartType.xlXYScatterLines; Rchart.ChartWizard(Title: "R-Chart " + dataSet.Name, HasLegend: true); var RseriesCollection = (SeriesCollection)Rchart.SeriesCollection(); var rSeries = RseriesCollection.NewSeries(); var averageRSeries = RseriesCollection.NewSeries(); var UCLSeries = RseriesCollection.NewSeries(); var LCLSeries = RseriesCollection.NewSeries(); rSeries.Name = ("Observation R"); averageRSeries.Name = ("Center Line"); UCLSeries.Name = ("UCL"); LCLSeries.Name = ("LCL"); rSeries.Values = plotRvalues; averageRSeries.Values = plotaverageOfRvalues; UCLSeries.Values = plotrChartUpperControlLimit; LCLSeries.Values = plotrChartLowerControlLimit; rSeries.XValues = ArrayIndex; averageRSeries.XValues = ArrayIndex; UCLSeries.XValues = ArrayIndex; LCLSeries.XValues = ArrayIndex; }
public static DataSet modify(DataSet dataSet, string newRange) { string tmp = dataSet.Range; int temp = tmp.IndexOf(':'); int start = tmp.IndexOf('$', temp + 1) + 1; char[] ch = tmp.ToCharArray(); ch[start] = newRange.ToCharArray()[0]; string newtmp = new string(ch); System.Diagnostics.Debug.WriteLine(tmp); System.Diagnostics.Debug.WriteLine(newtmp); Range range = dataSet.getWorksheet().Range[newtmp]; range.Select(); List <Variable> variables = createVariables(dataSet.getWorksheet(), range, dataSet.getRangeLayout(), dataSet.getVariableNamesInFirstRowOrColumn()); DataSet test = new DataSet(dataSet.getWorksheet(), range, dataSet.getName(), dataSet.getRangeLayout(), dataSet.getVariableNamesInFirstRowOrColumn(), variables); return(test); }