如果有更多数据,则绘制(时间数据),x轴 - 消失标签

时间:2012-06-14 11:13:20

标签: javascript charts flot

我的图表看起来像这样,我喜欢它(xaxis反过来:2月3日,2月4日,2月5日等):

CHART OK

但是当我添加更多时间数据时,每隔一个月就会消失: (没有更多的数据,每个月都适合!但它已经消失了......)

CHART WRONG

我希望每个月都像第一张图片一样展示.. 我无法扩大我的占位符:

<div id="placeholder1" style="width: 700px; height: 300px;"></div>

(必须有700px)

我的代码:

var data = [

    [1328223600000, 5],
    [1328310000000, 15],
    [1328396400000, 30],
    [1328482800000, 17],
    [1328655600000, 7],
    [1328742000000, 33],
    [1328828400000, 40],
    [1328914800000, 22],
    [1329001200000, 40],
    [1329087600000, 33],
    [1329174000000, 33],

]; 

var ds = new Array();

ds.push({
    data:data,
    bars: {
        show: true, 
        align: "center",
        barWidth: 1000*60*60*24, 
        fill: true,
    },
    color: "#aae0f0",
});


$.plot($("#placeholder1"), ds, {

grid:{ hoverable:true, clickable: true },

xaxis:
{
    mode: "time",
    minTickSize: [1, "day"],

    font: {
         size: 7,
         style: "italic",
         weight: "bold",
         family: "sans-serif",
         variant: "small-caps"
       },

    tickLength: 0,
    alignTicksWithAxis: 1,
},

series:
 {
    //stack: 1, // - not work too
    //bandwidth: { active: true , lineWidth: 8 },
 }

});

提前感谢您的回复。

PS。为什么我的 font:{} 方法也不起作用? :(


//我不是英语母语,所以请原谅我的语法错误。

1 个答案:

答案 0 :(得分:1)

您的字体选项不起作用,因为Flot不支持这些选项;在API docs搜索“xaxis”。您应该在.tickLabel类下的CSS中设置它们。

至于标签消失,你可以通过设置tickSize而不是minTickSize来解决它,但在某个时刻你的标签会重叠并开始变得难看。由于Flot不支持旋转/多行标签,唯一的方法是减少字体大小。