diff --git a/app/src/panels/metric/index.ts b/app/src/panels/metric/index.ts index f09974e135..e9fd0ab9ad 100644 --- a/app/src/panels/metric/index.ts +++ b/app/src/panels/metric/index.ts @@ -27,6 +27,7 @@ export default definePanel({ collectionField: 'collection', typeAllowList: ['integer', 'bigInteger', 'float', 'decimal'], allowPrimaryKey: true, + allowNone: true, }, width: 'half', }, diff --git a/app/src/panels/metric/metric.vue b/app/src/panels/metric/metric.vue index 0b3cadf8da..e7a1b28ab0 100644 --- a/app/src/panels/metric/metric.vue +++ b/app/src/panels/metric/metric.vue @@ -122,14 +122,18 @@ export default defineComponent({ const res = await api.get(`/items/${props.options.collection}`, { params: { aggregate: { - [props.options.function]: [props.options.field], + [props.options.function]: [props.options.field || '*'], }, filter: props.options.filter, sort: sort, }, }); - metric.value = Number(res.data.data[0][`${props.options.field}_${props.options.function}`]); + if (props.options.field) { + metric.value = Number(res.data.data[0][`${props.options.field}_${props.options.function}`]); + } else { + metric.value = Number(res.data.data[0][props.options.function]); + } } catch (err) { // oh no } finally {