2016-04-13 3 views
1

カラムを持つスパイダーウェブチャートを作成したいと思います。私はデモを手伝っていて、ポリゴンのグリッドラインとカラムを持つ極座標チャートを作成することができました。しかし、今や列の端は丸みを帯びており、真っ直ぐなポリゴンのグリッド線には追従しません。角を丸めずに列を作成することは可能ですか?私のコードと私jsfiddle以下ハイチャートspiderweb、丸められた辺のないカラム

fiddle

$(function() { 

$('#container').highcharts({ 

    chart: { 
     polar: true 
    }, 

    title: { 
     text: 'Highcharts Polar Chart' 
    }, 

    pane: { 
     startAngle: 0, 
     endAngle: 360 
    }, 

    xAxis: { 
     tickInterval: 45, 
     lineWidth: 0, 
     min: 0, 
     max: 360, 
     labels: { 
      formatter: function() { 
       return this.value + '°'; 
      } 
     } 
    }, 

    yAxis: { 
     gridLineInterpolation: 'polygon', 
        lineWidth: 0, 
     min: 0 
    }, 

    plotOptions: { 
     series: { 
      pointStart: 0, 
      pointInterval: 45 
     }, 
     column: { 
      pointPadding: 0, 
      groupPadding: 0 
     } 
    }, 

    series: [{ 
     type: 'column', 
     name: 'Column', 
     data: [8,1, 6, 5, 4, 3, 2, 1], 
     pointPlacement: 'between' 
    }] 
}); 

})。

答えて

2

デフォルトのオプションはありませんが、カスタムシェイプ(here)とラップ(more about extending HighchartsHighcharts.seriesTypes.column.prototype.translateの機能を定義できます。

問題は、この関数が既にハイチャートでラップされていることです。つまり、ラッパーがthis.xAxis.isRadial = false;に設定されているように注意してください。ハイチャートのコードはより多くのラッパーが実行されません。

例:http://jsfiddle.net/3fdeq741/

// Define a custom symbol path 
    Highcharts.SVGRenderer.prototype.symbols.cutArc = function(x, y, w, h, options) { 
    var start = options.start, 
     radius = w, 
     end = options.end, 
     innerRadius = options.innerR, 
     open = options.open, 
     cosStart = Math.cos(start), 
     sinStart = Math.sin(start), 
     cosEnd = Math.cos(end), 
     sinEnd = Math.sin(end); 

    return [ 
     'M', 
     x + radius * cosStart, 
     y + radius * sinStart, 
     'L', 
     x + radius * cosEnd, 
     y + radius * sinEnd, 
     'L', 
     x + innerRadius * cosEnd, 
     y + innerRadius * sinEnd, 
     'Z' 
    ]; 
    }; 
    if (Highcharts.VMLRenderer) { 
    Highcharts.VMLRenderer.prototype.symbols.cutArc = Highcharts.SVGRenderer.prototype.symbols.cutArc; 
    } 

    (function(H) { 
    H.wrap(H.seriesTypes.column.prototype, 'translate', function(proceed) { 
     //avoid running wrapper from highcharts-more 
     var temp = this.xAxis.isRadial; 
     this.xAxis.isRadial = false; 

     // Run original proceed method 
     proceed.apply(this, [].slice.call(arguments, 1)); 
     this.xAxis.isRadial = temp; 

     //run this instead of highcharts-more wrapper 
     var xAxis = this.xAxis, 
     len = this.yAxis.len, 
     center = xAxis.center, 
     startAngleRad = xAxis.startAngleRad, 
     renderer = this.chart.renderer, 
     start, 
     points, 
     point, 
     i; 

     if (xAxis.isRadial) { 
     points = this.points; 
     i = points.length; 
     while (i--) { 
      point = points[i]; 
      start = point.barX + startAngleRad; 
      point.shapeType = 'path'; 
      point.shapeArgs = { 
      d: renderer.symbols.cutArc(
       center[0], 
       center[1], 
       len - point.plotY, 
       null, { 
       start: start, 
       end: start + point.pointWidth, 
       innerR: len - H.pick(point.yBottom, len) 
       } 
      ) 
      }; 
      // Provide correct plotX, plotY for tooltip 
      this.toXY(point); 
      point.tooltipPos = [point.plotX, point.plotY]; 
      point.ttBelow = point.plotY > center[1]; 
     } 
     } 
    }); 
    }(Highcharts)); 
+0

それはそれは、単純なオプションではありません残念だが、これは素晴らしい作品。あなたの努力に感謝します! – TomDoes

+0

@TomDoesこれは現在ではないが、将来的に機能をリクエストするには、UserVoice http://highcharts.uservoice.com/forums/55896-generalに関する提案を投稿してください。すでに登録されているもの - 最も人気のあるアイデアが実装されます。 –

関連する問題