[英]How to center text vertically in a custom highcharts button
I am using Highcharts.js and the exporting module to add a custom text button on top of my chart. 我正在使用Highcharts.js和导出模块在图表上方添加自定义文本按钮。 I'm having troubles centring the text inside the custom button vertically.
我在将文本垂直置于“自定义”按钮内部时遇到麻烦。 How it looks:
外观:
Instead, "embed chart" text needs to look like the adjacent date picker. 相反,“嵌入图表”文本需要看起来像相邻的日期选择器。
My code: 我的代码:
exporting: {
buttons: {
contextButton: {
enabled: false
},
customButton: {
x: -1,
y: 30,
_titleKey: "embed",
onclick: createChart,
text: "embed chart",
theme: {
'stroke-width': 1,
height: 8,
align: 'center',
stroke: 'silver',
r: 0
}
}
}
}
jsFiddle: http://jsfiddle.net/F8MjD/ jsFiddle: http : //jsfiddle.net/F8MjD/
Any suggestions on how to change it? 关于如何更改它的任何建议?
Updated based on online demo: 根据在线演示更新:
The generated code: 生成的代码:
<text x="5" y="18" style="font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:black;fill:black;" zIndex="1">
<tspan x="5">embed chart</tspan>
</text>
y="18" should be y="13" y =“ 18”应该为y =“ 13”
Total overview 总概述
<g class="highcharts-button" top="-10px" useHtml="true" style="cursor:default;" stroke-linecap="round" transform="translate(710,40)">
<title/>
<rect rx="0" ry="0" fill="white" x="0.5" y="0.5" width="83" height="18" stroke="silver" stroke-width="1"/>
<text x="5" y="13" style="font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:black;fill:black;" zIndex="1">
<tspan x="5">embed chart</tspan>
</text>
</g>
Now the question is which setup do you need to use with highcharts to change that. 现在的问题是,您需要在highcharts中使用哪种设置来更改它。
您可以将padding设置为2值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.