2015-09-14 62 views
0

我使用高图来绘制图形。在x轴上绘制整数值。我需要使用数据数组中的日期时间格式化x轴标签。 this.point.mydate在标签格式化程序中不起作用。使用动态值在高图表中格式化轴标签

xAxis: { 
      tickInterval: 1, 
      min:1, 
      max:30, 
      allowDecimals: false, 
      title: { 
            text: 'Date' 
          }, 
          labels: { 
       formatter: function() { 

         return Highcharts.dateFormat('%b-%d', this.point.mydate); 

       } 
       } 
      }, 
+0

在标签中,您不能访问this.point,只能用于tick对象。请将您的示例重新创建为实时演示,或许[tickPositioner](http://api.highcharts.com/highcharts#xAxis.tickPositioner)将很有用,以点为单位返回滴答。 –

+0

@ SebastianBochan看到我需要显示格式标签,而不是x轴value.I有一个日期数组已经 – James

+0

您可以使用[tickPositions](http://api.highcharts.com/highcharts#xAxis.tickPositions)作为数组xAxis滴答声。 –

回答

0

您已经使用在X轴数据类型日期,它应该是日期时间如下。

xAxis: {   
     type: 'datetime', 
     labels: { 
      formatter: function() { 
       return Highcharts.dateFormat('%a %d %b', this.point.mydate); 
      } 
     } 
    } 
+0

Khoranjiya我使用整数值绘制坐标轴,并希望在日期时间显示坐标轴标记 – James

+0

您希望根据什么基础计算整数值中的日期 –

+0

Khoranjiya函数seriesItem(){var self = this; self.x ='',self .y ='',self.high = 0,self.mydate ='',self.total ='',self.color =''};我在x轴上绘制了self.x,在y轴上绘制了self.y.i在self.mydate中有一个日期值。我想在标签 – James