mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 17:34:51 +00:00
fix: update graph
This commit is contained in:
parent
a836ae20e9
commit
4a6ac51b7a
@ -16,13 +16,12 @@ limitations under the License. -->
|
|||||||
<div ref="chartRef" :style="`height:${height};width:${width};`"></div>
|
<div ref="chartRef" :style="`height:${height};width:${width};`"></div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { watch, ref, defineProps, Ref } from "vue";
|
import { watch, ref, defineProps, Ref, onMounted, onBeforeUnmount } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import { useECharts } from "@/hooks/useECharts";
|
import { useECharts } from "@/hooks/useEcharts";
|
||||||
/*global Nullable*/
|
/*global Nullable*/
|
||||||
const chartRef = ref<Nullable<HTMLDivElement>>(null);
|
const chartRef = ref<Nullable<HTMLDivElement>>(null);
|
||||||
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
|
const { setOptions, resize } = useECharts(chartRef as Ref<HTMLDivElement>);
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
clickEvent: { type: Function as PropType<(param: unknown) => void> },
|
clickEvent: { type: Function as PropType<(param: unknown) => void> },
|
||||||
height: { type: String, default: "100%" },
|
height: { type: String, default: "100%" },
|
||||||
@ -33,10 +32,24 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (!chartRef.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.addEventListener("resize", resize);
|
||||||
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.option,
|
() => props.option,
|
||||||
(opt) => {
|
(opt) => {
|
||||||
setOptions(opt);
|
setOptions(opt);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
if (!chartRef.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.removeEventListener("resize", resize);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -116,6 +116,7 @@ export function useECharts(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resize() {
|
function resize() {
|
||||||
|
console.log("resize");
|
||||||
chartInstance?.resize();
|
chartInstance?.resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,10 +51,22 @@ export const dashboardStore = defineStore({
|
|||||||
w: 24,
|
w: 24,
|
||||||
h: 12,
|
h: 12,
|
||||||
i: String(this.layout.length),
|
i: String(this.layout.length),
|
||||||
|
metrics: ["service_resp_time"],
|
||||||
|
queryMetricType: "readMetricsValues",
|
||||||
type: "Widget",
|
type: "Widget",
|
||||||
widget: {},
|
widget: {
|
||||||
graph: {},
|
title: "Title123",
|
||||||
standard: {},
|
tips: "Tooltip123",
|
||||||
|
},
|
||||||
|
graph: {
|
||||||
|
showBackground: true,
|
||||||
|
barWidth: 30,
|
||||||
|
type: "Line",
|
||||||
|
},
|
||||||
|
standard: {
|
||||||
|
sortOrder: "DEC",
|
||||||
|
unit: "s",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
this.layout = this.layout.map((d: LayoutConfig) => {
|
this.layout = this.layout.map((d: LayoutConfig) => {
|
||||||
d.y = d.y + newWidget.h;
|
d.y = d.y + newWidget.h;
|
||||||
@ -119,10 +131,22 @@ export const dashboardStore = defineStore({
|
|||||||
w: 24,
|
w: 24,
|
||||||
h: 12,
|
h: 12,
|
||||||
i: String(children.length),
|
i: String(children.length),
|
||||||
|
metrics: ["service_resp_time"],
|
||||||
|
queryMetricType: "readMetricsValues",
|
||||||
type: "Widget",
|
type: "Widget",
|
||||||
widget: {},
|
widget: {
|
||||||
graph: {},
|
title: "Title123",
|
||||||
standard: {},
|
tips: "Tooltip123",
|
||||||
|
},
|
||||||
|
graph: {
|
||||||
|
showBackground: true,
|
||||||
|
barWidth: 30,
|
||||||
|
type: "Line",
|
||||||
|
},
|
||||||
|
standard: {
|
||||||
|
sortOrder: "DEC",
|
||||||
|
unit: "s",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
if (this.layout[idx].children) {
|
if (this.layout[idx].children) {
|
||||||
const items = children.map((d: LayoutConfig) => {
|
const items = children.map((d: LayoutConfig) => {
|
||||||
|
@ -24,7 +24,7 @@ limitations under the License. -->
|
|||||||
<template #reference>
|
<template #reference>
|
||||||
<Icon iconName="ellipsis_v" size="middle" class="operation" />
|
<Icon iconName="ellipsis_v" size="middle" class="operation" />
|
||||||
</template>
|
</template>
|
||||||
<div class="tools" @click="setConfig">
|
<div class="tools" @click="editConfig">
|
||||||
<span>Edit</span>
|
<span>Edit</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="tools" @click="removeWidget">
|
<div class="tools" @click="removeWidget">
|
||||||
@ -104,7 +104,7 @@ export default defineComponent({
|
|||||||
function removeWidget() {
|
function removeWidget() {
|
||||||
dashboardStore.removeControls(props.data);
|
dashboardStore.removeControls(props.data);
|
||||||
}
|
}
|
||||||
function setConfig() {
|
function editConfig() {
|
||||||
dashboardStore.setConfigPanel(true);
|
dashboardStore.setConfigPanel(true);
|
||||||
dashboardStore.selectWidget(props.data);
|
dashboardStore.selectWidget(props.data);
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ export default defineComponent({
|
|||||||
state,
|
state,
|
||||||
appStoreWithOut,
|
appStoreWithOut,
|
||||||
removeWidget,
|
removeWidget,
|
||||||
setConfig,
|
editConfig,
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -16,7 +16,7 @@ limitations under the License. -->
|
|||||||
<Graph :option="option" />
|
<Graph :option="option" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineProps, ref, computed } from "vue";
|
import { defineProps, computed } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import { Event } from "@/types/events";
|
import { Event } from "@/types/events";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user