APLX Help : System Classes : The Chart and Series Objects : Using the Chart Object
|
|
![]() |
Using the Chart Object |
The main steps you need to carry out to create a chart are as follows:
The Chart object responds dynamically to each change you make. (You can
switch this off using the
Here is an example of a function which produces a simple chart showing two different series: ∇Chart_Microsoft;MS;data;years;revenue;income;⎕IO [1] ⍝ Sample line chart [2] MS←'⎕' ⎕NEW 'Window' ⋄ MS.title←'Sample chart' [3] MS.Chart.New 'Chart' ⋄ MS.Chart.align←¯1 ⋄ MS.Chart.type←'line' [4] MS.Chart.title←'Microsoft Financials FY 1985-2004' [5] MS.Chart.yaxislabel←'$ Millions' [6] ⍝ [7] MS.Chart.s1.New 'series' ⋄ MS.Chart.s1.caption←'Revenue' [8] MS.Chart.s2.New 'series' ⋄ MS.Chart.s2.caption←'Net Income' [9] ⍝ [10] ⍝ Set up data [11] ⎕IO←0 [12] years←1985+⍳20 [13] revenue←140 198 346 591 805 1186 1847 2777 3786 4714 6075 [14] revenue←revenue,9050 11936 15262 19747 22956 25296 28365 32187 36835 [15] income←24 39 72 124 171 279 463 708 953 1146 1453 [16] income←income,2195 3454 4490 7785 9421 7346 5355 7531 8168 [17] ⍝ [18] MS.Chart.s1.yvalues←revenue ⋄ MS.Chart.s1.xvalues←years [19] MS.Chart.s2.yvalues←income ⋄ MS.Chart.s2.xvalues←years ∇ This produces a window which contains the following chart: (Note that the number of ticks and labels shown may vary as the window is resized). We
can now customize the Chart object in various ways. For example, we
can use the MS.Chart.subtitle←'(since IPO)' MS.Chart.note←'Source: Microsoft Inc' MS.Chart.style←(1+8) The graph will now look like this: We can also set attributes of the individual series. For example, we might want the 'Net Income' line to be displayed as a dotted line, in green: MS.Chart.s2.linetype←2 MS.Chart.s2.color←0 180 0 |
|
APLX Help : System Classes : The Chart and Series Objects : Using the Chart Object
|
Copyright © 1996-2010 MicroAPL Ltd