Новости | FAQ | Авторы | Документация | В действии | Библиотека |
Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
pomah 20.06.2002 15:03
простейший график из вертикальных баров@CLASS graph @load[a;b] $x($a) $y($b) $gg[^image::create($x;$y;0xFFFFFF)] ^gg.bar(1;1;($x-4);($y-4);0) ^gg.bar(3;3;($x-2);($y-2);0) ^gg.bar(3;3;($x-6);($y-6);0xFFFFFF) @canvas[] $fromtop(30) $froml(40) $frombottom(10) $fromr(20) ^gg.bar($froml;($fromtop);($froml+2);($y-$frombottom);0xebebeb) ^gg.bar($froml;($y-$frombottom);($x-$fromr);($y-$frombottom-3);0xebebeb) $rect_coord[^table::create{x y ^eval($froml+7) ^eval($fromtop-5) ^eval($x-$fromr+4) ^eval($fromtop-4) ^eval($x-$fromr+4) ^eval($y-$frombottom-9) ^eval($froml+7) ^eval($y-$frombottom-9) }] ^gg.polybar(0xebebeb)[$rect_coord] $rect_coord[^table::create{x y $froml ^eval($fromtop-1) ^eval($froml+6) ^eval($fromtop-7) ^eval($x-$fromr+7) ^eval($fromtop-7) ^eval($x-$fromr+5) ^eval($fromtop-5) ^eval($froml+7) ^eval($fromtop-5) ^eval($froml+3) ^eval($fromtop-1) }] ^gg.polybar(0xb1b1b1)[$rect_coord] $rect_coord[^table::create{x y ^eval($froml+8) ^eval($y-$frombottom-8) ^eval($x-$fromr+4) ^eval($y-$frombottom-8) ^eval($x-$fromr) ^eval($y-$frombottom-4) ^eval($froml+4) ^eval($y-$frombottom-4) }] ^gg.polybar(0xb1b1b1)[$rect_coord] $rect_coord[^table::create{x y ^eval($x-$fromr+7) ^eval($fromtop-6) ^eval($x-$fromr+7) ^eval($y-$frombottom-7) ^eval($x-$fromr+1) ^eval($y-$frombottom-1) ^eval($x-$fromr+1) ^eval($y-$frombottom-4) ^eval($x-$fromr+5) ^eval($y-$frombottom-9) ^eval($x-$fromr+5) ^eval($fromtop-4) }] ^gg.polybar(0x767676)[$rect_coord] $rect_coord[^table::create{x y ^eval($froml+3) $fromtop ^eval($froml+7) ^eval($fromtop-4) ^eval($froml+7) ^eval($y-$frombottom-8) ^eval($froml+3) ^eval($y-$frombottom-4) }] ^gg.polybar(0x767676)[$rect_coord] @text[a;b;c] ^gg.font[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;A.gif](0) ^gg.text($a;$b)[$c] @show[] #$response:body[$x0 $x1 $y0 $y1] $response:body[^gg.gif[]] @plot[a] $maxx(1) $minx(0) $maxy(^find_max_y[$a]) $miny(0) $numx(^a.count[]) ^bar[$a] @find_max_y[a] $m(1) ^a.menu{ ^if($m<$a.value){ $m($a.value) } } $result(^math:round($m)) @bar[a] # plot area #^gg.bar(($froml+3);($fromtop);($x-$fromr);($y-$frombottom-4);0x00FF00) # Xi=3(n-1)+4 $xi(^eval(3*($numx-1)+4)) #^for[i](1;$numx){ $i(1) ^a.menu{ $x0(^castx[^eval((3*$i-2)/$xi)]) $x1(^castx[^eval((3*$i)/$xi)]) $y0(^casty[0]) $y1(^casty[$a.value]) ^gg.bar($x0;$y0;$x1;$y1;0x009933) $rect_coord[^table::create{x y ^eval($x1+1) $y0 ^eval($x1+5) ^eval($y0-4) ^eval($x1+5) ^eval($y1-4) ^eval($x1+1) $y1 }] ^gg.polybar(0x004D1A)[$rect_coord] $rect_coord[^table::create{x y ^eval($x1+5) ^eval($y1-5) ^eval($x1+1) ^eval($y1-1) ^eval($x0+1) ^eval($y1-1) ^eval($x0+5) ^eval($y1-5) }] ^gg.polybar(0x007327)[$rect_coord] ^i.inc[] } @castx[a] $result(^math:round(($a*($x-$fromr-$froml-3))+$froml+3)) @casty[a] $result(^math:round($y-$frombottom-4-(($a/$maxy)*($y-$frombottom-4-$fromtop))))test.gif
@USE graph.p @main[] $g[^graph::load[520;300]] ^g.canvas[] ^g.plot[^table::create{value 0.1 10.9 5.5 0.6 }] #^g.text[36;36;Hello World] ^g.show[]