Listing 2: Script of cd button "Bar Chart"
on mouseUp
initGraph
drawSideAxes
set Filled to TRUE
-- y-Achse beschriften
choose text tool
set TextSize to 9 -- für die Achsenbeschriftung
set TextAlign to Right
click at xOffset() - 5, yMax() + 5
type "0"
click at xOffset() - 5, yOffset() + 5
type maxLine("yValue")
repeat with i = 1 to number of lines¬
in bg fld "xValue"
drawBars i, line i of bg fld "yValue"
end repeat
closeGraph
end mouseUp
on drawBars x, y
-- Skalieren
put (xMax() - xOffset())/¬
(the number of lines in¬
bg fld "xValue") into maxBars
put round(3*maxBars/4) into barWidth
put (maxBars - barWidth) DIV 2 into barDist
scale 0, 0, maxBars, maxLine("yValue")
put round(barDist + xOffset() + (x - 1)*maxBars)¬
into barLeft
put convertY(y) into barTop
-- und Balkendiagramme zeichnen
choose rectangle tool
-- für jeden Balken eine andere Füllung wählen
set pattern to 12 + x
drag from barLeft, yMax() to¬
barLeft + barWidth, barTop
-- und beschriften
typeString barLeft + barDist, yMax() + 15,¬
line x of bg fld "xValue"
end drawBars
on typeString x, y, String
choose text tool
set textAlign to left
click at x, y
type String
end typeString
Zurück zum Inhaltsverzeichnis |