Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
D
DV-Project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
almohanad.hafez
DV-Project
Commits
70183756
Commit
70183756
authored
Feb 13, 2025
by
Almouhannad Hafez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hover effect to bar chart
parent
7494db58
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
index.html
index.html
+2
-2
stacked-bar-chart.ts
src/ts/charts/stacked-bar-chart.ts
+8
-2
No files found.
index.html
View file @
70183756
...
...
@@ -65,9 +65,9 @@
data-bs-parent=
"#olympicStatsAccordion"
>
<div
class=
"accordion-body"
>
<div
class=
"chart-description"
>
This chart shows the distribution of medals won
by
over genders.
This chart shows the distribution of medals won over genders.
</div>
<
canvas
id=
"medalDistributionByGenderChart"
></canvas
>
<
div
id=
"medalDistributionByGenderChart"
></div
>
</div>
</div>
</div>
...
...
src/ts/charts/stacked-bar-chart.ts
View file @
70183756
...
...
@@ -80,6 +80,7 @@ export class StackedBarChart extends Chart {
.
attr
(
'y'
,
15
)
.
attr
(
'text-anchor'
,
'middle'
)
.
style
(
'font-weight'
,
'bold'
)
.
style
(
'user-select'
,
'none'
)
.
text
(
'Filter by:'
);
keys
.
forEach
((
key
,
i
)
=>
{
...
...
@@ -95,6 +96,7 @@ export class StackedBarChart extends Chart {
legendItem
.
append
(
'text'
)
.
attr
(
'x'
,
25
).
attr
(
'y'
,
15
)
.
style
(
'user-select'
,
'none'
)
.
text
(
key
);
});
...
...
@@ -164,17 +166,21 @@ export class StackedBarChart extends Chart {
.
attr
(
'y'
,
vis
.
height
)
.
attr
(
'height'
,
0
)
.
on
(
'mouseover'
,
function
(
event
:
any
,
d
:
any
)
{
vis
.
tooltip
.
transition
().
duration
(
200
).
style
(
'opacity'
,
.
9
);
vis
.
tooltip
.
style
(
'opacity'
,
.
9
);
vis
.
tooltip
.
html
(
`
${
d
.
data
.
id
}
<br>
${
d
[
1
]
-
d
[
0
]}
`
)
.
style
(
'left'
,
(
event
.
pageX
-
20
)
+
'px'
)
.
style
(
'top'
,
(
event
.
pageY
-
60
)
+
'px'
);
// Highlight the hovered stack and less opacity for the others
allLayers
.
selectAll
(
'rect'
).
filter
((
di
:
any
)
=>
di
!==
d
).
style
(
'opacity'
,
0.3
);
})
.
on
(
'mousemove'
,
function
(
event
:
any
)
{
vis
.
tooltip
.
style
(
'left'
,
(
event
.
pageX
-
20
)
+
'px'
)
.
style
(
'top'
,
(
event
.
pageY
-
60
)
+
'px'
);
})
.
on
(
'mouseout'
,
function
()
{
vis
.
tooltip
.
transition
().
duration
(
200
).
style
(
'opacity'
,
0
);
vis
.
tooltip
.
style
(
'opacity'
,
0
);
vis
.
chart
.
selectAll
(
'rect'
).
style
(
'opacity'
,
1
);
});
enterRects
.
merge
(
rects
)
...
...
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