2015-02-24 35 views

回答

0

您可以使用渲染器在后台添加这样的矩形: http://jsfiddle.net/3Utat/25/

mouseOver: function() { 
     var chart = this.series.chart, 
      r = chart.renderer, 
      shape = this.shapeArgs, // shape args for the points rect element 
      xAxis = this.series.xAxis, 
      yAxis = this.series.yAxis, 
      y = yAxis.toPixels(this.total), // top left y-position of the rect 
      x = this.plotX + chart.plotLeft - shape.width/2, // point position + left offset + half width 
      height = yAxis.toPixels(yAxis.min) - y; // bottom - top 

     if (chart.hoverStack) { 
      chart.hoverStack.destroy(); 
     } 

     chart.hoverStack = r.rect(x, y, shape.width, height).attr({ 
       'stroke-width': 6, //border width 
       'stroke': 'black', //border color 
       'fill': 'transparent' //transparent fill color 
     }).add(); 

    }, 
    mouseOut: function() { 
     if (this.series.chart.hoverStack) { 
      this.series.chart.hoverStack.destroy(); 
      this.series.chart.hoverStack = false; 
     } 
    } 

示例使用的是mouseOvermouseOut事件,但在您的情况下,您可以使用click事件。

+0

Waoo,我雷尔ÿ感谢ü的回答。这真的解决了我的问题。虽然,这将需要一点了解你做了什么。我会问你是否觉得理解困难....再次感谢! – 2015-02-24 15:51:23

+0

我猜测是这样的,这就是为什么答案中的代码有相当的评论;)其余来自官方的API(toPixels,destroy,rect,attr,add等方法)。 – 2015-02-24 15:55:44

+0

@ Pawel ..我还没有尝试..,只是问,这可以为堆叠条形图也做一些调整? – 2015-02-24 15:58:57

0

至于建议的帕维尔,正确的小提琴边境上选择 堆积条形图是: -

http://jsfiddle.net/3Utat/26/

click: function() { 
         var chart = this.series.chart, 
          r = chart.renderer, 
          shape = this.shapeArgs, 
          xAxis = this.series.xAxis, 
          yAxis = this.series.yAxis, 
          y = yAxis.toPixels(this.total), 
          x = this.plotX - shape.width/2, 
          height = Math.abs(yAxis.toPixels(yAxis.min) - y); 

         if (chart.hoverStack) { 
          chart.hoverStack.destroy(); 
         } 

         chart.hoverStack = r.rect(x, chart.plotWidth+chart.plotLeft-y, shape.width, height).attr({ 
          'stroke-width': 6, 
           'stroke': 'black', 
          fill: 'transparent', 
          transform: 'translate(' + (chart.plotWidth+chart.plotLeft) + ' ' + (chart.plotHeight+chart.plotTop) + ') rotate(90) scale(-1,1)' 
         }).add(); 

        }