diff --git a/nezha-fronted/src/assets/css/components/chart/chart.scss b/nezha-fronted/src/assets/css/components/chart/chart.scss index ad64df03d..eb87dd792 100644 --- a/nezha-fronted/src/assets/css/components/chart/chart.scss +++ b/nezha-fronted/src/assets/css/components/chart/chart.scss @@ -83,6 +83,86 @@ } } } + .chart-header-error{ + position: absolute; + left: 0; + top: -1px; + } + } + .chart-screen-header { + display: flex; + justify-content:space-between; + align-items:center; + padding: 0 10px; + height: 39px; + font-size: 14px; + line-height: 40px; + color: $--color-text-primary; + transition: all 0.2s; + width: 100%; + box-sizing: border-box; + &.chart-header--float { + position: absolute; + width: 100%; + z-index: 100; + box-sizing: border-box; + height: 10px; + opacity: 0; + transition: all linear .2s; + + &:hover { + height: 39px; + opacity: 1; + } + } + .chart-header__title { + max-width: calc(100% - 100px); + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + } + .chart-header__tools { + display: flex; + justify-content: space-between; + align-items: center; + + .chart-header__tool { + margin-left: 20px; + cursor: pointer; + + .tool__icon { + visibility: hidden; + font-size: 14px; + color: $--color-text-primary; + } + .nz-chart-dropdown { + position: absolute; + top: 44px; + right: 0; + left: unset; + transform-origin: center top; + z-index: 1000; + width: 180px; + li { + padding-left: 15px !important; + padding-right: 0 !important; + width: calc(100% - 15px); + text-align: left; + i { + margin-right: 10px; + } + &:hover i { + color: $--color-primary; + } + } + } + } + } + .chart-header-error{ + position: absolute; + left: 0; + top: -1px; + } } .nz-panel-chart { height: 100%; @@ -314,9 +394,19 @@ } } } -.chart-fullscreen { +.chart-fullscreen.nz-dialog { + .el-dialog__header{ + display: none; + } .el-dialog__body { height: 100%; + padding: 0; + } + .panel-chart--fullscreen { + display: flex; + .nz-chart{ + padding: 0 20px 30px 20px; + } } } .chart-stat{ diff --git a/nezha-fronted/src/components/chart/ChartScreenHeader.vue b/nezha-fronted/src/components/chart/ChartScreenHeader.vue new file mode 100644 index 000000000..2eefd202b --- /dev/null +++ b/nezha-fronted/src/components/chart/ChartScreenHeader.vue @@ -0,0 +1,137 @@ + + + diff --git a/nezha-fronted/src/components/chart/chart-list-grid.vue b/nezha-fronted/src/components/chart/chart-list-grid.vue deleted file mode 100644 index e48a667ed..000000000 --- a/nezha-fronted/src/components/chart/chart-list-grid.vue +++ /dev/null @@ -1,2034 +0,0 @@ - - - - - diff --git a/nezha-fronted/src/components/chart/chart-list-group-grid.vue b/nezha-fronted/src/components/chart/chart-list-group-grid.vue deleted file mode 100644 index ba41ba79c..000000000 --- a/nezha-fronted/src/components/chart/chart-list-group-grid.vue +++ /dev/null @@ -1,1745 +0,0 @@ - - - - - - diff --git a/nezha-fronted/src/components/chart/chart-list-group.vue b/nezha-fronted/src/components/chart/chart-list-group.vue deleted file mode 100644 index c9b85584e..000000000 --- a/nezha-fronted/src/components/chart/chart-list-group.vue +++ /dev/null @@ -1,1596 +0,0 @@ - - - - diff --git a/nezha-fronted/src/components/chart/chart/chartGauge.vue b/nezha-fronted/src/components/chart/chart/chartGauge.vue index ae0ea5e71..671741f1a 100644 --- a/nezha-fronted/src/components/chart/chart/chartGauge.vue +++ b/nezha-fronted/src/components/chart/chart/chartGauge.vue @@ -223,7 +223,6 @@ export default { this.chartOption.color || (this.chartOption.color = initColor(20)) this.colorList = this.chartOption.color this.chartInfo.loaded && this.initChart() - console.log(this.isFullscreen , 'isFullscreen') }, beforeDestroy () { this.chartInstances.forEach(item => { diff --git a/nezha-fronted/src/components/chart/chart/chartPie.vue b/nezha-fronted/src/components/chart/chart/chartPie.vue index b4c5cf2c3..ab21fd9a7 100644 --- a/nezha-fronted/src/components/chart/chart/chartPie.vue +++ b/nezha-fronted/src/components/chart/chart/chartPie.vue @@ -78,7 +78,6 @@ export default { }, methods: { initChart (chartOption = this.chartOption) { - console.log(123123,chartOption,this.chartOption) this.legends = [] chartOption.series = this.initPieData(this.chartInfo, chartOption.series[0], this.chartData) // 生成series和legends if (this.isNoData) { @@ -97,7 +96,6 @@ export default { initPieData (chartInfo, seriesTemplate, originalDatas) { let colorIndex = 0 const s = lodash.cloneDeep(seriesTemplate) - console.log(s) s.data = [] originalDatas.forEach((originalData, expressionIndex) => { originalData.forEach((data, dataIndex) => { diff --git a/nezha-fronted/src/components/chart/chart/chartTable.vue b/nezha-fronted/src/components/chart/chart/chartTable.vue index 6cf5016e8..74d709b4c 100644 --- a/nezha-fronted/src/components/chart/chart/chartTable.vue +++ b/nezha-fronted/src/components/chart/chart/chartTable.vue @@ -102,7 +102,6 @@ export default { originalData.forEach((data, dataIndex) => { this.isNoData = false data.$labels = data.metric - console.log(data.values) const value = getMetricTypeValue(data.values, chartInfo.param.statistics || 'last') const showValue = chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(value, null, -1, 2) // const mapping = this.selectTableMapping(value, chartInfo.param.valueMapping) diff --git a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue index 8d12a2899..6509696c6 100644 --- a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue +++ b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue @@ -71,7 +71,7 @@ export default { return } const { minTime, maxTime, minValue, maxValue } = this.getMinMaxFromData(this.chartData) // 此处时间是秒 - chartOption.xAxis.axisLabel.formatter = this.xAxisLabelFormatter(minTime * 1000, maxTime * 1000) // 需转为毫秒 + chartOption.xAxis.axisLabel.formatter = this.xAxisLabelFormatter(minTime, maxTime)// 需转为毫秒 chartOption.tooltip.formatter = this.tooltipFormatter(this.chartInfo.param.stack) chartOption.tooltip.position = this.tooltipPosition chartOption.yAxis.axisLabel.formatter = this.yAxisLabelFormatter(minValue, maxValue) @@ -112,7 +112,9 @@ export default { return { minTime, maxTime, minValue, maxValue } }, xAxisLabelFormatter (minTime, maxTime) { - return function (value, index) { + return function (val, index) { + const value = val * 1000 + console.log(value, minTime, maxTime) let offset = localStorage.getItem('nz-sys-timezone') offset = moment.tz(offset).format('Z') offset = Number.parseInt(offset) @@ -139,6 +141,33 @@ export default { } } }, + xAxisLabelFormatter2 (value, minTime, maxTime) { + console.log(value, minTime, maxTime) + let offset = localStorage.getItem('nz-sys-timezone') + offset = moment.tz(offset).format('Z') + offset = Number.parseInt(offset) + const localOffset = new Date().getTimezoneOffset() * 60 * 1000 * -1 // 默认 一分钟显示时区偏移的结果 + const tData = new Date(value - localOffset + offset * 60 * 60 * 1000) + let hour = tData.getHours() + hour = hour > 9 ? hour : '0' + hour // 加0补充为两位数字 + let minute = tData.getMinutes() + minute = minute > 9 ? minute : '0' + minute // 如果分钟小于10,则在前面加0补充为两位数字 + if (minTime !== null && maxTime !== null) { + const diffSec = (maxTime - minTime) / 1000 + const secOneDay = 24 * 60 * 60// 1天的秒数 + const secOneMonth = secOneDay * 30// 30天的秒数 + if (diffSec <= secOneDay) { // 同一天 + return [hour, minute].join(':') + } else if (diffSec < secOneMonth) { // 大于1天,小于30天 + return [tData.getMonth() + 1, tData.getDate()].join('/') + ' ' + [hour, minute].join(':') + } else { // 大于等于30天 + return [tData.getMonth() + 1, tData.getDate()].join('/') + } + } else { + return [tData.getFullYear(), tData.getMonth() + 1, tData.getDate()].join('/') + '\n' + + [hour, minute].join(':') + } + }, tooltipFormatter (hasTotal) { // 堆叠图需要total数据 const self = this return function (params) { @@ -146,7 +175,6 @@ export default { let sum = 0 params.forEach((item, i) => { if (i === 0) { - console.log(item.data[0]) const value = bus.computeTimezone(item.data[0] * 1000) const tData = new Date(value) str += '
' diff --git a/nezha-fronted/src/components/chart/chartHeader.vue b/nezha-fronted/src/components/chart/chartHeader.vue index 7587c0757..62e01dd38 100644 --- a/nezha-fronted/src/components/chart/chartHeader.vue +++ b/nezha-fronted/src/components/chart/chartHeader.vue @@ -1,6 +1,6 @@