mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 12:14:01 +00:00
fix: render graphs
This commit is contained in:
parent
c282655369
commit
f19b69d050
@ -43,7 +43,6 @@ const props = defineProps({
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.log(chart.value);
|
|
||||||
drawEcharts();
|
drawEcharts();
|
||||||
window.addEventListener("resize", state.instanceChart.resize);
|
window.addEventListener("resize", state.instanceChart.resize);
|
||||||
}, 50);
|
}, 50);
|
||||||
|
@ -23,7 +23,7 @@ export const ConfigData: LayoutConfig = {
|
|||||||
i: "0",
|
i: "0",
|
||||||
metrics: ["service_resp_time"],
|
metrics: ["service_resp_time"],
|
||||||
queryMetricType: "readMetricsValues",
|
queryMetricType: "readMetricsValues",
|
||||||
visualization: "Line",
|
visualization: "Bar",
|
||||||
widget: {
|
widget: {
|
||||||
title: "Title",
|
title: "Title",
|
||||||
tips: "Tooltip",
|
tips: "Tooltip",
|
||||||
|
@ -86,7 +86,7 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { reactive, defineComponent, ref } from "vue";
|
import { reactive, defineComponent } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
|
@ -13,10 +13,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<Graph ref="chart" :option="option" :autoResize="true" />
|
<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";
|
||||||
|
|
||||||
@ -37,8 +37,6 @@ const props = defineProps({
|
|||||||
default: () => ({ theme: "light", showBackground: true, barWidth: 20 }),
|
default: () => ({ theme: "light", showBackground: true, barWidth: 20 }),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
/*global Nullable */
|
|
||||||
const chart = ref<Nullable<HTMLElement>>(null);
|
|
||||||
const option = computed(() => getOption());
|
const option = computed(() => getOption());
|
||||||
|
|
||||||
function getOption() {
|
function getOption() {
|
||||||
|
@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<Graph ref="chart" :option="option" :autoResize="true" />
|
<Graph :option="option" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineProps, ref, computed } from "vue";
|
import { defineProps, ref, computed } from "vue";
|
||||||
|
@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<Graph ref="chart" :option="option" :autoResize="true" />
|
<Graph :option="option" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineProps, ref, computed } from "vue";
|
import { defineProps, ref, computed } from "vue";
|
||||||
@ -30,8 +30,6 @@ const props = defineProps({
|
|||||||
theme: { type: String, default: "light" },
|
theme: { type: String, default: "light" },
|
||||||
itemEvents: { type: Array as PropType<Event[]>, default: () => [] },
|
itemEvents: { type: Array as PropType<Event[]>, default: () => [] },
|
||||||
});
|
});
|
||||||
/*global Nullable */
|
|
||||||
const chart = ref<Nullable<HTMLElement>>(null);
|
|
||||||
const option = computed(() => getOption());
|
const option = computed(() => getOption());
|
||||||
function getOption() {
|
function getOption() {
|
||||||
const keys = Object.keys(props.data || {}).filter(
|
const keys = Object.keys(props.data || {}).filter(
|
||||||
|
@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<Graph ref="chart" :option="option" :autoResize="true" />
|
<Graph :option="option" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineProps, ref, computed } from "vue";
|
import { defineProps, ref, computed } from "vue";
|
||||||
|
@ -35,50 +35,62 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts">
|
||||||
import { defineProps, reactive, onMounted } from "vue";
|
import { toRefs, reactive, defineComponent } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import { LayoutConfig } from "@/types/dashboard";
|
import { LayoutConfig } from "@/types/dashboard";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
|
import graphs from "../graphs";
|
||||||
const state = reactive({
|
const props = {
|
||||||
source: {},
|
|
||||||
});
|
|
||||||
const props = defineProps({
|
|
||||||
item: { type: Object as PropType<LayoutConfig>, default: () => ({}) },
|
item: { type: Object as PropType<LayoutConfig>, default: () => ({}) },
|
||||||
});
|
};
|
||||||
const appStoreWithOut = useAppStoreWithOut();
|
export default defineComponent({
|
||||||
const dashboardStore = useDashboardStore();
|
name: "Widget",
|
||||||
onMounted(() => {
|
components: { ...graphs },
|
||||||
queryMetrics();
|
props,
|
||||||
});
|
setup(props) {
|
||||||
async function queryMetrics() {
|
const state = reactive({
|
||||||
const json = await dashboardStore.fetchMetricValue(props.item);
|
source: {},
|
||||||
|
});
|
||||||
|
const { item } = toRefs(props);
|
||||||
|
const appStoreWithOut = useAppStoreWithOut();
|
||||||
|
const dashboardStore = useDashboardStore();
|
||||||
|
queryMetrics();
|
||||||
|
async function queryMetrics() {
|
||||||
|
const json = await dashboardStore.fetchMetricValue(props.item);
|
||||||
|
|
||||||
if (json.error) {
|
if (json.error) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const metricVal = json.data.readMetricsValues.values.values.map(
|
const metricVal = json.data.readMetricsValues.values.values.map(
|
||||||
(d: any) => d.value
|
(d: any) => d.value
|
||||||
);
|
);
|
||||||
const m = props.item.metrics && props.item.metrics[0];
|
const m = props.item.metrics && props.item.metrics[0];
|
||||||
if (!m) {
|
if (!m) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.source = {
|
state.source = {
|
||||||
[m]: metricVal,
|
[m]: metricVal,
|
||||||
};
|
};
|
||||||
console.log(state.source);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function removeWidget() {
|
function removeWidget() {
|
||||||
dashboardStore.removeWidget(props.item);
|
dashboardStore.removeWidget(props.item);
|
||||||
}
|
}
|
||||||
function setConfig() {
|
function setConfig() {
|
||||||
dashboardStore.setConfigPanel(true);
|
dashboardStore.setConfigPanel(true);
|
||||||
dashboardStore.selectWidget(props.item);
|
dashboardStore.selectWidget(props.item);
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
|
state,
|
||||||
|
appStoreWithOut,
|
||||||
|
removeWidget,
|
||||||
|
setConfig,
|
||||||
|
item,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.widget {
|
.widget {
|
||||||
|
Loading…
Reference in New Issue
Block a user