diff --git a/nezha-fronted/package.json b/nezha-fronted/package.json index 0f55b4013..eae87b470 100644 --- a/nezha-fronted/package.json +++ b/nezha-fronted/package.json @@ -74,6 +74,7 @@ "generate-asset-webpack-plugin": "^0.3.0", "git-revision-webpack-plugin": "^3.0.6", "html-webpack-plugin": "^2.30.1", + "lodash": "^4.17.21", "node-notifier": "^5.1.2", "optimize-css-assets-webpack-plugin": "^3.2.0", "ora": "^1.2.0", diff --git a/nezha-fronted/src/assets/css/components/chart/chart.scss b/nezha-fronted/src/assets/css/components/chart/chart.scss index 54cc63880..e2d0368eb 100644 --- a/nezha-fronted/src/assets/css/components/chart/chart.scss +++ b/nezha-fronted/src/assets/css/components/chart/chart.scss @@ -1,6 +1,8 @@ .panel-chart { border: 1px solid $--chart-box-border-color; height: 100%; + display: flex; + flex-direction: column; .chart-header { display: flex; @@ -68,3 +70,102 @@ } } } +.nz-chart { + height: calc(100% - 39px); + + .nz-chart__component { + display: flex; + height: 100%; + + .chart__canvas { + flex: 1; + } + &.nz-chart__component--bottom { + flex-direction: column; + .legend-container { + width: 100%; + max-height: 80px; + min-height: 25px; + } + } + &.nz-chart__component--right { + flex-direction: row; + } + &.nz-chart__component--left { + flex-direction: row-reverse; + } + &.nz-chart__component--right, &.nz-chart__component--left { + .legend-container { + flex-direction: column; + width: unset; + max-width: 50%; + max-height: unset; + min-height: unset; + } + } + } +} +.legend-container { + display: flex; + flex-wrap: wrap; + overflow: auto; + font-size: 12px; + text-align: left; + line-height: 18px; + padding: 0 10px 3px 10px; + box-sizing: border-box; + + .legend-item { + white-space: nowrap; + margin-right: 10px; + cursor: pointer; + display: inline-block; + line-height: 20px; + } + .legend-item, .legend--table-row { + &.legend-item--inactive, &.row--inactive { + color: $--color-text-secondary; + + .legend-shape { + background-color: $--background-color-1 !important; + } + } + } + + // 表格类型 + .legend--table { + display: table; + width: 100%; + + .legend--table-row { + display: table-row; + width: 100%; + } + .legend--table-row:not(:first-of-type):hover { + background-color: $--background-color-1; + cursor: pointer; + } + .legend--table-row:first-of-type { + color:#33a2e5; + font-weight: bold; + font-size: 12px; + .legend--table-cell:not(:first-of-type) { + cursor: pointer; + } + } + .legend--table-cell:first-of-type { + max-width: 600px; + width: 90%; + } + .legend--table-cell { + display: table-cell; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + word-break: break-all; + padding: 1px 5px; + box-sizing: border-box; + min-width: 50px; + } + } +} diff --git a/nezha-fronted/src/assets/css/components/charts/chart.scss b/nezha-fronted/src/assets/css/components/charts/chart.scss index 27630fe98..30d056d6c 100644 --- a/nezha-fronted/src/assets/css/components/charts/chart.scss +++ b/nezha-fronted/src/assets/css/components/charts/chart.scss @@ -23,7 +23,7 @@ .ft-gr{ color:lightgray; } -.legend-container{ +/*.legend-container{ width: calc(100% - 15px); overflow: auto; max-height:80px; @@ -48,7 +48,7 @@ .legend-container table tr:hover{ background-color: $--background-color-1; -} +}*/ .nz-icon-warning{ color: #e6a23c; } @@ -56,7 +56,7 @@ max-height: 80px; min-height:25px; } -.legend-item{ +/*.legend-item{ text-overflow:ellipsis; white-space:nowrap; margin-right:10px; @@ -65,7 +65,7 @@ display:inline-block; float:left; line-height: 20px; -} +}*/ .nz-chart-dropdown { position: absolute; top: 30px; diff --git a/nezha-fronted/src/components/chart/chart-list-grid.vue b/nezha-fronted/src/components/chart/chart-list-grid.vue index 8473dc663..0cf3cb698 100644 --- a/nezha-fronted/src/components/chart/chart-list-grid.vue +++ b/nezha-fronted/src/components/chart/chart-list-grid.vue @@ -775,7 +775,7 @@ export default { if (!params.panelId) { this.finshGetData = false return - } // 没有panelId不调用接口 + } this.$get('visual/panel/chart?panelId=' + params.panelId + '&groupId=0' + '&pageSize=-1').then(response => { response = chartData console.log(chartData) diff --git a/nezha-fronted/src/components/chart/chart.vue b/nezha-fronted/src/components/chart/chart.vue index efc98c891..10f5a788f 100644 --- a/nezha-fronted/src/components/chart/chart.vue +++ b/nezha-fronted/src/components/chart/chart.vue @@ -1,10 +1,85 @@ diff --git a/nezha-fronted/src/components/chart/chart/chartNoData.vue b/nezha-fronted/src/components/chart/chart/chartNoData.vue new file mode 100644 index 000000000..11763dace --- /dev/null +++ b/nezha-fronted/src/components/chart/chart/chartNoData.vue @@ -0,0 +1,13 @@ +