mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-14 09:00:50 +00:00
update legend
This commit is contained in:
parent
b014432632
commit
da177950c8
@ -51,13 +51,13 @@ export default function useLegendProcess(legend?: LegendOptions) {
|
|||||||
};
|
};
|
||||||
if (legend) {
|
if (legend) {
|
||||||
if (legend.min) {
|
if (legend.min) {
|
||||||
item.min = Math.min(...data[value]);
|
item.min = Math.min(...data[value]).toFixed(2);
|
||||||
if (key === 0) {
|
if (key === 0) {
|
||||||
headers.push({ value: "min", label: "Min" });
|
headers.push({ value: "min", label: "Min" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (legend.max) {
|
if (legend.max) {
|
||||||
item.max = Math.max(...data[value]);
|
item.max = Math.max(...data[value]).toFixed(2);
|
||||||
if (key === 0) {
|
if (key === 0) {
|
||||||
headers.push({ value: "max", label: "Max" });
|
headers.push({ value: "max", label: "Max" });
|
||||||
}
|
}
|
||||||
@ -67,16 +67,18 @@ export default function useLegendProcess(legend?: LegendOptions) {
|
|||||||
prev += next;
|
prev += next;
|
||||||
return prev;
|
return prev;
|
||||||
}, 0);
|
}, 0);
|
||||||
item.mean = total / data[value].length;
|
item.mean = (total / data[value].length).toFixed(2);
|
||||||
if (key === 0) {
|
if (key === 0) {
|
||||||
headers.push({ value: "mean", label: "Mean" });
|
headers.push({ value: "mean", label: "Mean" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (legend.total) {
|
if (legend.total) {
|
||||||
item.total = data[value].reduce((prev: number, next: number) => {
|
item.total = data[value]
|
||||||
|
.reduce((prev: number, next: number) => {
|
||||||
prev += next;
|
prev += next;
|
||||||
return prev;
|
return prev;
|
||||||
}, 0);
|
}, 0)
|
||||||
|
.toFixed(2);
|
||||||
if (key === 0) {
|
if (key === 0) {
|
||||||
headers.push({ value: "total", label: "Total" });
|
headers.push({ value: "total", label: "Total" });
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ const legend = reactive<LegendOptions>({
|
|||||||
mean: false,
|
mean: false,
|
||||||
asTable: false,
|
asTable: false,
|
||||||
toTheRight: false,
|
toTheRight: false,
|
||||||
width: 120,
|
width: 130,
|
||||||
...graph.value.legend,
|
...graph.value.legend,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,26 +14,26 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
:style="`width: ${config.width || '100%'}; max-height:${
|
:style="`width: ${
|
||||||
isRight ? '100%' : 130
|
config.width || (isRight ? '150px' : '100%')
|
||||||
}`"
|
}; max-height:${isRight ? '100%' : 130}`"
|
||||||
v-if="source.length"
|
v-if="tableData.length && config.asTable"
|
||||||
class="legend"
|
|
||||||
>
|
>
|
||||||
<div class="col-item">
|
<div class="col-item">
|
||||||
<span></span>
|
<span class="empty"></span>
|
||||||
<span v-for="h in headers" :key="h.value">{{ h.label }}</span>
|
<span v-for="h in headerRow" :key="h.value">{{ h.label }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-item" v-for="(item, index) in source" :key="index">
|
<div class="col-item" v-for="(item, index) in tableData" :key="index">
|
||||||
<span>
|
<span>
|
||||||
<Icon iconName="circle" :style="`color: ${colors[index]};`" />
|
<Icon iconName="circle" :style="`color: ${colors[index]};`" />
|
||||||
<i style="font-style: normal">{{ item.name }}</i>
|
<i style="font-style: normal">{{ item.name }}</i>
|
||||||
</span>
|
</span>
|
||||||
<span v-for="h in headers" :key="h.value">{{ item[h.value] }}</span>
|
<span v-for="h in headerRow" :key="h.value">{{ item[h.value] }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { computed } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import { LegendOptions } from "@/types/dashboard";
|
import { LegendOptions } from "@/types/dashboard";
|
||||||
import useLegendProcess from "@/hooks/useLegendProcessor";
|
import useLegendProcess from "@/hooks/useLegendProcessor";
|
||||||
@ -49,10 +49,33 @@ const props = defineProps({
|
|||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { aggregations, chartColors, isRight } = useLegendProcess(props.config);
|
|
||||||
const { source, headers } = aggregations(props.data);
|
const tableData = computed(() => {
|
||||||
|
const { aggregations } = useLegendProcess(props.config);
|
||||||
|
return aggregations(props.data).source;
|
||||||
|
});
|
||||||
|
const headerRow = computed(() => {
|
||||||
|
const { aggregations } = useLegendProcess(props.config);
|
||||||
|
return aggregations(props.data).headers;
|
||||||
|
});
|
||||||
|
const isRight = computed(() => useLegendProcess(props.config).isRight);
|
||||||
|
const colors = computed(() => {
|
||||||
const keys = Object.keys(props.data || {}).filter(
|
const keys = Object.keys(props.data || {}).filter(
|
||||||
(i: any) => Array.isArray(props.data[i]) && props.data[i].length
|
(i: any) => Array.isArray(props.data[i]) && props.data[i].length
|
||||||
);
|
);
|
||||||
const colors = chartColors(keys);
|
const { chartColors } = useLegendProcess(props.config);
|
||||||
|
return chartColors(keys);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.col-item {
|
||||||
|
font-size: 12px;
|
||||||
|
width: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
|
||||||
|
span {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user