主题
过滤控件
过滤控件说明
过滤控件 的定义
过滤控件用于在仪表盘中过滤图表数据,分为仪表盘内过滤控件和全局过滤控件。
过滤控件结构说明
| 字段 | 类型 | 描述 |
|---|---|---|
| uid | STRING | 过滤控件唯一识别 id |
| appId | LONG | 过滤控件所属的应用 id |
| dataAppId | LONG | 字段来源是数据包时的数据包 id |
| dashboardId | LONG | 过滤控件所属的仪表盘 id |
| datasetId | LONG | 过滤控件所是用的字段所属的数据集 id |
| title | STRING | 过滤控件标题 |
| filterType | STRING | 过滤控类型,可选值为:FILTER(过滤控件),FILTER_BTN(过滤按钮),PARAM(参数控件),MULTIPLE_DATE_PARAM(日期多选过滤控件) |
| fieldName | STRING | 过滤器所用的字段名称 |
| field | OBJECT | 过滤器所用的字段配置 |
| use | STRING | 过滤器过滤样式,默认传"checkbox"即可 |
| kind | OBJECT | 过滤器表达式类型,默认传"formula"即可 |
| op | OBJECT | 过滤器表达式,默认传"1=1"即可 |
| measureSubjectId | LONG | 业务指标模式下的主题域文件夹 id;非空时按业务指标过滤器处理 |
| candidateMeasures | OBJECT 数组 | 业务指标模式下的候选指标列表;新增/编辑时后端会结合当前维度从中重算 sourceMeasureKeys |
| sourceMeasureKeys | ARRAY | 业务指标模式下由后端回填的“当前过滤器关联指标列表”。普通主题域元素为 MetricFolder ID,动态主题域元素为指标 fieldName;若当前过滤器只用了维度(field/fieldSiblings),后端会按这些维度从 candidateMeasures 中筛出可一起分析的候选指标子集 |
| appParamBindings | OBJECT 数组 | 过滤器输出点到应用参数的绑定。缺省、null 或空数组表示不绑定;对象字段见下表 |
| options | OBJECT | 过滤控件样式相关配置 |
| options.style | OBJECT | 过滤控件样式配置 |
| options.titleStyle | OBJECT | 过滤控件标题样式配置 |
| children | LIST | 子过滤控件集合,list中的值为子控件的uid |
| isGlobalFilter | BOOLEAN | 过滤控件是否为全局控件 |
| controller | MAP | 过滤按钮控制的过滤控件映射表,key为要控制的过滤控件uid,value为boolean值:true(控制) |
| byDashboard | OBJECT | 全局过滤器在各仪表盘中的样式设置 |
| childrenByDashboard | OBJECT | 全局过滤器与各仪表盘中的过滤控件的父子关系 |
appParamBindings 对象结构:
| 字段 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| pointCode | STRING | 启用时是 | 输出点编码。文本单选/搜索为 value,文本多选为 values,数值单选为 value,数值范围为 min/max,日期时间单值为 value,日期时间范围为 start/end |
| targetAppId | LONG | 启用时是 | 目标应用参数所属应用 id。当前应用未开启数据应用分配或该配置未设置时,本应用可选,其他应用必须是当前用户有权限访问的数据集市;开启后,仅 data_use 关系中的可用数据包可选,本应用参数不可选 |
| targetParamId | LONG | 启用时是 | 目标应用参数 id |
| targetParamName | STRING | 启用时是 | 目标应用参数名称。参数名称是运行时访问和界面展示使用的键;保存时如果 targetParamId 存在,服务端会按当前参数定义补全或刷新该名称 |
| enabled | BOOLEAN | 是 | 是否启用。启用项会使用过滤器当前字段和目标参数当前定义校验输出点、目标范围、参数类型、多值配置和来源唯一性;禁用项允许保留暂时无法解析的目标 |
绑定项只持久化表中列出的五个字段,不复制参数类型、多值或粒度配置。同一过滤器中不可启用重复 pointCode,复制或导入时发现的重复项会全部禁用并保留,之后可正常重新保存。仪表盘控件与全局控件、同一仪表盘内其他控件共享参数来源唯一性;不同仪表盘之间互不冲突。
当前应用未开启数据应用分配或该配置未设置时,服务端会按绑定项即时校验外部 targetAppId 是否存在、当前用户是否有访问权限且属于数据集市,无需预先创建图表或过滤器;本应用目标不做这项额外校验。开启数据应用分配后只接受 data_use 关系中的目标,本应用和 data_extend 关系中的目标均不在可用范围内。
接口说明
新增过滤控件
新增过滤控件
请求URL
http
POST /api/apps/${appId}/filter-controllers HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...请求参数
URL 参数
| 字段 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| appId | INTEGER | 是 | 过滤控件所在的应用 id |
Request Body 参数
过滤控件配置信息,见过滤控件结构
返回对象的格式说明
| 字段 | 类型 | 说明 |
|---|---|---|
| version | STRING | 当前系统版本哈希值 |
| data | OBJECT | 过滤控件的完整配置信息,见过滤控件结构 |
接口示例1: 新增仪表盘内过滤控件
http
POST /api/apps/1/filter-controllers HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
// Request Body:
{
"title": "新建过滤器",
"options": {
"titleStyle": {
"textAlign": "center",
"position": "left"
},
"style": {
"method": "select",
"itemStyle": {
"borderTopColor": "#dadada",
"borderRightColor": "#dadada",
"borderBottomColor": "#dadada",
"borderLeftColor": "#dadada",
"maxHeight": 28,
"background": "#fff"
}
}
},
"filterType": "filter",
"fieldName": "director",
"field": {
"datasetId": 1,
"fieldName": "director",
"tags": {},
"defaultAggrType": "count",
"comment": "",
"type": "string",
"config": {},
"originType": "string",
"visible": true,
"nativeType": "bpchar",
"hideValue": false,
"detectedType": "string",
"suggestedTypes": [
"string"
],
"basicType": "string",
"dataAppId": 130713,
"_ukey": "director",
"labelOrigin": "director"
},
"use": "checkbox",
"appParamBindings": [
{
"pointCode": "values",
"targetAppId": 1,
"targetParamId": 7,
"targetParamName": "region",
"enabled": true
}
],
"kind": "formula",
"op": "1=1",
"appId": 1,
"uid": "01HJ0TE602Z2VERDA4CMY4JR59",
"dataAppId": 1,
"datasetId": 1,
"dashboardId": 1,
"dashboardOptions": {
"layouts": {
"1": {
"static": false,
"w": 4,
"moved": false,
"h": 4,
"x": 1,
"i": "1",
"y": 1,
"type": "chart",
"zIndex": 902,
"options": {}
},
"01HJ0TE602Z2VERDA4CMY4JR59": {
"i": "01HJ0TE602Z2VERDA4CMY4JR59",
"x": 1,
"y": 1,
"w": 4,
"h": 1,
"moved": false,
"static": false,
"zIndex": 904,
"type": "filter"
}
}
}
}说明
dashboardOptions.layouts为过滤控件在仪表盘内的样式配置,layouts为MAP类型,key是过滤控件uid或图表id,value为具体的样式配置,请注意,这里的options.layouts每次都需要传递完整的layouts而不是仅传当前新增的控件样式,如:仪表盘内已有一个图表和一个过滤控件,那么新增过滤控件时,layouts中应该有三个键值对,分别对应两个过滤控件和一个已有图表的样式。
接口示例2: 新增仪全局过滤控件
http
POST /api/apps/1/filter-controllers HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
// Request Body:
{
"title": "全局过滤器",
"options": {
"titleStyle": {},
"style": {
"method": "select",
"itemStyle": {
"borderTopColor": "#dadada",
"borderRightColor": "#dadada",
"borderBottomColor": "#dadada",
"borderLeftColor": "#dadada",
"maxHeight": 28,
"background": "#fff"
}
}
},
"filterType": "filter",
"appId": 130713,
"isGlobalFilter": true,
"uid": "01HJ0V48VGN5M8XV4FQDW9BZ6D",
"fieldName": "director",
"field": {
"datasetId": 1,
"fieldName": "director",
"tags": {},
"defaultAggrType": "count",
"type": "string",
"comment": "",
"originType": "string",
"config": {},
"visible": true,
"nativeType": "bpchar",
"hideValue": false,
"detectedType": "string",
"suggestedTypes": [
"string"
],
"basicType": "string",
"dataAppId": 130713,
"_ukey": "director",
"labelOrigin": "director"
},
"byDashboard": {
"1": {
"style": {
"method": "select",
"itemStyle": {
"borderTopColor": "#dadada",
"borderRightColor": "#dadada",
"borderBottomColor": "#dadada",
"borderLeftColor": "#dadada",
"maxHeight": 28,
"background": "#fff"
}
}
}
},
"children": [
"01HJ0TE602Z2VERDA4CMY4JR59"
],
"childrenByDashboard": {
"1": [
"01HJ0TE602Z2VERDA4CMY4JR59"
]
},
"dataAppId": 130713,
"datasetId": 1,
"inside": true
}说明
全局过滤控件不需要传递dashboardOptions
接口示例3: 新增参数控件
http
POST /api/apps/1/filter-controllers HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
// Request Body:
{
"uid": "01HJ0WYABBYAHBS8N33KVRHFJH",
"dashboardId": 1,
"appId": 1,
"options": {
"style": {
"method": "input"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
},
"mobileOptions": {
"style": {
"method": "input"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
}
},
"enableAll": false
},
"datasetId": 1,
"title": "参数控件",
"filterType": "param",
"field": {
"id": 1,
"name": "param",
"appId": 130713,
"options": {
"type": "string",
"subType": "ALL",
"allowAllValue": true,
"defaultValue": null
},
"extendAppTitle": "过滤控件",
"uid": "1",
"isParam": true,
"type": "string",
"datasetId": 1,
"dataAppId": 130713,
"labelOrigin": "param",
"label": "param"
},
"use": "paramInput",
"fieldName": "param",
"dashboardOptions": {
"layouts": {
"1": {
"static": false,
"w": 4,
"moved": false,
"h": 4,
"x": 1,
"options": {},
"i": "1",
"y": 1,
"type": "chart",
"zIndex": 902
},
"01HJ0WYABBYAHBS8N33KVRHFJH": {
"i": "01HJ0WYABBYAHBS8N33KVRHFJH",
"x": 1,
"y": 1,
"w": 4,
"h": 1,
"moved": false,
"static": false,
"zIndex": 910,
"type": "param"
}
}
}
}接口示例4: 新增过滤按钮
http
POST /api/apps/1/filter-controllers HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
// Request Body:
{
"version": 5000,
"title": "查询",
"options": {},
"filterType": "filterBtn",
"appId": 130713,
"uid": "01HJ0X4WF0SR2MEND24V1J5BNE",
"dashboardId": 1,
"dashboardOptions": {
"layouts": {
"1": {
"static": false,
"w": 4,
"moved": false,
"h": 4,
"x": 1,
"options": {},
"i": "1",
"y": 1,
"type": "chart",
"zIndex": 902
},
"01HJ0X4WF0SR2MEND24V1J5BNE": {
"i": "01HJ0X4WF0SR2MEND24V1J5BNE",
"x": 1,
"y": 1,
"w": 4,
"h": 1,
"moved": false,
"static": false,
"zIndex": 912,
"type": "filterBtn"
}
}
}
}说明
过滤按钮具体控制哪些过滤控件需要调用批量更新接口
更新过滤控件
更新过滤控件
请求URL
http
PUT /api/apps/${appId}/filter-controllers/{uid} HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...请求参数
URL 参数
| 字段 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| appId | INTEGER | 是 | 过滤控件所在的应用 id |
| uid | INTEGER | 是 | 过滤控件唯一识别id |
Request Body 参数
过滤控件配置信息,见过滤控件结构
返回对象的格式说明
| 字段 | 类型 | 说明 |
|---|---|---|
| version | STRING | 当前系统版本哈希值 |
| data | OBJECT | 过滤控件的完整配置信息,见过滤控件结构 |
接口示例
http
PUT /api/apps/1/filter-controllers/01HJ0TE602Z2VERDA4CMY4JR59 HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
// Request Body:
{
"uid": "01HJ0TE602Z2VERDA4CMY4JR59",
"dashboardId": 1,
"appId": 130713,
"options": {
"style": {
"method": "select"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
},
"mobileOptions": {
"style": {
"method": "select"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
}
}
},
"datasetId": 1,
"dataAppId": 130713,
"title": "新建过滤器",
"filterType": "filter",
"version": 5000,
"fieldName": "director",
"field": {
"datasetId": 1,
"fieldName": "director",
"tags": {},
"defaultAggrType": "count",
"comment": "",
"type": "string",
"config": {},
"originType": "string",
"visible": true,
"nativeType": "bpchar",
"hideValue": false,
"detectedType": "string",
"suggestedTypes": [
"string"
],
"basicType": "string",
"dataAppId": 130713,
"_ukey": "director",
"labelOrigin": "director"
},
"use": "checkbox",
"kind": "formula",
"op": "1=1"
}说明
更新不需要再次传递dashboardOptions
批量更新过滤控件
批量更新过滤控件
请求URL
http
PUT /api/apps/${appId}/filter-controllers HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...请求参数
URL 参数
| 字段 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| appId | INTEGER | 是 | 过滤控件所在的应用 id |
Request Body 参数
过滤控件配置信息,见过滤控件结构
返回对象的格式说明
| 字段 | 类型 | 说明 |
|---|---|---|
| version | STRING | 当前系统版本哈希值 |
| data | OBJECT | 过滤控件的完整配置信息,见过滤控件结构 |
接口示例
http
PUT /api/apps/1/filter-controllers/01HJ0TE602Z2VERDA4CMY4JR59 HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
// Request Body:
[
{
"op": "1=1",
"controller": {
"01HJ0X4WF0SR2MEND24V1J5BNE": true
},
"fieldsChain": [
{
"field": "月份",
"keys": [
"130145_datasetList_2"
],
"appId": 130145,
"datasetId": 2,
"label": "月份"
}
],
"fieldName": "director",
"use": "checkbox",
"kind": "formula",
"datasetName": "A_IVT_MOVIE",
"title": "新建过滤器",
"version": 5000,
"uid": "01HJ0TE602Z2VERDA4CMY4JR59",
"hasChain": true,
"field": {
"fieldName": "director",
"visible": true,
"suggestedTypes": [
"string"
],
"type": "string",
"detectedType": "string",
"tags": {},
"basicType": "string",
"defaultAggrType": "count",
"originType": "string",
"hideValue": false,
"appId": 130713,
"nativeType": "bpchar",
"_ukey": "director",
"datasetId": 1,
"comment": "",
"labelOrigin": "director",
"id": 125664649,
"config": {}
},
"children": [
"01HJ0TNJJFG2S7HGKA5B57A11S"
],
"dashboardId": 1,
"appId": 130713,
"options": {
"style": {
"method": "select"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
},
"mobileOptions": {
"style": {
"method": "select"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
}
}
},
"datasetId": 1,
"fieldSiblings": [],
"dataAppId": 130713,
"filterType": "filter"
},
{
"uid": "01HJ0WYABBYAHBS8N33KVRHFJH",
"controller": {
"01HJ0X4WF0SR2MEND24V1J5BNE": true
},
"fieldName": "d",
"field": {
"updatedBy": 8,
"isParam": true,
"isDelete": false,
"label": "d",
"type": "string",
"tags": {},
"createdAt": 1702984863536,
"uid": "1",
"extendAppTitle": "过滤控件",
"createdBy": 8,
"appId": 130713,
"name": "d",
"options": {
"allowAllValue": true,
"subType": "ALL",
"type": "string"
},
"datasetId": 1,
"labelOrigin": "d",
"id": 1,
"dataAppId": 130713,
"updatedAt": 1702984863536
},
"dashboardId": 1,
"use": "paramInput",
"appId": 130713,
"options": {
"style": {
"method": "input"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
},
"enableAll": false,
"mobileOptions": {
"style": {
"method": "input"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
}
}
},
"datasetId": 1,
"dataAppId": 130713,
"title": "新建参数控件",
"filterType": "param"
},
{
"uid": "01HJ0X4WF0SR2MEND24V1J5BNE",
"dashboardId": 1,
"appId": 130713,
"options": {},
"dataAppId": 130713,
"title": "查询",
"filterType": "filterBtn",
"version": 5000
}
]说明
该例为更新过滤按钮,需要将过滤按钮要控制的过滤控件的信息都放在list中并设置controller后传递,controller中为过滤按钮的uid
获取过滤控件列表
获取过滤控件列表
请求URL
http
GET /api/apps/${appId}/filter-controllers HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...请求参数
URL 参数
| 字段 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| appId | INTEGER | 是 | 过滤控件所在的应用 id |
Request Body 参数
过滤控件配置信息,见过滤控件结构
返回对象的格式说明
| 字段 | 类型 | 说明 |
|---|---|---|
| version | STRING | 当前系统版本哈希值 |
| data | OBJECT | 过滤控件的完整配置信息,见过滤控件结构 |
接口示例
http
GET /api/apps/1/filter-controllers HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
// Request Body:
{
"version": "version@9a5e106#6730f0d",
"code": 0,
"msg": "success",
"data": [
{
"op": "1=1",
"fieldsChain": [
{
"field": "月份",
"keys": [
"130145_datasetList_2"
],
"appId": 130145,
"datasetId": 2,
"label": "月份"
}
],
"fieldName": "director",
"use": "checkbox",
"kind": "formula",
"datasetName": "A_IVT_MOVIE",
"title": "新建过滤器",
"version": 5000,
"uid": "01HJ0TE602Z2VERDA4CMY4JR59",
"hasChain": true,
"field": {
"visible": true,
"fieldName": "director",
"suggestedTypes": [
"string"
],
"type": "string",
"detectedType": "string",
"tags": {},
"basicType": "string",
"originType": "string",
"defaultAggrType": "count",
"hideValue": false,
"appId": 130713,
"nativeType": "bpchar",
"_ukey": "director",
"datasetId": 1,
"comment": "",
"labelOrigin": "director",
"id": 125664649,
"config": {}
},
"children": [
"01HJ0TNJJFG2S7HGKA5B57A11S"
],
"dashboardId": 1,
"appId": 130713,
"options": {
"style": {
"method": "select"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
},
"mobileOptions": {
"style": {
"method": "select"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
}
}
},
"datasetId": 1,
"fieldSiblings": [],
"dataAppId": 130713,
"filterType": "filter"
},
{
"op": "1=1",
"fieldName": "stars",
"use": "checkbox",
"kind": "formula",
"datasetName": "A_IVT_MOVIE",
"title": "新建过滤器",
"version": 5000,
"uid": "01HJ0TNJJFG2S7HGKA5B57A11S",
"field": {
"visible": true,
"fieldName": "stars",
"suggestedTypes": [
"string"
],
"type": "string",
"detectedType": "string",
"tags": {},
"basicType": "string",
"originType": "string",
"defaultAggrType": "count",
"hideValue": false,
"appId": 130713,
"nativeType": "varchar",
"_ukey": "stars",
"datasetId": 1,
"comment": "",
"labelOrigin": "stars",
"id": 125664654,
"config": {}
},
"children": [
"01HJ0TRQ88JAJNHEQQK6NYE16F"
],
"dashboardId": 1,
"appId": 130713,
"options": {
"style": {
"method": "select"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
},
"mobileOptions": {
"style": {
"method": "select"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
}
}
},
"datasetId": 1,
"fieldSiblings": [],
"dataAppId": 130713,
"filterType": "filter"
},
{
"op": "1=1",
"fieldName": "zh_name",
"use": "checkbox",
"kind": "formula",
"datasetName": "A_IVT_MOVIE",
"title": "新建过滤器",
"version": 5000,
"uid": "01HJ0TRQ88JAJNHEQQK6NYE16F",
"field": {
"visible": true,
"fieldName": "zh_name",
"suggestedTypes": [
"string"
],
"type": "string",
"detectedType": "string",
"tags": {},
"basicType": "string",
"originType": "string",
"defaultAggrType": "count",
"hideValue": false,
"appId": 130713,
"nativeType": "bpchar",
"_ukey": "zh_name",
"datasetId": 1,
"comment": "",
"labelOrigin": "zh_name",
"id": 125664648,
"config": {}
},
"dashboardId": 1,
"appId": 130713,
"options": {
"style": {
"method": "select"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
},
"mobileOptions": {
"style": {
"method": "select"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
}
}
},
"datasetId": 1,
"fieldSiblings": [],
"dataAppId": 130713,
"filterType": "filter"
},
{
"uid": "01HJ0WYABBYAHBS8N33KVRHFJH",
"fieldName": "d",
"field": {
"isParam": true,
"updatedBy": 8,
"isDelete": false,
"label": "d",
"type": "string",
"tags": {},
"uid": "1",
"createdAt": "2023-12-19 19:21:03",
"extendAppTitle": "过滤控件",
"createdBy": 8,
"appId": 130713,
"name": "d",
"options": {
"allowAllValue": true,
"subType": "ALL",
"type": "string"
},
"datasetId": 1,
"labelOrigin": "d",
"id": 1,
"dataAppId": 130713,
"updatedAt": "2023-12-19 19:21:03"
},
"dashboardId": 1,
"use": "paramInput",
"appId": 130713,
"options": {
"enableAll": false,
"style": {
"method": "input"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
},
"mobileOptions": {
"style": {
"method": "input"
},
"titleStyle": {
"textAlign": "center",
"position": "left"
}
}
},
"datasetId": 1,
"dataAppId": 130713,
"title": "新建参数控件",
"filterType": "param",
"version": 5000
},
{
"uid": "01HJ0X4WF0SR2MEND24V1J5BNE",
"dashboardId": 1,
"appId": 130713,
"options": {},
"dataAppId": 130713,
"title": "查询",
"filterType": "filterBtn",
"version": 5000
}
],
"chartDataStartTimeMillis": 0
}