gpt4 book ai didi

javascript - 如何将限制过滤器应用于cubeJs的timeDimension属性?

转载 作者:太空宇宙 更新时间:2023-11-03 22:03:42 25 4
gpt4 key购买 nike

下面是我尝试使用cubejs应用2的限制的场景。这是 json 查询:

{
"measures": [
"actors.actorscount"
],
"timeDimensions": [
{
"dimension": "actors.createdAt",
"granularity": "month",
"dateRange": "Last quarter"
}
],
"dimensions": [
"actors.genre"
],
"filters": []
}

enter image description here

在将 limit=2 应用到下面的查询后,我得到了低于条形图的响应:

{
"measures": [
"actors.actorscount"
],
"timeDimensions": [
{
"dimension": "actors.createdAt",
"granularity": "month",
"dateRange": "Last quarter"
}
],
"dimensions": [
"actors.genre"
],
"filters": [],
"limit":2
}

我得到的当前条形图为: enter image description here

应用限制后预期条形图响应:

enter image description here

那么,应该怎样做才能获得正确的条形图响应?

最佳答案

这样的结果可以通过两个步骤来实现:

首先获得没有时间粒度的前 2 个维度:

{
"measures": [
"actors.actorscount"
],
"timeDimensions": [
{
"dimension": "actors.createdAt",
"dateRange": "Last quarter"
}
],
"dimensions": [
"actors.genre"
],
"order": { "actors.actorscount": "desc" },
"limit": 2
}

然后使用第一个查询结果中的两个顶部维度来获取所需的图表:

{
"measures": [
"actors.actorscount"
],
"timeDimensions": [
{
"dimension": "actors.createdAt",
"granularity": "month"
"dateRange": "Last quarter"
}
],
"dimensions": [
"actors.genre"
],
"filters": [{
"dimension": "actors.genre",
"operator": "equals",
"values": ["action", "comedy"]
}]
}

关于javascript - 如何将限制过滤器应用于cubeJs的timeDimension属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59983869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com