Dug*_*ugu 1 jquery reverse time-series flot
有谁知道如何以逆时间顺序使用 Flot 时间序列,首先显示最新日期?我一直想搜索一个选项,但在 API 中找不到。这是我的代码
var plot = $.plot("#placeholder1", [data], {
series: {
lines: {
show: true,
fill: 0.1
},
points: { show: true,
fill: 0.05 }
},
xaxis:
{
mode: "time",
minTickSize: [1, "day"],
ticks:7
},
grid: {
backgroundColor: { colors: [ "#fff", "#fff" ] },
borderColor: "#ccc",
borderWidth: {
top: 1,
right: 1,
bottom: 1,
left: 1
},
hoverable: true,
clickable: true,
markings: weekendAreas
},
legend: {
labelBoxBorderColor: "#fff",
position: "ne",
margin: [0, 0]
}
});
Run Code Online (Sandbox Code Playgroud)
您可以使用xaxis 变换函数来完成此操作:
xaxis: {
mode: "time",
minTickSize: [1, "day"],
ticks: 7,
transform: function (v) { return -v; }, // run it backwards
inverseTransform: function (v) { return -v; }
},
Run Code Online (Sandbox Code Playgroud)
这是一把小提琴。
运行代码:
xaxis: {
mode: "time",
minTickSize: [1, "day"],
ticks: 7,
transform: function (v) { return -v; }, // run it backwards
inverseTransform: function (v) { return -v; }
},
Run Code Online (Sandbox Code Playgroud)
var data = [
[1384436902000, Math.random() * 100],
[1384523302000, Math.random() * 100],
[1384609702000, Math.random() * 100],
[1384696102000, Math.random() * 100],
[1384782502000, Math.random() * 100],
[1384868902000, Math.random() * 100],
[1384955302000, Math.random() * 100]
];
var plot = $.plot("#placeholder1", [data], {
series: {
lines: {
show: true,
fill: 0.1
},
points: { show: true,
fill: 0.05 }
},
xaxis:
{
mode: "time",
minTickSize: [1, "day"],
ticks: 7,
transform: function (v) { return -v; },
inverseTransform: function (v) { return -v; }
},
grid: {
backgroundColor: { colors: [ "#fff", "#fff" ] },
borderColor: "#ccc",
borderWidth: {
top: 1,
right: 1,
bottom: 1,
left: 1
},
hoverable: true,
clickable: true
},
legend: {
labelBoxBorderColor: "#fff",
position: "ne",
margin: [0, 0]
}
});Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1251 次 |
| 最近记录: |