Listing 4: Script of cd button "Pie Chart"on mouseUp global midX, midY, radius, totalY put SumY() into totalY initGraph drawBox put 2*pi into twoPi put 0 into oldAngle -- den Mittelpunkt der Zeichenfläche bestimmen put xOffset() + (xMax() - xOffset()) DIV 2 into midX put yOffset() + (yMax() - yOffset()) DIV 2 into midY put 120 into radius -- dann den Kuchen zeichnen drawCircle midX, midY, radius -- die erste Linie bei "3 Uhr" (0°) choose line tool drag from midX, midY to midX + radius, midY -- und für jeden x-Wert ein Segment einzeichnen repeat with i = 1 to number of lines¬ in bg fld "yValue" put (line i of bg fld "yValue")*twoPi/totalY¬ into newAngle drawRadius oldAngle + newAngle fillSegment i, oldAngle + (newAngle/2) add newAngle to oldAngle end repeat -- die Label werden in einem zweiten Durchgang -- eingegeben put 0 into oldAngle repeat with i = 1 to number of lines¬ in bg fld "yValue" put (line i of bg Fld "yValue")*twoPi/totalY¬ into newAngle makeLabel i, oldAngle + (newAngle/2) add newAngle to oldAngle end repeat closeGraph end mouseUp on drawCircle x, y, radius -- einen Kreis in der gewohnten Notation (x,y) -- und Radius zeichnen choose oval tool drag from round(x-radius), round(y-radius)¬ to round(x+radius), round(y+radius) end drawCircle function SumY put 0 into summe repeat with i = 1 to number of lines¬ in bg fld "yValue" add line i of bg fld "yValue" to summe end repeat return summe end SumY on drawRadius segAngle global midX, midY, radius put round(radius*cos(segAngle)) into x put round(radius*sin(segAngle)) into y choose line tool drag from midX, midY to midX + x, midY - y end drawRadius on fillSegment i, segAngle global midX, midY, radius put SumY() into totalY -- einen Punkt zum Klicken im Segment berechnen put midX + round((radius - 2)*cos(segAngle)) into x put midY - round((radius - 2)*sin(segAngle)) into y choose bucket tool set pattern to 12 + 2*i click at x, y end fillSegment on makeLabel i, segAngle global midX, midY, radius, totalY -- einen Punkt zum Klicken im Segment berechnen put midX + round((radius - 2)*cos(segAngle)) into x put midY - round((radius - 2)*sin(segAngle)) into y -- und jetzt die Werte einsetzen choose text tool click at x, y set textSize to 9 set textAlign to Center set the numberFormat to 0.## type line i of bg fld "xValue" & return &¬ (100*(line i of bg fld "yValue"))/TotalY && "%" end makeLabel Zurück zum Inhaltsverzeichnis |