Pie Chart problems with Reports

2 posts, 0 answers
  1. Ryan
    Ryan avatar
    6 posts
    Member since:
    Oct 2012

    Posted 31 Aug Link to this post

    Hello,

     

    I am trying to create a Pie chart in code, and it is not looking like a pie, i feel like an just missing a setting at the points, but all resources I have read/reviewed have not helped be finish it. Thank for any help!

    01.ObjectDataSource src = new ObjectDataSource(curScope,"GetData");
    02. 
    03.Telerik.Reporting.Graph test = new Graph()
    04.{
    05.    NoDataMessage = "Yes, we have no data",
    06.    Location = new PointU(Unit.Inch(0), Unit.Inch(0)),
    07.    Size = new SizeU(Unit.Inch(8.0D), Unit.Inch(3.0D)),
    08.    StyleName = "Normal.TableGroup",
    09.    DataSource = src,
    10.    Name = "graph"+colIndex.ToString()               
    11.};
    12. 
    13.test.Titles.Add(new GraphTitle() { Text = "% of" + ReportTitle });
    14. 
    15.BarSeries pie = new BarSeries();
    16.pie.Name = "pie" + colIndex.ToString();
    17.var pallet = new ColorPalette();
    18.pallet.AddColors(Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.Orange);
    19.pie.ColorPalette = pallet;
    20.test.ColorPalette = pallet;
    21. 
    22.GraphGroup category = new GraphGroup()
    23.{
    24.    Name = "cat1"
    25.};
    26.category.Groupings.Add("=Fields.IngredientName");
    27.pie.CategoryGroup = category;
    28.test.CategoryGroups.Add(category);
    29. 
    30.GraphGroup series = new GraphGroup()
    31.{
    32.    Name = "series1"
    33.};
    34.series.Groupings.Add("=Fields.PercentOfTotal");
    35.//series.Sortings.Add("=Sum(Fields.PercentOfTotal)", SortDirection.Desc);
    36.//series.Sortings.Add("=Fields.IngredientName", SortDirection.Asc);
    37.//series.Filters.Add("=Sum(Fields.PercentOfTotal)", FilterOperator.TopN, "20");
    38.pie.SeriesGroup = series;
    39.test.SeriesGroups.Add(series);
    40. 
    41.PolarCoordinateSystem polar = new PolarCoordinateSystem();
    42. 
    43.var radCat = new Telerik.Reporting.GraphAxis()
    44.{
    45.    Name = "radialAx1",
    46.    Scale = new CategoryScale()
    47.    {
    48.        //SpacingSlotCount = 0,
    49.        PositionMode = AxisPositionMode.OnTicks                   
    50.    }
    51.};
    52. 
    53.var angNum = new Telerik.Reporting.GraphAxis()
    54.{
    55.    Name = "angularAx1",
    56.    Scale = new NumericalScale()
    57.    {
    58.        //SpacingSlotCount = 1
    59.    }
    60.};
    61. 
    62.polar.Name = "polarScale";
    63.polar.RadialAxis = radCat;
    64.polar.RadialAxis.Style.Visible = false;
    65. 
    66.polar.AngularAxis = angNum;
    67.polar.AngularAxis.Style.Visible = false;
    68. 
    69.test.CoordinateSystems.Add(polar);
    70.pie.CoordinateSystem = polar;
    71.                      
    72.pie.X = "=IsNull(Sum(Fields.PercentOfTotal), 0)";
    73.pie.LegendItem.Value = "=Fields.IngredientName";
    74.pie.ArrangeMode = GraphSeriesArrangeMode.Stacked100;
    75.//pie.DataPointLabel = "Sum(Fields.PercentOfTotal)/1000";
    76.//pie.DataPointLabelFormat = "{0:C0}K";

  2. Stef
    Admin
    Stef avatar
    3044 posts

    Posted 01 Sep Link to this post

    Hello Ryan,

    There is no need to wrap instantiated data objects in data source components - Do I need to use a Data Source component? Also the recommended approach is to design a sample report with test data through the VS Report Designer. Then you can get the auto-generated code and adjust it for usage at run-time.

    For example start with How to: Create Pie Chart. Note that the Series.Groups grouping generates the different pies in the case - Graph Structure.
    Once you have the auto-generated code and modify it, you can test the created report definition by serializing the report instance in a TRDX file and opening it with the Standalone Report Designer.


    I hope this helps.

    Regards,
    Stef
    Telerik by Progress
    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