Reputation: 2736
I need to create graph with dates on X axis and times on Y axis.
My JS code is:
jQuery(document).ready(function ($) {
var data = [["2013-04-25","00:11.557"],["2013-04-25","00:15.569"],["2013-04-25","00:11.733"],["2013-04-25","00:13.023"],["2014-04-26","00:22.333"]];
var plot1 = $.jqplot('chartdiv', [data], {
title:'Default Date Axis',
axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}},
series:[{lineWidth:4, markerOptions:{style:'square'}}]
});
});
The dates are showing correctly on the X axis, but I don't know how to display the values on Y axis.
How is this done in jqPlot plugin?
Upvotes: 0
Views: 803
Reputation: 153
I figured out the issue here.
The main issue here is y-axis
take only numeric
values like 11.557
, 15.569
, ... and so on.
Also, I need to add extra attribute tickOptions
for x-axis
as:
tickOptions:{formatString:'%Y-%m-%d'}
Here is what I got to work:
jQuery(document).ready(function($){
var data = [["2013-04-25",11.557],["2013-04-25",15.569],["2013-04-25",11.733],["2013-04-25",13.023],["2013-04-26",22.333]];
var plot1 = $.jqplot('chartdiv', [data], {
title: 'Default Date Axis',
axes:{
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
tickOptions:{formatString:'%Y-%m-%d'}
}
},
series: [{ lineWidth: 4, markerOptions: { style:'square' }}]
});
});
Upvotes: 2