our
$VERSION
=
'0.0002_01'
;
cex_to_px to_rgb group_to_NA pdl_to_plotly
)
;
sub
mode {
return
'lines'
;
}
classmethod marker (
$df
,
@rest
) {
return
;
}
classmethod to_trace (
$df
,
$params
,
@rest
) {
$df
= group_to_NA(
$df
);
my
$use_webgl
=
$class
->use_webgl(
$df
);
my
$plotly_trace_class
=
$use_webgl
?
'Chart::Plotly::Trace::Scattergl'
:
'Chart::Plotly::Trace::Scatter'
;
load
$plotly_trace_class
;
if
(
$log
->is_debug ) {
$log
->debug(
$use_webgl
?
"to use webgl"
:
"not to use webgl"
);
}
my
(
$x
,
$y
) =
map
{
$df
->at(
$_
) }
qw(x y)
;
my
$marker
=
$class
->marker(
$df
,
$params
,
@rest
);
my
$mode
=
$class
->mode;
my
$line
;
if
(
$mode
eq
'lines'
) {
my
$color
= to_rgb(
$df
->at(
'color'
)->slice( pdl(0) ) );
my
$size
= cex_to_px(
$df
->at(
'size'
)->slice( pdl(0) ) );
$size
= ifelse(
$size
< 2, 2,
$size
);
my
$linetype
=
$df
->at(
'linetype'
)->at(0);
$line
= {
color
=>
$color
->at(0),
width
=>
$size
->at(0),
(
$linetype
ne
'solid'
? (
dash
=>
$linetype
) : () ),
};
}
return
$plotly_trace_class
->new(
x
=>
$x
,
y
=>
$y
,
mode
=>
$mode
,
maybe
line
=>
$line
,
maybe
marker
=>
$marker
,
(
$use_webgl
? ()
: (
hovertext
=> pdl_to_plotly(
$df
->at(
'hovertext'
) ),
hoverinfo
=>
'text'
,
)
),
);
}
__PACKAGE__->meta->make_immutable;
1;