jquery flot和周数 [英] Jquery flot and week numbers
本文介绍了jquery flot和周数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我制作了一个页面,按周数绘制平均降雪量。现在我们进入了2010年,第1周我的图形在x轴(年周)上延伸了间隔。
我想要的是x轴上的周数(51,52,1,2等)和固定的间隔宽度。
任何人都知道如何做到这一点?
I made a page to plot average snowdepth by week number. Now that we entered 2010, week 1 my graph stretches the interval on the x-axis (yearweek). What I want is the weeknumber on the x-axis (51,52,1,2 etc), and a fixed intervalwidth. Anyone know how to do that?
<script id="source" language="javascript" type="text/javascript">
$(function () {
var d1 = [
[201001,118],[200952,112],[200951,102],[200950,97],[200949,93],
[200948,41],[200947,10],[200947,0]];
var d2 = [
[201001,33],[200952,31],[200951,31],[200950,25],[200949,23],
[200948,12],[200947,0],[200947,0]];
$.plot($("#placeholder"),
[{data:d1,lines:{show: true},
points:{show: true},label:"Mountain"},
{data:d2,lines:{show: true},points:{show: true},label:"Valley"}],
{xaxis: {tickSize:1, tickDecimals:0 }}
);
});
</script>
推荐答案
您可以定义一组'ticks' x轴,并映射你的星期数量在那里
you could define a set of 'ticks' for the x-axis, and map your week numbers there
{xaxis:
{
ticks: [[201001,'1'],[200952,'52'],[200951,'51'],....]
tickSize:1,
tickDecimals:0
}
}
<div id="placeholder" style="width:600px;height:300px;"></div>
<script id="source" language="javascript" type="text/javascript">
$(function () {
var d1 = [
[200952,112],[200951,102],[200950,97],[200949,93],[200948,41],[200947,10],[200946,0]];
var d2 = [
[200952,31],[200951,31],[200950,25],[200949,23],[200948,12],[200947,0],[200946,0]];
$.plot($("#placeholder"),
[{data:d1,lines:{show: true},
points:{show: true},label:"Mountain"},
{data:d2,lines:{show: true},points:{show: true},label:"Valley"}],
{xaxis: {
ticks: [[200952,'52'],[200951,'51'],[200950,'50'],[200949,'49'],[200948,'48'],[200947,'47'],[200946,'46']],
tickSize:1, tickDecimals:1 }}
);
});
</script>
看起来'200947'在您的数据集中是两次。
It seems '200947' is in your data set twice.
这篇关于jquery flot和周数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文