Subversion Repositories wimsdev

Rev

Rev 12547 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11344 bpr 1
!if $wims_read_parm!=slib_header
13586 bpr 2
  !goto proc
11344 bpr 3
!endif
4
 
11353 bpr 5
slib_parms=4\
12547 bpr 6
,[min_x, max_x,size_x,size_y] in real coord and in pixels, by default size_x=300,size_y=100\
11353 bpr 7
,3- or 5- vector for [d1,q1,mediane,q2,d2] or [q1,mediane,q2] \
8
,3- or 5-vector with m (mobile) or f (fixed) at each position\
9
,option:number="", raw anstype stick
10
slib_comment=<ul><li>option <span class="tt">number</span> is useful in case of several boxplots \
11
in the same html page, by default nothing</li>\
12
<li>option <span class="tt">raw</span> gives the javascript code</li>\
13
<li>option <span class="tt">anstype</span> gives the code necessary to use with anstype <span class="tt">jsxgraph</span></li>\
11356 bpr 14
<li>option <span class="tt">stick</span> gives the sticks to show, by default 1.</li></ul>
11344 bpr 15
 
11353 bpr 16
slib_out=Box plot. Some points can be fixed or mobile.
11344 bpr 17
slib_author=Bernadette, Perrin-Riou
18
slib_title=Box plot
19
slib_example=[0,10],[4,6,7],,number=1\
11353 bpr 20
[0,10,500,200],[4,6,7],[m,f],number=2\
11344 bpr 21
[0,10],[1,4,6,7,8],,number=3\
11356 bpr 22
[10,100,800,200],[21,54,66,77,89],[m,f,f,m,f],number=4 stick=10\
11350 bpr 23
[0,10],[1,2,6],,raw
11344 bpr 24
 
25
!exit
26
 
27
:proc
28
slib_out=
11353 bpr 29
!!!warning the name of the object
30
!distribute item $wims_read_parm into slib_range,slib_p,slib_fix,slib_opt
11344 bpr 31
 
32
!set slib_fix=!declosing $slib_fix
33
!set slib_range=!declosing $slib_range
11352 bpr 34
!distribute item $slib_range into slib_xmin,slib_xmax,slib_xsize,slib_ysize
35
!default slib_xsize=300
36
!default slib_ysize=100
37
!set slib_stick=!getopt stick in $slib_opt
11344 bpr 38
!default slib_stick=1
11352 bpr 39
!set slib_p=!declosing $slib_p
40
!set slib_p=!sort numeric item $slib_p
41
!set slib_ch=!itemcnt $slib_p
42
!if $slib_ch=3
43
  !distribute item $slib_p into slib_q1,slib_med,slib_q3
11344 bpr 44
!else
11352 bpr 45
  !distribute item $slib_p into slib_dec1,slib_q1,slib_med,slib_q3,slib_dec9
11344 bpr 46
!endif
11352 bpr 47
!set slib_opt=!declosing $slib_opt
48
!set slib_nb=!getopt number in $slib_opt
11353 bpr 49
!if !=$empty
11352 bpr 50
  slib_nb=_$slib_nb
11344 bpr 51
!endif
11352 bpr 52
!set slib_brd=brd$slib_nb
53
!set slib_jx=jxgbox$slib_nb
11353 bpr 54
 
55
!! the following definition of $slib_jxr and $slib_jxv is cruxial when use with the
56
!! anstype jsxgraph. Do not change it.
11356 bpr 57
!set slib_jxP=$(slib_jx)_P
11353 bpr 58
!set slib_jxr=$(slib_jx)_rep
59
!set slib_jxv=$(slib_jx)_var
11352 bpr 60
!set slib_h=3
61
!set slib_h1=$[$slib_h-1]
62
!set slib_h2=$[$slib_h+1]
63
!set slib_h3=$[$slib_h-2]
64
!set slib_h4=$[$slib_h+2]
65
slib_script1=var $slib_brd = JXG.JSXGraph.initBoard('$slib_jx', {\
66
 axis:false,boundingbox: [$slib_xmin, 7, $slib_xmax, -1], grid:true, shownavigation:false});\
11344 bpr 67
 xaxis = $slib_brd.create('axis', [[0, 0], [1, 0]], {\
11419 bpr 68
 ticks: {ticksDistance: $slib_stick, insertTicks: true, drawZero:true}});\
11344 bpr 69
 yaxis = $slib_brd.create('axis', [[0, 0], [0, 3]],{\
70
 ticks: {ticksDistance:2, insertTicks: false,visible:false},visible:false});
11350 bpr 71
 !set slib_font=face:'o', name:'', size:2, showInfobox: true
11356 bpr 72
 !set slib_script1=$slib_script1\
73
Axe=$slib_brd.create('line',[[$slib_xmin,$slib_h],[$slib_xmax,$slib_h]],{visible:false});
11352 bpr 74
!for slib_i=1 to $slib_ch
11344 bpr 75
   !if $(slib_fix[$slib_i])=f
76
     !set slib_fixme=,fixed:true,visible:false
77
   !else
11356 bpr 78
     !set slib_fixme=,snapToGrid:true
11344 bpr 79
   !endif
11355 bpr 80
   !if raw notwordof $slib_opt and anstype notwordof $slib_opt
11350 bpr 81
     !set slib_script1=$slib_script1\
11356 bpr 82
$(slib_jxP)$slib_i=$slib_brd.create('point',[$(slib_p[$slib_i]),$slib_h], {$slib_font$slib_fixme});
11350 bpr 83
   !else
84
     !set slib_script1=$slib_script1\
11356 bpr 85
$(slib_jx)glider$slib_i=$slib_brd.create('glider',[$(slib_jxv)$slib_i,$slib_h,Axe],{$slib_font$slib_fixme});\
86
$(slib_jxP)$slib_i=brd.create('point',[function(){return $(slib_jx)glider$slib_i.X()},function(){return $(slib_jx)glider$slib_i.Y()}],{$slib_font$slib_fixme});
11350 bpr 87
   !endif
11344 bpr 88
!next
11356 bpr 89
 
