1 此方法适合用于图表和网格明细数据一致时使用
2
3 function ProcessBeginScript(Report)
4 {
5
6 var Chart = Report.ControlByName("Chart1").AsChart;
7 var Recordset = Report.DetailGrid.Recordset;
8
9 Chart.GroupCount=Recordset.RecordCount;
10 Chart.SeriesCount=Recordset.Fields.Count-1+1;
11 //首先将原来数据全部置为0
12 for (SeriesIndex=0; SeriesIndex<Chart.SeriesCount; ++SeriesIndex)
13 for (GroupIndex=0; GroupIndex<Chart.GroupCount; ++GroupIndex)
14 Chart.Value(SeriesIndex, GroupIndex) = 0;
15
16
17
18 var Index = 0;
19 Chart.SeriesLabel(5)=‘毛利‘;
20 Recordset.First();
21 while (Index < Recordset.RecordCount)
22 {
23 Chart.GroupLabel(Index)=Recordset.Fields.Item(1).value;
24
25 for(i=0; i<Recordset.Fields.Count-1; ++i)
26 {
27 Chart.SeriesLabel(i)=Recordset.Fields.Item(i+2).Name;
28 var Val=Recordset.Fields.Item(i+2).value;
29 Chart.Value(i,Index) = Val;
30 Chart.Value(i+1,Index) =Recordset.Fields.Item(2).value-Recordset.Fields.Item(3).value-Recordset.Fields.Item(5).value ;
31 }
32
33 ++Index;
34 Recordset.Next();
35 };
36
37 }