View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

How to produce a graph

This tutorial will teach the reader how to produce a graph in Smalltalk.

1. Open the parcel manager and load the "BGOK" parcel.
graph_2.jpg

2. You should be able to see the new icon in the palette for editing canvas.
graph_3.jpg

3. Click the icon, and drop it in to the canvas.
Change the type of graph as you wish. This tutorial uses bar graph.
Also name the aspect field, such as "#graph" in this tutorial.
graph_4.jpg

4. Go to Data Series tab, and make new data sets.
For this tutorial, I'm making two new data sets, one for data itself and one for data labels.
For label data set, make sure you select label check box.
graph_5.jpg

5. Install the changes to your canvas and go to your system browser.
Initialize the graph as OrderedCollection. For example,
your_graph_name:= OrderedCollection new.

Now, you are free to add the data sets, using this format:
your_graph_name add: data_1.

Since we have two data sets, I'm going to add as arrays.
graph add: (Array with: 5 with: 'Apple'). 

This code makes sure that two data sets are added, one for "data" and one for "label".
Picture below show example code for this tutorial.
graph_6.jpg

6. Now, open your windowSpec.
You should be able to see the graph.
graph_7.jpg

7. If you have trouble: make sure that in the Definition tab in your class, superclass is set to
superclass: #{UI.something}
where "something" should be SimpleDialog, or etc.

Link to this Page