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
08d2392f
Commit
08d2392f
authored
Jan 30, 2019
by
Sascha Herzinger
Browse files
fixed tooltip
parent
01103e3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/charts/impl/Scatterplot.js
View file @
08d2392f
...
...
@@ -277,49 +277,51 @@ ${typeof this.categories.name === 'undefined' ? d[2] : this.categories[d[2]]}</b
legendElement
.
exit
()
.
remove
();
const
nodes
=
this
.
memory
.
selectAll
(
'
circle
'
).
nodes
();
const
nodes
=
this
.
memory
.
selectAll
(
'
circle
'
)
.
filter
(
d
=>
typeof
_selectedCategory
===
'
undefined
'
||
d
[
2
]
===
_selectedCategory
)
.
nodes
();
const
ctx
=
this
.
canvas
.
node
().
getContext
(
'
2d
'
);
const
hiddenCtx
=
this
.
hiddenCanvas
.
getContext
(
'
2d
'
);
this
.
colorToTooltipMap
=
{};
const
t
=
d3
.
timer
((
elapsed
)
=>
{
setTimeout
(()
=>
{
ctx
.
clearRect
(
0
,
0
,
width
,
height
);
nodes
.
forEach
((
node
)
=>
{
ctx
.
beginPath
();
ctx
.
arc
(
node
.
getAttribute
(
'
dx
'
),
node
.
getAttribute
(
'
dy
'
),
node
.
getAttribute
(
'
r
'
),
0
,
2
*
Math
.
PI
,
false
,
);
ctx
.
fillStyle
=
node
.
getAttribute
(
'
fillStyle
'
);
ctx
.
fill
();
});
},
0
);
if
(
elapsed
>
ANIMATION_DURATION
*
2
)
{
t
.
stop
();
this
.
colorToTooltipMap
=
{};
const
hiddenCtx
=
this
.
hiddenCanvas
.
getContext
(
'
2d
'
);
hiddenCtx
.
clearRect
(
0
,
0
,
width
,
height
);
nodes
.
forEach
((
node
,
i
)
=>
{
if
(
typeof
_selectedCategory
===
'
undefined
'
||
node
.
getAttribute
(
'
data-z
'
)
===
_selectedCategory
)
{
// draw visible point
ctx
.
beginPath
();
ctx
.
arc
(
node
.
getAttribute
(
'
dx
'
),
node
.
getAttribute
(
'
dy
'
),
node
.
getAttribute
(
'
r
'
),
0
,
2
*
Math
.
PI
,
false
,
);
ctx
.
fillStyle
=
node
.
getAttribute
(
'
fillStyle
'
);
ctx
.
fill
();
// draw invisible square with unique color
const
colorCode
=
i
+
1
;
// eslint-disable-next-line no-bitwise
const
r
=
colorCode
>>
16
;
// eslint-disable-next-line no-bitwise
const
g
=
colorCode
-
(
r
<<
16
)
>>
8
;
// eslint-disable-next-line no-bitwise
const
b
=
colorCode
-
(
r
<<
16
)
-
(
g
<<
8
);
this
.
colorToTooltipMap
[
`
${
r
}
:
${
g
}
:
${
b
}
`
]
=
node
.
getAttribute
(
'
title
'
);
hiddenCtx
.
fillStyle
=
`rgb(
${
r
}
,
${
g
}
,
${
b
}
)`
;
hiddenCtx
.
fillRect
(
parseInt
(
node
.
getAttribute
(
'
dx
'
)
-
node
.
getAttribute
(
'
r
'
),
10
),
parseInt
(
node
.
getAttribute
(
'
dy
'
)
-
node
.
getAttribute
(
'
r
'
),
10
),
Math
.
ceil
(
node
.
getAttribute
(
'
r
'
)
*
2
+
0.5
),
Math
.
ceil
(
node
.
getAttribute
(
'
r
'
)
*
2
+
0.5
),
);
}
const
colorCode
=
i
+
1
;
// eslint-disable-next-line no-bitwise
const
r
=
colorCode
>>
16
;
// eslint-disable-next-line no-bitwise
const
g
=
colorCode
-
(
r
<<
16
)
>>
8
;
// eslint-disable-next-line no-bitwise
const
b
=
colorCode
-
(
r
<<
16
)
-
(
g
<<
8
);
this
.
colorToTooltipMap
[
`
${
r
}
:
${
g
}
:
${
b
}
`
]
=
node
.
getAttribute
(
'
title
'
);
hiddenCtx
.
fillStyle
=
`rgb(
${
r
}
,
${
g
}
,
${
b
}
)`
;
hiddenCtx
.
fillRect
(
parseInt
(
node
.
getAttribute
(
'
dx
'
)
-
node
.
getAttribute
(
'
r
'
),
10
),
parseInt
(
node
.
getAttribute
(
'
dy
'
)
-
node
.
getAttribute
(
'
r
'
),
10
),
Math
.
ceil
(
node
.
getAttribute
(
'
r
'
)
*
2
+
0.5
),
Math
.
ceil
(
node
.
getAttribute
(
'
r
'
)
*
2
+
0.5
),
);
});
},
0
);
if
(
elapsed
>
ANIMATION_DURATION
*
2
)
t
.
stop
();
}
},
0
);
}
}
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