Created
March 16, 2017 09:40
-
-
Save zpbx/ac462e2a286420a18daec82f1a02b5bd to your computer and use it in GitHub Desktop.
把性能看板中的历史数据输出到控制台
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.body.onclick = function () { | |
const wrapper = document.querySelector('.grafana-tooltip') | |
if (!wrapper) { | |
console.error('no data!') | |
return | |
} | |
const date = wrapper.querySelector('.graph-tooltip-time').innerHTML.split(' ')[0] | |
const valueElements = Array.from(wrapper.querySelectorAll('.graph-tooltip-value')) | |
const values = valueElements.map((item) => { | |
const val = item.innerHTML || '' | |
let [qty, unit] = val.split(' ') | |
if (unit === 's') { | |
qty = qty * 1000 | |
} | |
return Math.round(qty) | |
}) | |
const output = [date, ...values].join(' | ') | |
console.log(output) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment