(
$GD::Graph::lines::VERSION
) =
'$Revision: 1.15 $'
=~ /\s([\d.]+)/;
@GD::Graph::lines::ISA
=
qw( GD::Graph::axestype )
;
sub
draw_data_set
{
my
$self
=
shift
;
my
$ds
=
shift
;
my
@values
=
$self
->{_data}->y_values(
$ds
) or
return
$self
->_set_error(
"Impossible illegal data set: $ds"
,
$self
->{_data}->error);
my
$dsci
=
$self
->set_clr(
$self
->pick_data_clr(
$ds
) );
my
$type
=
$self
->pick_line_type(
$ds
);
my
(
$xb
,
$yb
);
if
(
defined
$values
[0])
{
if
(
defined
(
$self
->{x_min_value}) &&
defined
(
$self
->{x_max_value}))
{
(
$xb
,
$yb
) =
$self
->val_to_pixel(
$self
->{_data}->get_x(0),
$values
[0],
$ds
);
}
else
{
(
$xb
,
$yb
) =
$self
->val_to_pixel(1,
$values
[0],
$ds
);
}
}
for
(
my
$i
= 0;
$i
<
@values
;
$i
++)
{
if
(!
defined
$values
[
$i
])
{
(
$xb
,
$yb
) = ()
if
$self
->{skip_undef};
next
;
}
my
(
$xe
,
$ye
);
if
(
defined
(
$self
->{x_min_value}) &&
defined
(
$self
->{x_max_value}))
{
(
$xe
,
$ye
) =
$self
->val_to_pixel(
$self
->{_data}->get_x(
$i
),
$values
[
$i
],
$ds
);
}
else
{
(
$xe
,
$ye
) =
$self
->val_to_pixel(
$i
+1,
$values
[
$i
],
$ds
);
}
if
(
defined
$xb
)
{
$self
->draw_line(
$xb
,
$yb
,
$xe
,
$ye
,
$type
,
$dsci
)
if
defined
$dsci
;
$self
->{_hotspots}->[
$ds
]->[
$i
] =
[
'line'
,
$xb
,
$yb
,
$xe
,
$ye
,
$self
->{line_width}];
}
(
$xb
,
$yb
) = (
$xe
,
$ye
);
}
return
$ds
;
}
sub
pick_line_type
{
my
$self
=
shift
;
my
$num
=
shift
;
ref
$self
->{line_types} ?
$self
->{line_types}[
$num
% (1 + $
$num
% 4 ?
$num
% 4 : 4
}
sub
draw_line
{
my
$self
=
shift
;
my
(
$xs
,
$ys
,
$xe
,
$ye
,
$type
,
$clr
) =
@_
;
my
$lw
=
$self
->{line_width};
my
$lts
=
$self
->{line_type_scale};
my
$style
= gdStyled;
my
@pattern
= ();
LINE: {
(
$type
== 2) &&
do
{
for
(1 ..
$lts
) {
push
@pattern
,
$clr
}
for
(1 ..
$lts
) {
push
@pattern
, gdTransparent }
$self
->{graph}->setStyle(
@pattern
);
last
LINE;
};
(
$type
== 3) &&
do
{
for
(1 .. 2) {
push
@pattern
,
$clr
}
for
(1 .. 2) {
push
@pattern
, gdTransparent }
$self
->{graph}->setStyle(
@pattern
);
last
LINE;
};
(
$type
== 4) &&
do
{
for
(1 ..
$lts
) {
push
@pattern
,
$clr
}
for
(1 .. 2) {
push
@pattern
, gdTransparent }
for
(1 .. 2) {
push
@pattern
,
$clr
}
for
(1 .. 2) {
push
@pattern
, gdTransparent }
$self
->{graph}->setStyle(
@pattern
);
last
LINE;
};
$style
=
$clr
;
}
my
$i
;
for
$i
(1..
$lw
)
{
my
$yslw
=
$ys
+
int
(
$lw
/2) -
$i
;
my
$yelw
=
$ye
+
int
(
$lw
/2) -
$i
;
$self
->{graph}->setStyle(
@pattern
)
if
(
@pattern
);
$self
->{graph}->line(
$xs
,
$yslw
,
$xe
,
$yelw
,
$style
);
}
}
sub
draw_legend_marker
{
my
$self
=
shift
;
my
(
$n
,
$x
,
$y
) =
@_
;
my
$ci
=
$self
->set_clr(
$self
->pick_data_clr(
$n
));
return
unless
defined
$ci
;
my
$type
=
$self
->pick_line_type(
$n
);
$y
+=
int
(
$self
->{lg_el_height}/2);
local
(
$self
->{line_width}) = 2;
$self
->draw_line(
$x
,
$y
,
$x
+
$self
->{legend_marker_width},
$y
,
$type
,
$ci
);
}
"Just another true value"
;