Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mark-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cylab
mark-web
Commits
3e53f274
Commit
3e53f274
authored
3 years ago
by
Georgi
Browse files
Options
Downloads
Patches
Plain Diff
Added a radar chart vizualisation for specific agents
parent
a413d428
No related branches found
No related tags found
1 merge request
!7
Radar chart
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
resources/views/app/radar.blade.php
+105
-0
105 additions, 0 deletions
resources/views/app/radar.blade.php
with
105 additions
and
0 deletions
resources/views/app/radar.blade.php
0 → 100644
+
105
−
0
View file @
3e53f274
@
extends
(
'layouts.app'
)
@
section
(
'content'
)
<
h1
class
=
"text-center"
>
{{
$label
}}
</
h1
>
<
svg
width
=
"600"
height
=
"600"
></
svg
>
<
script
src
=
"https://cdnjs.cloudflare.com/ajax/libs/d3/7.1.1/d3.min.js"
integrity
=
"sha512-COTaPOlz12cG4fSfcBsxZsjauBAyldqp+8FQUM/dZHm+ts/jR4AFoJhCqxy8K10Jrf3pojfsbq7fAPTb1XaVkg=="
crossorigin
=
"anonymous"
referrerpolicy
=
"no-referrer"
></
script
>
<
script
>
var
url
=
"/app/ranking/{{
$label
}}/json"
;
d3
.
json
(
url
)
.
then
(
data
=>
{
console
.
log
(
data
);
let
radar_data
=
[];
let
features
=
[];
//fill the features with the subject names
var
point
=
{};
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
var
subject
=
data
[
i
]
.
subject
.
name
;
features
.
push
(
subject
);
point
[
subject
]
=
data
[
i
]
.
score
*
10
;
};
radar_data
.
push
(
point
);
console
.
log
(
radar_data
);
let
svg
=
d3
.
select
(
"svg"
),
width
=
+
svg
.
attr
(
"width"
),
height
=
+
svg
.
attr
(
"height"
);
let
radialScale
=
d3
.
scaleLinear
()
.
domain
([
0
,
10
])
.
range
([
0
,
250
]);
let
ticks
=
[
2
,
4
,
6
,
8
,
10
];
//draw grid lines (circles)
ticks
.
forEach
(
t
=>
svg
.
append
(
"circle"
)
.
attr
(
"cx"
,
300
)
.
attr
(
"cy"
,
300
)
.
attr
(
"fill"
,
"none"
)
.
attr
(
"stroke"
,
"gray"
)
.
attr
(
"r"
,
radialScale
(
t
))
);
//draw tick labels
ticks
.
forEach
(
t
=>
svg
.
append
(
"text"
)
.
attr
(
"x"
,
305
)
.
attr
(
"y"
,
300
-
radialScale
(
t
))
.
text
(
t
.
toString
())
);
//draw axis for each feature
function
angleToCoordinate
(
angle
,
value
)
{
let
x
=
Math
.
cos
(
angle
)
*
radialScale
(
value
);
let
y
=
Math
.
sin
(
angle
)
*
radialScale
(
value
);
return
{
"x"
:
300
+
x
,
"y"
:
300
-
y
};
}
for
(
var
i
=
0
;
i
<
features
.
length
;
i
++
)
{
let
ft_name
=
features
[
i
];
let
angle
=
(
Math
.
PI
/
2
)
+
(
2
*
Math
.
PI
*
i
/
features
.
length
);
let
line_coordinate
=
angleToCoordinate
(
angle
,
10
);
let
label_coordinate
=
angleToCoordinate
(
angle
,
10.5
);
svg
.
append
(
"line"
)
.
attr
(
"x1"
,
300
)
.
attr
(
"y1"
,
300
)
.
attr
(
"x2"
,
line_coordinate
.
x
)
.
attr
(
"y2"
,
line_coordinate
.
y
)
.
attr
(
"stroke"
,
"black"
);
svg
.
append
(
"text"
)
.
attr
(
"x"
,
label_coordinate
.
x
)
.
attr
(
"y"
,
label_coordinate
.
y
)
.
text
(
ft_name
);
}
//drawing the line for the spider chart
let
line
=
d3
.
line
()
.
x
(
d
=>
d
.
x
)
.
y
(
d
=>
d
.
y
);
//get coordinates for a data point
function
getPathCoordinates
(
d
)
{
let
coordinates
=
[];
for
(
var
i
=
0
;
i
<
features
.
length
;
i
++
)
{
let
ft_name
=
features
[
i
];
let
angle
=
(
Math
.
PI
/
2
)
+
(
2
*
Math
.
PI
*
i
/
features
.
length
);
coordinates
.
push
(
angleToCoordinate
(
angle
,
d
[
ft_name
]));
}
return
coordinates
;
}
for
(
var
i
=
0
;
i
<
radar_data
.
length
;
i
++
)
{
let
d
=
radar_data
[
i
];
let
color
=
"red"
;
let
coordinates
=
getPathCoordinates
(
d
);
//draw the path element
svg
.
append
(
"path"
)
.
datum
(
coordinates
)
.
attr
(
"d"
,
line
)
.
attr
(
"stroke-width"
,
3
)
.
attr
(
"stroke"
,
color
)
.
attr
(
"fill"
,
color
)
.
attr
(
"stroke-opacity"
,
1
)
.
attr
(
"opacity"
,
0.5
);
}
});
</
script
>
@
endsection
\ No newline at end of file
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