| 1 | #!/bin/perl | ||
| 2 | package SVGraph::2D; | ||
| 3 | use SVGraph::Core; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use DateTime; | ||
| 7 | |||
| 8 | our @ISA=("SVGraph"); | ||
| 9 | |||
| 10 | |||
| 11 | # drawing the block | ||
| 12 | sub prepare_block | ||
| 13 | { | ||
| 14 | my ($self, %param)=@_; | ||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | # calculate left margin by max value digits length | ||
| 19 | my $digits=length(int($self->GetMax()))+2; | ||
| 20 | my $font_size=SVGraph::calc_fontsize( | ||
| 21 | $self->{'ENV'}{'y'}, | ||
| 22 | 's_from' => 100, | ||
| 23 | 's_to' => 500, | ||
| 24 | 'o_from' => 6, | ||
| 25 | 'o_to' => 13 | ||
| 26 | ); | ||
| 27 | |||
| 28 | $self->{'block_left'}=int($digits * ($font_size * 0.70)); | ||
| 29 | main::_log('block_left='.$self->{'block_left'}.'px'); | ||
| 30 | |||
| 31 | $self->{block_right}=int($self->{ENV}{x}-($self->{ENV}{x}*0.20)); | ||
| 32 | |||
| 33 | if (!$self->{ENV}{show_legend}) | ||
| 34 | { | ||
| 35 | $self->{block_right}=int($self->{ENV}{x}-($self->{ENV}{x}*0.05)); | ||
| 36 | } | ||
| 37 | |||
| 38 | $self->{block_up}=int($self->{ENV}{y}*0.15); | ||
| 39 | $self->{block_down}=int($self->{ENV}{y}-($self->{ENV}{y}*0.25)); | ||
| 40 | |||
| 41 | if ($self->{ENV}{show_legend_label}) | ||
| 42 | { | ||
| 43 | $self->{block_down}=int($self->{ENV}{y}-($self->{ENV}{y}*0.05)); | ||
| 44 | } | ||
| 45 | |||
| 46 | |||
| 47 | my $rgb; | ||
| 48 | |||
| 49 | if(defined $param{color}) | ||
| 50 | { | ||
| 51 | $rgb = $param{color}; | ||
| 52 | } | ||
| 53 | else | ||
| 54 | { | ||
| 55 | $rgb = 179; | ||
| 56 | } | ||
| 57 | |||
| 58 | my $g = $self->{SVG}->gradient | ||
| 59 | ( | ||
| 60 | -type => "linear", | ||
| 61 | id => "gr_back01", | ||
| 62 | x1 =>"0%", | ||
| 63 | y1 =>"0%", | ||
| 64 | x2 =>"0%", | ||
| 65 | y2 =>"100%", | ||
| 66 | ); | ||
| 67 | $g->stop | ||
| 68 | ( | ||
| 69 | offset=>"0%", | ||
| 70 | style=>"stop-color:rgb($rgb,$rgb,$rgb);stop-opacity:1" | ||
| 71 | ); | ||
| 72 | $g->stop | ||
| 73 | ( | ||
| 74 | offset=>"60%", | ||
| 75 | style=>"stop-color:rgb(248,248,248);stop-opacity:1" | ||
| 76 | ); | ||
| 77 | |||
| 78 | my $plus=5; | ||
| 79 | $self->{SVG}->polyline( | ||
| 80 | points => | ||
| 81 | ($self->{block_left}+$plus).",".($self->{block_up}+$plus)." ". | ||
| 82 | ($self->{block_right}+$plus).",".($self->{block_up}+$plus)." ". | ||
| 83 | ($self->{block_right}+$plus).",".($self->{block_down}+$plus)." ". | ||
| 84 | ($self->{block_left}+$plus).",".($self->{block_down}+$plus)." ". | ||
| 85 | ($self->{block_left}+$plus).",".($self->{block_up}+$plus), | ||
| 86 | 'stroke-width' =>"0px" , | ||
| 87 | 'stroke' =>"black", | ||
| 88 | # 'stroke-' =>"black", | ||
| 89 | 'stroke-linecap' =>"round", | ||
| 90 | 'stroke-linejoin' =>"round", | ||
| 91 | 'fill' =>"black", | ||
| 92 | 'fill-opacity' =>"0.4", | ||
| 93 | # 'fill' =>"rgb(230,230,230)", | ||
| 94 | # 'stroke-linecap'=>"square", | ||
| 95 | ); | ||
| 96 | |||
| 97 | my $block=$self->{SVG}->polyline( | ||
| 98 | points => | ||
| 99 | $self->{block_left}.",".$self->{block_up}." ". | ||
| 100 | $self->{block_right}.",".$self->{block_up}." ". | ||
| 101 | $self->{block_right}.",".$self->{block_down}." ". | ||
| 102 | $self->{block_left}.",".$self->{block_down}." ". | ||
| 103 | $self->{block_left}.",".$self->{block_up}, | ||
| 104 | 'stroke-width' =>"0.2px" , | ||
| 105 | 'stroke' =>"black", | ||
| 106 | # 'stroke-' =>"black", | ||
| 107 | 'stroke-linecap' =>"round", | ||
| 108 | 'stroke-linejoin' =>"round", | ||
| 109 | 'fill' =>"url(#gr_back01)", | ||
| 110 | # 'fill' =>"rgb(230,230,230)", | ||
| 111 | # 'stroke-linecap'=>"square", | ||
| 112 | ); | ||
| 113 | |||
| 114 | $self->{block_width}=$self->{block_right}-$self->{block_left}; # sirka bloku | ||
| 115 | $self->{block_height}=$self->{block_down}-$self->{block_up}; # vyska bloku | ||
| 116 | |||
| 117 | # write SVGraph text | ||
| 118 | my $dt = DateTime->now(); | ||
| 119 | $self->{SVG}->text | ||
| 120 | ( | ||
| 121 | 'x' => 1, | ||
| 122 | 'y' => $self->{'ENV'}{'y'}-2, | ||
| 123 | 'style' => { | ||
| 124 | #'text-anchor' => "end", | ||
| 125 | 'font-family' => "Verdana", | ||
| 126 | 'font-size' => '9px', | ||
| 127 | 'fill' => "gray", | ||
| 128 | }, | ||
| 129 | )->cdata("[Generated by SVGraph on ".$dt->year()."-".sprintf("%02d",$dt->month())."-".sprintf("%02d",$dt->day())." ".sprintf("%02d",$dt->hour()).":".sprintf("%02d",$dt->min())." GMT]"); | ||
| 130 | |||
| 131 | return 1; | ||
| 132 | |||
| 133 | } | ||
| 134 | |||
| 135 | |||
| 136 | sub prepare_axis | ||
| 137 | { | ||
| 138 | my $self=shift; | ||
| 139 | my $block=$self->{SVG}->polyline( | ||
| 140 | points => | ||
| 141 | $self->{block_left}.",".$self->{block_up}." ". | ||
| 142 | $self->{block_left}.",".$self->{block_down}." ". | ||
| 143 | $self->{block_right}.",".$self->{block_down}." ", | ||
| 144 | 'stroke-width' =>"1.0px", | ||
| 145 | 'stroke' =>"black", | ||
| 146 | # 'stroke-' =>"black", | ||
| 147 | 'stroke-linecap' =>"round", | ||
| 148 | 'stroke-linejoin' =>"round", | ||
| 149 | # 'fill' =>"rgb(230,230,230)", | ||
| 150 | 'fill-opacity' =>"0", | ||
| 151 | # 'stroke-linecap'=>"square", | ||
| 152 | ); | ||
| 153 | |||
| 154 | return 1; | ||
| 155 | } | ||
| 156 | |||
| 157 | |||
| 158 | |||
| 159 | |||
| 160 | sub prepare_axis_calculate | ||
| 161 | { | ||
| 162 | my $self=shift; | ||
| 163 | |||
| 164 | |||
| 165 | # | ||
| 166 | # calculation of the lines, which are normal to the X axis | ||
| 167 | # and thwe calculation of MIN and MAX | ||
| 168 | # | ||
| 169 | |||
| 170 | $self->{grid_x_main_lines}=$self->GetNumRows(); | ||
| 171 | $self->{grid_x_main_lines}=2 unless $self->{grid_x_main_lines}; # when none Rows | ||
| 172 | $self->{grid_x_main_lines}++ if $self->{type} eq "columns"; | ||
| 173 | |||
| 174 | $self->{value_max}=$self->GetMax(); | ||
| 175 | $self->{value_min}=$self->GetMin(); | ||
| 176 | #die "cannot prepare this Chart, none data inserted in rows" if $self->{value_max}==$self->{value_min}; | ||
| 177 | #$self->{value_min}=0 unless $self->{value_min}; | ||
| 178 | #$self->{value_max}=$self->{value_min}+10 if $self->{value_max}==$self->{value_min}; | ||
| 179 | |||
| 180 | #print "$self->{value_min} $self->{value_max}\n"; | ||
| 181 | |||
| 182 | foreach (keys %{$self->{row}{labelH}}) | ||
| 183 | { | ||
| 184 | $self->{value_max_all}=$self->GetRowSum($_) if $self->{value_max_all}<$self->GetRowSum($_); | ||
| 185 | } | ||
| 186 | |||
| 187 | $self->{value_max}=$self->{value_max_all} if $self->{ENV}{type}=~/stacked/; | ||
| 188 | |||
| 189 | |||
| 190 | if ($self->{ENV}{type}=~/percentage/) | ||
| 191 | { | ||
| 192 | $self->{value_max}=100; | ||
| 193 | $self->{value_min}=0; | ||
| 194 | $self->{grid_y_suffix}="%"; | ||
| 195 | } | ||
| 196 | |||
| 197 | $self->{grid_y_suffix}=$self->{ENV}{grid_y_suffix} if $self->{ENV}{grid_y_suffix}; | ||
| 198 | |||
| 199 | # empty graph | ||
| 200 | $self->{value_min}=0 unless $self->{value_min}; | ||
| 201 | $self->{value_max}=$self->{value_min}+10 if $self->{value_max}==$self->{value_min}; | ||
| 202 | |||
| 203 | #print "----------- $self->{value_max} - $self->{value_min}\n"; | ||
| 204 | |||
| 205 | # | ||
| 206 | # number of values on the Y axis | ||
| 207 | # | ||
| 208 | #$self->{grid_y_scale_minimum}=$self->{ENV}{grid_y_scale_minimum}; | ||
| 209 | $self->{grid_y_scale_minimum}=$self->{value_min} unless exists $self->{ENV}{grid_y_scale_minimum}; | ||
| 210 | $self->{grid_y_scale_maximum}=$self->{value_max} unless $self->{grid_y_scale_maximum}; | ||
| 211 | |||
| 212 | $self->{grid_y_scale_maximum}=$self->{grid_y_scale_minimum}+10 | ||
| 213 | if $self->{grid_y_scale_maximum}==$self->{grid_y_scale_minimum}; | ||
| 214 | |||
| 215 | |||
| 216 | $self->{grid_y_main_lines}=0;#=0; | ||
| 217 | ( | ||
| 218 | $self->{grid_y_scale_minimum}, | ||
| 219 | $self->{grid_y_scale_maximum}, | ||
| 220 | $self->{grid_y_main_lines} | ||
| 221 | ) = $self->CalculateMinMax( | ||
| 222 | $self->{grid_y_scale_minimum}, | ||
| 223 | $self->{grid_y_scale_maximum}, | ||
| 224 | int($self->{block_height}/40), | ||
| 225 | int($self->{block_height}/10), | ||
| 226 | ); | ||
| 227 | |||
| 228 | $self->{grid_y_scale}=$self->{grid_y_scale_maximum}-$self->{grid_y_scale_minimum}; | ||
| 229 | |||
| 230 | # counting of the spacing | ||
| 231 | $self->{grid_y_main_spacing}=$self->{grid_y_scale}/$self->{grid_y_main_lines} unless $self->{grid_y_main_spacing}; | ||
| 232 | $self->{block_height_scale} = $self->{grid_y_main_spacing} / ($self->{grid_y_scale} / $self->{block_height}); | ||
| 233 | |||
| 234 | # | ||
| 235 | # number of values, which will be displayed on the X axis | ||
| 236 | # | ||
| 237 | |||
| 238 | my $maximal=int($self->{block_width}/15); | ||
| 239 | |||
| 240 | $self->{grid_x_main_skipfull}=int($self->{grid_x_main_lines}/$maximal); | ||
| 241 | $self->{grid_x_main_skipfull}=1 unless $self->{grid_x_main_skipfull}; | ||
| 242 | $self->{block_width_scale}=$self->{block_width}/($self->{grid_x_main_lines}-1); | ||
| 243 | |||
| 244 | return 1; | ||
| 245 | } | ||
| 246 | |||
| 247 | |||
| 248 | |||
| 249 | |||
| 250 | |||
| 251 | |||
| 252 | |||
| 253 | |||
| 254 | |||
| 255 | |||
| 256 | |||
| 257 | |||
| 258 | |||
| 259 | |||
| 260 | |||
| 261 | |||
| 262 | |||
| 263 | sub prepare_axis_y | ||
| 264 | { | ||
| 265 | my $self=shift; | ||
| 266 | |||
| 267 | my $font_size=SVGraph::calc_fontsize( | ||
| 268 | $self->{ENV}{y}, | ||
| 269 | s_from => 100, | ||
| 270 | s_to => 500, | ||
| 271 | o_from => 6, | ||
| 272 | o_to => 13 | ||
| 273 | ); | ||
| 274 | |||
| 275 | for (0..$self->{grid_y_main_lines}) # je to X+1 | ||
| 276 | { | ||
| 277 | my $y=int($self->{block_down}-($_*$self->{block_height_scale})); | ||
| 278 | |||
| 279 | if ((($_*$self->{grid_y_main_spacing})+$self->{grid_y_scale_minimum})==0) | ||
| 280 | { | ||
| 281 | $self->{SVG}->line( | ||
| 282 | x1 => int($self->{block_left}-30), | ||
| 283 | y1 => $y, | ||
| 284 | x2 => int($self->{block_right}-0), | ||
| 285 | y2 => $y, | ||
| 286 | 'stroke-width' =>"1px" , | ||
| 287 | 'stroke' =>"black", | ||
| 288 | 'stroke-linecap' =>"round", | ||
| 289 | 'stroke-linejoin' =>"round", | ||
| 290 | # 'fill' =>"black", | ||
| 291 | # 'stroke-linecap'=>"square", | ||
| 292 | ); | ||
| 293 | } | ||
| 294 | else | ||
| 295 | { | ||
| 296 | $self->{SVG}->line( | ||
| 297 | x1 => int($self->{block_left}-($self->{block_left}*0.35)), | ||
| 298 | y1 => $y, | ||
| 299 | x2 => int($self->{block_right}-0), | ||
| 300 | y2 => $y, | ||
| 301 | 'stroke-width' =>"0.2px" , | ||
| 302 | 'stroke' =>"black", | ||
| 303 | 'stroke-linecap' =>"round", | ||
| 304 | 'stroke-linejoin' =>"round", | ||
| 305 | # 'fill' =>"black", | ||
| 306 | # 'stroke-linecap'=>"square", | ||
| 307 | ); | ||
| 308 | } | ||
| 309 | |||
| 310 | $self->{SVG}->text | ||
| 311 | ( | ||
| 312 | x => int($self->{block_left}-5), | ||
| 313 | y => $y-2, | ||
| 314 | style => { | ||
| 315 | 'text-anchor' => 'end', | ||
| 316 | 'font-family' => 'Verdana', | ||
| 317 | 'font-size' => $font_size.'px', | ||
| 318 | 'fill' => "black", | ||
| 319 | }, | ||
| 320 | )->cdata((($_*$self->{grid_y_main_spacing})+$self->{grid_y_scale_minimum}).$self->{grid_y_suffix}); | ||
| 321 | |||
| 322 | } | ||
| 323 | |||
| 324 | return 1; | ||
| 325 | } | ||
| 326 | |||
| 327 | |||
| 328 | |||
| 329 | |||
| 330 | |||
| 331 | |||
| 332 | |||
| 333 | |||
| 334 | |||
| 335 | |||
| 336 | sub prepare_axis_x | ||
| 337 | { | ||
| 338 | my $self=shift; | ||
| 339 | |||
| 340 | # | ||
| 341 | # draw the lines on the X axis | ||
| 342 | # | ||
| 343 | |||
| 344 | my $to=$self->{grid_x_main_lines}-1; | ||
| 345 | #$to=$self->{grid_x_main_lines}-2 if $self->{type} eq "columns"; | ||
| 346 | |||
| 347 | my $textsize=$self->{ENV}{show_label_textsize};$textsize=7 unless $textsize; | ||
| 348 | |||
| 349 | for (0..$to) | ||
| 350 | { | ||
| 351 | if ( | ||
| 352 | (( $_/$self->{grid_x_main_skipfull} == int($_/$self->{grid_x_main_skipfull}) ) | ||
| 353 | ||($_==($self->{grid_x_main_lines}-1))) | ||
| 354 | && ($self->{ENV}{show_grid_x}) | ||
| 355 | ) | ||
| 356 | { | ||
| 357 | |||
| 358 | |||
| 359 | =head1 | ||
| 360 | $self->{SVG}->path( | ||
| 361 | d=> | ||
| 362 | "M".int($self->{block_left}+($_*$self->{block_width_scale}))." ".$self->{block_up}." ". | ||
| 363 | "L".int($self->{block_left}+($_*$self->{block_width_scale}))." ".$self->{block_down}." ". | ||
| 364 | "L".(int($self->{block_left}+($_*$self->{block_width_scale}))+3)." ".($self->{block_down}+10)." Z", | ||
| 365 | 'stroke-width' =>"0.2px" , | ||
| 366 | 'stroke' =>"black", | ||
| 367 | 'stroke-linecap' =>"round", | ||
| 368 | 'stroke-linejoin' =>"round", | ||
| 369 | 'fill' =>"white", | ||
| 370 | 'fill-opacity' => "0", | ||
| 371 | ); | ||
| 372 | =cut | ||
| 373 | |||
| 374 | $self->{SVG}->line( | ||
| 375 | x1 => int($self->{block_left}+($_*$self->{block_width_scale})), | ||
| 376 | y1 => $self->{block_up}, | ||
| 377 | x2 => int($self->{block_left}+($_*$self->{block_width_scale})), | ||
| 378 | y2 => $self->{block_down}, | ||
| 379 | 'stroke-width' =>"0.2px" , | ||
| 380 | 'stroke' =>"black", | ||
| 381 | 'stroke-linecap' =>"round", | ||
| 382 | 'stroke-linejoin' =>"round", | ||
| 383 | ); | ||
| 384 | |||
| 385 | if (!$self->{ENV}{show_legend_label}) | ||
| 386 | { | ||
| 387 | |||
| 388 | $self->{SVG}->line( | ||
| 389 | x1 => int($self->{block_left}+($_*$self->{block_width_scale})), | ||
| 390 | y1 => $self->{block_down}, | ||
| 391 | x2 => int($self->{block_left}+($_*$self->{block_width_scale}))+7, | ||
| 392 | y2 => $self->{block_down}+20, | ||
| 393 | 'stroke-width' =>"0.2px" , | ||
| 394 | 'stroke' =>"black", | ||
| 395 | 'stroke-linecap' =>"round", | ||
| 396 | 'stroke-linejoin' =>"round", | ||
| 397 | ); | ||
| 398 | |||
| 399 | my $null=$self->{row}{label}[$_]; | ||
| 400 | $null=$_ unless $null; | ||
| 401 | $null="" if $self->{type} eq "columns" && $_ == $to; | ||
| 402 | |||
| 403 | my $x1=int($self->{block_left}+($_*$self->{block_width_scale})+($textsize/2)+1); | ||
| 404 | |||
| 405 | #$x1+=($self->{block_width_scale}/2)-5 if $self->{type} eq "columns"; | ||
| 406 | |||
| 407 | my $g=$self->{SVG}->g( | ||
| 408 | x=>$x1, | ||
| 409 | y=>$self->{block_down}+6, | ||
| 410 | style => | ||
| 411 | { | ||
| 412 | 'font-family' => 'Verdana', | ||
| 413 | 'font-size' => $textsize.'px', | ||
| 414 | 'fill' => "black", | ||
| 415 | # 'writing-mode' => "tb", | ||
| 416 | } | ||
| 417 | ); | ||
| 418 | my $txt=$g->text( | ||
| 419 | transform=>"translate(".int($x1).",".($self->{block_down}+8).") rotate(70)", | ||
| 420 | # cursor=>"move", | ||
| 421 | )->cdata($null); | ||
| 422 | |||
| 423 | =head1 | ||
| 424 | $g->animate | ||
| 425 | ( | ||
| 426 | 'attributeName'=>"font-weight", | ||
| 427 | 'begin'=>"mouseover", | ||
| 428 | 'end'=>"mouseout", | ||
| 429 | # 'from'=>"900", | ||
| 430 | # 'to'=>"900", | ||
| 431 | 'values'=>"900", | ||
| 432 | # 'dur'=>"10s", | ||
| 433 | # 'repeatDur'=>"freeze" | ||
| 434 | 'restart'=>"whenNotActive" | ||
| 435 | ); | ||
| 436 | $g->animate | ||
| 437 | ( | ||
| 438 | 'attributeName'=>"font-size", | ||
| 439 | 'begin'=>"mouseover", | ||
| 440 | 'end'=>"mouseout", | ||
| 441 | # 'from'=>$textsize*1.2, | ||
| 442 | # 'to'=>$textsize*1.2, | ||
| 443 | 'values'=>int($textsize*1.2).'px', | ||
| 444 | # 'dur'=>"10s", | ||
| 445 | # 'repeatDur'=>"freeze" | ||
| 446 | 'restart'=>"whenNotActive" | ||
| 447 | ); | ||
| 448 | =cut | ||
| 449 | |||
| 450 | } | ||
| 451 | |||
| 452 | |||
| 453 | } | ||
| 454 | else | ||
| 455 | { | ||
| 456 | $self->{SVG}->line( | ||
| 457 | x1 => int($self->{block_left}+($_*$self->{block_width_scale})), | ||
| 458 | y1 => $self->{block_down}-10, | ||
| 459 | x2 => int($self->{block_left}+($_*$self->{block_width_scale})), | ||
| 460 | y2 => $self->{block_down}+5, | ||
| 461 | 'stroke-width' =>"0.1px" , | ||
| 462 | 'stroke' =>"black", | ||
| 463 | 'stroke-linecap' =>"round", | ||
| 464 | 'stroke-linejoin' =>"round", | ||
| 465 | ); | ||
| 466 | } | ||
| 467 | } | ||
| 468 | return 1; | ||
| 469 | } | ||
| 470 | |||
| 471 | |||
| 472 | |||
| 473 | sub prepare_legend_label | ||
| 474 | { | ||
| 475 | my $self=shift; | ||
| 476 | |||
| 477 | return undef unless $self->{ENV}{show_legend_label}; | ||
| 478 | |||
| 479 | |||
| 480 | my $to=$self->{grid_x_main_lines}-1; | ||
| 481 | #$to=$self->{grid_x_main_lines}-2 if $self->{type} eq "columns"; | ||
| 482 | |||
| 483 | my $textsize=$self->{ENV}{show_label_textsize}; | ||
| 484 | $textsize=int($self->{block_width_scale}/2) unless $textsize; | ||
| 485 | $textsize=10 if $textsize>10; | ||
| 486 | |||
| 487 | for (0..$to) | ||
| 488 | { | ||
| 489 | |||
| 490 | if ( | ||
| 491 | ( $_/$self->{grid_x_main_skipfull} == int($_/$self->{grid_x_main_skipfull})) | ||
| 492 | ||($_==($self->{grid_x_main_lines}-1)) | ||
| 493 | ) | ||
| 494 | { | ||
| 495 | |||
| 496 | |||
| 497 | my $null=$self->{row}{label}[$_]; | ||
| 498 | $null=$_ unless $null; | ||
| 499 | $null="" if $self->{type} eq "columns" && $_ == $to; | ||
| 500 | |||
| 501 | my $x1=int($self->{block_left}+($_*$self->{block_width_scale})+($self->{block_width_scale}/2)+($textsize/4)); | ||
| 502 | |||
| 503 | #$x1+=($self->{block_width_scale}/2)-5 if $self->{type} eq "columns"; | ||
| 504 | |||
| 505 | |||
| 506 | my $g=$self->{SVG}->g( | ||
| 507 | x=>$x1, | ||
| 508 | y=>$self->{block_down}, | ||
| 509 | style => | ||
| 510 | { | ||
| 511 | 'font-family' => 'Verdana', | ||
| 512 | 'font-size' => $textsize.'px', | ||
| 513 | 'fill' => "black", | ||
| 514 | # 'stroke-width'=>"0.5px", | ||
| 515 | # 'stroke'=>"black", | ||
| 516 | # 'font-weight' => "bold" | ||
| 517 | # 'writing-mode' => "tb", | ||
| 518 | } | ||
| 519 | ); | ||
| 520 | my $txt=$g->text( | ||
| 521 | transform=>"translate(".int($x1).",".($self->{block_down}-6).") rotate(-90)", | ||
| 522 | # cursor=>"move", | ||
| 523 | )->cdata($null); | ||
| 524 | |||
| 525 | =head1 | ||
| 526 | $g->animate | ||
| 527 | ( | ||
| 528 | 'attributeName'=>"font-weight", | ||
| 529 | 'begin'=>"mouseover", | ||
| 530 | 'end'=>"mouseout", | ||
| 531 | # 'from'=>"900", | ||
| 532 | # 'to'=>"900", | ||
| 533 | 'values'=>"900", | ||
| 534 | # 'dur'=>"10s", | ||
| 535 | # 'repeatDur'=>"freeze" | ||
| 536 | 'restart'=>"whenNotActive" | ||
| 537 | ); | ||
| 538 | =cut | ||
| 539 | =head1 | ||
| 540 | $g->animate | ||
| 541 | ( | ||
| 542 | 'attributeName'=>"font-size", | ||
| 543 | 'begin'=>"mouseover", | ||
| 544 | 'end'=>"mouseout", | ||
| 545 | # 'from'=>$textsize*1.2, | ||
| 546 | # 'to'=>$textsize*1.2, | ||
| 547 | 'values'=>$textsize*1.2, | ||
| 548 | # 'dur'=>"10s", | ||
| 549 | # 'repeatDur'=>"freeze" | ||
| 550 | 'restart'=>"whenNotActive" | ||
| 551 | ); | ||
| 552 | =cut | ||
| 553 | |||
| 554 | } | ||
| 555 | } | ||
| 556 | |||
| 557 | |||
| 558 | return 1; | ||
| 559 | } | ||
| 560 | |||
| 561 | |||
| 562 | |||
| 563 | |||
| 564 | |||
| 565 | |||
| 566 | |||
| 567 | |||
| 568 | |||
| 569 | sub prepare_axis_x_mark | ||
| 570 | { | ||
| 571 | my $self=shift; | ||
| 572 | my %env=@_; | ||
| 573 | |||
| 574 | for (0..$self->{grid_x_main_lines}-1) | ||
| 575 | { | ||
| 576 | if ($self->{row}{markH}{$self->{row}{label}[$_]}) # MARK | ||
| 577 | { | ||
| 578 | |||
| 579 | next if $self->{row}{markH}{$self->{row}{label}[$_]}{front} && !$env{front}; | ||
| 580 | next if !$self->{row}{markH}{$self->{row}{label}[$_]}{front} && $env{front}; | ||
| 581 | |||
| 582 | my $size=$self->{row}{markH}{$self->{row}{label}[$_]}{size};$size=1 unless $size; | ||
| 583 | |||
| 584 | my $color=$self->{row}{markH}{$self->{row}{label}[$_]}{color}; | ||
| 585 | $color="black" unless $color; | ||
| 586 | $color="black" unless $SVGraph::colors::table{$color}; | ||
| 587 | |||
| 588 | $self->{SVG}->line( | ||
| 589 | x1 => int($self->{block_left}+($_*$self->{block_width_scale})), | ||
| 590 | y1 => $self->{block_up}-7, | ||
| 591 | x2 => int($self->{block_left}+($_*$self->{block_width_scale})), | ||
| 592 | y2 => $self->{block_down}, | ||
| 593 | 'stroke-width' =>$size."px" , | ||
| 594 | 'stroke' =>"rgb(".$SVGraph::colors::table{$color}{N2}.")", | ||
| 595 | 'stroke-opacity' =>"1", | ||
| 596 | 'stroke-linecap' =>"round", | ||
| 597 | 'stroke-linejoin' =>"round", | ||
| 598 | ); | ||
| 599 | |||
| 600 | $self->{SVG}->circle( | ||
| 601 | cx=>int($self->{block_left}+($_*$self->{block_width_scale})), | ||
| 602 | cy=>$self->{block_up}-10, | ||
| 603 | r=>2, | ||
| 604 | 'fill' => "white", | ||
| 605 | 'stroke' =>"rgb(".$SVGraph::colors::table{$color}{N2}.")", | ||
| 606 | 'stroke-width' => "1px", | ||
| 607 | ); | ||
| 608 | if ($self->{row}{markH}{$self->{row}{label}[$_]}{show_label}) | ||
| 609 | { | ||
| 610 | my $null=$self->{row}{label}[$_]; | ||
| 611 | $null=$_ unless $null; | ||
| 612 | $self->{SVG}->text( | ||
| 613 | x=>int($self->{block_left}+($_*$self->{block_width_scale}))+5, | ||
| 614 | y=>$self->{block_up}-7, | ||
| 615 | style => { | ||
| 616 | 'font-family' => 'Verdana', | ||
| 617 | 'font-size' => '8'.'px', | ||
| 618 | 'fill' => "black", | ||
| 619 | |||
| 620 | } | ||
| 621 | )->cdata($null); | ||
| 622 | } | ||
| 623 | } | ||
| 624 | } | ||
| 625 | |||
| 626 | return 1; | ||
| 627 | } | ||
| 628 | |||
| 629 | |||
| 630 | |||
| 631 | |||
| 632 | |||
| 633 | |||
| 634 | |||
| 635 | |||
| 636 | |||
| 637 | |||
| 638 | |||
| 639 | |||
| 640 | sub prepare_axis_y_mark | ||
| 641 | { | ||
| 642 | my $self=shift; | ||
| 643 | my %env=@_; | ||
| 644 | |||
| 645 | foreach my $mark (keys %{$self->{ValueMarkH}}) | ||
| 646 | { | ||
| 647 | next if $self->{ValueMarkH}{$mark}{front} && !$env{front}; | ||
| 648 | next if !$self->{ValueMarkH}{$mark}{front} && $env{front}; | ||
| 649 | next if $mark>$self->{grid_y_scale_maximum}; | ||
| 650 | next if $mark<$self->{grid_y_scale_minimum}; | ||
| 651 | |||
| 652 | my $size=$self->{ValueMarkH}{$mark}{size};$size=1 unless $size; | ||
| 653 | |||
| 654 | my $color=$self->{ValueMarkH}{$mark}{color}; | ||
| 655 | $color="black" unless $color; | ||
| 656 | $color="black" unless $SVGraph::colors::table{$color}; | ||
| 657 | |||
| 658 | my $height=(($mark-$self->{grid_y_scale_minimum})/($self->{grid_y_scale}/100))*($self->{block_height}/100); | ||
| 659 | $height=int($height*100)/100; | ||
| 660 | |||
| 661 | if (!$self->{ValueMarkH}{$mark}{right}) | ||
| 662 | { | ||
| 663 | $self->{SVG}->line( | ||
| 664 | x1 => 8, | ||
| 665 | y1 => $self->{block_down}-$height, | ||
| 666 | x2 => $self->{block_right}, | ||
| 667 | y2 => $self->{block_down}-$height, | ||
| 668 | 'stroke-width' =>$size."px" , | ||
| 669 | 'stroke' =>"rgb(".$SVGraph::colors::table{$color}{N1}.")", | ||
| 670 | 'stroke-linecap' =>"round", | ||
| 671 | 'stroke-linejoin' =>"round", | ||
| 672 | ); | ||
| 673 | |||
| 674 | $self->{SVG}->circle( | ||
| 675 | cx=>8, | ||
| 676 | cy=>$self->{block_down}-$height, | ||
| 677 | r=>2, | ||
| 678 | 'fill' => "white", | ||
| 679 | 'stroke' => "rgb(".$SVGraph::colors::table{$color}{N1}.")", | ||
| 680 | 'stroke-width' => "1px", | ||
| 681 | ); | ||
| 682 | } | ||
| 683 | else | ||
| 684 | { | ||
| 685 | $self->{SVG}->line( | ||
| 686 | x1 => $self->{block_left}, | ||
| 687 | y1 => $self->{block_down}-$height, | ||
| 688 | x2 => $self->{block_right}+10, | ||
| 689 | y2 => $self->{block_down}-$height, | ||
| 690 | 'stroke-width' =>$size."px" , | ||
| 691 | 'stroke' =>"rgb(".$SVGraph::colors::table{$color}{N1}.")", | ||
| 692 | 'stroke-linecap' =>"round", | ||
| 693 | 'stroke-linejoin' =>"round", | ||
| 694 | ); | ||
| 695 | $self->{SVG}->circle( | ||
| 696 | cx=>$self->{block_right}+10, | ||
| 697 | cy=>$self->{block_down}-$height, | ||
| 698 | r=>2, | ||
| 699 | 'fill' => "white", | ||
| 700 | 'stroke' => "rgb(".$SVGraph::colors::table{$color}{N1}.")", | ||
| 701 | 'stroke-width' => "1px", | ||
| 702 | ); | ||
| 703 | } | ||
| 704 | |||
| 705 | if ($self->{ValueMarkH}{$mark}{show_label}) | ||
| 706 | { | ||
| 707 | my $null=$self->{ValueMarkH}{$mark}{show_label_text}; | ||
| 708 | $null=$mark unless $null; | ||
| 709 | |||
| 710 | #$null=$_ unless $null; | ||
| 711 | if (!$self->{ValueMarkH}{$mark}{right}) | ||
| 712 | { | ||
| 713 | $self->{SVG}->text( | ||
| 714 | x=>5, | ||
| 715 | y=>$self->{block_down}-$height-5, | ||
| 716 | style => { | ||
| 717 | # 'text-anchor' => 'end', | ||
| 718 | 'font-family' => 'Verdana', | ||
| 719 | 'font-size' => '8'.'px', | ||
| 720 | 'fill' => "black", | ||
| 721 | } | ||
| 722 | )->cdata($null); | ||
| 723 | } | ||
| 724 | else | ||
| 725 | { | ||
| 726 | $self->{SVG}->text( | ||
| 727 | x=>$self->{block_right}+8, | ||
| 728 | y=>$self->{block_down}-$height-4, | ||
| 729 | style => { | ||
| 730 | # 'text-anchor' => 'end', | ||
| 731 | 'font-family' => 'Verdana', | ||
| 732 | 'font-size' => '8'.'px', | ||
| 733 | 'fill' => "black", | ||
| 734 | } | ||
| 735 | )->cdata($null); | ||
| 736 | } | ||
| 737 | } | ||
| 738 | |||
| 739 | |||
| 740 | } | ||
| 741 | |||
| 742 | |||
| 743 | return 1; | ||
| 744 | } | ||
| 745 | |||
| 746 | |||
| 747 | sub prepare_axis_y_markArea | ||
| 748 | { | ||
| 749 | my $self=shift; | ||
| 750 | my %env=@_; | ||
| 751 | |||
| 752 | foreach my $mark (keys %{$self->{ValueMarkAH}}) | ||
| 753 | { | ||
| 754 | if ($mark eq "_start") | ||
| 755 | { | ||
| 756 | die "minimal value not defined" unless exists $self->{grid_y_scale_minimum}; | ||
| 757 | my $newmark=$self->{grid_y_scale_minimum}; | ||
| 758 | #die "minimal value not defined" unless $newmark; | ||
| 759 | %{$self->{ValueMarkAH}{$newmark}}=%{$self->{ValueMarkAH}{$mark}}; | ||
| 760 | delete $self->{ValueMarkAH}{$mark}; | ||
| 761 | $mark=$newmark; | ||
| 762 | } | ||
| 763 | |||
| 764 | next if $self->{ValueMarkAH}{$mark}{front} && !$env{front}; | ||
| 765 | next if !$self->{ValueMarkAH}{$mark}{front} && $env{front}; | ||
| 766 | |||
| 767 | my $color=$self->{ValueMarkAH}{$mark}{color}; | ||
| 768 | $color="yellow" unless $color; | ||
| 769 | $color="yellow" unless $SVGraph::colors::table{$color}; | ||
| 770 | |||
| 771 | |||
| 772 | $self->{ValueMarkAH}{$mark}{end}=$self->{grid_y_scale_maximum} | ||
| 773 | if ($self->{ValueMarkAH}{$mark}{end}>$self->{grid_y_scale_maximum} || !$self->{ValueMarkAH}{$mark}{end}); | ||
| 774 | |||
| 775 | my $height0=(($mark-$self->{grid_y_scale_minimum})/($self->{grid_y_scale}/100))*($self->{block_height}/100); | ||
| 776 | $height0=int($height0*100)/100; | ||
| 777 | $height0=0 if $height0 < 0; | ||
| 778 | $height0=$self->{block_height} if $height0 > $self->{block_height}; | ||
| 779 | |||
| 780 | my $height1=(($self->{ValueMarkAH}{$mark}{end} - $self->{grid_y_scale_minimum}) / ($self->{grid_y_scale}/100)) * ($self->{block_height}/100); | ||
| 781 | $height1=int($height1*100)/100; | ||
| 782 | $height1=0 if $height1 < 0; | ||
| 783 | $height1=$self->{block_height} if $height1 > $self->{block_height}; | ||
| 784 | |||
| 785 | |||
| 786 | my $opacity=$self->{ValueMarkAH}{$mark}{'opacity'}; | ||
| 787 | $opacity="0.1" unless $opacity; | ||
| 788 | |||
| 789 | |||
| 790 | $self->{SVG}->polyline( | ||
| 791 | points => | ||
| 792 | $self->{block_left}.",".($self->{block_down}-$height1)." ". | ||
| 793 | $self->{block_right}.",".($self->{block_down}-$height1)." ". | ||
| 794 | $self->{block_right}.",".($self->{block_down}-$height0)." ". | ||
| 795 | $self->{block_left}.",".($self->{block_down}-$height0), | ||
| 796 | # 'stroke-width' =>"1.5px", | ||
| 797 | # 'stroke' =>"black", | ||
| 798 | # 'stroke-linecap' =>"round", | ||
| 799 | # 'stroke-linejoin' =>"round", | ||
| 800 | 'fill' =>"rgb(".$SVGraph::colors::table{$color}{B1}.")", | ||
| 801 | 'fill-opacity' =>$opacity, | ||
| 802 | # 'stroke-linecap'=>"square", | ||
| 803 | ); | ||
| 804 | |||
| 805 | |||
| 806 | |||
| 807 | } | ||
| 808 | |||
| 809 | return 1; | ||
| 810 | } | ||
| 811 | |||
| 812 | |||
| 813 | |||
| 814 | sub prepare_axis_x_markArea | ||
| 815 | { | ||
| 816 | my $self=shift; | ||
| 817 | my %env=@_; | ||
| 818 | |||
| 819 | foreach my $mark (keys %{$self->{row}{markAH}}) | ||
| 820 | { | ||
| 821 | if ($mark eq "_start") | ||
| 822 | { | ||
| 823 | my $newmark=$self->{row}{label}[0]; | ||
| 824 | |||
| 825 | die "first label of row not defined" unless $newmark; | ||
| 826 | %{$self->{row}{markAH}{$newmark}}=%{$self->{row}{markAH}{$mark}}; | ||
| 827 | delete $self->{row}{markAH}{$mark}; | ||
| 828 | $mark=$newmark; | ||
| 829 | } | ||
| 830 | |||
| 831 | next if $self->{row}{markAH}{$mark}{front} && !$env{front}; | ||
| 832 | next if !$self->{row}{markAH}{$mark}{front} && $env{front}; | ||
| 833 | |||
| 834 | my $row_start=$self->GetNumRow($mark); | ||
| 835 | |||
| 836 | |||
| 837 | my $row_end=$self->GetNumRows()-1; | ||
| 838 | |||
| 839 | $row_end=$self->GetNumRow($self->{row}{markAH}{$mark}{end}) if $self->{row}{markAH}{$mark}{end}; | ||
| 840 | |||
| 841 | # my $size=$self->{row}{markAH}{$mark}{size};$size=1 unless $size; | ||
| 842 | |||
| 843 | my $color=$self->{row}{markAH}{$mark}{color}; | ||
| 844 | $color="yellow" unless $color; | ||
| 845 | $color="yellow" unless $SVGraph::colors::table{$color}; | ||
| 846 | |||
| 847 | #print "mam farbu $color a end je $row_end $self->{row}{markAH}{$mark}{end}\n"; | ||
| 848 | |||
| 849 | my $row_x1=int($self->{block_left}+($row_start*$self->{block_width_scale})); | ||
| 850 | my $row_x2=int($self->{block_left}+($row_end*$self->{block_width_scale})); | ||
| 851 | |||
| 852 | if ($self->{'type'} eq "lines") | ||
| 853 | { | ||
| 854 | $row_x1=int($self->{'block_left'}+(($row_start-0.5)*$self->{'block_width_scale'})); | ||
| 855 | $row_x2=int($self->{'block_left'}+(($row_end-0.5)*$self->{'block_width_scale'})); | ||
| 856 | } | ||
| 857 | |||
| 858 | my $opacity=$self->{row}{markAH}{$mark}{'opacity'}; | ||
| 859 | $opacity="0.2" unless $opacity; | ||
| 860 | |||
| 861 | # my $color=$self->{row}{markH}{$self->{row}{label}[$_]}{color};$color="black" unless $color; | ||
| 862 | $self->{SVG}->polyline( | ||
| 863 | points => | ||
| 864 | $row_x1.",".($self->{block_up})." ". | ||
| 865 | $row_x2.",".($self->{block_up})." ". | ||
| 866 | $row_x2.",".$self->{block_down}." ". | ||
| 867 | $row_x1.",".$self->{block_down}, | ||
| 868 | # 'stroke-width' =>"1.5px", | ||
| 869 | # 'stroke' =>"black", | ||
| 870 | # 'stroke-linecap' =>"round", | ||
| 871 | # 'stroke-linejoin' =>"round", | ||
| 872 | 'fill' =>"rgb(".$SVGraph::colors::table{$color}{N2}.")", | ||
| 873 | 'fill-opacity' =>$opacity, | ||
| 874 | # 'stroke-linecap'=>"square", | ||
| 875 | ); | ||
| 876 | } | ||
| 877 | |||
| 878 | return 1; | ||
| 879 | } | ||
| 880 | |||
| 881 | |||
| 882 | |||
| 883 | |||
| 884 | |||
| 885 | |||
| 886 | |||
| 887 | |||
| 888 | 1; |