Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Sascha Herzinger
AdaCharts
Commits
968d5ca4
Commit
968d5ca4
authored
Jan 29, 2019
by
Sascha Herzinger
Browse files
no need to attach the hidden canvas to the DOM
parent
0fbe53bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/assets/css/scatterplot.css
View file @
968d5ca4
...
...
@@ -2,14 +2,6 @@
.ac-scatter-canvas
{
position
:
absolute
;
/*image-rendering: -moz-crisp-edges;*/
/*image-rendering: -webkit-crisp-edges;*/
/*image-rendering: pixelated;*/
/*image-rendering: crisp-edges;*/
}
.ac-scatter-invisible-canvas
{
visibility
:
hidden
;
}
.ac-scatter-svg
{
...
...
src/charts/impl/Scatterplot.js
View file @
968d5ca4
...
...
@@ -10,9 +10,7 @@ export default class extends Chart {
this
.
canvas
=
d3
.
select
(
container
)
.
append
(
'
canvas
'
)
.
attr
(
'
class
'
,
'
ac-scatter-canvas
'
);
this
.
hiddenCanvas
=
d3
.
select
(
container
)
.
append
(
'
canvas
'
)
.
attr
(
'
class
'
,
'
ac-scatter-canvas ac-scatter-invisible-canvas
'
);
this
.
hiddenCanvas
=
document
.
createElement
(
'
canvas
'
);
this
.
svg
=
d3
.
select
(
container
)
.
append
(
'
svg
'
)
.
attr
(
'
class
'
,
'
ac-scatter-svg
'
)
...
...
@@ -71,10 +69,8 @@ export default class extends Chart {
.
attr
(
'
height
'
,
height
)
.
style
(
'
transform
'
,
`translate(
${
margin
.
left
}
px,
${
margin
.
top
}
px)`
);
this
.
hiddenCanvas
.
attr
(
'
width
'
,
width
)
.
attr
(
'
height
'
,
height
)
.
style
(
'
transform
'
,
`translate(
${
margin
.
left
}
px,
${
margin
.
top
}
px)`
);
this
.
hiddenCanvas
.
width
=
width
;
this
.
hiddenCanvas
.
height
=
height
;
d3
.
select
(
this
.
container
).
select
(
'
svg
'
)
.
attr
(
'
width
'
,
width
+
margin
.
left
+
margin
.
right
)
...
...
@@ -131,7 +127,7 @@ export default class extends Chart {
this
.
svg
.
on
(
'
mousemove
'
,
(
d
,
i
,
nodes
)
=>
{
const
[
xPos
,
yPos
]
=
d3
.
mouse
(
nodes
[
i
]);
const
ctx
=
this
.
hiddenCanvas
.
node
().
getContext
(
'
2d
'
);
const
ctx
=
this
.
hiddenCanvas
.
getContext
(
'
2d
'
);
const
[
r
,
g
,
b
]
=
ctx
.
getImageData
(
xPos
,
yPos
,
1
,
1
).
data
;
const
tooltip
=
this
.
colorToTooltipMap
[
`
${
r
}
:
${
g
}
:
${
b
}
`
];
if
(
typeof
tooltip
===
'
undefined
'
)
{
...
...
@@ -170,7 +166,7 @@ ${d[2]}</br>
const
nodes
=
this
.
memory
.
selectAll
(
'
circle
'
).
nodes
();
const
ctx
=
this
.
canvas
.
node
().
getContext
(
'
2d
'
);
const
hiddenCtx
=
this
.
hiddenCanvas
.
node
().
getContext
(
'
2d
'
);
const
hiddenCtx
=
this
.
hiddenCanvas
.
getContext
(
'
2d
'
);
this
.
colorToTooltipMap
=
{};
ctx
.
clearRect
(
0
,
0
,
width
,
height
);
hiddenCtx
.
clearRect
(
0
,
0
,
width
,
height
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment