highcharts类别问题

时间:2011-12-03 02:17:05

标签: javascript highcharts

我正在将Highcharts用于带有mysql记录集的项目。 我有两件事我找不到解决方案:

  1. 值始终为3000到8000,如何在x轴上显示3000,3500,4000等?
  2. 图表允许我放大,我想显示y轴无论缩放级别,有没有办法?
  3. 这是我的代码:

    var SpectrumName = '<?php echo $SpectrumName; ?>';
    var SpectrumDate = '<?php echo $SpectrumDate; ?>';
    var chart;
    $(document).ready(function() {
    chart = new Highcharts.Chart({
       size:[ 400,250 ],
      chart: {
         renderTo: 'container',
         zoomType: 'xy',
         defaultSeriesType: 'line',
         marginRight: 130,
         marginBottom: 50,
    
      },
      title: {
         text: 'AstroSpec Observation of: ' + SpectrumName,
         x: -20 //center
      },
      subtitle: {
         text: 'Acquired on: ' + SpectrumDate,
         x: -20
      },
      xAxis: {
         categories: [<?php echo $x_colf1; ?>],
         labels: {
             formatter: function() {
                 if (this.index % 500) { // even numbers only
                     return this.value;
                 } else {
                     return false;
                 }
             }
         }
    
      },
    
      yAxis: {min: 0,
         title: {
            text: ''
         },
         plotLines: [{
            value: 30,
            width: 3,
            color: '#808080'
         }]
      },
      plotOptions: {
          series: {
              enableMouseTracking: false,
              marker: {
                  enabled: false
              }
          }
      },
    
      legend: {
         layout: 'vertical',
         align: 'right',
         verticalAlign: 'top',
         x: -10,
         y: 100,
         borderWidth: 0
      },
      series: [{
         name: 'R',
         data: [<?php echo $y_axis; ?>]
      }]
     });
    
    
    });
    

1 个答案:

答案 0 :(得分:2)

对于#1,请尝试按以下方式设置mintickInterval

xAxis: {
    min: 3000,
    tickInterval: 500
}

我没有完全满足要求#2。