diff --git a/src/components/Graph.vue b/src/components/Graph.vue index b580e315..03f50aa0 100644 --- a/src/components/Graph.vue +++ b/src/components/Graph.vue @@ -26,23 +26,30 @@ import { } from "vue"; import type { PropType } from "vue"; import * as echarts from "echarts"; -const dom = ref(null); -const state = reactive({ +// eslint-disable-next-line no-undef +const dom = ref>(null); +const state = reactive<{ instanceChart: any }>({ instanceChart: null, }); const props = defineProps({ clickEvent: { type: Function as PropType<(param: unknown) => void> }, - height: { type: Number, default: 100 }, - width: { type: Number, default: 300 }, - option: { type: Object as PropType, default: () => ({}) }, + height: { type: String, default: "100%" }, + width: { type: String, default: "100%" }, + option: { + type: Object as PropType<{ [key: string]: unknown }>, + default: () => ({}), + }, }); onMounted(() => { drawEcharts(); window.addEventListener("resize", state.instanceChart.resize); }); function drawEcharts(): void { + if (!dom.value) { + return; + } state.instanceChart = echarts.init(dom.value, ""); - state.instanceChart.setOption(state.option); + state.instanceChart.setOption(props.option); state.instanceChart.on("click", (params: any) => { if (!props.clickEvent) { return; diff --git a/src/views/dashboard/configuration/WidgetConfig.vue b/src/views/dashboard/configuration/WidgetConfig.vue index fcfe5653..863af2f5 100644 --- a/src/views/dashboard/configuration/WidgetConfig.vue +++ b/src/views/dashboard/configuration/WidgetConfig.vue @@ -14,7 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. -->