2017-04-22 18 views
0

私はanuglar-nvd3を使用しており、APIに関するドキュメントは見つかりません。私が今直面している問題は、xAxisとyAxisに最大値&の最小値を設定する方法です。言い換えれば軸上に最小値と最大値を設定する

に関係なくデータの、軸が-1の最小値を持っているでしょうし、1

Plunkerの最大:http://plnkr.co/edit/LKt3UJe5PnJOf8uQEwxr?p=preview

コード:

var app = angular.module('plunker', ['nvd3']); 

app.controller('MainCtrl', function($scope) { 
$scope.options = { 
      chart: { 
       type: 'scatterChart', 
       height: 450, 
       color: d3.scale.category10().range(), 
       scatter: { 
        onlyCircles: false 
       }, 
       showDistX: true, 
       showDistY: true, 
       tooltipContent: function(key) { 
        return '<h3>' + key + '</h3>'; 
       }, 
       duration: 350, 
       xAxis: { 
        scale: [0,5], 
        axisLabel: 'X Axis', 
        tickFormat: function(d){ 
         return d3.format('.02f')(d); 
        } 
       }, 
       yAxis: { 
        axisLabel: 'Y Axis', 
        tickFormat: function(d){ 
         return d3.format('.02f')(d); 
        }, 
        axisLabelDistance: -5 
       }, 
       zoom: { 
        //NOTE: All attributes below are optional 
        enabled: false, 
        scaleExtent: [1, 10], 
        useFixedDomain: false, 
        useNiceScale: false, 
        horizontalOff: false, 
        verticalOff: false, 
        unzoomEventType: 'dblclick.zoom' 
       }, 
       margin: { 
        top: 100, 
        right: 100, 
        left: 100, 
        bottom: 100 
       } 
      } 
     }; 

     $scope.data = [ 
     { 
      "key":"static", 
      "color":"#fff", 
      "values":[ 
      { 
       "x":-1, 
       "y":-1, 
       "size":0.0000001, 
       "shape":"circle", 
       "series":0 
      }, 
      { 
       "x":1, 
       "y":1, 
       "size":0.0000001, 
       "shape":"circle", 
       "series":0 
      } 
      ] 
     }, 
     { 
      "key":"Group 0", 
      "color":"#1f77b4", 
      "values":[ 
      { 
       "x":-0.5, 
       "y":-0.5, 
       "size":0.5, 
       "shape":"circle", 
       "series":0 
      } 
      ] 
     }, 
     { 
      "key":"Group 1", 
      "color":"#ff7f0e", 
      "values":[ 
      { 
       "x":-0.5, 
       "y":0.5, 
       "size":0.5, 
       "shape":"circle", 
       "series":0 
      } 
      ] 
     }, 
     { 
      "key":"Group 2", 
      "color":"#2ca02c", 
      "values":[ 
      { 
       "x":0.5, 
       "y":-0.5, 
       "size":0.5, 
       "shape":"circle", 
       "series":0 
      } 
      ] 
     }, 
     { 
      "key":"Group 3", 
      "color":"#d62728", 
      "values":[ 
      { 
       "x":0.5, 
       "y":0.5, 
       "size":0.5, 
       "shape":"circle", 
       "series":0 
      } 
      ] 
     } 
    ]; 

}); 

答えて

0

は、あなたが試してみました

forceY: [-1, 1], 
forceX: [-1, 1], 
+0

これは感謝しました。私が従うことができるオンラインの文書はありますか? –

+0

NVD3のドキュメントをご覧ください。 https://nvd3-community.github.io/nvd3/examples/documentation.html Angular NVD3は、関数呼び出しを設定オプションに変換します。 – jeznag

関連する問題