11352 bpr 90
!if $slib_ch=5
11344 bpr 91
  !set slib_scriptmove=$slib_brd.on('move', function(){\
11356 bpr 92
$(slib_jxP)1.moveTo([Math.min($(slib_jxP)1.X(),$(slib_jxP)2.X()), $slib_h]);\
93
$(slib_jxP)2.moveTo([Math.min($(slib_jxP)2.X(),$(slib_jxP)3.X()), $slib_h]);\
94
$(slib_jxP)3.moveTo([Math.min($(slib_jxP)3.X(),$(slib_jxP)4.X()), $slib_h]);\
95
$(slib_jxP)4.moveTo([Math.min($(slib_jxP)4.X(),$(slib_jxP)5.X()), $slib_h]);\
96
$(slib_jxP)5.moveTo([Math.max($(slib_jxP)4.X(),$(slib_jxP)5.X()), $slib_h]);
11344 bpr 97
 
98
!else
99
  !set slib_scriptmove=$slib_brd.on('move', function(){\
11356 bpr 100
$(slib_jxP)1.moveTo([Math.min($(slib_jxP)1.X(),$(slib_jxP)2.X()), $slib_h]);\
101
$(slib_jxP)2.moveTo([Math.min($(slib_jxP)2.X(),$(slib_jxP)3.X()), $slib_h]);\
102
$(slib_jxP)3.moveTo([$(slib_jxP)3.X(), $slib_h]);
11344 bpr 103
!endif
104
 
11352 bpr 105
!set slib_scriptmove=$slib_scriptmove });
106
!if $slib_ch=5
11344 bpr 107
  !set slib_script2=\
11356 bpr 108
$(slib_jx)_pt1m=$slib_brd.create('point',[function(){return $(slib_jxP)1.X()},$slib_h2], {$slib_font,visible:false});\
109
$(slib_jx)_pt1p=$slib_brd.create('point',[function(){return $(slib_jxP)1.X()},$slib_h1], {$slib_font,visible:false});\
110
$(slib_jx)_pt5m=$slib_brd.create('point',[function(){return $(slib_jxP)5.X()},$slib_h2], {$slib_font,visible:false});\
111
$(slib_jx)_pt5p=$slib_brd.create('point',[function(){return $(slib_jxP)5.X()},$slib_h1], {$slib_font,visible:false});\
112
$(slib_jx)_pt2m=$slib_brd.create('point',[function(){return $(slib_jxP)2.X()},$slib_h4], {$slib_font,visible:false});\
113
$(slib_jx)_pt2p=$slib_brd.create('point',[function(){return $(slib_jxP)2.X()},$slib_h3], {$slib_font,visible:false});\
114
$(slib_jx)_pt3m=$slib_brd.create('point',[function(){return $(slib_jxP)3.X()},$slib_h4], {$slib_font,visible:false});\
115
$(slib_jx)_pt3p=$slib_brd.create('point',[function(){return $(slib_jxP)3.X()},$slib_h3], {$slib_font,visible:false});\
116
$(slib_jx)_pt4m=$slib_brd.create('point',[function(){return $(slib_jxP)4.X()},$slib_h4], {$slib_font,visible:false});\
117
$(slib_jx)_pt4p=$slib_brd.create('point',[function(){return $(slib_jxP)4.X()},$slib_h3], {$slib_font,visible:false});\
11344 bpr 118
 
13586 bpr 119
  !set slib_script3=\
11356 bpr 120
$slib_brd.create('line',[$(slib_jxP)1,$(slib_jxP)2],{straightFirst:false, straightLast:false});\
121
$slib_brd.create('line',[$(slib_jxP)4,$(slib_jxP)5],{straightFirst:false, straightLast:false});\
11353 bpr 122
$slib_brd.create('line',[$(slib_jx)_pt1m,$(slib_jx)_pt1p],{straightFirst:false, straightLast:false});\
123
$slib_brd.create('line',[$(slib_jx)_pt5m,$(slib_jx)_pt5p],{straightFirst:false, straightLast:false});\
124
$slib_brd.create('line',[$(slib_jx)_pt2m,$(slib_jx)_pt2p],{straightFirst:false, straightLast:false});\
125
$slib_brd.create('line',[$(slib_jx)_pt3m,$(slib_jx)_pt3p],{straightFirst:false, straightLast:false});\
126
$slib_brd.create('line',[$(slib_jx)_pt4m,$(slib_jx)_pt4p],{straightFirst:false, straightLast:false});\
127
$slib_brd.create('line',[$(slib_jx)_pt2m,$(slib_jx)_pt4m],{straightFirst:false, straightLast:false});\
128
$slib_brd.create('line',[$(slib_jx)_pt2p,$(slib_jx)_pt4p],{straightFirst:false, straightLast:false});
11352 bpr 129
 
11344 bpr 130
!else
131
  !set slib_script2=\
11356 bpr 132
$(slib_jx)_pt1m=$slib_brd.create('point',[function(){return $(slib_jxP)1.X()},$slib_h4], {$slib_font,visible:false});\
133
$(slib_jx)_pt1p=$slib_brd.create('point',[function(){return $(slib_jxP)1.X()},$slib_h3], {$slib_font,visible:false});\
134
$(slib_jx)_pt2m=$slib_brd.create('point',[function(){return $(slib_jxP)2.X()},$slib_h4], {$slib_font,visible:false});\
135
$(slib_jx)_pt2p=$slib_brd.create('point',[function(){return $(slib_jxP)2.X()},$slib_h3], {$slib_font,visible:false});\
136
$(slib_jx)_pt3m=$slib_brd.create('point',[function(){return $(slib_jxP)3.X()},$slib_h4], {$slib_font,visible:false});\
137
$(slib_jx)_pt3p=$slib_brd.create('point',[function(){return $(slib_jxP)3.X()},$slib_h3], {$slib_font,visible:false});\
11344 bpr 138
 
139
  !set slib_script3=\
11353 bpr 140
  $slib_brd.create('line',[$(slib_jx)_pt1m,$(slib_jx)_pt1p],{straightFirst:false, straightLast:false});\
141
$slib_brd.create('line',[$(slib_jx)_pt2m,$(slib_jx)_pt2p],{straightFirst:false, straightLast:false});\
142
$slib_brd.create('line',[$(slib_jx)_pt3m,$(slib_jx)_pt3p],{straightFirst:false, straightLast:false});\
143
$slib_brd.create('line',[$(slib_jx)_pt1m,$(slib_jx)_pt3m],{straightFirst:false, straightLast:false});\
144
$slib_brd.create('line',[$(slib_jx)_pt1p,$(slib_jx)_pt3p],{straightFirst:false, straightLast:false});
11344 bpr 145
!endif
146
 
147
!set slib_out=$slib_script1\
148
$slib_scriptmove\
149
$slib_script2\
150
$slib_script3
151
 
11353 bpr 152
!if anstype iswordof $slib_opt
13586 bpr 153
  slib_out=$slib_jx $slib_brd Y=$slib_h\
154
  $slib_out
11356 bpr 155
 
13586 bpr 156
  slib_out=$slib_out
11356 bpr 157
 
158
  !for slib_i=1 to $slib_ch
13586 bpr 159
    slib_out=$slib_out$(slib_jxr)$slib_i=$(slib_jxP)$slib_i;
11344 bpr 160
  !next
11356 bpr 161
  slib_out=$slib_out\
162
 
163
  !for slib_i=1 to $slib_ch
13586 bpr 164
    slib_out=$slib_out$(slib_jxv)$slib_i=$(slib_p[$slib_i]);
11356 bpr 165
  !next
11353 bpr 166
!else
167
  !if raw notwordof $slib_opt
168
    !readproc slib/geo2D/jsxgraph $slib_jx,$(slib_xsize) x $(slib_ysize),$slib_out
169
  !endif
11344 bpr 170
!endif