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