Difference: CDOverviewDatasetDefinition (6 vs. 7)

Revision 72011-12-22 - JeanNeron

Line: 1 to 1
 
META TOPICPARENT name="CDChartDirectorDesignerAPI"

Datasets Overview

Line: 20 to 20
  The following code illustrates adding a layer of data to a bar chart:
Changed:
<
<
* ================================================================
*
* Add a bar chart layer to the chart
GOSUB 0CD .XY ADD BAR LAYER
*
* Add data group
GOSUB 0CD .LAYER ADD DATA GROUP
*
* Add dataset
GOSUB 0CD .LAYER ADD DATASET
* ================================================================
* Initialize dataset
* ================================================================
PASS 1 FIELD SHARE? N
GOSUB 0CD .DATASET INITIALIZE
*
* Link dataset to group
GOSUB 0CD .LAYER LINK DATASET
*
* ================================================================
* Add data to dataset
* ================================================================
*
PASS 85 FIELD SHARE? N
GOSUB 0CD .POINT ADD NEW
*
PASS 156 FIELD SHARE? N
GOSUB 0CD .POINT ADD NEW
*
PASS 179.5 FIELD SHARE? N
GOSUB 0CD .POINT ADD NEW
*
PASS 211 FIELD SHARE? N
GOSUB 0CD .POINT ADD NEW
*
PASS 123 FIELD SHARE? N
GOSUB 0CD .POINT ADD NEW
>
>
* ================================================================
*
* Add a bar chart layer to the chart
GOSUB 0CD .XY ADD BAR LAYER
*
* Add data group
GOSUB 0CD .LAYER ADD DATA GROUP
*
* Add dataset template
GOSUB 0CD .LAYER ADD DATASET TM
* ================================================================
* Initialize dataset
* ================================================================
PASS 1 FIELD SHARE? N
GOSUB 0CD .DATASET INITIALIZE
*
* Link dataset template to dataset
GOSUB 0CD .LAYER LINK DATASET TM
*
* ================================================================
* Add data to dataset
* ================================================================
*
PASS 85 FIELD SHARE? N
GOSUB 0CD .POINT ADD NEW
*
PASS 156 FIELD SHARE? N
GOSUB 0CD .POINT ADD NEW
*
PASS 179.5 FIELD SHARE? N
GOSUB 0CD .POINT ADD NEW
*
PASS 211 FIELD SHARE? N
GOSUB 0CD .POINT ADD NEW
*
PASS 123 FIELD SHARE? N
GOSUB 0CD .POINT ADD NEW
 
Changed:
<
<
In this example, there was only one set of data, so the default names were used for creating and linking the data. A more complicated example would be where we have network usage for 3 different servers for a one week period (Mon - Fri). First we would initialize a 'data set' for one of the servers (possibly naming it 'SERVER1') via .DATASET INITIALIZE. Then we would add each days network usage for that server via .POINT ADD NEW. We would repeat the steps for the second and third server, naming each 'data set' as appropriate. We now have three 'data sets' that contain the 'data points' of the network usage for each server. To plot this on a bar chart, we would create a 'Layer' for our chart via .XY ADD BAR LAYER, then add a 'data group' via.LAYER ADD DATA GROUP. Next we would add 'data set templates' for each of the 3 servers via .LAYER ADD DATASET. This defines the presentation of our chart, without referring to the actual data. To add the data to our chart, would use .LAYER LINK DATASET to link our previously entered data with the 'data set templates.
>
>
In this example, there was only one set of data, so the default names were used for creating and linking the data. A more complicated example would be where we have network usage for 3 different servers for a one week period (Mon - Fri). First we would initialize a 'data set' for one of the servers (possibly naming it 'SERVER1') via .DATASET INITIALIZE. Then we would add each days network usage for that server via .POINT ADD NEW. We would repeat the steps for the second and third server, naming each 'data set' as appropriate. We now have three 'data sets' that contain the 'data points' of the network usage for each server. To plot this on a bar chart, we would create a 'Layer' for our chart via .XY ADD BAR LAYER, then add a 'data group' via.LAYER ADD DATA GROUP. Next we would add 'data set templates' for each of the 3 servers via .LAYER ADD DATASET TM. This defines the presentation of our chart, without referring to the actual data. To add the data to our chart, would use .LAYER LINK DATASET TM to link our previously entered data with the 'data set templates.
  The following illustrates this example:
      *

