Пример #1
0
        public override void DataBind()
        {
            if (!Visible)   // don't databind if we aren't going to use it.
            {
                return;
            }
            DataTable table = getTableFromObject(DataSource);

            //Normalize RaceLabelNames: Replace Old Race Labels with New labels:
            ReplaceOldRaceLabelsWithNew(table);

            //backwards compatibility
            if (SeriesColumnName == ColumnPicker.CommonGraphNames.OrgSchoolTypeLabel.ToString() &&
                !table.Columns.Contains(ColumnPicker.CommonGraphNames.OrgSchoolTypeLabel.ToString()))
            {
                SeriesColumnName = "OrgLevelLabel";
            }

            SaveOriginalAxisAndSeriesLabels(table);
            table = SortDataSource(table);
            table = TransformDataSource(table);
            GraphBarChart.OverrideSeriesColumnNames(table, customSeriesLabelsMap);
            GraphBarChart.ReplaceColumnValues(table, LabelColumnName, OverrideAxisXLabels);

            DataSource = table;

            base.DataBind();
            GraphHorizBarChart.SetSeriesColors(this.Series, SeriesColors);
            SetSeriesPatterns(this.Series, OverrideSeriesPatterns);
        }
Пример #2
0
        public static void ReplaceOldRaceLabelsWithNew(DataTable table)
        {
            if (!table.Columns.Contains(SligoCS.DAL.WI.v_Template_Keys_WWoDisEconELP.RaceShortLabel))
            {
                return;
            }

            Hashtable mapOldAndNewRaceLabels = new Hashtable();

            mapOldAndNewRaceLabels.Add("Black Not Hisp", "Black");
            mapOldAndNewRaceLabels.Add("White Not Hisp", "White");
            mapOldAndNewRaceLabels.Add("Comb.", "Combined Small N");
            mapOldAndNewRaceLabels.Add("Hisp", "Hispanic");

            GraphBarChart.ReplaceColumnValues(table, SligoCS.DAL.WI.v_Template_Keys_WWoDisEconELP.RaceShortLabel, mapOldAndNewRaceLabels);
        }
Пример #3
0
        private DataTable TransformDataSource(DataTable source)
        {
            DataTable table = null; //return

            if ((Type == StackedType.Stacked100 || Type == StackedType.Normal) &&
                MeasureColumns.Count > 0)
            {//transform for stacked bars
                table = GetMeasureColumnsAndCastAsDouble(source, MeasureColumns);
                table = GraphBarChart.TransferColumnsBetweenDS(source, table, new List <String>(new string[] { LabelColumnName }));
            }
            else //Simple bar (usually, but can be for stacked too)
            {
                table = pivotDataSet(source);
            }

            return(table);
        }
        public override void DataBind()
        {
            DataTable tbl = GraphBarChart.getTableFromObject(DataSource);

            //Normalize RaceLabelNames: Replace Old Race Labels with New labels:
            GraphBarChart.ReplaceOldRaceLabelsWithNew(tbl);

            tbl = TransformDataSource(tbl);

            GraphBarChart.OverrideSeriesColumnNames(tbl, customSeriesLabelsMap);

            DataSource = (object)tbl;
            Height     = (int)(Height.Value + tbl.Rows.Count * ((tbl.Rows.Count * AutoHeightIncreaseFactor > 35000) ? 1 : AutoHeightIncreaseFactor)); //multiply rowcount by 20, unless it will exceed the graph's Height Property Maximum (~35,000);
            base.DataBind();

            if (!String.IsNullOrEmpty(YAxisSuffix))
            {
                SetYAxisSuffix(YAxisSuffix);
            }
        }
        private DataTable TransformDataSource(DataTable table)
        {
            List <String> sortColumns;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            if (String.IsNullOrEmpty(OrderBy))
            {
                sortColumns = new List <string>(LabelColumns.ToArray());
            }
            else
            {
                sortColumns = new List <String>(OrderBy.Split(",".ToCharArray()));
            }

            sortColumns.ForEach(
                delegate(string col) {
                System.Text.StringBuilder column = new System.Text.StringBuilder(col);

                column.Replace("YearFormatted ASC", "YearFormatted");
                column.Replace("YearFormatted", "YearFormatted DESC");
                column.Replace("year ASC", "year");
                column.Replace("year", "year DESC");

                if (sb.Length > 1)
                {
                    sb.Append(",");
                }
                sb.Append(column);
            }
                );

            OrderBy = sb.ToString();

            //throw new Exception(sortColumns.Count.ToString());
            //throw new Exception(OrderBy);

            if (SelectedSortBySecondarySort)
            {
                if (LabelColumns.Count < 2)
                {
                    throw new Exception("Only one Label Column given with SelectedSortBySecondarySort is True.");
                }

                table = DataTableSorter.SecondarySortCompareSelectedFloatToTop(
                    table,
                    ((PageBaseWI)Page).QueryMarshaller, OrderBy
                    );
            }
            else
            {
                table = DataTableSorter.SortAndCompareSelectedFloatToTop(
                    table,
                    ((PageBaseWI)Page).QueryMarshaller, OrderBy
                    );
            }

            DataTable final = GraphBarChart.GetMeasureColumnsAndCastAsDouble(table, MeasureColumns);

            if (LabelColumns.Count > 1)
            {
                final = AddMergeRowStyleColumn(table, final, LabelColumns);
            }
            else
            {
                final = GraphBarChart.TransferColumnsBetweenDS(table, final, LabelColumns);
                //final = AddMergeRowStyleColumn(table, final, new List<String>(new String[]{LabelColumns[0], LabelColumns[0]}));
            }

            return(final);
        }