2017-03-02 31 views
0

私はc3.jsグラフを実際より小さくしたいと思っています。私は幅で演奏しましたが、それが大きければ大きい値を切り捨てます。c3.jsで棒グラフのサイズを変更するには

赤色のグラフは620pxです。フェード/カットオフなしですべての値が表示される最初のグラフのサイズにしたい。軸パディングの値を設定

enter image description here

var chart = c3 
      .generate({ 
       bindto : "#topSources", 
       size : { 
        height : 180, 
        width : 620 
       }, 
       bar : { 
        width : 16 
       }, 
       padding : { 
        right : 230, 
        top : 50 
       }, 
       color : { 
        pattern : [ '#008000', '#008000', '#008000', '#008000', 
          '#008000' ] 
       }, 
       data : { 
        columns : [ [ 'Throughput', data.columns[0][1], 
          data.columns[0][2], data.columns[0][3], 
          data.columns[0][4], data.columns[0][5] ] ], 
        type : 'bar', 
        labels : { 
         format : { 
          Throughput : d3.format('$'), 

         } 
        }, 

        color : function(inColor, data) { 
         var colors = [ '#008000', '#008000', '#008000', 
           '#008000', '#008000' ]; 
         if (data.index !== undefined) { 
          return colors[data.index]; 
         } 

         return inColor; 
        } 
       }, 
       axis : { 
        rotated : true, 
        x : { 
         type : 'category', 
         show : false, 
        }, 
        y : { 
         show : false 
        } 
       }, 
       tooltip : { 
        grouped : false 
       }, 
       legend : { 
        show : false 
       } 
      }); 

答えて

1

(それが回転棒グラフこの場合、Y軸の底だから)。 80pxでラベルの長さのほとんどがカバーされます。フォントサイズなどを変更すると、別のものにする必要があります。

axis : { 
     ... 
     y : { 
     show : false, 
     padding: { // use these 3 lines 
      bottom: 80, 
     }, 
     } 
}, 
+0

何もしませんでした。 – AppSensei

+0

私のために働く - > http://jsfiddle.net/60zvcfng/1/ – mgraham

+0

正の数で試してください。 – AppSensei

関連する問題