| author | ymh <ymh.work@gmail.com> |
| Sat, 10 Jun 2017 08:33:03 +0200 | |
| changeset 532 | 1190ea937f2d |
| parent 467 | 762fc0eb4946 |
| permissions | -rw-r--r-- |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
|
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
import Ember from 'ember'; |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
|
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
export default Ember.Service.extend({ |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
|
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
// inspired by http://stackoverflow.com/a/39089679 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
getWidthOfText(txt, fontsize){ |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
// Create dummy span |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
var e = document.createElement('span'); |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
|
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
// set the base font defined in app.scss |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
//e.className = 'base-font'; |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
e.style.fontFamily = 'sans-serif'; |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
// Set font-size |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
e.style.fontSize = fontsize; |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
// Set text |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
e.innerHTML = txt; |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
// Return width |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
e.style.visibility = 'hidden'; |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
|
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
document.body.appendChild(e); |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
let w = e.offsetWidth; |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
document.body.removeChild(e); |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
|
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
return w; |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
} |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
}); |