admin管理员组文章数量:1287593
i would like to use the jQPlot and will render an axis as a series of date values - the raw package of jQPlot can be font here:
/
.html
The Problem is this:
a) xaxis don't start at the left side and also it will show values that i don't want to see
b) just the same problem on the right with more numbers that dont need
c) i would like to have all days on the xaxis 1 2 3 4 5 ... not 31 3 6 9 ...
d) is it possible to set a kind of offset to the bottom (just a little bit ...)
Screenshot:
My Code:
$.jqplot('chartdiv', [
[
['2012-08-01', 0],
['2012-08-02', 0],
['2012-08-03', 0],
['2012-08-04', 0],
['2012-08-05', 0],
['2012-08-06', 0],
['2012-08-07', 1],
['2012-08-08', 0],
['2012-08-09', 6],
['2012-08-10', 0],
['2012-08-11', 0],
['2012-08-12', 0],
['2012-08-13', 0],
['2012-08-14', 0],
['2012-08-15', 0],
['2012-08-16', 0],
['2012-08-17', 0],
['2012-08-18', 0],
['2012-08-19', 0],
['2012-08-20', 0],
['2012-08-21', 0],
['2012-08-22', 0],
['2012-08-23', 0],
['2012-08-24', 0],
['2012-08-25', 0],
['2012-08-26', 0],
['2012-08-27', 0],
['2012-08-28', 0],
['2012-08-29', 0],
['2012-08-30', 0],
['2012-08-31', 0]
]
], {
title: 'Downloadstatistik',
axes: {
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {
formatString: '%#d',
tickInterval: '1 month'
},
pad: 1.0
},
yaxis: {
tickOptions: {
formatString: '%.0f'
},
min: 0
}
}
});
i would like to use the jQPlot and will render an axis as a series of date values - the raw package of jQPlot can be font here:
http://www.jqplot./
http://www.jqplot./docs/files/plugins/jqplot-dateAxisRenderer-js.html
The Problem is this:
a) xaxis don't start at the left side and also it will show values that i don't want to see
b) just the same problem on the right with more numbers that dont need
c) i would like to have all days on the xaxis 1 2 3 4 5 ... not 31 3 6 9 ...
d) is it possible to set a kind of offset to the bottom (just a little bit ...)
Screenshot:
My Code:
$.jqplot('chartdiv', [
[
['2012-08-01', 0],
['2012-08-02', 0],
['2012-08-03', 0],
['2012-08-04', 0],
['2012-08-05', 0],
['2012-08-06', 0],
['2012-08-07', 1],
['2012-08-08', 0],
['2012-08-09', 6],
['2012-08-10', 0],
['2012-08-11', 0],
['2012-08-12', 0],
['2012-08-13', 0],
['2012-08-14', 0],
['2012-08-15', 0],
['2012-08-16', 0],
['2012-08-17', 0],
['2012-08-18', 0],
['2012-08-19', 0],
['2012-08-20', 0],
['2012-08-21', 0],
['2012-08-22', 0],
['2012-08-23', 0],
['2012-08-24', 0],
['2012-08-25', 0],
['2012-08-26', 0],
['2012-08-27', 0],
['2012-08-28', 0],
['2012-08-29', 0],
['2012-08-30', 0],
['2012-08-31', 0]
]
], {
title: 'Downloadstatistik',
axes: {
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {
formatString: '%#d',
tickInterval: '1 month'
},
pad: 1.0
},
yaxis: {
tickOptions: {
formatString: '%.0f'
},
min: 0
}
}
});
Share
Improve this question
asked Aug 9, 2012 at 20:45
spotlrspotlr
3195 silver badges15 bronze badges
1 Answer
Reset to default 10To start, you should try to set your tickInterval to "1 day" :)
After this, the trick is to set your xaxis min and max according to first and last values of your dates array.
Here's an example :
var timeline = [[
['2012-08-01', 0], ['2012-08-02', 0], ['2012-08-03', 0],
['2012-08-04', 0], ['2012-08-05', 0], ['2012-08-06', 0],
['2012-08-07', 1], ['2012-08-08', 0], ['2012-08-09', 6],
['2012-08-10', 0], ['2012-08-11', 0], ['2012-08-12', 0],
['2012-08-13', 0], ['2012-08-14', 0], ['2012-08-15', 0],
['2012-08-16', 0], ['2012-08-17', 0], ['2012-08-18', 0],
['2012-08-19', 0], ['2012-08-20', 0], ['2012-08-21', 0],
['2012-08-22', 0], ['2012-08-23', 0], ['2012-08-24', 0],
['2012-08-25', 0], ['2012-08-26', 0], ['2012-08-27', 0],
['2012-08-28', 0], ['2012-08-29', 0], ['2012-08-30', 0],
['2012-08-31', 0]
]];
var plot = $.jqplot('chartdiv', timeline, {
title: 'Downloadstatistik',
axes: {
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
tickOptions: { formatString: '%#d' },
tickInterval: '1 day',
min: timeline[0][0][0],
max: timeline[0][timeline[0].length-1][0]
},
yaxis: {
tickOptions: { formatString: '%.0f' },
min: 0
}
}
});
Also I think no pad is needed.
Edit (new jsFiddle added):
You can test this sample code here : http://jsfiddle/JhHPz/4/
本文标签: javascriptWhy does jQPlot dateAxisRenderer not working correctStack Overflow
版权声明:本文标题:javascript - Why does jQPlot dateAxisRenderer not working correct? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741249531a2365532.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论