Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vulnerability-indicators
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Water Mission Area
VizLab
vulnerability-indicators
Commits
bab9f5f5
Commit
bab9f5f5
authored
1 year ago
by
Clarke, Aileen
Browse files
Options
Downloads
Patches
Plain Diff
WIP - experimenting with beeswarm
parent
9debe2c0
No related branches found
No related tags found
1 merge request
!11
Restructure site
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/BubbleChart.vue
+6
-6
6 additions, 6 deletions
src/components/BubbleChart.vue
src/components/BubbleChart2.vue
+126
-0
126 additions, 0 deletions
src/components/BubbleChart2.vue
src/views/VisualizationView.vue
+3
-1
3 additions, 1 deletion
src/views/VisualizationView.vue
with
135 additions
and
7 deletions
src/components/BubbleChart.vue
+
6
−
6
View file @
bab9f5f5
...
...
@@ -26,7 +26,11 @@
d
.
evidence_val
=
+
d
.
evidence_val
;
return
d
;
});
}
};
// }
function
createBubbleChart
()
{
// ... SVG setup ...
...
...
@@ -176,7 +180,6 @@
function
handleMouseMove
(
event
,
d
)
{
const
[
x
,
y
]
=
d3
.
pointer
(
event
);
const
containerRect
=
document
.
getElementById
(
'
chart-container
'
).
getBoundingClientRect
();
console
.
log
(
containerRect
);
tooltip
.
html
(
`
${
d
.
determinant
}
`
)
.
style
(
"
left
"
,
(
x
)
+
"
px
"
)
...
...
@@ -193,10 +196,7 @@
d3
.
select
(
this
)
.
style
(
"
opacity
"
,
1
);
}
}
}
</
script
>
...
...
This diff is collapsed.
Click to expand it.
src/components/BubbleChart2.vue
0 → 100644
+
126
−
0
View file @
bab9f5f5
<
template
>
<div
id=
"chart-container"
>
</div>
</
template
>
<
script
setup
>
import
{
onMounted
,
ref
}
from
"
vue
"
;
import
*
as
d3
from
'
d3
'
;
// global variables
const
publicPath
=
import
.
meta
.
env
.
BASE_URL
;
const
data
=
ref
([]);
// load data and then make chart
onMounted
(()
=>
{
loadData
().
then
(()
=>
{
if
(
data
.
value
.
length
>
0
)
{
createBubbleChart
();
}
});
});
async
function
loadData
()
{
data
.
value
=
await
d3
.
csv
(
publicPath
+
'
indicator_uncertainty.csv
'
,
d
=>
{
d
.
level_agreement
=
+
d
.
level_agreement
;
d
.
evidence_val
=
+
d
.
evidence_val
;
return
d
;
});
};
function
createBubbleChart
()
{
const
height
=
400
;
const
width
=
1000
;
let
margin
=
{
top
:
20
,
right
:
20
,
bottom
:
20
,
left
:
20
}
const
categories
=
Array
.
from
(
new
Set
(
data
.
value
.
map
(
d
=>
d
.
dimension
)));
// Unique categories
const
colorScale
=
d3
.
scaleOrdinal
(
d3
.
schemeDark2
)
.
domain
(
categories
)
const
svg
=
d3
.
select
(
"
#chart-container
"
)
.
append
(
'
svg
'
)
.
attr
(
'
width
'
,
width
)
.
attr
(
'
height
'
,
height
);
// set x axis scale based on level of agreement
const
xScale
=
d3
.
scaleLinear
()
.
domain
([
1
,
d3
.
max
(
data
.
value
,
d
=>
d
.
level_agreement
)])
.
range
([
margin
.
left
,
width
-
margin
.
right
]);
// set radius based on evidence value
const
radiusScale
=
d3
.
scaleLinear
()
.
domain
([
d3
.
min
(
data
.
value
,
d
=>
d
.
evidence_val
),
d3
.
max
(
data
.
value
,
d
=>
d
.
evidence_val
)])
.
range
([
10
,
50
]);
// add xAxis g to svg
const
xAxis
=
svg
.
append
(
'
g
'
)
.
attr
(
"
transform
"
,
"
translate(0,
"
+
(
height
-
margin
.
bottom
)
+
"
)
"
)
.
call
(
d3
.
axisBottom
(
xScale
))
// add line that connects bubble to xAxis
// const xLine = svg.append("line")
// .attr("stroke","rgb(96, 126,139)")
// .attr("stroke-dasharray", "1,2");
const
bubbles
=
svg
.
selectAll
(
"
.bubble
"
)
.
data
(
data
.
value
)
.
enter
().
append
(
"
circle
"
)
.
attr
(
"
class
"
,
"
bubble
"
)
.
attr
(
'
r
'
,
d
=>
radiusScale
(
d
.
evidence_val
))
.
style
(
'
fill
'
,
d
=>
colorScale
(
d
.
dimension
));
// run force simulation
const
simulation
=
d3
.
forceSimulation
()
// .force("x", forceX)
// .force("y", forceY)
// .force("collide", forceCollide)
// .force("charge", forceManyBody)
.
nodes
(
data
.
value
)
.
on
(
"
tick
"
,
ticked
)
.
alpha
(.
2
)
.
restart
();
function
ticked
()
{
bubbles
.
attr
(
"
cx
"
,
d
=>
d
.
x
)
.
attr
(
"
cy
"
,
d
=>
d
.
y
);
}
// create tooltip
const
tooltip
=
d3
.
select
(
"
#chart-container
"
)
.
append
(
"
div
"
)
.
attr
(
"
class
"
,
"
tooltip
"
)
.
style
(
"
opacity
"
,
0
);
}
</
script
>
<
style
scoped
lang=
"scss"
>
.bubble
{
stroke
:
black
;
/* Dark outline */
stroke-width
:
2px
;
/* Thicker outline */
fill-opacity
:
0
.8
;
/* Higher fill opacity */
}
#chart-container
{
text-align
:
center
;
position
:
relative
;
}
#chart-container
svg
{
max-width
:
100%
;
max-height
:
100%
;
height
:
auto
;
/* Maintain aspect ratio */
display
:
inline-block
;
}
.chart-text
{
user-select
:
none
;
}
</
style
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/views/VisualizationView.vue
+
3
−
1
View file @
bab9f5f5
...
...
@@ -3,6 +3,7 @@
<VizTitle
/>
<Maps
/>
<Dendrogram
/>
<BeeswarmChart2
/>
<BeeswarmChart
/>
<ReferencesSection
/>
<AuthorshipSection
/>
...
...
@@ -13,7 +14,8 @@
import
VizTitle
from
'
.././components/VizTitle.vue
'
import
Maps
from
'
.././components/Maps.vue
'
import
Dendrogram
from
'
.././components/Dendrogram.vue
'
import
BeeswarmChart
from
'
../components/BubbleChart.vue
'
;
import
BeeswarmChart2
from
'
../components/BubbleChart2.vue
'
;
import
BeeswarmChart
from
'
../components/BubbleChart.vue
'
import
ReferencesSection
from
'
.././components/References.vue
'
import
AuthorshipSection
from
'
.././components/Authorship.vue
'
</
script
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment