in shadingsphere-benchmark-ui/src/utils/mixin.js [166:249]
formatData(sourceData) {
const hash = location.hash
const showVersion = hash.split('?showVersion=')[1] || ''
const map = []
const legend = {}
const series = {}
const desc = {}
const xAxis = {}
for (const v in sourceData) {
map.push(v)
if (v !== 'DESC') {
legend[v] = []
series[v] = []
xAxis[v] = []
}
}
for (const m of map) {
if (
Object.prototype.toString.call(sourceData[m]) === '[object Array]'
) {
for (const mm of sourceData[m]) {
legend[m].push(mm.type)
const data = []
for (const mmm of Object.keys(mm.data)) {
if (xAxis[m].length <= mm.data.length && mmm >= xAxis[m].length) {
xAxis[m].push(Number(mmm) + 1)
}
// data.push({
// ...mm.data[mmm],
// value: mm.data[mmm].Throughout,
// Date: moment(new Date(mm.data[mmm].Date)).format('YYYY-MM-DD HH:mm:ss')
// })
}
const len = mm.data.length - 1
if (len) {
for (let i = len; len > 30 ? i >= len - 30 : i >= 0; i--) {
data.unshift({
...mm.data[i],
value: mm.data[i].Throughout,
Date: moment(new Date(mm.data[i].Date)).format('YYYY-MM-DD HH:mm:ss')
})
}
}
// showVersion.includes('3.') show 3.X version
if (showVersion.includes('3.')) {
series[m].push({
name: mm.type,
type: 'line',
data
})
} else {
if (mm.type.includes('3.')) {
continue
}
series[m].push({
name: mm.type,
type: 'line',
data
})
}
}
} else {
for (const k of map) {
if (k !== m) {
desc[k] = {
mysqlVerison: sourceData[m]['mysqlVerison'],
encryptRule: sourceData[m]['encryptRule'],
masterSlaveRule: sourceData[m]['masterSlaveRule'],
shardingRule: sourceData[m]['shardingRule'],
tableDescription: sourceData[m]['tableDescription'],
sqlExample: sourceData[m][k].SqlExample
}
}
}
}
}
this.legend = legend
this.series = series
this.desc = desc
this.xAxis = xAxis
}