Search This Blog

Wednesday, November 26, 2014

SQR: How to create Summary Charts using print-chart

Usually Summary reports, show up break up of count of records processed of the total records.
Representing these Summary reports through diagrams will help client understand better.

 Declare-Chart is used to describe the layout of the chart.
Array is created to store data.
Through Print-Chart we read data from Array and print onto the chart.

Below is one sample code to retrieve data and display in chart.

Begin-Setup
 Create-Array    ! This Array is passed to the Print-Chart
    Name = emp_hired
    Size = 10    ! Maximum of 10 rows of data
    Field = count:number:3    ! Fields in each row
  Declare-Chart tot_emp_hired
    Chart-Size = ( 30,30)
    Title = 'Employee Fetched'
    Type = histogram
    3D-Effects = yes
    X-Axis-Label = 'Company'
    Y-Axis-Label = 'Employee Hired'
  End-Declare
End-Setup

begin-program
 do Stdapi-Init        !stdapi.sqc
 do Init-DateTime    ! datetime.sqc
 do Init-Number        ! number.sqc
 do Get-Current-DateTime! curdttim.sqc
 do EmpChartReport
 do Stdapi-Term            !stdapi.sqc
end-program

begin-procedure EmpChartReport
! Load the array with the Chart Data. Max rows is specified in Create-Array
  Put  20
  Into emp_hired(0)  count(0)
  Put  12
  Into emp_hired(1)  count(0)   
  Put  4
  Into emp_hired(2)  count(0)

  Move 5 TO #x
  Move 10 TO #y
  Move 3 TO #row
  Move 3 TO #col

 Print-Chart tot_emp_hired (#x,#y)
    Fill = color
    Sub-Title = 'Employee hired report'
    Data-Array-Row-Count = #row   
    Data-Array-Column-Count = #col
    Data-Array-Column-Labels = ('ABC1', 'ABC2', 'ABC3')
    Data-Array = emp_hired
end-procedure

Sample Output:

No comments: