【问题标题】:angularjs nvd3 multibar chart xAxis tick not showingangularjs nvd3多条形图xAxis刻度未显示
【发布时间】:2016-11-30 07:31:02
【问题描述】:
  1. 我正在使用 angularjs nvd3 多条形图
  2. 图表 xAxis 刻度不显示如下。

  3. 我想显示所有 xAxis 刻度 %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);                                                                                
          }                                                                                                        
       }                                                                                                           
       }                                                                                                               
    };                                                                                                                 

请帮帮我。

【问题讨论】:

    标签: d3.js charts angular-nvd3


    【解决方案1】:

    尝试在图表对象中添加以下优先级

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

    【讨论】:

      猜你喜欢
      • 2016-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多