mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-08-03 17:51:56 +00:00
fix: update heat map
This commit is contained in:
parent
e85d819356
commit
0ab8b17f9d
@ -28,7 +28,7 @@ export function useQueryProcessor(config: any) {
|
|||||||
const appStore = useAppStoreWithOut();
|
const appStore = useAppStoreWithOut();
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
if (!selectorStore.currentService) {
|
if (!selectorStore.currentService && dashboardStore.entity !== "All") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const conditions: { [key: string]: unknown } = {
|
const conditions: { [key: string]: unknown } = {
|
||||||
|
@ -101,3 +101,24 @@ export const ConfigData2: any = {
|
|||||||
},
|
},
|
||||||
children: [],
|
children: [],
|
||||||
};
|
};
|
||||||
|
export const ConfigData3: any = {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
w: 8,
|
||||||
|
h: 12,
|
||||||
|
i: "0",
|
||||||
|
metrics: ["all_heatmap"],
|
||||||
|
metricTypes: ["readHeatMap"],
|
||||||
|
type: "Widget",
|
||||||
|
widget: {
|
||||||
|
title: "all_heatmap",
|
||||||
|
tips: "Tooltip",
|
||||||
|
},
|
||||||
|
graph: {
|
||||||
|
type: "HeatMap",
|
||||||
|
},
|
||||||
|
standard: {
|
||||||
|
unit: "min",
|
||||||
|
},
|
||||||
|
children: [],
|
||||||
|
};
|
||||||
|
@ -18,7 +18,7 @@ import { defineStore } from "pinia";
|
|||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
import { LayoutConfig } from "@/types/dashboard";
|
import { LayoutConfig } from "@/types/dashboard";
|
||||||
import graph from "@/graph";
|
import graph from "@/graph";
|
||||||
import { ConfigData, ConfigData1, ConfigData2 } from "../data";
|
import { ConfigData, ConfigData1, ConfigData2, ConfigData3 } from "../data";
|
||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import { NewControl } from "../data";
|
import { NewControl } from "../data";
|
||||||
@ -146,12 +146,16 @@ export const dashboardStore = defineStore({
|
|||||||
},
|
},
|
||||||
setEntity(type: string) {
|
setEntity(type: string) {
|
||||||
this.entity = type;
|
this.entity = type;
|
||||||
|
// todo
|
||||||
if (type === "ServiceInstance") {
|
if (type === "ServiceInstance") {
|
||||||
this.layout = [ConfigData1];
|
this.layout = [ConfigData1];
|
||||||
}
|
}
|
||||||
if (type === "Endpoint") {
|
if (type === "Endpoint") {
|
||||||
this.layout = [ConfigData2];
|
this.layout = [ConfigData2];
|
||||||
}
|
}
|
||||||
|
if (type == "All") {
|
||||||
|
this.layout = [ConfigData3];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setConfigs(param: { [key: string]: unknown }) {
|
setConfigs(param: { [key: string]: unknown }) {
|
||||||
const actived = this.activedGridItem.split("-");
|
const actived = this.activedGridItem.split("-");
|
||||||
|
59
src/views/dashboard/configuration/graph-styles/HeatMap.vue
Normal file
59
src/views/dashboard/configuration/graph-styles/HeatMap.vue
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<!-- Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License. -->
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<span class="label">{{ t("fontSize") }}</span>
|
||||||
|
<el-slider
|
||||||
|
class="slider"
|
||||||
|
v-model="fontSize"
|
||||||
|
show-input
|
||||||
|
input-size="small"
|
||||||
|
:min="10"
|
||||||
|
:max="20"
|
||||||
|
:step="1"
|
||||||
|
@change="updateConfig({ fontSize })"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const dashboardStore = useDashboardStore();
|
||||||
|
const fontSize = ref(dashboardStore.selectedGrid.graph.fontSize);
|
||||||
|
|
||||||
|
function updateConfig(param: { [key: string]: unknown }) {
|
||||||
|
const graph = {
|
||||||
|
...dashboardStore.selectedGrid.graph,
|
||||||
|
...param,
|
||||||
|
};
|
||||||
|
dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, graph });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.slider {
|
||||||
|
width: 500px;
|
||||||
|
margin-top: -13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
@ -93,6 +93,10 @@ export default defineComponent({
|
|||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
|
|
||||||
|
if (dashboardStore.entity === EntityType[1].value) {
|
||||||
|
queryMetrics();
|
||||||
|
}
|
||||||
|
|
||||||
async function queryMetrics() {
|
async function queryMetrics() {
|
||||||
const params = await useQueryProcessor(props.data);
|
const params = await useQueryProcessor(props.data);
|
||||||
if (!params) {
|
if (!params) {
|
||||||
@ -143,10 +147,7 @@ export default defineComponent({
|
|||||||
watch(
|
watch(
|
||||||
() => [selectorStore.currentPod],
|
() => [selectorStore.currentPod],
|
||||||
() => {
|
() => {
|
||||||
if (
|
if (dashboardStore.entity === EntityType[0].value) {
|
||||||
dashboardStore.entity === EntityType[0].value ||
|
|
||||||
dashboardStore.entity === EntityType[1].value
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
queryMetrics();
|
queryMetrics();
|
||||||
|
@ -41,7 +41,7 @@ export const MetricChartType: any = {
|
|||||||
],
|
],
|
||||||
sortMetrics: [{ label: "Top List", value: "TopList" }],
|
sortMetrics: [{ label: "Top List", value: "TopList" }],
|
||||||
readLabeledMetricsValues: [{ label: "Line", value: "Line" }],
|
readLabeledMetricsValues: [{ label: "Line", value: "Line" }],
|
||||||
readHeatMap: [{ label: "Heatmap", value: "Heatmap" }],
|
readHeatMap: [{ label: "Heat Map", value: "HeatMap" }],
|
||||||
readSampledRecords: [{ label: "Top List", value: "TopList" }],
|
readSampledRecords: [{ label: "Top List", value: "TopList" }],
|
||||||
};
|
};
|
||||||
export const DefaultGraphConfig: { [key: string]: any } = {
|
export const DefaultGraphConfig: { [key: string]: any } = {
|
||||||
@ -93,6 +93,9 @@ export const DefaultGraphConfig: { [key: string]: any } = {
|
|||||||
dashboardName: "",
|
dashboardName: "",
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
},
|
},
|
||||||
|
HeatMap: {
|
||||||
|
type: "HeatMap",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum MetricsType {
|
export enum MetricsType {
|
||||||
|
@ -23,7 +23,9 @@ import { StandardConfig } from "@/types/dashboard";
|
|||||||
/*global defineProps */
|
/*global defineProps */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
type: Object as PropType<{ nodes: number[][]; buckets: number[][] }>,
|
type: Object as PropType<{
|
||||||
|
[key: string]: { nodes: number[][]; buckets: number[][] };
|
||||||
|
}>,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
@ -37,8 +39,11 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const option = computed(() => getOption());
|
const option = computed(() => getOption());
|
||||||
|
|
||||||
function getOption() {
|
function getOption() {
|
||||||
const source = (props.data.nodes || []).map((d: number[]) => d[2]);
|
const metric = props.config.metrics[0];
|
||||||
|
const nodes = (props.data[metric] && props.data[metric].nodes) || [];
|
||||||
|
const source = (nodes || []).map((d: number[]) => d[2]);
|
||||||
const maxItem = Math.max(...source);
|
const maxItem = Math.max(...source);
|
||||||
const minItem = Math.min(...source);
|
const minItem = Math.min(...source);
|
||||||
const colorBox = [
|
const colorBox = [
|
||||||
@ -63,15 +68,16 @@ function getOption() {
|
|||||||
"#761212",
|
"#761212",
|
||||||
"#671010",
|
"#671010",
|
||||||
];
|
];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tooltip: {
|
tooltip: {
|
||||||
position: "top",
|
position: "top",
|
||||||
formatter: (a: any) =>
|
// formatter: (a: any) =>
|
||||||
`${a.data[1] * 100}${props.standard.unit} [ ${a.data[2]} ]`,
|
// `${a.data[1] * 100}${props.standard.unit} [ ${a.data[2]} ]`,
|
||||||
textStyle: {
|
// textStyle: {
|
||||||
fontSize: 13,
|
// fontSize: 13,
|
||||||
color: "#ccc",
|
// color: "#ccc",
|
||||||
},
|
// },
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
top: 15,
|
top: 15,
|
||||||
@ -112,7 +118,7 @@ function getOption() {
|
|||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
type: "heatmap",
|
type: "heatmap",
|
||||||
data: props.data.nodes || [],
|
data: nodes || [],
|
||||||
emphasis: {
|
emphasis: {
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
shadowBlur: 10,
|
shadowBlur: 10,
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import Area from "./Area.vue";
|
import Area from "./Area.vue";
|
||||||
import Line from "./Line.vue";
|
import Line from "./Line.vue";
|
||||||
import Bar from "./Bar.vue";
|
import Bar from "./Bar.vue";
|
||||||
import Heatmap from "./HeatMap.vue";
|
import HeatMap from "./HeatMap.vue";
|
||||||
import TopList from "./TopList.vue";
|
import TopList from "./TopList.vue";
|
||||||
import Table from "./Table.vue";
|
import Table from "./Table.vue";
|
||||||
import Pie from "./Pie.vue";
|
import Pie from "./Pie.vue";
|
||||||
@ -30,7 +30,7 @@ import ServiceList from "./ServiceList.vue";
|
|||||||
export default {
|
export default {
|
||||||
Line,
|
Line,
|
||||||
Bar,
|
Bar,
|
||||||
Heatmap,
|
HeatMap,
|
||||||
TopList,
|
TopList,
|
||||||
Area,
|
Area,
|
||||||
Table,
|
Table,
|
||||||
|
@ -40,7 +40,7 @@ limitations under the License. -->
|
|||||||
size="mini"
|
size="mini"
|
||||||
placeholder="Select a data"
|
placeholder="Select a data"
|
||||||
@change="changePods"
|
@change="changePods"
|
||||||
class="selectors"
|
class="selectorPod"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="selectors-item" v-if="states.key === 2">
|
<div class="selectors-item" v-if="states.key === 2">
|
||||||
@ -149,6 +149,9 @@ async function getServices() {
|
|||||||
if (!dashboardStore.layerId) {
|
if (!dashboardStore.layerId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (dashboardStore.entity === EntityType[1].value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const json = await selectorStore.fetchServices(dashboardStore.layerId);
|
const json = await selectorStore.fetchServices(dashboardStore.layerId);
|
||||||
if (json.errors) {
|
if (json.errors) {
|
||||||
ElMessage.error(json.errors);
|
ElMessage.error(json.errors);
|
||||||
@ -173,7 +176,7 @@ async function changeService(service: Service[]) {
|
|||||||
|
|
||||||
function changePods(pod: Option[]) {
|
function changePods(pod: Option[]) {
|
||||||
if (pod[0]) {
|
if (pod[0]) {
|
||||||
selectorStore.setCurrentPod(pod[0].value);
|
selectorStore.setCurrentPod(pod[0]);
|
||||||
} else {
|
} else {
|
||||||
selectorStore.setCurrentPod("");
|
selectorStore.setCurrentPod("");
|
||||||
}
|
}
|
||||||
@ -260,10 +263,14 @@ async function fetchPods(type: string, setPod: boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.selectors {
|
.selectors {
|
||||||
min-width: 180px;
|
min-width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selectors-item {
|
.selectors-item {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.selectorPod {
|
||||||
|
width: 340px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user