line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tk::ForDummies::Graph::Bars;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5658
|
use warnings;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
7
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
86
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#==================================================================
|
8
|
|
|
|
|
|
|
# Author : Djibril Ousmanou
|
9
|
|
|
|
|
|
|
# Copyright : 2010
|
10
|
|
|
|
|
|
|
# Update : 19/06/2010 22:47:33
|
11
|
|
|
|
|
|
|
# AIM : Create bars graph
|
12
|
|
|
|
|
|
|
#==================================================================
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION);
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
15
|
|
|
|
|
|
|
$VERSION = '1.10';
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
7
|
use base qw/Tk::Derived Tk::Canvas::GradientColor/;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
739
|
|
18
|
|
|
|
|
|
|
use Tk::Balloon;
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Tk::ForDummies::Graph::Utils qw (:DUMMIES);
|
21
|
|
|
|
|
|
|
use Tk::ForDummies::Graph qw (:DUMMIES);
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Construct Tk::Widget 'Bars';
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub Populate {
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my ( $CompositeWidget, $RefParameters ) = @_;
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Get initial parameters
|
30
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies} = _InitConfig();
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$CompositeWidget->SUPER::Populate($RefParameters);
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$CompositeWidget->Advertise( 'GradientColor' => $CompositeWidget );
|
35
|
|
|
|
|
|
|
$CompositeWidget->Advertise( 'canvas' => $CompositeWidget->SUPER::Canvas );
|
36
|
|
|
|
|
|
|
$CompositeWidget->Advertise( 'Canvas' => $CompositeWidget->SUPER::Canvas );
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# remove highlightthickness if necessary
|
39
|
|
|
|
|
|
|
unless ( exists $RefParameters->{-highlightthickness} ) {
|
40
|
|
|
|
|
|
|
$CompositeWidget->configure( -highlightthickness => 0 );
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$CompositeWidget->ConfigSpecs(
|
44
|
|
|
|
|
|
|
-title => [ 'PASSIVE', 'Title', 'Title', undef ],
|
45
|
|
|
|
|
|
|
-titlecolor => [ 'PASSIVE', 'Titlecolor', 'TitleColor', 'black' ],
|
46
|
|
|
|
|
|
|
-titlefont =>
|
47
|
|
|
|
|
|
|
[ 'PASSIVE', 'Titlefont', 'TitleFont', $CompositeWidget->{RefInfoDummies}->{Font}{DefaultTitle} ],
|
48
|
|
|
|
|
|
|
-titleposition => [ 'PASSIVE', 'Titleposition', 'TitlePosition', 'center' ],
|
49
|
|
|
|
|
|
|
-titleheight =>
|
50
|
|
|
|
|
|
|
[ 'PASSIVE', 'Titleheight', 'TitleHeight', $CompositeWidget->{RefInfoDummies}->{Title}{Height} ],
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
-xlabel => [ 'PASSIVE', 'Xlabel', 'XLabel', undef ],
|
53
|
|
|
|
|
|
|
-xlabelcolor => [ 'PASSIVE', 'Xlabelcolor', 'XLabelColor', 'black' ],
|
54
|
|
|
|
|
|
|
-xlabelfont =>
|
55
|
|
|
|
|
|
|
[ 'PASSIVE', 'Xlabelfont', 'XLabelFont', $CompositeWidget->{RefInfoDummies}->{Font}{DefaultLabel} ],
|
56
|
|
|
|
|
|
|
-xlabelposition => [ 'PASSIVE', 'Xlabelposition', 'XLabelPosition', 'center' ],
|
57
|
|
|
|
|
|
|
-xlabelheight => [
|
58
|
|
|
|
|
|
|
'PASSIVE', 'Xlabelheight',
|
59
|
|
|
|
|
|
|
'XLabelHeight', $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{xlabelHeight}
|
60
|
|
|
|
|
|
|
],
|
61
|
|
|
|
|
|
|
-xlabelskip => [ 'PASSIVE', 'Xlabelskip', 'XLabelSkip', 0 ],
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
-xvaluecolor => [ 'PASSIVE', 'Xvaluecolor', 'XValueColor', 'black' ],
|
64
|
|
|
|
|
|
|
-xvaluevertical => [ 'PASSIVE', 'Xvaluevertical', 'XValueVertical', 0 ],
|
65
|
|
|
|
|
|
|
-xvaluespace => [
|
66
|
|
|
|
|
|
|
'PASSIVE', 'Xvaluespace',
|
67
|
|
|
|
|
|
|
'XValueSpace', $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{ScaleValuesHeight}
|
68
|
|
|
|
|
|
|
],
|
69
|
|
|
|
|
|
|
-xvalueview => [ 'PASSIVE', 'Xvalueview', 'XValueView', 1 ],
|
70
|
|
|
|
|
|
|
-yvalueview => [ 'PASSIVE', 'Yvalueview', 'YValueView', 1 ],
|
71
|
|
|
|
|
|
|
-xvaluesregex => [ 'PASSIVE', 'Xvaluesregex', 'XValuesRegex', qr/.+/ ],
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
-ylabel => [ 'PASSIVE', 'Ylabel', 'YLabel', undef ],
|
74
|
|
|
|
|
|
|
-ylabelcolor => [ 'PASSIVE', 'Ylabelcolor', 'YLabelColor', 'black' ],
|
75
|
|
|
|
|
|
|
-ylabelfont =>
|
76
|
|
|
|
|
|
|
[ 'PASSIVE', 'Ylabelfont', 'YLabelFont', $CompositeWidget->{RefInfoDummies}->{Font}{DefaultLabel} ],
|
77
|
|
|
|
|
|
|
-ylabelposition => [ 'PASSIVE', 'Ylabelposition', 'YLabelPosition', 'center' ],
|
78
|
|
|
|
|
|
|
-ylabelwidth => [
|
79
|
|
|
|
|
|
|
'PASSIVE', 'Ylabelwidth',
|
80
|
|
|
|
|
|
|
'YLabelWidth', $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{ylabelWidth}
|
81
|
|
|
|
|
|
|
],
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
-yvaluecolor => [ 'PASSIVE', 'Yvaluecolor', 'YValueColor', 'black' ],
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
-labelscolor => [ 'PASSIVE', 'Labelscolor', 'LabelsColor', undef ],
|
86
|
|
|
|
|
|
|
-valuescolor => [ 'PASSIVE', 'Valuescolor', 'ValuesColor', undef ],
|
87
|
|
|
|
|
|
|
-textcolor => [ 'PASSIVE', 'Textcolor', 'TextColor', undef ],
|
88
|
|
|
|
|
|
|
-textfont => [ 'PASSIVE', 'Textfont', 'TextFont', undef ],
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
-boxaxis => [ 'PASSIVE', 'Boxaxis', 'BoxAxis', 0 ],
|
91
|
|
|
|
|
|
|
-noaxis => [ 'PASSIVE', 'Noaxis', 'NoAxis', 0 ],
|
92
|
|
|
|
|
|
|
-zeroaxisonly => [ 'PASSIVE', 'Zeroaxisonly', 'ZeroAxisOnly', 0 ],
|
93
|
|
|
|
|
|
|
-zeroaxis => [ 'PASSIVE', 'Zeroaxis', 'ZeroAxis', 0 ],
|
94
|
|
|
|
|
|
|
-longticks => [ 'PASSIVE', 'Longticks', 'LongTicks', 0 ],
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
-xtickheight => [
|
97
|
|
|
|
|
|
|
'PASSIVE', 'Xtickheight',
|
98
|
|
|
|
|
|
|
'XTickHeight', $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{TickHeight}
|
99
|
|
|
|
|
|
|
],
|
100
|
|
|
|
|
|
|
-xtickview => [ 'PASSIVE', 'Xtickview', 'XTickView', 1 ],
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
-yticknumber => [
|
103
|
|
|
|
|
|
|
'PASSIVE', 'Yticknumber',
|
104
|
|
|
|
|
|
|
'YTickNumber', $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{TickNumber}
|
105
|
|
|
|
|
|
|
],
|
106
|
|
|
|
|
|
|
-ytickwidth =>
|
107
|
|
|
|
|
|
|
[ 'PASSIVE', 'Ytickwidth', 'YtickWidth', $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{TickWidth} ],
|
108
|
|
|
|
|
|
|
-ytickview => [ 'PASSIVE', 'Ytickview', 'YTickView', 1 ],
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
-alltickview => [ 'PASSIVE', 'Alltickview', 'AllTickView', 1 ],
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
-width => [ 'SELF', 'width', 'Width', $CompositeWidget->{RefInfoDummies}->{Canvas}{Width} ],
|
113
|
|
|
|
|
|
|
-height => [ 'SELF', 'height', 'Height', $CompositeWidget->{RefInfoDummies}->{Canvas}{Height} ],
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
-linewidth => [ 'PASSIVE', 'Linewidth', 'LineWidth', 1 ],
|
116
|
|
|
|
|
|
|
-colordata =>
|
117
|
|
|
|
|
|
|
[ 'PASSIVE', 'Colordata', 'ColorData', $CompositeWidget->{RefInfoDummies}->{Legend}{Colors} ],
|
118
|
|
|
|
|
|
|
-overwrite => [ 'PASSIVE', 'Overwrite', 'OverWrite', 0 ],
|
119
|
|
|
|
|
|
|
-cumulate => [ 'PASSIVE', 'Cumulate', 'Cumulate', 0 ],
|
120
|
|
|
|
|
|
|
-spacingbar => [ 'PASSIVE', 'Spacingbar', 'SpacingBar', 1 ],
|
121
|
|
|
|
|
|
|
-showvalues => [ 'PASSIVE', 'Showvalues', 'ShowValues', 0 ],
|
122
|
|
|
|
|
|
|
-outlinebar => [ 'PASSIVE', 'Outlinebar', 'OutlineBar', 'black' ],
|
123
|
|
|
|
|
|
|
);
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$CompositeWidget->Delegates( DEFAULT => $CompositeWidget, );
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# recreate graph after widget resize
|
128
|
|
|
|
|
|
|
$CompositeWidget->enabled_automatic_redraw();
|
129
|
|
|
|
|
|
|
$CompositeWidget->disabled_gradientcolor();
|
130
|
|
|
|
|
|
|
}
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub _Balloon {
|
133
|
|
|
|
|
|
|
my ($CompositeWidget) = @_;
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# balloon defined and user want to stop it
|
136
|
|
|
|
|
|
|
if ( defined $CompositeWidget->{RefInfoDummies}->{Balloon}{Obj}
|
137
|
|
|
|
|
|
|
and $CompositeWidget->{RefInfoDummies}->{Balloon}{State} == 0 )
|
138
|
|
|
|
|
|
|
{
|
139
|
|
|
|
|
|
|
$CompositeWidget->_DestroyBalloonAndBind();
|
140
|
|
|
|
|
|
|
return;
|
141
|
|
|
|
|
|
|
}
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# balloon not defined and user want to stop it
|
144
|
|
|
|
|
|
|
elsif ( $CompositeWidget->{RefInfoDummies}->{Balloon}{State} == 0 ) {
|
145
|
|
|
|
|
|
|
return;
|
146
|
|
|
|
|
|
|
}
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# balloon defined and user want to start it again (may be new option)
|
149
|
|
|
|
|
|
|
elsif ( defined $CompositeWidget->{RefInfoDummies}->{Balloon}{Obj}
|
150
|
|
|
|
|
|
|
and $CompositeWidget->{RefInfoDummies}->{Balloon}{State} == 1 )
|
151
|
|
|
|
|
|
|
{
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# destroy the balloon, it will be re create above
|
154
|
|
|
|
|
|
|
$CompositeWidget->_DestroyBalloonAndBind();
|
155
|
|
|
|
|
|
|
}
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Balloon creation
|
158
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Balloon}{Obj} = $CompositeWidget->Balloon(
|
159
|
|
|
|
|
|
|
-statusbar => $CompositeWidget,
|
160
|
|
|
|
|
|
|
-background => $CompositeWidget->{RefInfoDummies}->{Balloon}{Background},
|
161
|
|
|
|
|
|
|
);
|
162
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Balloon}{Obj}->attach(
|
163
|
|
|
|
|
|
|
$CompositeWidget,
|
164
|
|
|
|
|
|
|
-balloonposition => 'mouse',
|
165
|
|
|
|
|
|
|
-msg => $CompositeWidget->{RefInfoDummies}->{Legend}{MsgBalloon},
|
166
|
|
|
|
|
|
|
);
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# no legend, no bind
|
169
|
|
|
|
|
|
|
unless ( my $LegendTextNumber = $CompositeWidget->{RefInfoDummies}->{Legend}{LegendTextNumber} ) {
|
170
|
|
|
|
|
|
|
return;
|
171
|
|
|
|
|
|
|
}
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# bind legend and bars
|
174
|
|
|
|
|
|
|
for my $IndexLegend ( 1 .. $CompositeWidget->{RefInfoDummies}->{Legend}{LegendTextNumber} ) {
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
my $LegendTag = $IndexLegend . $CompositeWidget->{RefInfoDummies}->{TAGS}{Legend};
|
177
|
|
|
|
|
|
|
my $BarTag = $IndexLegend . $CompositeWidget->{RefInfoDummies}->{TAGS}{Bar};
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
$CompositeWidget->bind(
|
180
|
|
|
|
|
|
|
$LegendTag,
|
181
|
|
|
|
|
|
|
'',
|
182
|
|
|
|
|
|
|
sub {
|
183
|
|
|
|
|
|
|
my $OtherColor = $CompositeWidget->{RefInfoDummies}->{Balloon}{ColorData}->[0];
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
# Change color if bar have the same color
|
186
|
|
|
|
|
|
|
if ( $OtherColor eq $CompositeWidget->{RefInfoDummies}{Bar}{$BarTag}{color} ) {
|
187
|
|
|
|
|
|
|
$OtherColor = $CompositeWidget->{RefInfoDummies}->{Balloon}{ColorData}->[1];
|
188
|
|
|
|
|
|
|
}
|
189
|
|
|
|
|
|
|
$CompositeWidget->itemconfigure( $BarTag, -fill => $OtherColor, );
|
190
|
|
|
|
|
|
|
}
|
191
|
|
|
|
|
|
|
);
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
$CompositeWidget->bind(
|
194
|
|
|
|
|
|
|
$LegendTag,
|
195
|
|
|
|
|
|
|
'',
|
196
|
|
|
|
|
|
|
sub {
|
197
|
|
|
|
|
|
|
$CompositeWidget->itemconfigure( $BarTag,
|
198
|
|
|
|
|
|
|
-fill => $CompositeWidget->{RefInfoDummies}{Bar}{$BarTag}{color}, );
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# Allow value bar to display
|
201
|
|
|
|
|
|
|
$CompositeWidget->itemconfigure( $CompositeWidget->{RefInfoDummies}->{TAGS}{BarValues},
|
202
|
|
|
|
|
|
|
-fill => 'black', );
|
203
|
|
|
|
|
|
|
}
|
204
|
|
|
|
|
|
|
);
|
205
|
|
|
|
|
|
|
}
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
return;
|
208
|
|
|
|
|
|
|
}
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub set_legend {
|
211
|
|
|
|
|
|
|
my ( $CompositeWidget, %InfoLegend ) = @_;
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
my $RefLegend = $InfoLegend{-data};
|
214
|
|
|
|
|
|
|
unless ( defined $RefLegend ) {
|
215
|
|
|
|
|
|
|
$CompositeWidget->_error(
|
216
|
|
|
|
|
|
|
"Can't set -data in set_legend method. "
|
217
|
|
|
|
|
|
|
. "May be you forgot to set the value\n"
|
218
|
|
|
|
|
|
|
. "Eg : set_legend( -data => ['legend1', 'legend2', ...] );",
|
219
|
|
|
|
|
|
|
1
|
220
|
|
|
|
|
|
|
);
|
221
|
|
|
|
|
|
|
}
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
unless ( defined $RefLegend and ref($RefLegend) eq 'ARRAY' ) {
|
224
|
|
|
|
|
|
|
$CompositeWidget->_error(
|
225
|
|
|
|
|
|
|
"Can't set -data in set_legend method. Bad data\n"
|
226
|
|
|
|
|
|
|
. "Eg : set_legend( -data => ['legend1', 'legend2', ...] );",
|
227
|
|
|
|
|
|
|
1
|
228
|
|
|
|
|
|
|
);
|
229
|
|
|
|
|
|
|
}
|
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
my @LegendOption = qw / -box -legendmarkerheight -legendmarkerwidth -heighttitle /;
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
foreach my $OptionName (@LegendOption) {
|
234
|
|
|
|
|
|
|
if ( defined $InfoLegend{$OptionName}
|
235
|
|
|
|
|
|
|
and $InfoLegend{$OptionName} !~ m{^\d+$} )
|
236
|
|
|
|
|
|
|
{
|
237
|
|
|
|
|
|
|
$CompositeWidget->_error(
|
238
|
|
|
|
|
|
|
"'Can't set $OptionName to " . "'$InfoLegend{$OptionName}', $InfoLegend{$OptionName}' isn't numeric",
|
239
|
|
|
|
|
|
|
1
|
240
|
|
|
|
|
|
|
);
|
241
|
|
|
|
|
|
|
}
|
242
|
|
|
|
|
|
|
}
|
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
# Check legend and data size
|
245
|
|
|
|
|
|
|
if ( my $RefData = $CompositeWidget->{RefInfoDummies}->{Data}{RefAllData} ) {
|
246
|
|
|
|
|
|
|
unless ( $CompositeWidget->_CheckSizeLengendAndData( $RefData, $RefLegend ) ) {
|
247
|
|
|
|
|
|
|
undef $CompositeWidget->{RefInfoDummies}->{Legend}{DataLegend};
|
248
|
|
|
|
|
|
|
return;
|
249
|
|
|
|
|
|
|
}
|
250
|
|
|
|
|
|
|
}
|
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
# Get Legend options
|
253
|
|
|
|
|
|
|
# Title
|
254
|
|
|
|
|
|
|
if ( defined $InfoLegend{-title} ) {
|
255
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{title} = $InfoLegend{-title};
|
256
|
|
|
|
|
|
|
}
|
257
|
|
|
|
|
|
|
else {
|
258
|
|
|
|
|
|
|
undef $CompositeWidget->{RefInfoDummies}->{Legend}{title};
|
259
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{HeightTitle} = 0;
|
260
|
|
|
|
|
|
|
}
|
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
# Title and legend font
|
263
|
|
|
|
|
|
|
if ( defined $InfoLegend{-titlefont} ) {
|
264
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{titlefont} = $InfoLegend{-titlefont};
|
265
|
|
|
|
|
|
|
}
|
266
|
|
|
|
|
|
|
if ( defined $InfoLegend{-legendfont} ) {
|
267
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{legendfont} = $InfoLegend{-legendfont};
|
268
|
|
|
|
|
|
|
}
|
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
# box legend
|
271
|
|
|
|
|
|
|
if ( defined $InfoLegend{-box} ) {
|
272
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{box} = $InfoLegend{-box};
|
273
|
|
|
|
|
|
|
}
|
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
# title color
|
276
|
|
|
|
|
|
|
if ( defined $InfoLegend{-titlecolors} ) {
|
277
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{titlecolors} = $InfoLegend{-titlecolors};
|
278
|
|
|
|
|
|
|
}
|
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
# legendmarkerheight
|
281
|
|
|
|
|
|
|
if ( defined $InfoLegend{-legendmarkerheight} ) {
|
282
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{HCube} = $InfoLegend{-legendmarkerheight};
|
283
|
|
|
|
|
|
|
}
|
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
# legendmarkerwidth
|
286
|
|
|
|
|
|
|
if ( defined $InfoLegend{-legendmarkerwidth} ) {
|
287
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{WCube} = $InfoLegend{-legendmarkerwidth};
|
288
|
|
|
|
|
|
|
}
|
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
# heighttitle
|
291
|
|
|
|
|
|
|
if ( defined $InfoLegend{-heighttitle} ) {
|
292
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{HeightTitle} = $InfoLegend{-heighttitle};
|
293
|
|
|
|
|
|
|
}
|
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
# Get the biggest length of legend text
|
296
|
|
|
|
|
|
|
my @LengthLegend = map { length; } @{$RefLegend};
|
297
|
|
|
|
|
|
|
my $BiggestLegend = _MaxArray( \@LengthLegend );
|
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
# 100 pixel => 13 characters, 1 pixel => 0.13 pixels then 1 character = 7.69 pixels
|
300
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{WidthOneCaracter} = 7.69;
|
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
# Max pixel width for a legend text for us
|
303
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{LengthTextMax}
|
304
|
|
|
|
|
|
|
= int( $CompositeWidget->{RefInfoDummies}->{Legend}{WidthText}
|
305
|
|
|
|
|
|
|
/ $CompositeWidget->{RefInfoDummies}->{Legend}{WidthOneCaracter} );
|
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
# We have free space
|
308
|
|
|
|
|
|
|
my $Diff = $CompositeWidget->{RefInfoDummies}->{Legend}{LengthTextMax} - $BiggestLegend;
|
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
# Get new size width for a legend text with one pixel security
|
311
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{WidthText}
|
312
|
|
|
|
|
|
|
-= ( $Diff - 1 ) * $CompositeWidget->{RefInfoDummies}->{Legend}{WidthOneCaracter};
|
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
# Store Reference data
|
315
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{DataLegend} = $RefLegend;
|
316
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{NbrLegend} = scalar @{$RefLegend};
|
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
return 1;
|
319
|
|
|
|
|
|
|
}
|
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
sub _Legend {
|
322
|
|
|
|
|
|
|
my ( $CompositeWidget, $RefLegend ) = @_;
|
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
# One legend width
|
325
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{LengthOneLegend}
|
326
|
|
|
|
|
|
|
= +$CompositeWidget->{RefInfoDummies}->{Legend}{SpaceBeforeCube} # space between each legend
|
327
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Legend}{WCube} # width legend marker
|
328
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Legend}{SpaceAfterCube} # space after marker
|
329
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Legend}{WidthText} # legend text width allowed
|
330
|
|
|
|
|
|
|
;
|
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
# Number of legends per line
|
333
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{NbrPerLine}
|
334
|
|
|
|
|
|
|
= int( $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{Width}
|
335
|
|
|
|
|
|
|
/ $CompositeWidget->{RefInfoDummies}->{Legend}{LengthOneLegend} );
|
336
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{NbrPerLine} = 1
|
337
|
|
|
|
|
|
|
if ( $CompositeWidget->{RefInfoDummies}->{Legend}{NbrPerLine} == 0 );
|
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
# How many legend we will have
|
340
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{LegendTextNumber}
|
341
|
|
|
|
|
|
|
= scalar @{ $CompositeWidget->{RefInfoDummies}->{Data}{RefAllData} } - 1;
|
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
=for NumberLines:
|
344
|
|
|
|
|
|
|
We calculate the number of lines set for the legend graph.
|
345
|
|
|
|
|
|
|
If wa can set 11 legends per line, then for 3 legend, we will need one line
|
346
|
|
|
|
|
|
|
and for 12 legends, we will need 2 lines
|
347
|
|
|
|
|
|
|
If NbrLeg / NbrPerLine = integer => get number of lines
|
348
|
|
|
|
|
|
|
If NbrLeg / NbrPerLine = float => int(float) + 1 = get number of lines
|
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
=cut
|
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{NbrLine}
|
353
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Legend}{LegendTextNumber}
|
354
|
|
|
|
|
|
|
/ $CompositeWidget->{RefInfoDummies}->{Legend}{NbrPerLine};
|
355
|
|
|
|
|
|
|
unless (
|
356
|
|
|
|
|
|
|
int( $CompositeWidget->{RefInfoDummies}->{Legend}{NbrLine} )
|
357
|
|
|
|
|
|
|
== $CompositeWidget->{RefInfoDummies}->{Legend}{NbrLine} )
|
358
|
|
|
|
|
|
|
{
|
359
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{NbrLine}
|
360
|
|
|
|
|
|
|
= int( $CompositeWidget->{RefInfoDummies}->{Legend}{NbrLine} ) + 1;
|
361
|
|
|
|
|
|
|
}
|
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
# Total Height of Legend
|
364
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{Height}
|
365
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Legend}{HeightTitle} # Hauteur Titre légende
|
366
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Legend}{NbrLine}
|
367
|
|
|
|
|
|
|
* $CompositeWidget->{RefInfoDummies}->{Legend}{HLine};
|
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
# Get number legend text max per line to reajust our graph
|
370
|
|
|
|
|
|
|
if ( $CompositeWidget->{RefInfoDummies}->{Legend}{LegendTextNumber}
|
371
|
|
|
|
|
|
|
< $CompositeWidget->{RefInfoDummies}->{Legend}{NbrPerLine} )
|
372
|
|
|
|
|
|
|
{
|
373
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{NbrPerLine}
|
374
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Legend}{LegendTextNumber};
|
375
|
|
|
|
|
|
|
}
|
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
return;
|
378
|
|
|
|
|
|
|
}
|
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
sub _ViewLegend {
|
381
|
|
|
|
|
|
|
my ($CompositeWidget) = @_;
|
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
# legend option
|
384
|
|
|
|
|
|
|
my $LegendTitle = $CompositeWidget->{RefInfoDummies}->{Legend}{title};
|
385
|
|
|
|
|
|
|
my $legendmarkercolors = $CompositeWidget->cget( -colordata );
|
386
|
|
|
|
|
|
|
my $legendfont = $CompositeWidget->{RefInfoDummies}->{Legend}{legendfont};
|
387
|
|
|
|
|
|
|
my $titlecolor = $CompositeWidget->{RefInfoDummies}->{Legend}{titlecolors};
|
388
|
|
|
|
|
|
|
my $titlefont = $CompositeWidget->{RefInfoDummies}->{Legend}{titlefont};
|
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
# display legend title
|
391
|
|
|
|
|
|
|
if ( defined $LegendTitle ) {
|
392
|
|
|
|
|
|
|
my $xLegendTitle = $CompositeWidget->{RefInfoDummies}->{Axis}{CxMin}
|
393
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Legend}{SpaceBeforeCube};
|
394
|
|
|
|
|
|
|
my $yLegendTitle
|
395
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Axis}{CyMin}
|
396
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{TickHeight}
|
397
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{ScaleValuesHeight}
|
398
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{xlabelHeight};
|
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
$CompositeWidget->createText(
|
401
|
|
|
|
|
|
|
$xLegendTitle,
|
402
|
|
|
|
|
|
|
$yLegendTitle,
|
403
|
|
|
|
|
|
|
-text => $LegendTitle,
|
404
|
|
|
|
|
|
|
-anchor => 'nw',
|
405
|
|
|
|
|
|
|
-font => $titlefont,
|
406
|
|
|
|
|
|
|
-fill => $titlecolor,
|
407
|
|
|
|
|
|
|
-width => $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{Width},
|
408
|
|
|
|
|
|
|
-tags => [
|
409
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{TitleLegend},
|
410
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph},
|
411
|
|
|
|
|
|
|
],
|
412
|
|
|
|
|
|
|
);
|
413
|
|
|
|
|
|
|
}
|
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
# Display legend
|
416
|
|
|
|
|
|
|
my $IndexColor = 0;
|
417
|
|
|
|
|
|
|
my $IndexLegend = 0;
|
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
# initialisation of balloon message
|
420
|
|
|
|
|
|
|
#$CompositeWidget->{RefInfoDummies}->{Legend}{MsgBalloon} = {};
|
421
|
|
|
|
|
|
|
for my $NumberLine ( 0 .. $CompositeWidget->{RefInfoDummies}->{Legend}{NbrLine} - 1 ) {
|
422
|
|
|
|
|
|
|
my $x1Cube = $CompositeWidget->{RefInfoDummies}->{Axis}{CxMin}
|
423
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Legend}{SpaceBeforeCube};
|
424
|
|
|
|
|
|
|
my $y1Cube
|
425
|
|
|
|
|
|
|
= ( $CompositeWidget->{RefInfoDummies}->{Axis}{CyMin}
|
426
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{TickHeight}
|
427
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{ScaleValuesHeight}
|
428
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{xlabelHeight}
|
429
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Legend}{HeightTitle}
|
430
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Legend}{HLine} / 2 )
|
431
|
|
|
|
|
|
|
+ $NumberLine * $CompositeWidget->{RefInfoDummies}->{Legend}{HLine};
|
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
my $x2Cube = $x1Cube + $CompositeWidget->{RefInfoDummies}->{Legend}{WCube};
|
434
|
|
|
|
|
|
|
my $y2Cube = $y1Cube - $CompositeWidget->{RefInfoDummies}->{Legend}{HCube};
|
435
|
|
|
|
|
|
|
my $xText = $x2Cube + $CompositeWidget->{RefInfoDummies}->{Legend}{SpaceAfterCube};
|
436
|
|
|
|
|
|
|
my $yText = $y2Cube;
|
437
|
|
|
|
|
|
|
my $MaxLength = $CompositeWidget->{RefInfoDummies}->{Legend}{LengthTextMax};
|
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
LEGEND:
|
440
|
|
|
|
|
|
|
for my $NumberLegInLine ( 0 .. $CompositeWidget->{RefInfoDummies}->{Legend}{NbrPerLine} - 1 ) {
|
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
my $LineColor = $legendmarkercolors->[$IndexColor];
|
443
|
|
|
|
|
|
|
unless ( defined $LineColor ) {
|
444
|
|
|
|
|
|
|
$IndexColor = 0;
|
445
|
|
|
|
|
|
|
$LineColor = $legendmarkercolors->[$IndexColor];
|
446
|
|
|
|
|
|
|
}
|
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
# Cut legend text if too long
|
449
|
|
|
|
|
|
|
my $Legende = $CompositeWidget->{RefInfoDummies}->{Legend}{DataLegend}->[$IndexLegend];
|
450
|
|
|
|
|
|
|
next unless ( defined $Legende );
|
451
|
|
|
|
|
|
|
my $NewLegend = $Legende;
|
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
if ( length $NewLegend > $MaxLength ) {
|
454
|
|
|
|
|
|
|
$MaxLength -= 3;
|
455
|
|
|
|
|
|
|
$NewLegend =~ s/^(.{$MaxLength}).*/$1/;
|
456
|
|
|
|
|
|
|
$NewLegend .= '...';
|
457
|
|
|
|
|
|
|
}
|
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
my $Tag = ( $IndexLegend + 1 ) . $CompositeWidget->{RefInfoDummies}->{TAGS}{Legend};
|
460
|
|
|
|
|
|
|
$CompositeWidget->createRectangle(
|
461
|
|
|
|
|
|
|
$x1Cube, $y1Cube, $x2Cube, $y2Cube,
|
462
|
|
|
|
|
|
|
-fill => $LineColor,
|
463
|
|
|
|
|
|
|
-outline => $LineColor,
|
464
|
|
|
|
|
|
|
-tags => [ $Tag, $CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph}, ],
|
465
|
|
|
|
|
|
|
);
|
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
my $Id = $CompositeWidget->createText(
|
468
|
|
|
|
|
|
|
$xText, $yText,
|
469
|
|
|
|
|
|
|
-text => $NewLegend,
|
470
|
|
|
|
|
|
|
-anchor => 'nw',
|
471
|
|
|
|
|
|
|
-tags => [ $Tag, $CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph}, ],
|
472
|
|
|
|
|
|
|
);
|
473
|
|
|
|
|
|
|
if ($legendfont) {
|
474
|
|
|
|
|
|
|
$CompositeWidget->itemconfigure( $Id, -font => $legendfont, );
|
475
|
|
|
|
|
|
|
}
|
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
$IndexColor++;
|
478
|
|
|
|
|
|
|
$IndexLegend++;
|
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
# cube
|
481
|
|
|
|
|
|
|
$x1Cube += $CompositeWidget->{RefInfoDummies}->{Legend}{LengthOneLegend};
|
482
|
|
|
|
|
|
|
$x2Cube += $CompositeWidget->{RefInfoDummies}->{Legend}{LengthOneLegend};
|
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
# Text
|
485
|
|
|
|
|
|
|
$xText += $CompositeWidget->{RefInfoDummies}->{Legend}{LengthOneLegend};
|
486
|
|
|
|
|
|
|
my $BarTag = $IndexLegend . $CompositeWidget->{RefInfoDummies}->{TAGS}{Bar};
|
487
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{MsgBalloon}->{$Tag} = $Legende;
|
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
#$CompositeWidget->{RefInfoDummies}->{Legend}{MsgBalloon}->{$BarTag} = $Legende;
|
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
if ( $IndexLegend == $CompositeWidget->{RefInfoDummies}->{Legend}{LegendTextNumber} ) {
|
492
|
|
|
|
|
|
|
last LEGEND;
|
493
|
|
|
|
|
|
|
}
|
494
|
|
|
|
|
|
|
}
|
495
|
|
|
|
|
|
|
}
|
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
# box legend
|
498
|
|
|
|
|
|
|
my $x1Box = $CompositeWidget->{RefInfoDummies}->{Axis}{CxMin};
|
499
|
|
|
|
|
|
|
my $y1Box
|
500
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Axis}{CyMin}
|
501
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{TickHeight}
|
502
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{ScaleValuesHeight}
|
503
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{xlabelHeight};
|
504
|
|
|
|
|
|
|
my $x2Box
|
505
|
|
|
|
|
|
|
= $x1Box
|
506
|
|
|
|
|
|
|
+ ( $CompositeWidget->{RefInfoDummies}->{Legend}{NbrPerLine}
|
507
|
|
|
|
|
|
|
* $CompositeWidget->{RefInfoDummies}->{Legend}{LengthOneLegend} );
|
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
# Reajuste box if width box < legend title text
|
510
|
|
|
|
|
|
|
my @InfoLegendTitle = $CompositeWidget->bbox( $CompositeWidget->{RefInfoDummies}->{TAGS}{TitleLegend} );
|
511
|
|
|
|
|
|
|
if ( $InfoLegendTitle[2] and $x2Box <= $InfoLegendTitle[2] ) {
|
512
|
|
|
|
|
|
|
$x2Box = $InfoLegendTitle[2] + 2;
|
513
|
|
|
|
|
|
|
}
|
514
|
|
|
|
|
|
|
my $y2Box = $y1Box + $CompositeWidget->{RefInfoDummies}->{Legend}{Height};
|
515
|
|
|
|
|
|
|
$CompositeWidget->createRectangle(
|
516
|
|
|
|
|
|
|
$x1Box, $y1Box, $x2Box, $y2Box,
|
517
|
|
|
|
|
|
|
-tags => [
|
518
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{BoxLegend},
|
519
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph},
|
520
|
|
|
|
|
|
|
],
|
521
|
|
|
|
|
|
|
);
|
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
return;
|
524
|
|
|
|
|
|
|
}
|
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
sub _axis {
|
527
|
|
|
|
|
|
|
my ($CompositeWidget) = @_;
|
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
# x axis width
|
530
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{Width}
|
531
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Canvas}{Width}
|
532
|
|
|
|
|
|
|
- ( 2 * $CompositeWidget->{RefInfoDummies}->{Canvas}{WidthEmptySpace}
|
533
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{ylabelWidth}
|
534
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{ScaleValuesWidth}
|
535
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{TickWidth} );
|
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
# get Height legend
|
538
|
|
|
|
|
|
|
if ( $CompositeWidget->{RefInfoDummies}->{Legend}{NbrLegend} > 0 ) {
|
539
|
|
|
|
|
|
|
$CompositeWidget->_Legend( $CompositeWidget->{RefInfoDummies}->{Legend}{DataLegend} );
|
540
|
|
|
|
|
|
|
}
|
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
# Height y axis
|
543
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{Height}
|
544
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Canvas}{Height} # Largeur canvas
|
545
|
|
|
|
|
|
|
- (
|
546
|
|
|
|
|
|
|
2 * $CompositeWidget->{RefInfoDummies}->{Canvas}{HeightEmptySpace} # 2 fois les espace vides
|
547
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Title}{Height} # Hauteur du titre
|
548
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{TickHeight} # Hauteur tick (axe x)
|
549
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{ScaleValuesHeight} # Hauteur valeurs axe
|
550
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{xlabelHeight} # Hauteur x label
|
551
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Legend}{Height} # Hauteur légende
|
552
|
|
|
|
|
|
|
);
|
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
#===========================
|
555
|
|
|
|
|
|
|
# Y axis
|
556
|
|
|
|
|
|
|
# Set 2 points (CxMin, CyMin) et (CxMin, CyMax)
|
557
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CxMin} # Coordonnées CxMin
|
558
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Canvas}{WidthEmptySpace} # Largeur vide
|
559
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{ylabelWidth} # Largeur label y
|
560
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{ScaleValuesWidth} # Largeur valeur axe y
|
561
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{TickWidth}; # Largeur tick axe y
|
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CyMax} # Coordonnées CyMax
|
564
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Canvas}{HeightEmptySpace} # Hauteur vide
|
565
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Title}{Height} # Hauteur titre
|
566
|
|
|
|
|
|
|
;
|
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CyMin} # Coordonnées CyMin
|
569
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Axis}{CyMax} # Coordonnées CyMax (haut)
|
570
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{Height} # Hauteur axe Y
|
571
|
|
|
|
|
|
|
;
|
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
# display Y axis
|
574
|
|
|
|
|
|
|
$CompositeWidget->createLine(
|
575
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CxMin},
|
576
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CyMin},
|
577
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CxMin},
|
578
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CyMax},
|
579
|
|
|
|
|
|
|
-tags => [
|
580
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{yAxis},
|
581
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllAXIS},
|
582
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph},
|
583
|
|
|
|
|
|
|
],
|
584
|
|
|
|
|
|
|
);
|
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
#===========================
|
587
|
|
|
|
|
|
|
# X axis
|
588
|
|
|
|
|
|
|
# Set 2 points (CxMin,CyMin) et (CxMax,CyMin)
|
589
|
|
|
|
|
|
|
# ou (Cx0,Cy0) et (CxMax,Cy0)
|
590
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CxMax} = $CompositeWidget->{RefInfoDummies}->{Axis}{CxMin}
|
591
|
|
|
|
|
|
|
+ $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{Width};
|
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
# Bottom x axis
|
594
|
|
|
|
|
|
|
$CompositeWidget->createLine(
|
595
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CxMin},
|
596
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CyMin},
|
597
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CxMax},
|
598
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CyMin},
|
599
|
|
|
|
|
|
|
-tags => [
|
600
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{xAxis},
|
601
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllAXIS},
|
602
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph},
|
603
|
|
|
|
|
|
|
],
|
604
|
|
|
|
|
|
|
);
|
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
# POINT (0,0)
|
607
|
|
|
|
|
|
|
# min positive value >= 0
|
608
|
|
|
|
|
|
|
if ( $CompositeWidget->{RefInfoDummies}->{Data}{MinYValue} >= 0 ) {
|
609
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Cx0} = $CompositeWidget->{RefInfoDummies}->{Axis}{CxMin};
|
610
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Cy0} = $CompositeWidget->{RefInfoDummies}->{Axis}{CyMin};
|
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{HeightUnit} # Height unit for value = 1
|
613
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{Height}
|
614
|
|
|
|
|
|
|
/ ( $CompositeWidget->{RefInfoDummies}->{Data}{MaxYValue} - 0 );
|
615
|
|
|
|
|
|
|
}
|
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
# min positive value < 0
|
618
|
|
|
|
|
|
|
else {
|
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{HeightUnit} # Height unit for value = 1
|
621
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{Height}
|
622
|
|
|
|
|
|
|
/ ( $CompositeWidget->{RefInfoDummies}->{Data}{MaxYValue}
|
623
|
|
|
|
|
|
|
- $CompositeWidget->{RefInfoDummies}->{Data}{MinYValue} );
|
624
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Cx0} = $CompositeWidget->{RefInfoDummies}->{Axis}{CxMin};
|
625
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Cy0}
|
626
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Axis}{CyMin}
|
627
|
|
|
|
|
|
|
+ ( $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{HeightUnit}
|
628
|
|
|
|
|
|
|
* $CompositeWidget->{RefInfoDummies}->{Data}{MinYValue} );
|
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
# X Axis (0,0)
|
631
|
|
|
|
|
|
|
$CompositeWidget->createLine(
|
632
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Cx0},
|
633
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Cy0},
|
634
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{CxMax},
|
635
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Cy0},
|
636
|
|
|
|
|
|
|
-tags => [
|
637
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{xAxis0},
|
638
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllAXIS},
|
639
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph},
|
640
|
|
|
|
|
|
|
],
|
641
|
|
|
|
|
|
|
);
|
642
|
|
|
|
|
|
|
}
|
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
return;
|
645
|
|
|
|
|
|
|
}
|
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
sub _xtick {
|
648
|
|
|
|
|
|
|
my ($CompositeWidget) = @_;
|
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
my $xvaluecolor = $CompositeWidget->cget( -xvaluecolor );
|
651
|
|
|
|
|
|
|
my $longticks = $CompositeWidget->cget( -longticks );
|
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
# x coordinates y ticks on bottom x axis
|
654
|
|
|
|
|
|
|
my $Xtickx1 = $CompositeWidget->{RefInfoDummies}->{Axis}{CxMin};
|
655
|
|
|
|
|
|
|
my $Xticky1 = $CompositeWidget->{RefInfoDummies}->{Axis}{CyMin};
|
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
# x coordinates y ticks on 0,0 x axis if the graph have only y value < 0
|
658
|
|
|
|
|
|
|
if ( $CompositeWidget->cget( -zeroaxisonly ) == 1
|
659
|
|
|
|
|
|
|
and $CompositeWidget->{RefInfoDummies}->{Data}{MaxYValue} > 0 )
|
660
|
|
|
|
|
|
|
{
|
661
|
|
|
|
|
|
|
$Xticky1 = $CompositeWidget->{RefInfoDummies}->{Axis}{Cy0};
|
662
|
|
|
|
|
|
|
}
|
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
my $Xtickx2 = $Xtickx1;
|
665
|
|
|
|
|
|
|
my $Xticky2 = $Xticky1 + $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{TickHeight};
|
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
# Coordinates of x values (first value)
|
668
|
|
|
|
|
|
|
my $XtickxValue = $CompositeWidget->{RefInfoDummies}->{Axis}{CxMin}
|
669
|
|
|
|
|
|
|
+ ( $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick} / 2 );
|
670
|
|
|
|
|
|
|
my $XtickyValue = $Xticky2 + ( $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{ScaleValuesHeight} / 2 );
|
671
|
|
|
|
|
|
|
my $NbrLeg = scalar( @{ $CompositeWidget->{RefInfoDummies}->{Data}{RefXLegend} } );
|
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
my $xlabelskip = $CompositeWidget->cget( -xlabelskip );
|
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
# index of tick and vlaues that will be skip
|
676
|
|
|
|
|
|
|
my %IndiceToSkip;
|
677
|
|
|
|
|
|
|
if ( defined $xlabelskip ) {
|
678
|
|
|
|
|
|
|
for ( my $i = 1; $i <= $NbrLeg; $i++ ) {
|
679
|
|
|
|
|
|
|
$IndiceToSkip{$i} = 1;
|
680
|
|
|
|
|
|
|
$i += $xlabelskip;
|
681
|
|
|
|
|
|
|
}
|
682
|
|
|
|
|
|
|
}
|
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
for ( my $Indice = 1; $Indice <= $NbrLeg; $Indice++ ) {
|
685
|
|
|
|
|
|
|
my $data = $CompositeWidget->{RefInfoDummies}->{Data}{RefXLegend}->[ $Indice - 1 ];
|
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
# tick
|
688
|
|
|
|
|
|
|
$Xtickx1 += $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick};
|
689
|
|
|
|
|
|
|
$Xtickx2 = $Xtickx1;
|
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
# tick legend
|
692
|
|
|
|
|
|
|
my $RegexXtickselect = $CompositeWidget->cget( -xvaluesregex );
|
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
if ( $data =~ m{$RegexXtickselect} ) {
|
695
|
|
|
|
|
|
|
next unless ( defined $IndiceToSkip{$Indice} );
|
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
# Long tick
|
698
|
|
|
|
|
|
|
if ( defined $longticks and $longticks == 1 ) {
|
699
|
|
|
|
|
|
|
$Xticky1 = $CompositeWidget->{RefInfoDummies}->{Axis}{CyMax};
|
700
|
|
|
|
|
|
|
$Xticky2 = $CompositeWidget->{RefInfoDummies}->{Axis}{CyMin};
|
701
|
|
|
|
|
|
|
}
|
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
$CompositeWidget->createLine(
|
704
|
|
|
|
|
|
|
$Xtickx1, $Xticky1, $Xtickx2, $Xticky2,
|
705
|
|
|
|
|
|
|
-tags => [
|
706
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{xTick},
|
707
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllTick},
|
708
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph},
|
709
|
|
|
|
|
|
|
],
|
710
|
|
|
|
|
|
|
);
|
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
if ( defined $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick}
|
713
|
|
|
|
|
|
|
and defined $CompositeWidget->{RefInfoDummies}->{Legend}{WidthOneCaracter} )
|
714
|
|
|
|
|
|
|
{
|
715
|
|
|
|
|
|
|
my $MaxLength = $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick};
|
716
|
|
|
|
|
|
|
my $WidthData = $CompositeWidget->{RefInfoDummies}->{Legend}{WidthOneCaracter} * length $data;
|
717
|
|
|
|
|
|
|
my $NbrCharacter = int( $MaxLength / $CompositeWidget->{RefInfoDummies}->{Legend}{WidthOneCaracter} );
|
718
|
|
|
|
|
|
|
if ( defined $MaxLength and $WidthData > $MaxLength ) {
|
719
|
|
|
|
|
|
|
$data =~ s/^(.{$NbrCharacter}).*/$1/;
|
720
|
|
|
|
|
|
|
$data .= '...';
|
721
|
|
|
|
|
|
|
}
|
722
|
|
|
|
|
|
|
}
|
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
$CompositeWidget->createText(
|
725
|
|
|
|
|
|
|
$XtickxValue,
|
726
|
|
|
|
|
|
|
$XtickyValue,
|
727
|
|
|
|
|
|
|
-text => $data,
|
728
|
|
|
|
|
|
|
-fill => $xvaluecolor,
|
729
|
|
|
|
|
|
|
-tags => [
|
730
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{xValues},
|
731
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllValues},
|
732
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph},
|
733
|
|
|
|
|
|
|
],
|
734
|
|
|
|
|
|
|
);
|
735
|
|
|
|
|
|
|
}
|
736
|
|
|
|
|
|
|
$XtickxValue += $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick};
|
737
|
|
|
|
|
|
|
}
|
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
return;
|
740
|
|
|
|
|
|
|
}
|
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
sub _ViewData {
|
743
|
|
|
|
|
|
|
my ($CompositeWidget) = @_;
|
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
my $legendmarkercolors = $CompositeWidget->cget( -colordata );
|
746
|
|
|
|
|
|
|
my $overwrite = $CompositeWidget->cget( -overwrite );
|
747
|
|
|
|
|
|
|
my $cumulate = $CompositeWidget->cget( -cumulate );
|
748
|
|
|
|
|
|
|
my $spacingbar = $CompositeWidget->cget( -spacingbar );
|
749
|
|
|
|
|
|
|
my $showvalues = $CompositeWidget->cget( -showvalues );
|
750
|
|
|
|
|
|
|
my $outlinebar = $CompositeWidget->cget( -outlinebar );
|
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
# number of value for x axis
|
753
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{xtickNumber}
|
754
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Data}{NumberXValues};
|
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
# Space between x ticks
|
757
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick}
|
758
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{Width}
|
759
|
|
|
|
|
|
|
/ ( $CompositeWidget->{RefInfoDummies}->{Data}{xtickNumber} + 1 );
|
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
my $IdData = 0;
|
762
|
|
|
|
|
|
|
my $IndexColor = 0;
|
763
|
|
|
|
|
|
|
my $WidthBar = $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick}
|
764
|
|
|
|
|
|
|
/ $CompositeWidget->{RefInfoDummies}->{Data}{NumberRealData};
|
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
my @CumulateY = (0) x scalar @{ $CompositeWidget->{RefInfoDummies}->{Data}{RefAllData}->[0] };
|
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
foreach my $RefArrayData ( @{ $CompositeWidget->{RefInfoDummies}->{Data}{RefAllData} } ) {
|
769
|
|
|
|
|
|
|
if ( $IdData == 0 ) {
|
770
|
|
|
|
|
|
|
$IdData++;
|
771
|
|
|
|
|
|
|
next;
|
772
|
|
|
|
|
|
|
}
|
773
|
|
|
|
|
|
|
my $NumberData = 1; # Number of data
|
774
|
|
|
|
|
|
|
foreach my $data ( @{$RefArrayData} ) {
|
775
|
|
|
|
|
|
|
unless ( defined $data ) {
|
776
|
|
|
|
|
|
|
push @CumulateY, 0;
|
777
|
|
|
|
|
|
|
$NumberData++;
|
778
|
|
|
|
|
|
|
next;
|
779
|
|
|
|
|
|
|
}
|
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
my ( $x, $y, $x0, $y0 ) = ();
|
782
|
|
|
|
|
|
|
if ( $overwrite == 1 or $cumulate == 1 ) {
|
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
# coordinates x and y values
|
785
|
|
|
|
|
|
|
$x = $CompositeWidget->{RefInfoDummies}->{Axis}{Cx0}
|
786
|
|
|
|
|
|
|
+ $NumberData * $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick};
|
787
|
|
|
|
|
|
|
$y = $CompositeWidget->{RefInfoDummies}->{Axis}{Cy0}
|
788
|
|
|
|
|
|
|
- ( $data * $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{HeightUnit} );
|
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
# coordinates x0 and y0 values
|
791
|
|
|
|
|
|
|
$x0 = $x - $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick};
|
792
|
|
|
|
|
|
|
$y0 = $CompositeWidget->{RefInfoDummies}->{Axis}{Cy0};
|
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
# cumulate bars
|
795
|
|
|
|
|
|
|
if ( $cumulate == 1 ) {
|
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
$y -= $CumulateY[ $NumberData - 1 ];
|
798
|
|
|
|
|
|
|
$y0 = $y + ( $data * $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{HeightUnit} );
|
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
$CumulateY[ $NumberData - 1 ]
|
801
|
|
|
|
|
|
|
+= ( $data * $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{HeightUnit} );
|
802
|
|
|
|
|
|
|
}
|
803
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
# space between bars
|
805
|
|
|
|
|
|
|
if ( $spacingbar == 1 ) {
|
806
|
|
|
|
|
|
|
$x -= $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick} / 4;
|
807
|
|
|
|
|
|
|
$x0 += $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick} / 4;
|
808
|
|
|
|
|
|
|
}
|
809
|
|
|
|
|
|
|
}
|
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
# No overwrite
|
812
|
|
|
|
|
|
|
else {
|
813
|
|
|
|
|
|
|
$x
|
814
|
|
|
|
|
|
|
= $CompositeWidget->{RefInfoDummies}->{Axis}{Cx0}
|
815
|
|
|
|
|
|
|
+ $NumberData * $CompositeWidget->{RefInfoDummies}->{Axis}{Xaxis}{SpaceBetweenTick}
|
816
|
|
|
|
|
|
|
- ( ( $CompositeWidget->{RefInfoDummies}->{Data}{NumberRealData} - $IdData ) * $WidthBar );
|
817
|
|
|
|
|
|
|
$y = $CompositeWidget->{RefInfoDummies}->{Axis}{Cy0}
|
818
|
|
|
|
|
|
|
- ( $data * $CompositeWidget->{RefInfoDummies}->{Axis}{Yaxis}{HeightUnit} );
|
819
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
# coordinates x0 and y0 values
|
821
|
|
|
|
|
|
|
$x0 = $x - $WidthBar;
|
822
|
|
|
|
|
|
|
$y0 = $CompositeWidget->{RefInfoDummies}->{Axis}{Cy0};
|
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
# space between bars
|
825
|
|
|
|
|
|
|
if ( $spacingbar == 1 ) {
|
826
|
|
|
|
|
|
|
$x -= $WidthBar / 4;
|
827
|
|
|
|
|
|
|
$x0 += $WidthBar / 4;
|
828
|
|
|
|
|
|
|
}
|
829
|
|
|
|
|
|
|
}
|
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
my $LineColor = $legendmarkercolors->[$IndexColor];
|
832
|
|
|
|
|
|
|
unless ( defined $LineColor ) {
|
833
|
|
|
|
|
|
|
$IndexColor = 0;
|
834
|
|
|
|
|
|
|
$LineColor = $legendmarkercolors->[$IndexColor];
|
835
|
|
|
|
|
|
|
}
|
836
|
|
|
|
|
|
|
my $tag = $IdData . $CompositeWidget->{RefInfoDummies}->{TAGS}{Bar};
|
837
|
|
|
|
|
|
|
my $tag2 = $IdData . "_$NumberData" . $CompositeWidget->{RefInfoDummies}->{TAGS}{Bar};
|
838
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Legend}{MsgBalloon}->{$tag2}
|
839
|
|
|
|
|
|
|
= "Sample : $CompositeWidget->{RefInfoDummies}->{Data}{RefAllData}->[0]->[$NumberData-1]\n"
|
840
|
|
|
|
|
|
|
. "Value : $data";
|
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
$CompositeWidget->createRectangle(
|
843
|
|
|
|
|
|
|
$x0, $y0, $x, $y,
|
844
|
|
|
|
|
|
|
-fill => $LineColor,
|
845
|
|
|
|
|
|
|
-tags => [
|
846
|
|
|
|
|
|
|
$tag, $tag2,
|
847
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllData},
|
848
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph},
|
849
|
|
|
|
|
|
|
],
|
850
|
|
|
|
|
|
|
-width => $CompositeWidget->cget( -linewidth ),
|
851
|
|
|
|
|
|
|
-outline => $outlinebar,
|
852
|
|
|
|
|
|
|
);
|
853
|
|
|
|
|
|
|
if ( $showvalues == 1 ) {
|
854
|
|
|
|
|
|
|
$CompositeWidget->createText(
|
855
|
|
|
|
|
|
|
$x0 + ( $x - $x0 ) / 2,
|
856
|
|
|
|
|
|
|
$y - 8,
|
857
|
|
|
|
|
|
|
-text => $data,
|
858
|
|
|
|
|
|
|
-font => $CompositeWidget->{RefInfoDummies}->{Font}{DefaultBarValues},
|
859
|
|
|
|
|
|
|
-tags => [
|
860
|
|
|
|
|
|
|
$tag,
|
861
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{BarValues},
|
862
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{TAGS}{AllTagsDummiesGraph},
|
863
|
|
|
|
|
|
|
],
|
864
|
|
|
|
|
|
|
);
|
865
|
|
|
|
|
|
|
}
|
866
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}{Bar}{$tag}{color} = $LineColor;
|
868
|
|
|
|
|
|
|
$NumberData++;
|
869
|
|
|
|
|
|
|
}
|
870
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
$IdData++;
|
872
|
|
|
|
|
|
|
$IndexColor++;
|
873
|
|
|
|
|
|
|
}
|
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
return 1;
|
876
|
|
|
|
|
|
|
}
|
877
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
sub plot {
|
879
|
|
|
|
|
|
|
my ( $CompositeWidget, $RefData, %option ) = @_;
|
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
my $overwrite = $CompositeWidget->cget( -overwrite );
|
882
|
|
|
|
|
|
|
my $cumulate = $CompositeWidget->cget( -cumulate );
|
883
|
|
|
|
|
|
|
my $yticknumber = $CompositeWidget->cget( -yticknumber );
|
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
if ( defined $option{-substitutionvalue}
|
886
|
|
|
|
|
|
|
and _isANumber( $option{-substitutionvalue} ) )
|
887
|
|
|
|
|
|
|
{
|
888
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{SubstitutionValue} = $option{-substitutionvalue};
|
889
|
|
|
|
|
|
|
}
|
890
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{NumberRealData} = scalar( @{$RefData} ) - 1;
|
892
|
|
|
|
|
|
|
|
893
|
|
|
|
|
|
|
unless ( defined $RefData ) {
|
894
|
|
|
|
|
|
|
$CompositeWidget->_error('data not defined');
|
895
|
|
|
|
|
|
|
return;
|
896
|
|
|
|
|
|
|
}
|
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
unless ( scalar @{$RefData} > 1 ) {
|
899
|
|
|
|
|
|
|
$CompositeWidget->_error('You must have at least 2 arrays');
|
900
|
|
|
|
|
|
|
return;
|
901
|
|
|
|
|
|
|
}
|
902
|
|
|
|
|
|
|
|
903
|
|
|
|
|
|
|
# Check legend and data size
|
904
|
|
|
|
|
|
|
if ( my $RefLegend = $CompositeWidget->{RefInfoDummies}->{Legend}{DataLegend} ) {
|
905
|
|
|
|
|
|
|
unless ( $CompositeWidget->_CheckSizeLengendAndData( $RefData, $RefLegend ) ) {
|
906
|
|
|
|
|
|
|
undef $CompositeWidget->{RefInfoDummies}->{Legend}{DataLegend};
|
907
|
|
|
|
|
|
|
}
|
908
|
|
|
|
|
|
|
}
|
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
# Check array size
|
911
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{NumberXValues} = scalar @{ $RefData->[0] };
|
912
|
|
|
|
|
|
|
my $i = 0;
|
913
|
|
|
|
|
|
|
my @arrayTemp = (0) x scalar @{ $RefData->[0] };
|
914
|
|
|
|
|
|
|
foreach my $RefArray ( @{$RefData} ) {
|
915
|
|
|
|
|
|
|
unless ( scalar @{$RefArray} == $CompositeWidget->{RefInfoDummies}->{Data}{NumberXValues} ) {
|
916
|
|
|
|
|
|
|
$CompositeWidget->_error( 'Make sure that every array has the ' . 'same size in plot data method', 1 );
|
917
|
|
|
|
|
|
|
return;
|
918
|
|
|
|
|
|
|
}
|
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
# Get min and max size
|
921
|
|
|
|
|
|
|
if ( $i != 0 ) {
|
922
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
# substitute none real value
|
924
|
|
|
|
|
|
|
my $j = 0;
|
925
|
|
|
|
|
|
|
foreach my $data ( @{$RefArray} ) {
|
926
|
|
|
|
|
|
|
if ( defined $data and !_isANumber($data) ) {
|
927
|
|
|
|
|
|
|
$data = $CompositeWidget->{RefInfoDummies}->{Data}{SubstitutionValue};
|
928
|
|
|
|
|
|
|
}
|
929
|
|
|
|
|
|
|
$arrayTemp[$j] += $data; # For cumulate option
|
930
|
|
|
|
|
|
|
$j++;
|
931
|
|
|
|
|
|
|
}
|
932
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{MaxYValue}
|
933
|
|
|
|
|
|
|
= _MaxArray( [ $CompositeWidget->{RefInfoDummies}->{Data}{MaxYValue}, _MaxArray($RefArray) ] );
|
934
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{MinYValue}
|
935
|
|
|
|
|
|
|
= _MinArray( [ $CompositeWidget->{RefInfoDummies}->{Data}{MinYValue}, _MinArray($RefArray) ] );
|
936
|
|
|
|
|
|
|
}
|
937
|
|
|
|
|
|
|
$i++;
|
938
|
|
|
|
|
|
|
}
|
939
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{RefXLegend} = $RefData->[0];
|
940
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{RefAllData} = $RefData;
|
941
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{PlotDefined} = 1;
|
942
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
if ( $cumulate == 1 ) {
|
944
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{MaxYValue} = _MaxArray( \@arrayTemp );
|
945
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{MinYValue} = _MinArray( \@arrayTemp );
|
946
|
|
|
|
|
|
|
}
|
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
if ( $CompositeWidget->{RefInfoDummies}->{Data}{MinYValue} > 0 ) {
|
949
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{MinYValue} = 0;
|
950
|
|
|
|
|
|
|
}
|
951
|
|
|
|
|
|
|
while ( ( $CompositeWidget->{RefInfoDummies}->{Data}{MaxYValue} / $yticknumber ) % 5 != 0 ) {
|
952
|
|
|
|
|
|
|
$CompositeWidget->{RefInfoDummies}->{Data}{MaxYValue}
|
953
|
|
|
|
|
|
|
= int( $CompositeWidget->{RefInfoDummies}->{Data}{MaxYValue} + 1 );
|
954
|
|
|
|
|
|
|
}
|
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
$CompositeWidget->_GraphForDummiesConstruction;
|
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
return 1;
|
959
|
|
|
|
|
|
|
}
|
960
|
|
|
|
|
|
|
|
961
|
|
|
|
|
|
|
1;
|
962
|
|
|
|
|
|
|
__END__
|