Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
meshviewer
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
infrastruktur
meshviewer
Commits
e9bf073e
Commit
e9bf073e
authored
Jun 19, 2016
by
Xaver Maierhofer
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Read canvas font from css
Easier to adjust
parent
83f457fb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/forcegraph.js
+5
-2
5 additions, 2 deletions
lib/forcegraph.js
lib/map/labelslayer.js
+3
-3
3 additions, 3 deletions
lib/map/labelslayer.js
scss/modules/_forcegraph.scss
+1
-0
1 addition, 0 deletions
scss/modules/_forcegraph.scss
scss/modules/_variables.scss
+1
-1
1 addition, 1 deletion
scss/modules/_variables.scss
with
10 additions
and
6 deletions
lib/forcegraph.js
+
5
−
2
View file @
e9bf073e
...
@@ -12,6 +12,7 @@ define(["d3", "helper"], function (d3, helper) {
...
@@ -12,6 +12,7 @@ define(["d3", "helper"], function (d3, helper) {
var
zoomBehavior
;
var
zoomBehavior
;
var
force
;
var
force
;
var
el
;
var
el
;
var
font
;
var
doAnimation
=
false
;
var
doAnimation
=
false
;
var
intNodes
=
[];
var
intNodes
=
[];
var
intLinks
=
[];
var
intLinks
=
[];
...
@@ -591,6 +592,8 @@ define(["d3", "helper"], function (d3, helper) {
...
@@ -591,6 +592,8 @@ define(["d3", "helper"], function (d3, helper) {
el
=
document
.
createElement
(
"
div
"
);
el
=
document
.
createElement
(
"
div
"
);
el
.
classList
.
add
(
"
graph
"
);
el
.
classList
.
add
(
"
graph
"
);
font
=
window
.
getComputedStyle
(
el
).
fontSize
+
"
"
+
window
.
getComputedStyle
(
el
).
fontFamily
;
zoomBehavior
=
d3
.
behavior
.
zoom
()
zoomBehavior
=
d3
.
behavior
.
zoom
()
.
scaleExtent
([
1
/
3
,
3
])
.
scaleExtent
([
1
/
3
,
3
])
.
on
(
"
zoom
"
,
onPanZoom
)
.
on
(
"
zoom
"
,
onPanZoom
)
...
@@ -696,12 +699,12 @@ define(["d3", "helper"], function (d3, helper) {
...
@@ -696,12 +699,12 @@ define(["d3", "helper"], function (d3, helper) {
var
buffer
=
document
.
createElement
(
"
canvas
"
);
var
buffer
=
document
.
createElement
(
"
canvas
"
);
var
r
=
window
.
devicePixelRatio
;
var
r
=
window
.
devicePixelRatio
;
var
bctx
=
buffer
.
getContext
(
"
2d
"
);
var
bctx
=
buffer
.
getContext
(
"
2d
"
);
bctx
.
font
=
"
11px Assistant, sans-serif
"
;
bctx
.
font
=
font
;
var
width
=
bctx
.
measureText
(
name
).
width
;
var
width
=
bctx
.
measureText
(
name
).
width
;
var
scale
=
zoomBehavior
.
scaleExtent
()[
1
]
*
r
;
var
scale
=
zoomBehavior
.
scaleExtent
()[
1
]
*
r
;
buffer
.
width
=
(
width
+
2
*
lineWidth
)
*
scale
;
buffer
.
width
=
(
width
+
2
*
lineWidth
)
*
scale
;
buffer
.
height
=
(
16
+
2
*
lineWidth
)
*
scale
;
buffer
.
height
=
(
16
+
2
*
lineWidth
)
*
scale
;
bctx
.
font
=
"
11px Assistant, sans-serif
"
;
bctx
.
font
=
font
;
bctx
.
scale
(
scale
,
scale
);
bctx
.
scale
(
scale
,
scale
);
bctx
.
textBaseline
=
"
middle
"
;
bctx
.
textBaseline
=
"
middle
"
;
bctx
.
textAlign
=
"
center
"
;
bctx
.
textAlign
=
"
center
"
;
...
...
This diff is collapsed.
Click to expand it.
lib/map/labelslayer.js
+
3
−
3
View file @
e9bf073e
...
@@ -11,7 +11,7 @@ define(["leaflet", "rbush"],
...
@@ -11,7 +11,7 @@ define(["leaflet", "rbush"],
[
"
center
"
,
"
ideographic
"
,
2
/
8
],
[
"
center
"
,
"
ideographic
"
,
2
/
8
],
[
"
right
"
,
"
ideographic
"
,
3
/
8
]];
[
"
right
"
,
"
ideographic
"
,
3
/
8
]];
var
fontFamily
=
"
Assistant, sans-serif
"
;
var
fontFamily
=
window
.
getComputedStyle
(
document
.
querySelector
(
'
body
'
)).
fontFamily
;
var
nodeRadius
=
4
;
var
nodeRadius
=
4
;
var
ctx
=
document
.
createElement
(
"
canvas
"
).
getContext
(
"
2d
"
);
var
ctx
=
document
.
createElement
(
"
canvas
"
).
getContext
(
"
2d
"
);
...
@@ -99,7 +99,7 @@ define(["leaflet", "rbush"],
...
@@ -99,7 +99,7 @@ define(["leaflet", "rbush"],
// - label (string)
// - label (string)
// - color (string)
// - color (string)
var
labelsOnline
=
d
.
online
.
map
(
prepareLabel
(
"
rgba(0, 0, 0, 0.9)
"
,
1
0
,
8
,
true
,
13
));
var
labelsOnline
=
d
.
online
.
map
(
prepareLabel
(
"
rgba(0, 0, 0, 0.9)
"
,
1
1
,
8
,
true
,
13
));
var
labelsOffline
=
d
.
offline
.
map
(
prepareLabel
(
"
rgba(212, 62, 42, 0.9)
"
,
9
,
5
,
false
,
16
));
var
labelsOffline
=
d
.
offline
.
map
(
prepareLabel
(
"
rgba(212, 62, 42, 0.9)
"
,
9
,
5
,
false
,
16
));
var
labelsNew
=
d
.
new
.
map
(
prepareLabel
(
"
rgba(48, 99, 20, 0.9)
"
,
11
,
8
,
true
,
0
));
var
labelsNew
=
d
.
new
.
map
(
prepareLabel
(
"
rgba(48, 99, 20, 0.9)
"
,
11
,
8
,
true
,
0
));
var
labelsLost
=
d
.
lost
.
map
(
prepareLabel
(
"
rgba(212, 62, 42, 0.9)
"
,
11
,
8
,
true
,
0
));
var
labelsLost
=
d
.
lost
.
map
(
prepareLabel
(
"
rgba(212, 62, 42, 0.9)
"
,
11
,
8
,
true
,
0
));
...
@@ -216,7 +216,7 @@ define(["leaflet", "rbush"],
...
@@ -216,7 +216,7 @@ define(["leaflet", "rbush"],
var
ctx
=
canvas
.
getContext
(
"
2d
"
);
var
ctx
=
canvas
.
getContext
(
"
2d
"
);
ctx
.
lineWidth
=
5
;
ctx
.
lineWidth
=
5
;
ctx
.
strokeStyle
=
"
rgba(255, 255, 255, 0.
8
)
"
;
ctx
.
strokeStyle
=
"
rgba(255, 255, 255, 0.
7
)
"
;
ctx
.
miterLimit
=
2
;
ctx
.
miterLimit
=
2
;
function
drawLabel
(
d
)
{
function
drawLabel
(
d
)
{
...
...
This diff is collapsed.
Click to expand it.
scss/modules/_forcegraph.scss
+
1
−
0
View file @
e9bf073e
.graph
{
.graph
{
background
:
$color-gray-dark
;
background
:
$color-gray-dark
;
font
:
$font-size-small
$font-family
;
height
:
100%
;
height
:
100%
;
width
:
100%
;
width
:
100%
;
...
...
This diff is collapsed.
Click to expand it.
scss/modules/_variables.scss
+
1
−
1
View file @
e9bf073e
...
@@ -15,7 +15,7 @@ $font-family: Assistant, sans-serif !default;
...
@@ -15,7 +15,7 @@ $font-family: Assistant, sans-serif !default;
$font-family-icons
:
ionicons
!
default
;
$font-family-icons
:
ionicons
!
default
;
$font-family-monospace
:
monospace
!
default
;
$font-family-monospace
:
monospace
!
default
;
$font-size
:
15px
!
default
;
$font-size
:
15px
!
default
;
$font-size-small
:
$font-size
/
1
.4
!
default
;
$font-size-small
:
11px
!
default
;
$button-font-size
:
1
.6rem
!
default
;
$button-font-size
:
1
.6rem
!
default
;
$button-distance
:
16px
!
default
;
$button-distance
:
16px
!
default
;
...
...
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