Example #1
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);
        }
        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);
        }