mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-13 02:17:25 +01:00
Correct negative relative timestamps for node view
This commit is contained in:
parent
1921be661b
commit
6e0c13df89
@ -96,14 +96,28 @@
|
|||||||
: null
|
: null
|
||||||
const plotSeries = [{}]
|
const plotSeries = [{}]
|
||||||
const plotData = [new Array(longestSeries)]
|
const plotData = [new Array(longestSeries)]
|
||||||
for (let i = 0; i < longestSeries; i++) // TODO: Cache/Reuse this array?
|
|
||||||
plotData[0][i] = i * timestep
|
if (forNode === true) {
|
||||||
|
// Negative Timestamp Buildup
|
||||||
|
for (let i = 0; i <= longestSeries; i++) {
|
||||||
|
plotData[0][i] = (longestSeries - i) * timestep * -1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Positive Timestamp Buildup
|
||||||
|
for (let j = 0; j < longestSeries; j++) // TODO: Cache/Reuse this array?
|
||||||
|
plotData[0][j] = j * timestep
|
||||||
|
}
|
||||||
|
|
||||||
let plotBands = undefined
|
let plotBands = undefined
|
||||||
if (useStatsSeries) {
|
if (useStatsSeries) {
|
||||||
plotData.push(statisticsSeries.min)
|
plotData.push(statisticsSeries.min)
|
||||||
plotData.push(statisticsSeries.max)
|
plotData.push(statisticsSeries.max)
|
||||||
plotData.push(statisticsSeries.mean)
|
plotData.push(statisticsSeries.mean)
|
||||||
|
if (forNode === true) { // timestamp 0 with null value for reversed time axis
|
||||||
|
if (plotData[1].length != 0) plotData[1].push(null)
|
||||||
|
if (plotData[2].length != 0) plotData[2].push(null)
|
||||||
|
if (plotData[3].length != 0) plotData[3].push(null)
|
||||||
|
}
|
||||||
plotSeries.push({ scale: 'y', width: lineWidth, stroke: 'red' })
|
plotSeries.push({ scale: 'y', width: lineWidth, stroke: 'red' })
|
||||||
plotSeries.push({ scale: 'y', width: lineWidth, stroke: 'green' })
|
plotSeries.push({ scale: 'y', width: lineWidth, stroke: 'green' })
|
||||||
plotSeries.push({ scale: 'y', width: lineWidth, stroke: 'black' })
|
plotSeries.push({ scale: 'y', width: lineWidth, stroke: 'black' })
|
||||||
@ -114,6 +128,7 @@
|
|||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < series.length; i++) {
|
for (let i = 0; i < series.length; i++) {
|
||||||
plotData.push(series[i].data)
|
plotData.push(series[i].data)
|
||||||
|
if (forNode === true && plotData[1].length != 0) plotData[1].push(null) // timestamp 0 with null value for reversed time axis
|
||||||
plotSeries.push({
|
plotSeries.push({
|
||||||
scale: 'y',
|
scale: 'y',
|
||||||
width: lineWidth,
|
width: lineWidth,
|
||||||
@ -122,6 +137,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// console.log("Input Series: ", metric, series)
|
||||||
|
// console.log("Data: ", plotData)
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
@ -130,14 +149,8 @@
|
|||||||
{
|
{
|
||||||
scale: 'x',
|
scale: 'x',
|
||||||
space: 35,
|
space: 35,
|
||||||
incrs: timeIncrs(timestep, maxX),
|
incrs: timeIncrs(timestep, maxX, forNode),
|
||||||
values: (_, vals) => {
|
values: (_, vals) => vals.map(v => formatTime(v))
|
||||||
if (forNode === true) {
|
|
||||||
return vals.map(v => formatTime(v, forNode)).reverse()
|
|
||||||
} else {
|
|
||||||
return vals.map(v => formatTime(v))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scale: 'y',
|
scale: 'y',
|
||||||
@ -261,19 +274,23 @@
|
|||||||
let h = Math.floor(t / 3600)
|
let h = Math.floor(t / 3600)
|
||||||
let m = Math.floor((t % 3600) / 60)
|
let m = Math.floor((t % 3600) / 60)
|
||||||
if (h == 0)
|
if (h == 0)
|
||||||
return forNode ? `-${m}m` : `${m}m`
|
return `${m}m`
|
||||||
else if (m == 0)
|
else if (m == 0)
|
||||||
return forNode ? `-${h}h` : `${h}h`
|
return `${h}h`
|
||||||
else
|
else
|
||||||
return forNode ? `-${h}:${m}h` : `${h}:${m}h`
|
return `${h}:${m}h`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function timeIncrs(timestep, maxX) {
|
export function timeIncrs(timestep, maxX, forNode) {
|
||||||
let incrs = []
|
if (forNode === true) {
|
||||||
for (let t = timestep; t < maxX; t *= 10)
|
return [60, 300, 900, 1800, 3600, 7200, 14400, 21600] // forNode fixed increments
|
||||||
incrs.push(t, t * 2, t * 3, t * 5)
|
} else {
|
||||||
|
let incrs = []
|
||||||
|
for (let t = timestep; t < maxX; t *= 10)
|
||||||
|
incrs.push(t, t * 2, t * 3, t * 5)
|
||||||
|
|
||||||
return incrs
|
return incrs
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function findThresholds(metricConfig, scope, subCluster) {
|
export function findThresholds(metricConfig, scope, subCluster) {
|
||||||
|
Loading…
Reference in New Issue
Block a user