2015-02-24 38 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(); 

        }