public void BuildSummaryChartData(double timePeriod, string obsElement, string obsElementType, double obsValue, string obsValueType) { ChartDataClass tempElementDataClass; Hashtable tempElementLevelHash; // does the element type exist in the hash table? if (this.chartDataObsElementSummaryHashTable.ContainsKey(obsElementType)) { tempElementLevelHash = (Hashtable)this.chartDataObsElementSummaryHashTable[obsElementType]; //This is the hashtable that contains all the instances of the ElementType //Does the element exist in the hashtable if (tempElementLevelHash.ContainsKey(obsElement)) { tempElementDataClass = (ChartDataClass)tempElementLevelHash[obsElement]; tempElementDataClass.TimeData.Add(timePeriod.ToString(), obsValue.ToString()); tempElementDataClass.TimeStamps.Add(timePeriod); tempElementDataClass.HighData.Add(obsValue); } //if not, create a new element hash to contain it else { tempElementDataClass = new ChartDataClass(); tempElementDataClass.TimeData.Add(timePeriod.ToString(), obsValue.ToString()); tempElementDataClass.TimeStamps.Add(timePeriod); tempElementDataClass.HighData.Add(obsValue); tempElementLevelHash.Add(obsElement, tempElementDataClass); } } else { tempElementDataClass = new ChartDataClass(); tempElementDataClass.TimeData.Add(timePeriod.ToString(), obsValue.ToString()); tempElementDataClass.TimeStamps.Add(timePeriod); tempElementDataClass.HighData.Add(obsValue); tempElementLevelHash = new Hashtable(); tempElementLevelHash.Add(obsElement, tempElementDataClass); this.chartDataObsElementSummaryHashTable.Add(obsElementType, tempElementLevelHash); } }
public void Normalize(int durationOfModule) { Hashtable finalElementHT = new Hashtable(); Hashtable finalSubElementHT = new Hashtable(); Hashtable elementHashT = null; ChartDataClass replacementDataClass = new ChartDataClass(); ArrayList timepoints = new ArrayList(); for (double i = 0; i < durationOfModule; i++) { timepoints.Add(i); } ArrayList dataAtTimepoints = new ArrayList(); ArrayList dataAtIconType = new ArrayList(); double lastval = 0; double iconlastval = 1.0; foreach (string elementLevel in this.chartDataObsElementHashTable.Keys) { if (elementLevel != "InfoElement") // hack - skip info element data { elementHashT = (Hashtable)this.chartDataObsElementHashTable[elementLevel]; finalSubElementHT = new Hashtable(); lastval = 0; foreach (string ElementItems in elementHashT.Keys) { ChartDataClass tempDataClass = (ChartDataClass)elementHashT[ElementItems]; dataAtTimepoints = new ArrayList(); dataAtIconType = new ArrayList(); lastval = 0; iconlastval = 1.0; for (double i = 0; i < durationOfModule; i++) { if (tempDataClass.TimeStamps.Contains(i)) { lastval = tempDataClass.HighData[tempDataClass.TimeStamps.IndexOf(i)]; dataAtTimepoints.Add(lastval); iconlastval = tempDataClass.IconType[tempDataClass.TimeStamps.IndexOf(i)]; dataAtIconType.Add(iconlastval); } else { dataAtTimepoints.Add(lastval); dataAtIconType.Add(0.0); } } replacementDataClass = new ChartDataClass(); for (int k = 0; k < durationOfModule; k++) { replacementDataClass.TimeStamps.Add((double)timepoints[k]); replacementDataClass.HighData.Add((double)dataAtTimepoints[k]); replacementDataClass.IconType.Add((double)dataAtIconType[k]); replacementDataClass.TimeData.Add(timepoints[k].ToString(), dataAtTimepoints[k].ToString()); } finalSubElementHT[ElementItems] = replacementDataClass; } finalElementHT[elementLevel] = finalSubElementHT; } else { // info element finalElementHT[elementLevel] = (Hashtable)this.chartDataObsElementHashTable[elementLevel]; // use existing table } } this.chartDataObsElementHashTable = finalElementHT; }