简体   繁体   中英

jQplot Date axis chart starting point

I dont seem to be able to get my chart to start on the first date the plot data and finishes on the last one.

    $(document).ready(function(){
  var line1=[['01-Nov-12',18],['02-Nov-12',18],['03-Nov-12',18],['04-Nov-12',18],['05-Nov-12',18],['06-Nov-12',18],['07-Nov-12',18],['08-Nov-12',18],['09-Nov-12',18],['10-Nov-12',18],['12-Nov-12',0],['13-Nov-12',0],['14-Nov-12',0],['15-Nov-12',0],['16-Nov-12',0],['17-Nov-12',0],['18-Nov-12',0],['19-Nov-12',0],['20-Nov-12',0],['21-Nov-12',0],['22-Nov-12',0],['23-Nov-12',0],['24-Nov-12',0]];

  var line2=[['01-Nov-12',20],['02-Nov-12',20],['03-Nov-12',20],['04-Nov-12',20],['05-Nov-12',20],['06-Nov-12',20],['07-Nov-12',20],['08-Nov-12',20],['09-Nov-12',20],['10-Nov-12',20],['12-Nov-12',0],['13-Nov-12',0],['14-Nov-12',0],['15-Nov-12',0],['16-Nov-12',0],['17-Nov-12',0],['18-Nov-12',0],['19-Nov-12',0],['20-Nov-12',0],['21-Nov-12',0],['22-Nov-12',0],['23-Nov-12',0],['24-Nov-12',0]];

  var plot2 = $.jqplot('openCloseChart', [line1, line2], {
    title:'Opened/Closed Complaints Chart',
    axes:{
      xaxis:{
        renderer:$.jqplot.DateAxisRenderer,
          tickOptions:{
            formatString:'%b %#d'
          }
      },
      yaxis:{
        min:0,
        tickOptions:{
          formatString:'%d'
        }
      }
    },
    highlighter: {
      show: true
    },
    cursor: {
      show: false,
      tooltipLocation:'sw'
    },
    legend: {
        show: true,
        location: 'e',
        placement: 'outside',
        labels:['Opened', 'Closed']
    }
  });
});

I have created the following example:

http://jsfiddle.net/tBZbf/5/

Can I get the graph to start on the first data point and finish on the last date dynamically? in this example 1rst of November and finish on the 24th.

  xaxis:{
    min:'01-Nov-12',
    max:'24-Nov-12',
  },

http://jsfiddle.net/QpjXd/

A more complete answer can be found here: Why does jQPlot dateAxisRenderer not working correct?

(It just explains better how to add the hooks).

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