2016-11-30 113 views
0
  1. 我使用angularjs nvd3多梳圖表
  2. 圖表x軸刻度不顯示如下圖所示。 enter image description hereangularjs nvd3多梳圖表x軸刻度不顯示

  3. 我想告訴所有的X軸形成打勾%Y /%M /%d%H:%M

這是我的代碼。

this.$scope.options = {                        
    chart: {                          
     type: 'multiBarChart',                      
     height: 450,                         
     margin : {                         
      top: 20,                         
      right: 20,                        
      bottom: 60,                        
      left: 65                         
     },                           

     x: function(d){ return d[0]; },                    
     y: function(d){ return d[1]; },                    

     color: d3.scale.category10().range(),                  
     duration: 300,                        
     stacked: true,                        
     clipEdge: true,                        
     clipVoronoi: false,                       

     xAxis: {                          
      axisLabel: 'Time',                      
      tickFormat: function(d) {                     
      let formedDate = d3.time.format('%Y/%m/%d %H:%M')(new Date(d));          
      return formedDate                      
      },                          
      showMaxMin: false,                      
      staggerLabels: true                      
     },                           

     yAxis: {                          
      axisLabel: 'Data',                      
      axisLabelDistance: -20,                     
      tickFormat: function(d){                     
      return d3.format()(d);                     
      }                           
     }                           
     }                            
    };                             

請幫幫我。

回答

0

嘗試添加以下重點在你的圖表對象

chart = { 
    ... 
    reduceXTicks:false, 
    ... 
    xAxis : { 
     .tickFormat: "%Y/%m/%d %H:%M" 
    } 
}