我正在更改JS代码中span元素的dy。当我在chrome开发人员工具中更改dy时,它看起来像是正确的格式并带有正确dy值的屏幕截图:
我在js中使用以下代码来创建这种效果:
var myEle = document.getElementById("dynamicsubtitle1");
myEle && myEle.parentNode.removeChild(myEle);
var chart = this,
rend = chart.renderer,
pie = chart.series[0],
left = chart.plotLeft + pie.center[0],
top = pie.center[1] + 20;
if(!rend.getElementById)
var text = rend.text('<span class="pietitle" style="color:#000; vertical-align:top; text-align:center">' + "Total<br>"
+ '<span class="pietitle" style="color:#000; vertical-align:top; text-align:center" position:"relative" dy="1vw">' + "Incidents<br>"
+ '<span class="piedata" dy="2vw" style="color:#000; text-align:center; vertical-align:top; font-weight:bold">' + this.series[0].total, left, top).attr({
'text-anchor': 'middle',
'id': 'dynamicsubtitle1',
'zIndex': 10
}).addClass('customTitle').add();
但是,结果是这样的(屏幕快照中dy默认恢复为15)
我尝试在行高和边距上在CSS中获得相同的效果,但是无论我怎么尝试,这似乎都不适用。任何建议将不胜感激!