我想在我的chart / svg中添加这些元素:
<g
transform="matrix(1.25,0,0,-1.25,175.4,27)">
<path
d="M 0,0 -4.252,-11.338 -4.252,0 0,0 z"
style="fill:#711f1c;fill-opacity:1;fill-rule:nonzero;stroke:none"
/>
</g>
我使用了渲染器(在chart > event > load
中):
window.chart_myid = new Highcharts.Chart({
chart: {
events : {
load : function(){
this.renderer.g("myshape")
.attr({
"transform" : "matrix(1.25,0,0,-1.25,175.4,27)"
})
.add();
this.renderer.path(['M', 0, 0, 'L', -4.252, -11.338, -4.252, 0, 0, 0, 'z'])
.css({
'fill' : '#711f1c',
'fill-opacity' : '1',
'fill-rule' : 'nonzero',
'stroke' : 'none'
})
.add("myshape");
}
}
}
结果是:
<g class="highcharts-myshape"
transform="matrix(1.25,0,0,-1.25,175.4,27)"/>
<path
fill="none"
d="M 0 0 L -4.252 -11.338 -4.252 0 0 0 z"
style="fill:#711f1c;fill-opacity:1;fill-rule:nonzero;stroke:none;"
/>
<path>
元素添加到<g>
元素中?答案 0 :(得分:3)
你需要将g元素而不是其名称传递给add ie。
var g = this.renderer.g("myshape")
.attr({
"transform" : "matrix(1.25,0,0,-1.25,175.4,27)"
})
.add();
this.renderer.path(['M', 0, 0, 'L', -4.252, -11.338, -4.252, 0, 0, 0, 'z'])
.css({
'fill' : '#711f1c',
'fill-opacity' : '1',
'fill-rule' : 'nonzero',
'stroke' : 'none'
})
.add(g);