Skip to content

Commit 75f3a60

Browse files
majin1102majin.nathan
andauthored
[UI] Optimize snapshot charts representation (#4071)
Co-authored-by: majin.nathan <majin.nathan@bytedance.com>
1 parent 063c401 commit 75f3a60

File tree

4 files changed

+97
-18
lines changed

4 files changed

+97
-18
lines changed

amoro-web/src/utils/chart.ts

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function sortLineChartDataByKey(obj: ILineChartOriginalData = {}, sortCallback:
4343
* @param data
4444
* @returns Echarts options
4545
*/
46-
export function generateLineChartOption(titleText: string, data: ILineChartOriginalData) {
46+
export function generateLineChartOption(_titleText: string, data: ILineChartOriginalData) {
4747
if (!data) {
4848
return {}
4949
}
@@ -55,26 +55,30 @@ export function generateLineChartOption(titleText: string, data: ILineChartOrigi
5555
},
5656
yAxis: {
5757
type: 'value',
58+
boundaryGap: [0, '1%'],
59+
splitNumber: 6,
5860
},
5961
xAxis: {
6062
type: 'category',
6163
data: dataKeys.map(d => dateFormat(d)),
64+
axisLabel: {
65+
show: false,
66+
},
6267
axisTick: {
63-
alignWithLabel: true,
64-
interval: 0,
68+
show: false,
69+
},
70+
axisLine: {
71+
show: false,
6572
},
6673
},
6774
grid: {
68-
top: 40,
69-
bottom: 50,
70-
left: '1%',
75+
left: 0,
76+
right: 0,
77+
top: 36,
78+
bottom: 6,
7179
containLabel: true,
7280
},
7381
}
74-
titleText && (option.title = {
75-
left: 'center',
76-
text: titleText,
77-
})
7882
const legendMap: Record<string, number[]> = {}
7983
Object.values(data).forEach((val) => {
8084
const keys = Object.keys(val)
@@ -86,8 +90,22 @@ export function generateLineChartOption(titleText: string, data: ILineChartOrigi
8690
legendMap[tKey].push(val[key])
8791
})
8892
})
89-
option.legend = { top: 'bottom', data: Object.keys(legendMap), lineStyle: { opacity: 0 } }
90-
option.series = Object.keys(legendMap).map(key => ({
93+
const legendKeys = Object.keys(legendMap)
94+
option.legend = {
95+
show: true,
96+
top: 0,
97+
left: 'center',
98+
orient: 'horizontal',
99+
itemWidth: 7,
100+
itemHeight: 7,
101+
icon: 'circle',
102+
itemGap: 6,
103+
textStyle: {
104+
fontSize: 13,
105+
lineHeight: 24,
106+
},
107+
}
108+
option.series = legendKeys.map(key => ({
91109
name: key,
92110
type: 'line',
93111
symbol: 'circle',

amoro-web/src/views/tables/components/Optimizing.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ onMounted(() => {
422422
:deep(.ant-table-thead > tr > th) {
423423
padding: 4px 16px !important;
424424
}
425+
426+
:deep(.ant-table-row-expand-icon) {
427+
border-radius: 0 !important;
428+
}
425429
}
426430
427431
.status-icon {

amoro-web/src/views/tables/components/Selector.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,14 @@ onMounted(() => {
171171
</a-select-option>
172172
</a-select>
173173
</div>
174+
<div class="selector-extra">
175+
<slot name="extra" />
176+
</div>
174177
</div>
175178
</template>
176179

177180
<style lang="less">
178181
.branch-selector {
179-
margin-top: 32px;
180182
display: flex;
181183
align-items: center;
182184
@@ -252,5 +254,11 @@ onMounted(() => {
252254
text-align: center;
253255
color: #102048;
254256
}
257+
258+
.selector-extra {
259+
display: flex;
260+
align-items: center;
261+
padding-left: 18px;
262+
}
255263
}
256264
</style>

amoro-web/src/views/tables/components/Snapshots.vue

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ limitations under the License.
2020
import { onMounted, reactive, ref, shallowReactive } from 'vue'
2121
import { useI18n } from 'vue-i18n'
2222
import { useRoute } from 'vue-router'
23+
import { CaretDownOutlined, CaretRightOutlined } from '@ant-design/icons-vue'
2324
import Selector from './Selector.vue'
2425
import { usePagination } from '@/hooks/usePagination'
2526
import type { BreadcrumbSnapshotItem, IColumns, ILineChartOriginalData, SnapshotItem } from '@/types/common.type'
@@ -61,8 +62,10 @@ const sourceData = reactive({
6162
table: '',
6263
...query,
6364
})
65+
6466
const recordChartOption = ref<ECOption>({})
6567
const fileChartOption = ref<ECOption>({})
68+
const showCharts = ref(false)
6669
const tblRef = ref<string>('')
6770
const operation = ref<string>('')
6871
@@ -185,6 +188,10 @@ function toggleBreadcrumb(record: SnapshotItem) {
185188
}
186189
}
187190
191+
function toggleCharts() {
192+
showCharts.value = !showCharts.value
193+
}
194+
188195
onMounted(() => {
189196
hasBreadcrumb.value = false
190197
})
@@ -193,15 +200,36 @@ onMounted(() => {
193200
<template>
194201
<div class="table-snapshots">
195202
<template v-if="!hasBreadcrumb">
196-
<a-row>
203+
<Selector
204+
:catalog="sourceData.catalog"
205+
:db="sourceData.db"
206+
:table="sourceData.table"
207+
:disabled="loading"
208+
@consumer-change="onConsumerChange"
209+
@ref-change="onRefChange"
210+
>
211+
<template #extra>
212+
<div class="snapshots-charts-header" @click="toggleCharts">
213+
<span class="snapshots-charts-title">Charts</span>
214+
<span class="snapshots-charts-icon">
215+
<CaretRightOutlined v-if="!showCharts" />
216+
<CaretDownOutlined v-else />
217+
</span>
218+
</div>
219+
</template>
220+
</Selector>
221+
<a-row v-if="showCharts" :gutter="32">
197222
<a-col :span="12">
198-
<Chart :loading="loading" :options="recordChartOption" />
223+
<div class="snapshots-chart-wrap">
224+
<Chart height="300px" :loading="loading" :options="recordChartOption" />
225+
</div>
199226
</a-col>
200227
<a-col :span="12">
201-
<Chart :loading="loading" :options="fileChartOption" />
228+
<div class="snapshots-chart-wrap">
229+
<Chart height="300px" :loading="loading" :options="fileChartOption" />
230+
</div>
202231
</a-col>
203232
</a-row>
204-
<Selector :catalog="sourceData.catalog" :db="sourceData.db" :table="sourceData.table" :disabled="loading" @consumer-change="onConsumerChange" @ref-change="onRefChange" />
205233
<a-table
206234
row-key="snapshotId"
207235
:columns="columns"
@@ -281,8 +309,29 @@ onMounted(() => {
281309
padding: 0;
282310
}
283311
312+
:deep(.ant-table-row-expand-icon) {
313+
border-radius: 0 !important;
314+
}
315+
284316
.ant-table-wrapper {
285-
margin-top: 24px;
317+
margin-top: 18px;
318+
}
319+
320+
.snapshots-charts-header {
321+
display: flex;
322+
align-items: center;
323+
cursor: pointer;
324+
}
325+
326+
.snapshots-charts-title {
327+
margin-right: 4px;
328+
}
329+
330+
.snapshots-charts-icon {
331+
font-size: 10px;
332+
color: #999;
333+
display: inline-flex;
334+
align-items: center;
286335
}
287336
}
288337
</style>

0 commit comments

Comments
 (0)