feat: add Avg calculations (#66)

This commit is contained in:
Fine0830
2022-04-14 18:15:28 +08:00
committed by GitHub
parent 69a9c6de13
commit 26db1ec23e
5 changed files with 42 additions and 15 deletions

View File

@@ -263,10 +263,12 @@ export const TextColors: { [key: string]: string } = {
export const CalculationOpts = [
{ label: "Percentage", value: "percentage" },
{ label: "Apdex", value: "apdex" },
{ label: "Avg-preview", value: "average" },
{ label: "Percentage + Avg-preview", value: "percentageAvg" },
{ label: "Apdex + Avg-preview", value: "apdexAvg" },
{ label: "Byte to KB", value: "byteToKB" },
{ label: "Byte to MB", value: "byteToMB" },
{ label: "Byte to GB", value: "byteToGB" },
{ label: "Average", value: "average" },
{
label: "Milliseconds to YYYY-MM-DD HH:mm:ss",
value: "convertMilliseconds",

View File

@@ -23,7 +23,7 @@ limitations under the License. -->
}"
>
{{ singleVal.toFixed(2) }}
<span class="unit" v-show="config.showUnit">
<span class="unit" v-show="config.showUnit && unit">
{{ decodeURIComponent(unit) }}
</span>
</div>
@@ -55,7 +55,9 @@ const metricConfig = computed(() => props.config.metricConfig || []);
const key = computed(() => Object.keys(props.data)[0]);
const singleVal = computed(() => Number(props.data[key.value]));
const unit = computed(
() => metricConfig.value[0] && encodeURIComponent(metricConfig.value[0].unit)
() =>
metricConfig.value[0] &&
encodeURIComponent(metricConfig.value[0].unit || "")
);
</script>
<style lang="scss" scoped>