Line: 35 to 35
 
    • Link the data to the data set templates PASS SERVER1 FIELD SHARE? N PASS DS1 FIELD SHARE? N
Changed:
<
<
GOSUB 0CD .LAYER LINK DATASET
>
>
GOSUB 0CD .LAYER LINK DATASET TM
  PASS SERVER2 FIELD SHARE? N PASS DS2 FIELD SHARE? N
Changed:
<
<
GOSUB 0CD .LAYER LINK DATASET
>
>
GOSUB 0CD .LAYER LINK DATASET TM
  PASS SERVER3 FIELD SHARE? N PASS DS3 FIELD SHARE? N
Changed:
<
<
GOSUB 0CD .LAYER LINK DATASET
>
>
GOSUB 0CD .LAYER LINK DATASET TM
  * GOSUB :RENDER CHART END
Line: 53 to 53
  GOSUB 0CD .LAYER ADD DATA GROUP * PASS DS1 FIELD SHARE? N
Changed:
<
<
GOSUB 0CD .LAYER ADD DATASET
>
>
GOSUB 0CD .LAYER ADD DATASET TM
  *
    • Set Legend Title PASS Server # 1 FIELD SHARE? N
Line: 66 to 66
 
    • Add second dataset to group * PASS DS2 FIELD SHARE? N
Changed:
<
<
GOSUB 0CD .LAYER ADD DATASET
>
>
GOSUB 0CD .LAYER ADD DATASET TM
  *
    • Set Legend Title and Layer Name PASS Server # 2 FIELD SHARE? N
Line: 79 to 79
 
    • Add third dataset to group * PASS DS3 FIELD SHARE? N
Changed:
<
<
GOSUB 0CD .LAYER ADD DATASET
>
>
GOSUB 0CD .LAYER ADD DATASET TM
  *
    • Set Legend Title and Layer Name PASS Server # 3 FIELD SHARE? N
Line: 265 to 265
  RETURN
Changed:
<
<
In this example, when we defined the data set templates, we gave each of them a name (DS1, DS2, DS3), and when we added our data sets, we gave each of them a name as well (SERVER1, SERVER2, SERVER3). We were then able to link the date set template with the data set via .LAYER LINK DATASET, passing it the specific names we wanted linked. If we wanted to render this chart with a different set of data, all we have to do is create 3 new data sets, relink them using .LAYER LINK DATASET, and then render the chart again. Notice when we called .XY ADD BAR LAYER, we passed the OFF parameter to suppress the automatic creation and linking of data groups, data set templates and data sets. Since we are managing this ourselves, we did not want the routine to do it for us. Also notice the technique of passing an empty field to .XY ADD BAR LAYER. We wanted to pass the first and third parameters, so we had to have a dummy field to pass as the second parameter (--- TEMP 1 in this case).
>
>
In this example, when we defined the data set templates, we gave each of them a name (DS1, DS2, DS3), and when we added our data sets, we gave each of them a name as well (SERVER1, SERVER2, SERVER3). We were then able to link the date set template with the data set via .LAYER LINK DATASET TM, passing it the specific names we wanted linked. If we wanted to render this chart with a different set of data, all we have to do is create 3 new data sets, relink them using .LAYER LINK DATASET TM, and then render the chart again. Notice when we called .XY ADD BAR LAYER, we passed the OFF parameter to suppress the automatic creation and linking of data groups, data set templates and data sets. Since we are managing this ourselves, we did not want the routine to do it for us. Also notice the technique of passing an empty field to .XY ADD BAR LAYER. We wanted to pass the first and third parameters, so we had to have a dummy field to pass as the second parameter (--- TEMP 1 in this case).
 

Comments

Read what other users have said about this page or add your own comments.

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback