Column Graph Showing Sums

2 posts, 0 answers
  1. Brian
    Brian avatar
    4 posts
    Member since:
    Jan 2016

    Posted 04 Feb Link to this post

    I have a report with a stored procedure for a datasource, returning 196 rows, which contain current month and YTD sums of database fields.  I want to generate a column graph that displays 6 of these sum fields for all 196 rows.  Is it possible to display the sum aggregate function result of a field as a column in the graph?  For instance, Column1 would be the name of a field in my datasource.  I want to display the sum of all 196 Column1 fields as a column in the graph.  I have each of the 6 columns as GraphGroups and as BarSeries objects.  I think it's trying to graph values from every row, but I only want one entry, the sum.  This is my first Telerik report and graph.  Any help would be appreciated.

                 // 
                // graphMonthGrandTotals
                // 
                graphGroup1.Name = "categoryGroup";
                this.graphMonthGrandTotals.CategoryGroups.Add(graphGroup1);
                this.graphMonthGrandTotals.CoordinateSystems.Add(this.cartesianCoordinateSystem1);
                this.graphMonthGrandTotals.DataSource = this.sqlDataSource;
                this.graphMonthGrandTotals.Legend.Style.LineColor = System.Drawing.Color.LightGray;
                this.graphMonthGrandTotals.Legend.Style.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D);
                this.graphMonthGrandTotals.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.60000002384185791D), Telerik.Reporting.Drawing.Unit.Inch(1.4659316539764404D));
                this.graphMonthGrandTotals.Name = "graphMonthGrandTotals";
                this.graphMonthGrandTotals.PlotAreaStyle.LineColor = System.Drawing.Color.LightGray;
                this.graphMonthGrandTotals.PlotAreaStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D);
                this.graphMonthGrandTotals.Series.Add(this.barSeries1);
                this.graphMonthGrandTotals.Series.Add(this.barSeries2);
                this.graphMonthGrandTotals.Series.Add(this.barSeries3);
                this.graphMonthGrandTotals.Series.Add(this.barSeries4);
                this.graphMonthGrandTotals.Series.Add(this.barSeries5);
                this.graphMonthGrandTotals.Series.Add(this.barSeries6);
                graphGroup7.ChildGroups.Add(graphGroup2);
                graphGroup7.Groupings.Add(new Telerik.Reporting.Grouping("= Fields.Column1"));
                graphGroup7.Name = "column1Group";
                graphGroup7.Sortings.Add(new Telerik.Reporting.Sorting("= Fields.Column1", Telerik.Reporting.SortDirection.Asc));
                graphGroup6.ChildGroups.Add(graphGroup7);
                graphGroup6.Groupings.Add(new Telerik.Reporting.Grouping("= Fields.Column2"));
                graphGroup6.Name = "column2Group";
                graphGroup6.Sortings.Add(new Telerik.Reporting.Sorting("= Fields.Column2", Telerik.Reporting.SortDirection.Asc));
                graphGroup5.ChildGroups.Add(graphGroup6);
                graphGroup5.Groupings.Add(new Telerik.Reporting.Grouping("= Fields.Column3"));
                graphGroup5.Name = "column3Group";
                graphGroup5.Sortings.Add(new Telerik.Reporting.Sorting("= Fields.Column3", Telerik.Reporting.SortDirection.Asc));
                graphGroup4.ChildGroups.Add(graphGroup5);
                graphGroup4.Groupings.Add(new Telerik.Reporting.Grouping("= Fields.Column4"));
                graphGroup4.Name = "column4Group";
                graphGroup4.Sortings.Add(new Telerik.Reporting.Sorting("= Fields.Column4", Telerik.Reporting.SortDirection.Asc));
                graphGroup3.ChildGroups.Add(graphGroup4);
                graphGroup3.Groupings.Add(new Telerik.Reporting.Grouping("= Fields.Column5"));
                graphGroup3.Name = "column5Group";
                graphGroup3.Sortings.Add(new Telerik.Reporting.Sorting("= Fields.Column5", Telerik.Reporting.SortDirection.Asc));
                this.graphMonthGrandTotals.SeriesGroups.Add(graphGroup3);
                this.graphMonthGrandTotals.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(4.9000000953674316D), Telerik.Reporting.Drawing.Unit.Inch(2.5250000953674316D));
                graphTitle1.Position = Telerik.Reporting.GraphItemPosition.TopCenter;
                graphTitle1.Style.LineColor = System.Drawing.Color.LightGray;
                graphTitle1.Style.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D);
                graphTitle1.Text = "Showing Month Grand Totals";
                this.graphMonthGrandTotals.Titles.Add(graphTitle1);

                this.barSeries1.CategoryGroup = graphGroup1;
                this.barSeries1.CoordinateSystem = this.cartesianCoordinateSystem1;
                this.barSeries1.DataPointLabel = "Column1";
                this.barSeries1.DataPointLabelStyle.Visible = false;
                this.barSeries1.DataPointStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D);
                this.barSeries1.DataPointStyle.Visible = true;
                this.barSeries1.LegendItem.Value = "Column1";
                this.barSeries1.Name = "barSeries1";
                this.barSeries1.SeriesGroup = graphGroup2;
                this.barSeries1.Y = "= Sum(Fields.Column1)";

  2. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 08 Feb Link to this post

    Hello Brian,

    You can use the Graph Wizard and leave the Groups/Series boxes empty in the corresponding step of the wizard. Provide a data field only for the Values. The wizard will generate a graph showing data for all rows.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
Back to Top