/// <summary>
    /// Label update
    /// </summary>
    private void updateTableLabels(TimeSeriesClasses.PollutantReleases data1, TimeSeriesClasses.PollutantReleases data2)
    {
        this.grdCompareDetails.Visible = true;

        List <CompareDetailElement> elements = new List <CompareDetailElement>();

        elements.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Total"),
                                              data1 != null ? QuantityFormat.Format(data1.Quantity, data1.QuantityUnit) : String.Empty,
                                              data2 != null ? QuantityFormat.Format(data2.Quantity, data2.QuantityUnit) : String.Empty));

        elements.Add(new CompareDetailElement(Resources.GetGlobal("Pollutant", "AccidentalQuantity"),
                                              data1 != null ? QuantityFormat.Format(data1.QuantityAccidental, data1.QuantityAccidentalUnit) : String.Empty,
                                              data2 != null ? QuantityFormat.Format(data2.QuantityAccidental, data2.QuantityAccidentalUnit) : String.Empty));

        // data binding
        this.grdCompareDetails.DataSource = elements;
        grdCompareDetails.DataBind();
    }
예제 #2
0
 protected string GetReportingFacilities(object obj)
 {
     TimeSeriesClasses.PollutantReleases row = (TimeSeriesClasses.PollutantReleases)obj;
     return(NumberFormat.Format(row.Facilities));
 }
예제 #3
0
 /// <summary>
 /// Data binding
 /// </summary>
 protected int GetYear(object obj)
 {
     TimeSeriesClasses.PollutantReleases row = (TimeSeriesClasses.PollutantReleases)obj;
     return(row.Year);
 }
    /// <summary>
    /// Create trend sheet
    /// </summary>
    private void createTrendSheet(TrendReleaseContent type, int facilityid, MediumFilter.Medium medium)
    {
        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.PollutantReleases> data = getTimeSeriesData(facilityid, medium);

        // Time series sheet
        if (type == TrendReleaseContent.TimeSeries)
        {
            ViewState[CONTENT_TYPE] = TrendReleaseContent.TimeSeries;
            if (data != null && data.Count > 0)
            {
                this.ucStackColumnTime.Visible = true;

                // initialize chart

                Color[]           colors      = getColors(medium);
                string[]          labelTexts  = new string[] { Resources.GetGlobal("Common", "Accidental"), Resources.GetGlobal("Common", "Controlled") };
                ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None, ChartHatchStyle.None };
                this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantReleaseTrend.CODE_KG, colors, hatchStyles, labelTexts);

                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("Pollutant", "ReleasesTotal"), QuantityFormat.Format(v.Quantity, v.QuantityUnit)),
                                                  String.Format("{0}: {1}", Resources.GetGlobal("Pollutant", "ReleasesAccidentalReleases"), QuantityFormat.Format(v.QuantityAccidental, v.QuantityAccidentalUnit)),
                                                  (v.AccidentalPercent > 0.0) ? String.Format("{0}: {1:F5}%", Resources.GetGlobal("Pollutant", "ReleasesAccidentalPercentValue"), v.AccidentalPercent) : String.Format("{0}: 0%", Resources.GetGlobal("Pollutant", "ReleasesAccidentalPercentValue")) };


                    TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData
                    {
                        Year    = v.Year,
                        Values  = new double?[] { TimeSeriesUtils.RangeValue(v.QuantityAccidental), TimeSeriesUtils.RangeValue(v.Quantity) - TimeSeriesUtils.RangeValue(v.QuantityAccidental) },
                        ToolTip = ToolTipFormatter.FormatLines(tip)
                    };
                    bars.Add(cd);
                }

                if ((medium == MediumFilter.Medium.Air) || (medium == MediumFilter.Medium.Water))
                {
                    this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYears(bars, showEPER));
                }
                if (medium == MediumFilter.Medium.Soil)
                {
                    this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYearsTimeSeries(bars, showEPER));
                }
            }
        }

        // comparison
        if (type == TrendReleaseContent.Comparison)
        {
            ViewState[CONTENT_TYPE] = TrendReleaseContent.Comparison;

            if (data != null && data.Count > 0)
            {
                this.compareTable.Visible = true;

                // Create chart
                this.ucStackColumnCompare.Visible = true;

                Color[]           colors      = getColors(medium);
                ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None, ChartHatchStyle.None };
                string[]          labelTexts  = new string[] { Resources.GetGlobal("Common", "Accidental"), Resources.GetGlobal("Common", "Controlled") };

                this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantReleaseTrend.CODE_KG, colors, hatchStyles, labelTexts);
                //this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantReleaseTrend.CODE_TNE, colors, labelTexts);

                // init year combo boxes
                this.ucYearCompareSeries.Visible = true;
                int year1 = this.ucYearCompareSeries.Year1;
                int year2 = this.ucYearCompareSeries.Year2;
                // reset
                resetLabels();

                TimeSeriesClasses.PollutantReleases data1 = data.Where(d => d.Year == year1).DefaultIfEmpty(new TimeSeriesClasses.PollutantReleases(year1)).Single();
                TimeSeriesClasses.PollutantReleases data2 = data.Where(d => d.Year == year2).DefaultIfEmpty(new TimeSeriesClasses.PollutantReleases(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.QuantityAccidental, data1.Quantity - data1.QuantityAccidental };
                    }

                    if (data2 != null)
                    {
                        dataTo.Values = new double?[] { data2.QuantityAccidental, data2.Quantity - data2.QuantityAccidental };
                    }

                    // 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;
            }
        }
    }
예제 #5
0
    /// <summary>
    /// Create trend sheet
    /// </summary>
    private void createTrendSheet(TrendReleaseContent type, int facilityid, MediumFilter.Medium medium)
    {
        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.PollutantReleases> data = getTimeSeriesData(facilityid, medium);



        // comparison
        if (type == TrendReleaseContent.Comparison)
        {
            ViewState[CONTENT_TYPE] = TrendReleaseContent.Comparison;

            if (data != null && data.Count > 0)
            {
                this.compareTable.Visible = true;

                // Create chart
                this.ucStackColumnCompare.Visible = true;

                Color[]  colors     = getColors(medium);
                string[] labelTexts = new string[] { "", Resources.GetGlobal("Common", "ControlledEPER") }; //, Resources.GetGlobal("Common", "Accidental") };

                // init year combo boxes
                // this.ucYearCompareEPER.Visible = true;
                int year1 = this.ucYearCompareEPER.Year1;
                int year2 = this.ucYearCompareEPER.Year2;
                // reset
                resetLabels();

                TimeSeriesClasses.PollutantReleases data1 = data.Where(d => d.Year == year1).DefaultIfEmpty(new TimeSeriesClasses.PollutantReleases(year1)).Single();
                TimeSeriesClasses.PollutantReleases data2 = data.Where(d => d.Year == year2).DefaultIfEmpty(new TimeSeriesClasses.PollutantReleases(year2)).Single();

                bool dataFound = data1 != null || data2 != null;

                if (data1.Quantity >= 100000)
                {
                    this.ucStackColumnCompare.Initialize(colors.Length, StackColumnTypeEPER.Comparison, "TNE", colors, labelTexts);
                }
                else
                {
                    this.ucStackColumnCompare.Initialize(colors.Length, StackColumnTypeEPER.Comparison, PollutantReleaseTrend.CODE_KG, colors, labelTexts);
                }


                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.QuantityAccidental, data1.Quantity - data1.QuantityAccidental };
                    }

                    if (data2 != null)
                    {
                        dataTo.Values = new double?[] { data2.QuantityAccidental, data2.Quantity - data2.QuantityAccidental };
                    }

                    // 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;
            }
        }
    }