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
a07c6350
Commit
a07c6350
authored
Jan 29, 2019
by
Sascha Herzinger
Browse files
tooltip works (but is misplaced)
parent
fc27b6d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/assets/css/scatterplot.css
View file @
a07c6350
...
...
@@ -39,3 +39,14 @@
.ac-scatter-axis
.tick
text
{
font-size
:
1.5em
;
}
.ac-scatter-tooltip
{
white-space
:
nowrap
;
font-size
:
0.75em
;
position
:
absolute
;
background
:
rgba
(
0
,
0
,
0
,
0.7
);
pointer-events
:
none
;
color
:
white
;
padding
:
0.5vh
;
visibility
:
hidden
;
}
src/charts/impl/Scatterplot.js
View file @
a07c6350
...
...
@@ -17,6 +17,9 @@ export default class extends Chart {
.
append
(
'
svg
'
)
.
attr
(
'
class
'
,
'
ac-scatter-svg
'
)
.
append
(
'
g
'
);
this
.
tooltip
=
d3
.
select
(
container
)
.
append
(
'
div
'
)
.
attr
(
'
class
'
,
'
ac-scatter-tooltip
'
);
this
.
values
=
[];
this
.
callback
=
()
=>
{};
...
...
@@ -32,9 +35,9 @@ export default class extends Chart {
}
render
({
values
,
callback
,
})
{
values
,
callback
,
})
{
this
.
values
=
typeof
values
===
'
undefined
'
?
this
.
values
:
values
;
this
.
callback
=
typeof
callback
===
'
undefined
'
?
this
.
callback
:
callback
;
...
...
@@ -123,14 +126,27 @@ export default class extends Chart {
.
attr
(
'
class
'
,
'
ac-scatter-brush
'
)
.
call
(
brush
);
this
.
svg
.
on
(
'
mousemove
'
,
(
d
,
i
,
nodes
)
=>
{
const
[
xPos
,
yPos
]
=
d3
.
mouse
(
nodes
[
i
]);
const
ctx
=
this
.
hiddenCanvas
.
node
().
getContext
(
'
2d
'
);
const
[
r
,
g
,
b
]
=
ctx
.
getImageData
(
xPos
,
yPos
,
1
,
1
).
data
;
const
tooltip
=
this
.
colorToTooltipMap
[
`
${
r
}
:
${
g
}
:
${
b
}
`
];
if
(
typeof
tooltip
===
'
undefined
'
)
return
;
// background color
});
this
.
svg
.
on
(
'
mousemove
'
,
(
d
,
i
,
nodes
)
=>
{
const
[
xPos
,
yPos
]
=
d3
.
mouse
(
nodes
[
i
]);
const
ctx
=
this
.
hiddenCanvas
.
node
().
getContext
(
'
2d
'
);
const
[
r
,
g
,
b
]
=
ctx
.
getImageData
(
xPos
,
yPos
,
1
,
1
).
data
;
const
tooltip
=
this
.
colorToTooltipMap
[
`
${
r
}
:
${
g
}
:
${
b
}
`
];
if
(
typeof
tooltip
===
'
undefined
'
)
{
this
.
tooltip
.
style
(
'
visibility
'
,
'
hidden
'
);
}
else
{
this
.
tooltip
.
style
(
'
left
'
,
`
${
x
}
px`
)
.
style
(
'
top
'
,
`
${
y
}
px`
)
.
style
(
'
visibility
'
,
'
visible
'
)
.
html
(
tooltip
);
}
})
.
on
(
'
mouseleave
'
,
()
=>
{
this
.
tooltip
.
style
(
'
visibility
'
,
'
hidden
'
);
});
const
point
=
this
.
memory
.
selectAll
(
'
.ac-scatter-point
'
)
.
data
(
values
);
...
...
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