mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 10:05:24 +00:00
view the values
This commit is contained in:
parent
6cb20aa301
commit
de90ae6d9b
@ -23,6 +23,12 @@ export function useListConfig(config: any, index: number) {
|
||||
const line =
|
||||
config.metricTypes[index] === MetricQueryTypes.ReadMetricsValues &&
|
||||
calculation !== Calculations.Average;
|
||||
const isAvg =
|
||||
config.metricTypes[index] === MetricQueryTypes.ReadMetricsValues &&
|
||||
calculation === Calculations.Average;
|
||||
|
||||
return { isLinear: line };
|
||||
return {
|
||||
isLinear: line,
|
||||
isAvg,
|
||||
};
|
||||
}
|
||||
|
@ -284,7 +284,13 @@ export function usePodsSource(
|
||||
d[name] = aggregation(resp.data[key], c);
|
||||
}
|
||||
if (config.metricTypes[index] === MetricQueryTypes.ReadMetricsValues) {
|
||||
d[name] = calculateExp(resp.data[key].values.values, c);
|
||||
d[name] = {};
|
||||
if (c.calculation === Calculations.Average) {
|
||||
d[name]["avg"] = calculateExp(resp.data[key].values.values, c);
|
||||
}
|
||||
d[name]["values"] = resp.data[key].values.values.map(
|
||||
(val: { value: number }) => aggregation(val.value, c)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@ -338,7 +344,7 @@ function calculateExp(
|
||||
return data;
|
||||
}
|
||||
|
||||
function aggregation(
|
||||
export function aggregation(
|
||||
val: number,
|
||||
config: { calculation: string }
|
||||
): number | string {
|
||||
|
@ -17,8 +17,10 @@ limitations under the License. -->
|
||||
<div
|
||||
v-if="!isNaN(singleVal)"
|
||||
class="chart-card"
|
||||
:class="{ center: config.textAlign === 'center' }"
|
||||
:style="{ fontSize: `${config.fontSize}px`, textAlign: config.textAlign }"
|
||||
:style="{
|
||||
fontSize: `${config.fontSize}px`,
|
||||
justifyContent: config.textAlign || 'center',
|
||||
}"
|
||||
>
|
||||
{{ singleVal.toFixed(2) }}
|
||||
<span v-show="config.showUnit">
|
||||
@ -52,7 +54,6 @@ const { t } = useI18n();
|
||||
const metricConfig = computed(() => props.config.metricConfig || []);
|
||||
const key = computed(() => Object.keys(props.data)[0]);
|
||||
const singleVal = computed(() => Number(props.data[key.value]));
|
||||
console.log(props.data);
|
||||
const unit = computed(
|
||||
() => metricConfig.value[0] && encodeURIComponent(metricConfig.value[0].unit)
|
||||
);
|
||||
@ -60,15 +61,10 @@ const unit = computed(
|
||||
<style lang="scss" scoped>
|
||||
.chart-card {
|
||||
color: #333;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.center {
|
||||
box-sizing: border-box;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-pack: center;
|
||||
-webkit-box-align: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.no-data {
|
||||
|
@ -59,7 +59,7 @@ limitations under the License. -->
|
||||
showXAxis: false,
|
||||
showYAxis: false,
|
||||
smallTips: true,
|
||||
showSymbol: true,
|
||||
showlabels: false,
|
||||
}"
|
||||
/>
|
||||
<Card
|
||||
|
@ -60,7 +60,7 @@ limitations under the License. -->
|
||||
showXAxis: false,
|
||||
showYAxis: false,
|
||||
smallTips: true,
|
||||
showSymbol: true,
|
||||
showlabels: false,
|
||||
}"
|
||||
/>
|
||||
<Card
|
||||
|
@ -65,7 +65,9 @@ limitations under the License. -->
|
||||
<div class="chart">
|
||||
<Line
|
||||
v-if="useListConfig(config, index).isLinear"
|
||||
:data="{ [metric]: scope.row[metric] }"
|
||||
:data="{
|
||||
[metric]: scope.row[metric] && scope.row[metric].values,
|
||||
}"
|
||||
:intervalTime="intervalTime"
|
||||
:config="{
|
||||
showXAxis: false,
|
||||
@ -74,6 +76,35 @@ limitations under the License. -->
|
||||
showlabels: false,
|
||||
}"
|
||||
/>
|
||||
<el-popover
|
||||
v-else-if="useListConfig(config, index).isAvg"
|
||||
placement="left"
|
||||
:width="400"
|
||||
trigger="click"
|
||||
>
|
||||
<template #reference>
|
||||
<Card
|
||||
:data="{
|
||||
[metric]: scope.row[metric] && scope.row[metric].avg,
|
||||
}"
|
||||
:config="{ textAlign: 'left' }"
|
||||
/>
|
||||
</template>
|
||||
<div class="view-line">
|
||||
<Line
|
||||
:data="{
|
||||
[metric]: scope.row[metric] && scope.row[metric].values,
|
||||
}"
|
||||
:intervalTime="intervalTime"
|
||||
:config="{
|
||||
showXAxis: false,
|
||||
showYAxis: false,
|
||||
smallTips: true,
|
||||
showlabels: false,
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
</el-popover>
|
||||
<Card
|
||||
v-else
|
||||
:data="{ [metric]: scope.row[metric] }"
|
||||
@ -241,6 +272,7 @@ async function queryServiceMetrics(currentServices: Service[]) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log(services.value);
|
||||
services.value = currentServices;
|
||||
}
|
||||
function objectSpanMethod(param: any): any {
|
||||
@ -320,10 +352,15 @@ watch(
|
||||
@import "./style.scss";
|
||||
|
||||
.chart {
|
||||
height: 60px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.inputs {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.view-line {
|
||||
width: 300px;
|
||||
height: 200px;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user