/// <summary> /// Create trend sheet /// </summary> private void createTrendSheet(TrendTransferContent type, int facilityid, string pollutantCode) { this.ucStackColumnTime.Visible = false; this.ucStackColumnCompare.Visible = false; this.ucYearCompareSeries.Visible = false; this.compareTable.Visible = false; // Get time series data, used by all sub sheets List <TimeSeriesClasses.PollutantTransfers> data = getTimeSeriesData(facilityid, pollutantCode); // Time series sheet if (type == TrendTransferContent.TimeSeries) { ViewState[CONTENT_TYPE] = TrendTransferContent.TimeSeries; if (data != null && data.Count > 0) { this.ucStackColumnTime.Visible = true; Color[] colors = new Color[] { Global.ColorWasteWater }; ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None }; this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantTransferTrend.CODE_KG, colors, hatchStyles, null); //this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantTransferTrend.CODE_TNE, colors, null); List <TimeSeriesUtils.BarData> bars = new List <TimeSeriesUtils.BarData>(); foreach (var v in data) { string[] tip = new string[] { String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year), String.Format("{0}: {1}", Resources.GetGlobal("Common", "Quantity"), QuantityFormat.Format(v.Quantity, v.QuantityUnit)) }; TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData { Year = v.Year, Values = new double?[] { v.Quantity }, ToolTip = ToolTipFormatter.FormatLines(tip) }; bars.Add(cd); } this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYears(bars, showEPER)); } } // comparison if (type == TrendTransferContent.Comparison) { ViewState[CONTENT_TYPE] = TrendTransferContent.Comparison; if (data != null && data.Count > 0) { this.compareTable.Visible = true; // Create chart this.ucStackColumnCompare.Visible = true; Color[] colors = new Color[] { Global.ColorWasteWater }; ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None }; this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantTransferTrend.CODE_KG, colors, hatchStyles, null); //this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantTransferTrend.CODE_TNE, colors, null); // init year combo boxes this.ucYearCompareSeries.Visible = true; int year1 = this.ucYearCompareSeries.Year1; int year2 = this.ucYearCompareSeries.Year2; // reset resetLabels(); TimeSeriesClasses.PollutantTransfers data1 = data.Where(d => d.Year == year1).DefaultIfEmpty(new TimeSeriesClasses.PollutantTransfers(year1)).Single(); TimeSeriesClasses.PollutantTransfers data2 = data.Where(d => d.Year == year2).DefaultIfEmpty(new TimeSeriesClasses.PollutantTransfers(year2)).Single(); bool dataFound = data1 != null || data2 != null; if (dataFound) { TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData { Year = year1 }; TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData { Year = year2 }; if (data1 != null) { dataFrom.Values = new double?[] { data1.Quantity }; } if (data2 != null) { dataTo.Values = new double?[] { data2.Quantity }; } // from and to bar this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>() { dataFrom, dataTo }); updateTableLabels(data1, data2); } // display that no data found for the selected years this.lbNoDataForSelectedYears.Visible = !dataFound; } } }
/// <summary> /// Create trend sheet /// </summary> private void createTrendSheet(TrendTransferContent type, int facilityid, string pollutantCode) { this.ucStackColumnTime.Visible = false; this.ucStackColumnCompare.Visible = false; //this.ucYearCompareEPER.Visible = false; this.compareTable.Visible = false; // Get time series data, used by all sub sheets List <TimeSeriesClasses.PollutantTransfers> data = getTimeSeriesData(facilityid, pollutantCode); // comparison if (type == TrendTransferContent.Comparison) { ViewState[CONTENT_TYPE] = TrendTransferContent.Comparison; if (data != null && data.Count > 0) { this.compareTable.Visible = true; // Create chart this.ucStackColumnCompare.Visible = true; Color[] colors = new Color[] { Global.ColorWasteWater }; // init year combo boxes // this.ucYearCompareEPER.Visible = true; int year1 = this.ucYearCompareEPER.Year1; int year2 = this.ucYearCompareEPER.Year2; // reset resetLabels(); TimeSeriesClasses.PollutantTransfers data1 = data.Where(d => d.Year == year1).DefaultIfEmpty(new TimeSeriesClasses.PollutantTransfers(year1)).Single(); TimeSeriesClasses.PollutantTransfers data2 = data.Where(d => d.Year == year2).DefaultIfEmpty(new TimeSeriesClasses.PollutantTransfers(year2)).Single(); bool dataFound = data1 != null || data2 != null; if (data1.Quantity >= 100000) { this.ucStackColumnCompare.Initialize(colors.Length, StackColumnTypeEPER.Comparison, "TNE", colors, null); } else { this.ucStackColumnCompare.Initialize(colors.Length, StackColumnTypeEPER.Comparison, PollutantTransferTrend.CODE_KG, colors, null); } if (dataFound) { TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData { Year = year1 }; TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData { Year = year2 }; if (data1 != null) { dataFrom.Values = new double?[] { data1.Quantity }; } if (data2 != null) { dataTo.Values = new double?[] { data2.Quantity }; } // from and to bar this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>() { dataFrom, dataTo }); updateTableLabels(data1, data2); } // display that no data found for the selected years this.lbNoDataForSelectedYears.Visible = !dataFound; } } }