$Chart::Clicker::Renderer::Point::VERSION
=
'2.90'
;
has
'shape'
=> (
is
=>
'rw'
,
does
=>
'Geometry::Primitive::Shape'
,
default
=>
sub
{
Geometry::Primitive::Circle->new({
radius
=> 3,
});
}
);
has
'shape_brush'
=> (
is
=>
'rw'
,
isa
=>
'Graphics::Primitive::Brush'
,
);
override
(
'finalize'
,
sub
{
my
(
$self
) =
@_
;
my
$clicker
=
$self
->clicker;
my
$width
=
$self
->width;
my
$height
=
$self
->height;
my
$dses
=
$clicker
->get_datasets_for_context(
$self
->context);
foreach
my
$ds
(@{
$dses
}) {
foreach
my
$series
(@{
$ds
->series }) {
my
$ctx
=
$clicker
->get_context(
$ds
->context);
my
$domain
=
$ctx
->domain_axis;
my
$range
=
$ctx
->range_axis;
my
$min
=
$range
->range->lower;
my
@vals
= @{
$series
->
values
};
my
@keys
= @{
$series
->
keys
};
for
(0..(
$series
->key_count - 1)) {
my
$x
=
$domain
->mark(
$width
,
$keys
[
$_
]);
next
unless
defined
(
$x
);
my
$ymark
=
$range
->mark(
$height
,
$vals
[
$_
]);
next
unless
defined
(
$ymark
);
my
$y
=
$height
-
$ymark
;
$self
->move_to(
$x
,
$y
);
$self
->draw_point(
$x
,
$y
,
$series
,
$_
);
}
my
$op
= Graphics::Primitive::Operation::Fill->new(
paint
=> Graphics::Primitive::Paint::Solid->new(
color
=>
$clicker
->color_allocator->
next
)
);
if
(
defined
(
$self
->shape_brush)) {
$op
->preserve(1);
}
$self
->
do
(
$op
);
if
(
defined
(
$self
->shape_brush)) {
my
$op3
= Graphics::Primitive::Operation::Stroke->new;
$op3
->brush(
$self
->shape_brush->clone);
$self
->
do
(
$op3
);
}
}
}
return
1;
});
sub
draw_point {
my
(
$self
,
$x
,
$y
,
$series
,
$count
) =
@_
;
my
$shape
=
$self
->shape->clone;
$shape
->origin(Geometry::Primitive::Point->new(
x
=>
$x
,
y
=>
$y
));
$self
->path->add_primitive(
$shape
);
}
__PACKAGE__->meta->make_immutable;
no
Moose;
1;