2012-02-08 42 views
2

我使用高分散散点图。我想给点选择一个点发光效果。所以我使用chart.renderer.rect()方法创建一个SVG元素并将其添加到选定点后面。但我没有得到所选点的xy位置。请帮帮我。Highcharts javascript

下面是我正在使用的代码。

chart.renderer.rect(1, 1, 30, 30, 5) 
.attr({ 
     'stroke-width': 2, 
     stroke: 'red', 
     fill: 'yellow', 
     zIndex: 3, 
     translateX: 220, 
     translateY: 265 
}) 
.add(); 

在此先感谢..!

+0

请出示你的代码的其余部分。 – Blowsie 2012-02-08 11:08:47

回答

1

变换不attr对象部分看这里...... http://www.highcharts.com/ref/#element

attr Object hash : Element Since 2.0 
Apply attributes to the SVG/VML elements. These attributes for the most parts correspond to SVG, but some are specific to Highcharts, like zIndex and rotation for text. 

Most important available attributes: 

d 
end 
fill 
height 
r 
rotation 
start 
stroke 
stroke-width 
style 
text 
translateX 
translateY 
visibility 
width 
x 
y 
zIndex 
+0

我试着用translateX,translateY。它显示矩形。但是这个职位并不在适当的地方。 point.x和point.y是图形点。但我需要一个容器中的某个点的xy位置 – user1196935 2012-02-08 11:39:10

+0

我建议您将代码放在jsfiddle上,以便人们可以看到其余的代码并尝试修复它 – Blowsie 2012-02-08 12:28:38

3

请看下面的例子。 http://jsfiddle.net/cfKzS/7/ 如果你想要图表的x和y位置,你可以访问为this.x和this.y. 或者,如果你想以像素为单位的位置,你可以使用这样的事情:

plotOptions: { 
    series: { 
     allowPointSelect: true, 
     point: { 
      events: { 
       select: function(e) { 
        $report.html('chart x position: ' + e.target.plotX + '<br>' + 'chart y position: ' + e.target.plotY); 
       } 
      } 
     } 
    } 
}