简体   繁体   中英

how to format jqplot yaxis as integer

How can I format y axis ticks strings to be integer and not decimal. At the moment the tickets are showing with numbers such as 076165412.654666666666 and I would like them to show as 76165412 instead.

  var data = [['2013/02/11',20130211],['2013/02/10',20130210],['2013/02/12',20130212],['2013/02/15',20130215],['2013/02/16',71],['2013/02/17',81],['2013/02/18',71],['2013/02/06',735],['2013/02/19',90]];

  var options = {
    title: 'Monthly statistics for EnrAll',
    autoscale:true,
    axes: {
      xaxis: {
        renderer: $.jqplot.DateAxisRenderer,
        labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
        tickRenderer: $.jqplot.CanvasAxisTickRenderer,
        min:'Feb 01, 2013',
        max:'Feb 20, 2013',
        numberTicks: 15,
        tickOptions: {
          formatString:'%b %#d',
          angle: 15
        }
      },
      yaxis: {
        label: 'Count',    
        min:'0'         
      }
    },
    highlighter: {
      show: true,
      tooltipFadeSpeed: 'fast'
    }
  };

样本图

All I did to fix this one was to change the way the minimum y-axis value is specified.

Currently you have min:'0' , change it to min:0 (ie, a number rather than a string). For further insurance you could set tickOptions and force an integer representation, though I didn't need this myself:

tickOptions: {
    formatString: '%d'
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM