2014-10-17 62 views
0

在此高图表编码中,我想更改X轴以显示月份和年份(ex-Feb-20014)在这里,我的代码工作。怎么办?我想至少去5年。我的图表是柱形图。请注意,高图表X轴显示月份和年份

<script type="text/javascript"> 
        $(function() { 
     // Set up the chart 
         var chart = new Highcharts.Chart({ 
          chart: { 
           renderTo: 'container', 
           type: 'column', 
           margin: 75, 
           options3d: { 
            enabled: false, 
            alpha: 15, 
            beta: 15, 
            depth: 50, 
            viewDistance: 25 
           } 
          }, 
          title: { 
           text: 'Payment Details' 
          }, 
          plotOptions: { 
           column: { 
            depth: 25 
           } 
          }, 
          series: [{ 
            data: [ 
     <?php 
     for ($i = 0; $i <= 12; $i++) { 
      echo $i. ','; 
     } 
     ?> 

            ] 

           }] 
         }); 

         function showValues() { 
          $('#R0-value').html(chart.options.chart.options3d.alpha); 
          $('#R1-value').html(chart.options.chart.options3d.beta); 
         } 

     // Activate the sliders 
         $('#R0').on('change', function() { 
          chart.options.chart.options3d.alpha = this.value; 
          showValues(); 
          chart.redraw(false); 
         }); 
         $('#R1').on('change', function() { 
          chart.options.chart.options3d.beta = this.value; 
          showValues(); 
          chart.redraw(false); 
         }); 

         showValues(); 
        }); 
       </script> 
+1

http://api.highcharts.com/highcharts#xAxis – 2014-10-17 04:10:30

+1

标签格式 - > HTTP: //api.highcharts.com/highcharts#xAxis.labels.formatter – artm 2014-10-17 04:11:48

回答

2

试试这个:

xAxis: { 
    type: 'datetime',   
    labels: { 
     formatter: function() { 
      return Highcharts.dateFormat('%b-%Y', this.value); 
     } 
    } 
}, 

从文档:

%b - Abbreviated month name, based on the locale(Jan through Dec) 

%Y - Four digit representation for the year(Example: 2038) 
+0

但它也是2010年1月 - 2010年的展示。我想将其定制为jan-2014 – Nadishan 2014-10-17 12:08:45

+0

您能否在小提琴中表达您的问题? – Swetha 2014-10-17 12:10:43

+0

如果您的数据是2010年,其显示2010年,而不是2014年。因此,请将您的数据调整到正确的范围。 – 2014-10-20 10:19:26

相关问题