我有一个Flot图表,在x轴刻度标签上显示日期,但是在点之间显示标签。我只想在有值(点)时显示x轴刻度标签。这可能吗?
以下是我的代码:
sin.push([dataToTimestamp('01/03/2017'), 60000]);
sin.push([dataToTimestamp('02/03/2017'), 70000]);
sin.push([dataToTimestamp('03/03/2017'), 50000]);
cos.push([dataToTimestamp('01/03/2017'), 50000]);
cos.push([dataToTimestamp('02/03/2017'), 80000]);
cos.push([dataToTimestamp('03/03/2017'), 70000]);
var line_data1 = {
data: sin,
color: "#3c8dbc"
};
var line_data2 = {
data: cos,
color: "#00c0ef"
};
$.plot("#line-chart", [line_data1, line_data2], {
grid: {
hoverable: true,
borderColor: "#f3f3f3",
borderWidth: 1,
tickColor: "#f3f3f3"
},
series: {
shadowSize: 0,
lines: {
show: true
},
points: {
show: true
}
},
lines: {
fill: false,
color: ["#3c8dbc", "#f56954"]
},
yaxis: {
show: true,
},
xaxis: {
show: true,
mode: "time",
timeformat:"%d/%m/%y",
//timeformat:"%d/%m/%y %H:%M:%S",
//tickSize: [4, 'hour']
}
});
答案 0 :(得分:0)
您可以尝试使用
tickSize: [1, 'day']
xaxis
选项中的或直接用
指定刻度ticks: [dataToTimestamp('01/03/2017'), dataToTimestamp('02/03/2017'), dataToTimestamp('03/03/2017')]
请参阅documentation以获取更多帮助。