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";