Listing 3: Script of cd button "Line Chart"
on mouseUp
initGraph
put minLine("xValue") into x1
put minLine("yValue") into y1
put maxLine("xValue") into x2
put maxLine("yValue") into y2
if the hilite of cd button "Achsenkreuz" = TRUE then
-- erst einmal Ränder abchecken
if x1 > 0 then put 0 into x1
if y1 > 0 then put 0 into y1
if x2 < 0 then put 0 into x2
if y2 < 0 then put 0 into y2
end if
-- dann skalieren
scale x1,y1, x2,y2
-- Achsenkreuz zeichnen
if the hilite of cd button "Achsenkreuz" = TRUE then
drawLineAxes x1, y2
else
drawSideAxes
end if
-- yAchse beschriften
choose text tool
set textSize to 9
if the hilite of cd button "Achsenkreuz" = TRUE then
click at xOrigin(x1), yOffset() - 12
set textAlign to Center
type item 1 of bg fld "yLabel"
click at xOrigin(x1), yOffset() - 2
type y2
click at xOrigin(x1), yMax() + 12
type y1
else
click at xOffset(), yOffset() - 10
set textAlign to Center
type item 1 of bg fld "yLabel"
click at xOffset() - 5, yOffset() + 5
set textAlign to Right
type y2
click at xOffset() - 5, yMax() + 5
type y1
end if
-- xAchse beschriften
if the hilite of cd button "Achsenkreuz" = TRUE then
click at xOffset() - 5, yOrigin(y2) + 5
set textAlign to Right
type x1
click at xMax(), yOrigin(y2) + 15
set textAlign to Center
type item 1 of bg fld "xLabel"
click at xMax() + 3, yOrigin(y2) + 5
set textAlign to Left
type x2
else
click at xOffset(), yMax() + 15
set textAlign to Center
type x1
click at xOffset() + (xMax() - xOffset())¬
DIV 2, yMax() + 15
type item 1 of bg fld "xLabel"
click at xMax(), yMax() + 15
type x2
end if
repeat with i = 1 to number of lines¬
in bg fld "xValue"
put convertX(line i of bg fld "xValue") into x
put convertY(line i of bg fld "yValue") into y
plotPoint x, y
if i > 1 then
-- den ersten Punkt überspringen
connectPoints prevx, prevy, x, y
end if
put x into prevx
put y into prevy
end repeat
closeGraph
end mouseUp
on plotPoint x, y
choose oval tool
drag from x-2, y-2 to x+2, y+2
end plotPoint
on connectPoints x1,y1, x2,y2
choose line tool
drag from x1, y1 to x2, y2
end connectPoints
Zurück zum Inhaltsverzeichnis |