NEZ-3121 fix:dashboard chart timeseries Y 轴刻度错误
This commit is contained in:
@@ -169,18 +169,40 @@ export default {
|
||||
delete chartOption.tooltip.position
|
||||
}
|
||||
// 左y轴
|
||||
chartOption.yAxis[0].axisLabel.formatter = this.yAxisLabelFormatter(minValue, maxValue, copies, unit, decimals)
|
||||
|
||||
const leftData = this.chartData.filter(item => !item[0].yAxisIndex)
|
||||
console.log(leftData)
|
||||
const leftInfo = this.getMinMaxFromData(leftData, this.chartInfo.unit) //
|
||||
chartOption.yAxis[0].minInterval = chartDataFormat.Interval(leftInfo.maxValue, leftInfo.copies, leftInfo.unit.type, 'min')
|
||||
chartOption.yAxis[0].maxInterval = chartDataFormat.Interval(leftInfo.maxValue, leftInfo.copies, leftInfo.unit.type, 'max') * Math.ceil(chartOption.series.length / 5)
|
||||
if (this.chartInfo.param.stack) {
|
||||
chartOption.yAxis[0].maxInterval = chartOption.yAxis[0].maxInterval * (Math.ceil(chartOption.series.length / 5) + 1)
|
||||
}
|
||||
if (unit.type === 'Time' || unit.type === 'Date & Time') {
|
||||
delete chartOption.yAxis[0].minInterval
|
||||
delete chartOption.yAxis[0].maxInterval
|
||||
}
|
||||
chartOption.yAxis[0].min = this.chartInfo.param.min ? this.chartInfo.param.min : undefined
|
||||
chartOption.yAxis[0].max = this.chartInfo.param.max ? this.chartInfo.param.max : undefined
|
||||
chartOption.yAxis[0].axisLabel.formatter = this.yAxisLabelFormatter(minValue, maxValue, copies, unit, decimals)
|
||||
|
||||
// 右y轴
|
||||
if (this.chartInfo.param.enable.rightYAxis) {
|
||||
// 如果全都为右y轴数据 则右y轴显示网格
|
||||
const unit = chartDataFormat.getUnit(lodash.get(this, 'chartInfo.param.rightYAxis.unit', 2))
|
||||
const allRight = this.series.every(item => item.yAxisIndex == 1)
|
||||
chartOption.yAxis[1].splitLine.show = allRight
|
||||
|
||||
const unit = chartDataFormat.getUnit(lodash.get(this, 'chartInfo.param.rightYAxis.unit', 2))
|
||||
const rightData = this.chartData.filter(item => item[0].yAxisIndex)
|
||||
console.log(rightData, unit)
|
||||
const rightInfo = this.getMinMaxFromData(rightData, lodash.get(this, 'chartInfo.param.rightYAxis.unit', 2)) //
|
||||
chartOption.yAxis[1].minInterval = chartDataFormat.Interval(rightInfo.maxValue, rightInfo.copies, rightInfo.unit.type, 'min')
|
||||
chartOption.yAxis[1].maxInterval = chartDataFormat.Interval(rightInfo.maxValue, rightInfo.copies, rightInfo.unit.type, 'max') * Math.ceil(chartOption.series.length / 5)
|
||||
if (this.chartInfo.param.stack) {
|
||||
chartOption.yAxis[1].maxInterval = chartOption.yAxis[1].maxInterval * (Math.ceil(chartOption.series.length / 5) + 1)
|
||||
}
|
||||
if (unit.type === 'Time' || unit.type === 'Date & Time') {
|
||||
delete chartOption.yAxis[1].minInterval
|
||||
delete chartOption.yAxis[1].maxInterval
|
||||
}
|
||||
chartOption.yAxis[1].axisLabel.formatter = this.yAxisLabelFormatter(undefined, undefined, undefined, unit, decimals)
|
||||
chartOption.yAxis[1].min = this.chartInfo.param.rightYAxis.min ? this.chartInfo.param.rightYAxis.min : undefined
|
||||
chartOption.yAxis[1].max = this.chartInfo.param.rightYAxis.max ? this.chartInfo.param.rightYAxis.max : undefined
|
||||
|
||||
@@ -369,6 +369,11 @@ function asciiCompute (num, ascii, units, dot = 2) {
|
||||
carry = parseInt(log)
|
||||
num = num / Math.pow(ascii, carry)
|
||||
}
|
||||
// if (num > 255) {
|
||||
// const log = Math.log(num) / Math.log(ascii)
|
||||
// carry = parseInt(log)
|
||||
// num = num / Math.pow(ascii, carry)
|
||||
// }
|
||||
if (Number.isInteger(num)) {
|
||||
return num * SIGN + ' ' + units[carry]
|
||||
} else {
|
||||
@@ -847,6 +852,11 @@ export default {
|
||||
interVal = Math.ceil(interVal) * Math.pow(1024, pow)
|
||||
}
|
||||
interVal = !isNaN(interVal) ? interVal : 1
|
||||
if (interVal >= 1 && interVal <= 512) {
|
||||
interVal = 512
|
||||
} else if (interVal > 512 && interVal <= 1024) {
|
||||
interVal = 1024
|
||||
}
|
||||
return interVal
|
||||
}
|
||||
if (type === 'DataRate' || type === 'Misc') {
|
||||
|
||||
@@ -84,6 +84,7 @@ export default {
|
||||
this.isNoData = true
|
||||
originalDatas.forEach((originalData, expressionIndex) => {
|
||||
originalData.forEach((data, dataIndex) => {
|
||||
console.log(data, 'data')
|
||||
if (colorIndex >= 20 && !this.showAllData) {
|
||||
colorIndex++
|
||||
return
|
||||
@@ -97,6 +98,9 @@ export default {
|
||||
chartInfo.param.rightYAxis && chartInfo.param.rightYAxis.elementNames.forEach(item => {
|
||||
if (data.elements.name == item) {
|
||||
s.yAxisIndex = 1
|
||||
data.yAxisIndex = 1
|
||||
} else {
|
||||
data.yAxisIndex = 0
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user