fix: reset the data when there are no queries to execute (#2491)

- Resets the chart rendering when there are no queries, fixes the alert
preview chart when switching from the SQL to promql
This commit is contained in:
ktx-kirtan
2024-01-16 19:53:29 +05:30
committed by GitHub
parent 9519e2a34c
commit 1a1146b0bc
@@ -31,7 +31,11 @@ export const usePanelDataLoader = (
variablesData: any,
chartPanelRef: any
) => {
const log = (...args: any[]) => {};
const log = (...args: any[]) => {
// if (true) {
// console.log(panelSchema?.value?.title + ": ", ...args);
// }
};
const state = reactive({
data: [] as any,
@@ -157,6 +161,10 @@ export const usePanelDataLoader = (
// Checking if there are queries to execute
if (!panelSchema.value.queries?.length || !hasAtLeastOneQuery()) {
log("loadData: there are no queries to execute");
state.loading = false;
state.data = [];
state.metadata = {}
return;
}