feat: tank tree svg cards ready

This commit is contained in:
Michael Shabanov committed 2022-07-21 13:20:59 +02:00
1 parent 0d98e81a8f
commit 8c490edcc6
9 files changed
+139 -4

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@@ -27,6 +27,7 @@
<script src="echarts/echarts.js"></script>
<script src="echarts/echarts-interop.js"></script>
<script src="media-queries.js"></script>
<script src="svg-helper.js"></script>
<script>navigator.serviceWorker.register('service-worker.js');</script>
</body>
@@ -0,0 +1,23 @@
var svgHelper = svgHelper || {};
svgHelper.CalculateTextBlockDimensions = function (textParams) {
const svg = `
<svg xmlns="http://www.w3.org/2000/svg">
<text
x="0"
y="0"
text-anchor="start"
alignment-baseline="before-edge"
font-family="${textParams.Font}"
font-size="${textParams.Size}">
${textParams.Text}
</text>
</svg>`;
const el = document.createElement("div");
el.innerHTML = svg;
document.body.appendChild(el);
const svgText = el.querySelector('text').getBBox();
el.remove();
const result = { Height: Math.round(svgText.height), Width: Math.round(svgText.width) };
return result;
};