1. 图表

1.1. 图表说明

1.1.1. 图表的定义

图表是由表达某个业务计算的数据绘制。

图表结构说明

Chart
字段 类型 描述
appId LONG 图表所属的应用 id
dataAppId LONG 图表用的数据集所属的应用 id
dashboardId LONG 图表所属的仪表盘 id
title STRING 图表标题
datasetId LONG 图表所用的主表数据集 id
options OBJECT 仪表盘配置信息
options.axes HE 数组 用于绘图的维度和度量计算方法
options.timebar HE 时间轴过滤器
options.where HE 数组 图表的过滤条件,主要是用于原始字段的过滤
options.having HE 数组 图表的过滤条件,主要用户图内指标的过滤
options.sort HE 数组 图表的排序条件
options.limit INTEGER 数据的行数限制
options.offset INTEGER 数据的偏移量
options.refresh BOOL 是否强制刷新。取图表数据时,true表示不会用缓存,false表示可以使用缓存
options.fieldsPolicy ENUM 取field的规则,详情见下表
options.publishConfig OBJECT 图表在发布或者共享时的交互配置
hsVersion INTEGER 可选,本次编辑的版本号,从0开始,修改前先GET待修改资源获取当前版本号,修改时带上刚刚获取的版本号,服务端会检查并发冲突。不带版本号不检查并发冲突。
ChartDto
字段 类型 描述
schema OBJECT 图表schema信息,参见数据集结构说明 options.schema
datasetName STRING 图表用的数据集名称
isCollaborated BOOLEAN 是否协作
targetDashboardId LONG 仪表盘id
dashboardOptions OBJECT 仪表盘配置信息
sourceAppId LONG 链接图表的源图表所在应用的 id
sourceId LONG 链接图表的源图表 id
importType STRING LINK 表示链接,COPY 表示复制

options.fieldsPolicy 枚举说明说明

ENUM 描述
all 取图表用到的所有dataset的所有fields
AXES_USED 取图表中维度、度量用到的所有fields
USED 取图表用到的有fields
AXES_ALL 取图表中维度、度量用到的所有dataset的所有fields
DATASET_TABLE 用户数据集表格取数据

1.2. 接口说明

1.2.1. 创建图表

创建图表。

请求URL

POST /api/apps/{appId}/dashboards/{dashboardId}/charts

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
request body 参数

每种图表的共同结构见ChartDto结构说明

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 每种图表的共同结构见ChartDto结构说明

接口示例1: 在仪表盘中创建图表

POST /api/v1/apps/1/dashboards/1/charts

{
  "options": {
    "name": "Table",
    "version": 3000
  },
  "dashboardOptions": {
    "layouts": {
      "1": {
        "h": 12,
        "i": "1",
        "w": 24,
        "x": 0,
        "y": 0
      },
      "null": {
        "i": null,
        "x": 0,
        "y": 12,
        "w": 12,
        "h": 6
      }
    }
  },
  "title": "新建探索"
}

返回:

{
  "version": "versionxxx",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "title": "新建探索",
    "createdBy": 159,
    "createdAt": "2020-01-10 12:39:33",
    "updatedBy": 159,
    "updatedAt": "2020-01-10 12:39:33",
    "visible": true,
    "appId": 43980,
    "options": {
      "name": "Table",
      "version": 3000
    },
    "dashboardId": 1,
    "datasetIds": [
    ],
    "dashboardOptions": {
      "layouts": {
        "1": {
          "h": 12,
          "i": "1",
          "w": 24,
          "x": 0,
          "y": 0
        },
        "null": {
          "i": "2",
          "x": 0,
          "y": 12,
          "w": 12,
          "h": 6
        }
      }
    }
  }
}

接口示例1: 在应用中创建业务指标

POST /api/v1/apps/1/charts

{
  "options": {
    "name": "Table",
    "version": 3000
  },
  "title": "新建探索"
}

返回:

{
  "version": "3.5-SNAPSHOT@@git.commit.id.abbrev@#null",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 5,
    "title": "新建探索",
    "createdBy": 1,
    "createdAt": "2021-05-18 09:47:01",
    "updatedBy": 1,
    "updatedAt": "2021-05-18 09:47:01",
    "appId": 154,
    "options": {
      "name": "Table",
      "version": 3000
    },
    "datasetIds": []
  }
}

1.2.2. 获取仪表盘中的图表

获取仪表盘中的图表。

请求URL

GET /api/apps/{appId}/dashboards/{dashboardId}/charts

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 每种图表的共同结构见ChartDto结构说明

1.2.3. 获取应用中的业务指标

获取应用中的业务指标

请求URL

GET /api/apps/{appId}/charts

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
orderBy STRING 用来排序的字段
orderType STRING 排序的方向,可选值为 asc、desc
chartNames STRING 要搜索的图表类型,多个用 , 分隔,比如 bar,table
excludeLinkChart BOOL 是否包含链接图表

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 每种图表的共同结构见ChartDto结构说明

1.2.4. 通过 ID 获取仪表盘中的图表信息

通过 ID 获取仪表盘中的图表信息

请求URL

GET /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 每种图表的共同结构见ChartDto结构说明

当图表所在应用是发布区应用或者通过共享链接访问时,data 里的 options.publishConfig 会用应用的 options.publishConfig 赋值。

1.2.5. 通过 ID 获取仪表盘中的业务指标信息

通过 ID 获取仪表盘中的业务指标信息

请求URL

GET /api/apps/{appId}/charts/{chartId}

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
chartId INTEGER 图表的 Id

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 每种图表的共同结构见ChartDto结构说明

1.2.6. 更新仪表盘中的图表信息

更新仪表盘中的图表信息

请求URL

PUT /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id
request body 参数

每种图表的共同结构见ChartDto结构说明。在有 axes 但是数据库中的图表没有 datasetId 的时候,request body 中的 chart.datasetId是必须的。

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 每种图表的共同结构见ChartDto结构说明

接口示例1: 更新图表

PUT /api/v1/apps/1/dashboards/charts/1

{
  "options": {
    "name": "Pie",
    "axes": [
      {
        "fieldName": "director",
        "datasetId": 3,
        "axisName": "group",
        "labelOrigin": "director",
        "fieldType": "string",
        "uid": "u_bb3509cb74ac545d_0",
        "parentUid": null,
        "keyChain": [
          "group",
          "none"
        ],
        "scaleRange": {
          "minAuto": true,
          "min": 0,
          "maxAuto": true,
          "max": 0
        },
        "kind": "function",
        "op": "group",
        "args": [
          {
            "kind": "field",
            "op": "director",
            "dataset": 3
          }
        ]
      }
    ],
    "marks": [
      {
        "color": {
          "schema": [
            "#4479EC",
            "#A3B9ED",
            "#7759CA",
            "#53BBEC",
            "#ACD667",
            "#868F90",
            "#6071C6",
            "#6ADAC2",
            "#339BEB",
            "#72B15E"
          ]
        }
      }
    ],
    "zoomPath": [],
    "version": 3200,
    "sort": []
  },
  "dataAppId": 4662,
  "datasetId": 3
}

返回:

{
  "version": "3.2-SNAPSHOT@a3b6ee4#d800fee",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "updatedBy": 1,
    "updatedAt": "2020-07-06 10:38:58",
    "appId": 4662,
    "datasetId": 3,
    "options": {
      "name": "Pie",
      "axes": [
        {
          "fieldName": "director",
          "datasetId": 3,
          "axisName": "group",
          "labelOrigin": "director",
          "fieldType": "string",
          "uid": "u_bb3509cb74ac545d_0",
          "keyChain": [
            "group",
            "none"
          ],
          "scaleRange": {
            "minAuto": true,
            "min": 0,
            "maxAuto": true,
            "max": 0
          },
          "kind": "function",
          "op": "group",
          "args": [
            {
              "kind": "field",
              "op": "director",
              "dataset": 3
            }
          ]
        }
      ],
      "zoomPath": [],
      "marks": [
        {
          "color": {
            "schema": [
              "#4479EC",
              "#A3B9ED",
              "#7759CA",
              "#53BBEC",
              "#ACD667",
              "#868F90",
              "#6071C6",
              "#6ADAC2",
              "#339BEB",
              "#72B15E"
            ]
          }
        }
      ],
      "sort": [],
      "version": 3200
    },
    "dashboardId": 1,
    "dataAppId": 4662,
    "datasetIds": [
      3
    ]
  }
}

1.2.7. 更新应用中的业务指标信息

更新应用中的业务指标信息

请求URL

PUT /api/apps/{appId}/charts/{chartId}

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
chartId INTEGER 图表的 Id
request body 参数

每种图表的共同结构见ChartDto结构说明。在有 axes 但是数据库中的图表没有 datasetId 的时候,request body 中的 chart.datasetId是必须的。

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 每种图表的共同结构见ChartDto结构说明

接口示例1: 更新应用中的业务指标信息

PUT /api/v1/apps/charts/1

{
  "options": {
    "name": "Pie",
    "axes": [
      {
        "fieldName": "director",
        "datasetId": 3,
        "axisName": "group",
        "labelOrigin": "director",
        "fieldType": "string",
        "uid": "u_bb3509cb74ac545d_0",
        "parentUid": null,
        "keyChain": [
          "group",
          "none"
        ],
        "scaleRange": {
          "minAuto": true,
          "min": 0,
          "maxAuto": true,
          "max": 0
        },
        "kind": "function",
        "op": "group",
        "args": [
          {
            "kind": "field",
            "op": "director",
            "dataset": 3
          }
        ]
      }
    ],
    "marks": [
      {
        "color": {
          "schema": [
            "#4479EC",
            "#A3B9ED",
            "#7759CA",
            "#53BBEC",
            "#ACD667",
            "#868F90",
            "#6071C6",
            "#6ADAC2",
            "#339BEB",
            "#72B15E"
          ]
        }
      }
    ],
    "zoomPath": [],
    "version": 3200,
    "sort": []
  },
  "dataAppId": 4662,
  "datasetId": 3
}

返回:

{
  "version": "3.2-SNAPSHOT@a3b6ee4#d800fee",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "updatedBy": 1,
    "updatedAt": "2020-07-06 10:38:58",
    "appId": 4662,
    "datasetId": 3,
    "options": {
      "name": "Pie",
      "axes": [
        {
          "fieldName": "director",
          "datasetId": 3,
          "axisName": "group",
          "labelOrigin": "director",
          "fieldType": "string",
          "uid": "u_bb3509cb74ac545d_0",
          "keyChain": [
            "group",
            "none"
          ],
          "scaleRange": {
            "minAuto": true,
            "min": 0,
            "maxAuto": true,
            "max": 0
          },
          "kind": "function",
          "op": "group",
          "args": [
            {
              "kind": "field",
              "op": "director",
              "dataset": 3
            }
          ]
        }
      ],
      "zoomPath": [],
      "marks": [
        {
          "color": {
            "schema": [
              "#4479EC",
              "#A3B9ED",
              "#7759CA",
              "#53BBEC",
              "#ACD667",
              "#868F90",
              "#6071C6",
              "#6ADAC2",
              "#339BEB",
              "#72B15E"
            ]
          }
        }
      ],
      "sort": [],
      "version": 3200
    },
    "dashboardId": 1,
    "dataAppId": 4662,
    "datasetIds": [
      3
    ]
  }
}

1.2.8. 删除仪表盘中的图表

删除仪表盘中的图表

请求URL

DELETE /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
msg STRING 成功返回 success

1.2.9. 删除业务指标

删除业务指标

请求URL

DELETE /api/apps/{appId}/charts/{chartId}

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
chartId INTEGER 图表的 Id

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
msg STRING 成功返回 success

1.2.10. 批量导入图表、业务指标

批量导入图表、业务指标

请求URL

POST /api/apps/{appId}/dashboards/{dashboardId}/charts/import

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
request body 参数

每种图表的共同结构见ChartDto结构说明。在有 axes 但是数据库中的图表没有 datasetId 的时候,request body 中的 chart.datasetId是必须的。

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 每种图表的共同结构见ChartDto结构说明

接口示例1: 以链接方式导入业务指标

POST /api/apps/10744/dashboards/1/charts/import

[
  {
    "id": 4,
    "sourceAppId": "154",
    "importType": "LINK",
    "dataAppId": "154",
    "dashboardOptions": {
      "layouts": {
        "null": {
          "i": null,
          "x": 0,
          "y": 6,
          "w": 6,
          "h": 6,
          "moved": false,
          "static": false
        }
      }
    }
  }
]

返回:

{
  "version": "3.5-SNAPSHOT@@git.commit.id.abbrev@#null",
  "code": 0,
  "msg": "success",
  "data": [
    {
      "id": 3,
      "title": "kpi-test-2",
      "createdBy": 1,
      "createdAt": "2021-05-08 17:39:34",
      "updatedBy": 1,
      "updatedAt": "2021-05-11 13:42:29",
      "visible": true,
      "isDelete": false,
      "appId": 10744,
      "datasetId": 1,
      "options": {},
      "dataAppId": 154,
      "datasetIds": [
        1
      ]
    }
  ]
}

接口示例2: 以拷贝方式导入业务指标

POST /api/apps/10744/dashboards/1/charts/import

[
  {
    "id": 4,
    "sourceAppId": "154",
    "importType": "COPY",
    "dataAppId": "154",
    "dashboardOptions": {
      "layouts": {
        "null": {
          "i": null,
          "x": 0,
          "y": 6,
          "w": 6,
          "h": 6,
          "moved": false,
          "static": false
        }
      }
    }
  }
]

返回:

{
  "version": "3.5-SNAPSHOT@@git.commit.id.abbrev@#null",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 1,
    "title": "新建仪表盘",
    "createdBy": 1,
    "createdAt": "2021-04-15 11:40:21",
    "updatedBy": 1,
    "updatedAt": "2021-05-18 10:24:09",
    "visible": true,
    "isDelete": false,
    "appId": 10744,
    "options": {
      "layouts": {
        "1": {
          "static": false,
          "w": 6,
          "moved": false,
          "h": 6,
          "x": 0,
          "i": "1",
          "y": 0
        },
        "2": {
          "static": false,
          "w": 6,
          "moved": false,
          "h": 6,
          "x": 6,
          "i": "2",
          "y": 0
        },
        "3": {
          "static": false,
          "w": 6,
          "moved": false,
          "h": 6,
          "x": 0,
          "i": "3",
          "y": 6
        }
      },
      "filters": [],
      "page": {
        "padding": [
          0,
          0,
          0,
          0
        ],
        "background": "rgba(255, 255, 255, 1)",
        "width": 1280,
        "showGrid": false,
        "height": 800
      },
      "type": "Dashboard",
      "charts": [
        3,
        2,
        1
      ],
      "config": {
        "mode": {
          "current": "pc",
          "pc": true,
          "mobile": true
        },
        "pc": {
          "w": 12,
          "gap": 10,
          "scale": "4*3",
          "theme": {
            "base": "CLASSIC"
          }
        },
        "background": {
          "image": "",
          "size": "auto",
          "position-x": "left",
          "position-y": "top",
          "repeat": "no-repeat"
        },
        "mobile": {
          "mode": "auto",
          "w": 6,
          "gap": 10,
          "scale": "1*1",
          "theme": {
            "base": "CLASSIC"
          }
        },
        "showGrid": false
      }
    },
    "type": "Dashboard"
  }
}

1.2.11. 断开图表链接

断开图表链接

请求URL

PUT /api/apps/{appId}/{dashboardId}/charts/{chartId}/break-link

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 每种图表的共同结构见ChartDto结构说明

接口示例1: 对链接图表断开链接

PUT /api/apps/10744/dashboards/1/charts/3/break-link

返回: 图表的详细配置,参见 ChartDto结构说明

1.2.12. 获取指定id图表数据总行数

获取指定id图表数据总行数。

请求URL

GET /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/data/count

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id

返回对象的格式说明

字段 类型 说明
data.totalHits INTEGER 图表数据的总行数

1.2.13. 获取指定id图表数据总行数

获取指定id图表数据总行数。

请求URL

GET /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/data/count

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id

返回对象的格式说明

字段 类型 说明
data.totalHits INTEGER 图表数据的总行数

1.2.14. 使用用户参数获取图表数据

使用用户参数获取图表数据。

请求URL

POST /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/data

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id
request body 参数

{"options":{ "options的详细信息"}}

返回对象的格式说明

数据集数据 datasetResultDto

接口示例1

  1. 请求 POST /api/v1/apps/1/dashboards/1/charts/1/data
{
  "options": {
    "axes": [
      {
        "op": "group",
        "uid": "u_edbee8adba68e26a_0",
        "kind": "function",
        "args": [
          {
            "kind": "field",
            "op": "region_name",
            "dataset": 3
          }
        ]
      },
      {
        "op": "sum",
        "uid": "u_9f886f9cb7bdf1d2_1",
        "kind": "function",
        "args": [
          {
            "kind": "field",
            "op": "region_id",
            "dataset": 3
          }
        ]
      }
    ]
  }
}
  1. 响应结果
{
  "data": {
    "data": [
      [
        "Americas",
        2
      ],
      [
        "Middle East and Africa",
        4
      ],
      [
        "Asia",
        3
      ],
      [
        "Europe",
        1
      ]
    ],
    "schema": [
      {
        "fieldName": "u_edbee8adba68e26a_0"
      },
      {
        "fieldName": "u_9f886f9cb7bdf1d2_1"
      }
    ]
  }
}

1.2.15. 使用用户参数获取图表数据总行数

使用用户参数获取图表数据总行数。

请求URL

POST /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/data/count

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id
request body 参数

{"options":{ "options的详细信息"}}

返回对象的格式说明

字段 类型 说明
data.totalHits INTEGER 图表数据的总行数

1.2.16. 使用用户参数获取图表数据

使用用户参数获取图表数据。

请求URL

POST /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/data/

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id
offset INTEGER 数据量的偏移值
limit INTEGER 数据量的上限
request body 参数

{"options":{ "options的详细信息"}}

返回对象的格式说明

数据集数据 datasetResultDto

接口示例1: 创建图表

POST /api/v1/apps/1/dashboards/1/charts/1/data/

{
  "options": {
    "axes": [
      {
        "toScaleTime": false,
        "op": "day",
        "scaleRange": {
          "minAuto": true,
          "min": 0,
          "maxAuto": true,
          "max": 0
        },
        "fieldName": "real_date_3365",
        "kind": "function",
        "axisName": "group",
        "label": "日期",
        "keyChain": [
          "day",
          "none"
        ],
        "args": [
          {
            "op": "real_date_3365",
            "kind": "field",
            "dataset": 3366
          }
        ],
        "formatter": {
          "aggregate": "day"
        },
        "uid": "u_107f5bf77be04999_0",
        "formatterOrigin": {
          "aggregate": "day"
        },
        "datasetId": 3366,
        "labelOrigin": "时间",
        "fieldType": "date"
      },
      {
        "op": "c3",
        "scaleRange": {
          "minAuto": true,
          "min": 0,
          "maxAuto": false,
          "max": 1
        },
        "fieldName": "c3",
        "kind": "field",
        "axisName": "y1",
        "keyChain": [
          "none"
        ],
        "formatter": {
          "scientificNotation": false,
          "unit": "",
          "prefix": "",
          "suffix": "",
          "decimal": 2,
          "thousands": false,
          "percent": "%"
        },
        "uid": "u_409214f201c6ce01_4",
        "newColumn": true,
        "isConstant": false,
        "formatterOrigin": {
          "scientificNotation": false,
          "unit": "",
          "prefix": "",
          "suffix": "",
          "decimal": 2,
          "thousands": false,
          "percent": "%"
        },
        "datasetId": 3366,
        "labelOrigin": "完成率",
        "isAggregate": true,
        "dataset": 3366,
        "fieldType": "number"
      },
      {
        "op": "c4",
        "scaleRange": {
          "minAuto": true,
          "min": 0,
          "maxAuto": true,
          "max": 0
        },
        "fieldName": "c4",
        "kind": "field",
        "axisName": "y1",
        "keyChain": [
          "none"
        ],
        "uid": "u_cbc569ab32ff31d1_4",
        "newColumn": true,
        "isConstant": false,
        "datasetId": 3366,
        "labelOrigin": "进入QA的问题",
        "isAggregate": true,
        "dataset": 3366,
        "fieldType": "number"
      },
      {
        "op": "c5",
        "scaleRange": {
          "minAuto": true,
          "min": 0,
          "maxAuto": true,
          "max": 0
        },
        "fieldName": "c5",
        "kind": "field",
        "axisName": "y",
        "keyChain": [
          "none"
        ],
        "uid": "u_c852341365aa3994_5",
        "newColumn": true,
        "isConstant": false,
        "datasetId": 3366,
        "labelOrigin": "未关闭问题",
        "isAggregate": true,
        "dataset": 3366,
        "fieldType": "number"
      },
      {
        "op": "c1",
        "scaleRange": {
          "minAuto": true,
          "min": 0,
          "maxAuto": true,
          "max": 0
        },
        "fieldName": "c1",
        "kind": "field",
        "axisName": "y1",
        "keyChain": [
          "none"
        ],
        "uid": "u_c8f6e35a15596acf_4",
        "newColumn": true,
        "isConstant": false,
        "datasetId": 3366,
        "labelOrigin": "当日关闭问题",
        "isAggregate": true,
        "dataset": 3366,
        "fieldType": "number"
      },
      {
        "op": "c0",
        "scaleRange": {
          "minAuto": true,
          "min": 0,
          "maxAuto": true,
          "max": 0
        },
        "fieldName": "c0",
        "kind": "field",
        "axisName": "y",
        "keyChain": [
          "none"
        ],
        "uid": "u_c3f773f19fcb0912_5",
        "newColumn": true,
        "isConstant": false,
        "datasetId": 3366,
        "labelOrigin": "累计关闭问题",
        "isAggregate": true,
        "dataset": 3366,
        "fieldType": "number"
      }
    ],
    "name": "LineBar",
    "limit": 10000,
    "timebar": {
      "args": [
        {
          "op": "real_date_3365",
          "kind": "field",
          "dataset": 3366
        },
        {
          "op": "All Avaliable Date",
          "kind": "constant"
        }
      ],
      "op": "time_in_range",
      "field": "real_date_3365",
      "dateRange": [
        "2019-02-01 00:00:00",
        "2019-04-03 20:23:56"
      ],
      "kind": "function",
      "show": true,
      "datasetId": 3366,
      "fields": [
        [
          3366,
          "real_date_3365"
        ]
      ]
    },
    "sort": [
      {
        "op": "u_107f5bf77be04999_0",
        "baseUid": "u_107f5bf77be04999_0",
        "kind": "reference",
        "datasetId": 3366,
        "sortByValue": "dataSource",
        "axisType": "Dimension",
        "dataset": 3366,
        "direction": "asc"
      }
    ],
    "version": 3100
  }
}

返回:

{
  "version": "3.2-SNAPSHOT@@git.commit.id.abbrev@#d800fee",
  "code": 0,
  "msg": "success",
  "data": {
    "data": [
      [
        "2020-05-13",
        0.67027804410354745925,
        24,
        3795,
        6,
        6991
      ],
      [
        "2020-05-14",
        0.67088001532126783491,
        30,
        3789,
        15,
        7006
      ]
    ],
    "schema": [
      {
        "fieldName": "u_107f5bf77be04999_0",
        "config": {},
        "nativeType": "date",
        "suggestedTypes": [
          null
        ],
        "visible": true
      },
      {
        "fieldName": "u_409214f201c6ce01_4",
        "config": {},
        "nativeType": "numeric",
        "suggestedTypes": [
          null
        ],
        "visible": true
      },
      {
        "fieldName": "u_cbc569ab32ff31d1_4",
        "config": {},
        "nativeType": "int8",
        "suggestedTypes": [
          null
        ],
        "visible": true
      },
      {
        "fieldName": "u_c852341365aa3994_5",
        "config": {},
        "nativeType": "int8",
        "suggestedTypes": [
          null
        ],
        "visible": true
      },
      {
        "fieldName": "u_c8f6e35a15596acf_4",
        "config": {},
        "nativeType": "int8",
        "suggestedTypes": [
          null
        ],
        "visible": true
      },
      {
        "fieldName": "u_c3f773f19fcb0912_5",
        "config": {},
        "nativeType": "int8",
        "suggestedTypes": [
          null
        ],
        "visible": true
      }
    ],
    "pagable": true,
    "importSwitchable": true,
    "randomable": false
  }
}

1.2.17. 通过ID获取图表SQL

通过ID获取图表SQL

请求URL

GET /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/sql-debug

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id
vendorDesc STRING 指定的sql数据源描述,格式为<类型><大版本号><小版本号>_<商业版本号>,其中 类型 是必填的。比如:mysql_8_10_analyticdb

接口示例1:

GET /api/apps/15/dashboards/2/charts/1/sql-debug

返回:

{
   "version": "4.0-SNAPSHOT@@git.commit.id.abbrev@#7c54292",
   "code": 0,
   "msg": "success",
   "data": [
      "SELECT (TO_CHAR(\"dataset_10\".\"area_name\")) AS \"u_b0772f7276218305_0\", count(TO_CHAR(\"dataset_10\".\"area_name\")) AS \"u_5548a7b1fdef7781_1\" FROM \"DM\".\"map_china_area\" \"dataset_10\" GROUP BY (TO_CHAR(\"dataset_10\".\"area_name\")) ORDER BY \"u_b0772f7276218305_0\" ASC NULLS LAST LIMIT 1000"
   ]
}

接口示例2:

GET /api/apps/15/dashboards/2/charts/1/sql-debug?vendorDesc=mysql

返回:

{
   "version": "4.0-SNAPSHOT@@git.commit.id.abbrev@#7c54292",
   "code": 0,
   "msg": "success",
   "data": [
      "SELECT (TO_CHAR(`dataset_10`.`area_name`)) AS `u_b0772f7276218305_0`, count(TO_CHAR(`dataset_10`.`area_name`)) AS `u_5548a7b1fdef7781_1` FROM `DM`.`map_china_area` `dataset_10` GROUP BY (TO_CHAR(`dataset_10`.`area_name`)) ORDER BY `u_b0772f7276218305_0` ASC NULLS LAST LIMIT 1000"
   ]
}

1.2.18. 通过ID获取图表SQL执行计划

通过ID获取图表SQL执行计划

请求URL

GET /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/sql-explain

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
dashboardId INTEGER 图表所在的仪表盘 Id
chartId INTEGER 图表的 Id

接口示例1:

GET /api/apps/15/dashboards/2/charts/1/sql-explain

返回:

{
  "version": "4.0-SNAPSHOT@@git.commit.id.abbrev@#7c54292",
  "code": 0,
  "msg": "success",
  "data": [
    [
      [
        "id",
        "select_type",
        "table",
        "partitions",
        "type",
        "possible_keys",
        "key",
        "key_len",
        "ref",
        "rows",
        "filtered",
        "Extra"
      ],
      [
        1,
        "SIMPLE",
        "dataset_1",
        null,
        "ALL",
        null,
        null,
        null,
        null,
        267,
        100.0,
        "Using temporary; Using filesort"
      ]
    ]
  ]
}

1.2.19. 通过Options获取图表SQL

通过Options获取图表SQL

请求URL

POST /api/apps/{appId}/sql-debug

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
vendorDesc STRING 指定的sql数据源描述,格式为<类型><大版本号><小版本号>_<商业版本号>,其中 类型 是必填的。比如:mysql_8_10_analyticdb
RequestBody 参数

图表数据 chart

接口示例1:

POST /api/apps/15/sql-debug

请求:

{
  "options": {
    "name": "Bar",
    "icon": "icon-bar",
    "categories": [
      "common",
      "bar"
    ],
    "axisConf": [
      {
        "axisName": "group",
        "type": "Dimension",
        "shape": "Single",
        "acceptType": [
          "number",
          "integer",
          "string",
          "date",
          "time",
          "boolean",
          "bool"
        ],
        "minimal": 1,
        "sortable": true,
        "defaultSort": "asc",
        "timeable": false,
        "referenceable": true,
        "aggregatable": true,
        "customAggregate": false,
        "advancedAggregatable": false,
        "formattable": true,
        "mergeable": true,
        "axisType": "xAxis",
        "show": true,
        "valueType": "category",
        "position": "bottom",
        "axisLabel": {
          "wordBreak": 0,
          "wordEllipsis": 0,
          "align": "center",
          "show": true,
          "inside": false,
          "interval": 0,
          "rotate": 0,
          "margin": 8,
          "color": "#999",
          "fontFamily": "Arial",
          "fontSize": 12,
          "fontWeight": "normal"
        },
        "_controlLabel": false,
        "axisLine": {
          "show": true,
          "lineStyle": {
            "color": "rgba(153, 153, 153, 0.3)",
            "type": "solid",
            "width": 1
          }
        },
        "splitLine": {
          "show": false,
          "lineStyle": {
            "color": "rgba(153, 153, 153, 0.3)",
            "type": "dashed",
            "width": 1
          }
        },
        "axisTick": {
          "show": false
        }
      },
      {
        "axisName": "y",
        "type": "Metric",
        "shape": "Single",
        "acceptType": [
          "number",
          "integer",
          "string",
          "date",
          "time",
          "boolean",
          "bool"
        ],
        "minimal": 1,
        "timeable": false,
        "referenceable": true,
        "aggregatable": true,
        "customAggregate": false,
        "advancedAggregatable": true,
        "formattable": true,
        "axisType": "yAxis",
        "show": true,
        "supportChangeScale": true,
        "valueType": "value",
        "position": "left",
        "gridIndex": 0,
        "polarIndex": 0,
        "boundaryGap": [
          0,
          "10%"
        ],
        "combine": null,
        "_controlLabel": true,
        "min": null,
        "max": null,
        "scale": false,
        "splitNumber": 5,
        "axisLabel": {
          "verticalAlign": "middle",
          "show": true,
          "inside": false,
          "interval": 0,
          "rotate": 0,
          "margin": 8,
          "color": "#999",
          "fontFamily": "Arial",
          "fontSize": 12,
          "fontWeight": "normal"
        },
        "axisLine": {
          "show": true,
          "lineStyle": {
            "color": "rgba(153, 153, 153, 0.3)",
            "type": "solid",
            "width": 1
          }
        },
        "splitLine": {
          "show": true,
          "lineStyle": {
            "color": "rgba(153, 153, 153, 0.3)",
            "type": "dashed",
            "width": 1
          }
        },
        "axisTick": {
          "show": false
        }
      }
    ],
    "legends": [
      {
        "show": true,
        "position": "right",
        "targetMark": 0,
        "icon": "circle",
        "textStyle": {
          "color": "#999",
          "fontStyle": "normal",
          "fontWeight": "normal",
          "fontFamily": "Arial",
          "fontSize": 12,
          "lineHeight": null,
          "backgroundColor": "transparent",
          "borderColor": "transparent",
          "borderWidth": 0,
          "borderRadius": 0,
          "padding": 0,
          "shadowColor": "transparent",
          "shadowBlur": 0,
          "shadowOffsetX": 0,
          "shadowOffsetY": 0,
          "width": null,
          "height": null,
          "rich": null
        }
      }
    ],
    "dataZooms": [
      {
        "showDetail": false,
        "type": "slider",
        "start": 0,
        "end": 100,
        "show": false,
        "position": "bottom"
      }
    ],
    "marks": [
      {
        "type": "bar",
        "axisName": "y",
        "groupAxisName": "group",
        "xAxisIndex": null,
        "yAxisIndex": null,
        "seriesLayoutBy": "column",
        "label": {
          "_axisControlled": true,
          "show": false,
          "rotate": 0,
          "position": "top",
          "distance": 10,
          "color": "#999",
          "fontFamily": "Arial",
          "fontWeight": "normal",
          "fontSize": 14,
          "_selectedAxisHash": {
            "u_32a8edf1946cd3c3_1": true
          }
        },
        "animation": true,
        "animationThreshold": 10000,
        "animationDuration": 1000,
        "animationEasing": "cubicOut",
        "showBackground": true,
        "backgroundStyle": {
          "color": "rgba(0, 0, 0, 0)"
        },
        "_borderRadius": {
          "value": 0,
          "radiusControl": {
            "topLeft": true,
            "topRight": true,
            "bottomLeft": true,
            "bottomRight": true
          }
        },
        "color": {
          "type": "linear",
          "schema": [
            "rgba(88,103,186,0.1)",
            "#5867BA"
          ]
        },
        "size": {
          "kind": "constant",
          "type": "percent",
          "op": 50,
          "min": 10,
          "max": 100
        },
        "shadow": {
          "show": false,
          "shadowBlur": 10,
          "shadowColor": "rgba(0, 0, 0, 0.2)"
        },
        "opacity": 1,
        "shadowColor": "transparent",
        "shadowBlur": 0,
        "shadowOffsetX": 0,
        "shadowOffsetY": 0,
        "barMaxWidth": 50,
        "barMinHeight": 2
      }
    ],
    "custom": {
      "other": {
        "componentType": "combine",
        "title": "其他",
        "value": [
          {
            "componentType": "colorPicker",
            "softLink": "marks[0].backgroundStyle.color",
            "title": "柱状背景"
          },
          {
            "componentType": "barBorderRadius",
            "softLinkObj": "marks[0]._borderRadius"
          }
        ],
        "locale": {
          "title": {
            "en-US": "Other",
            "zh-CN": "其他",
            "zh-TW": "其他"
          },
          "value[0].title": {
            "en-US": "Bar background",
            "zh-CN": "柱状背景",
            "zh-TW": "柱狀背景"
          },
          "value": [
            {
              "title": {
                "en-US": "Bar background",
                "zh-CN": "柱状背景",
                "zh-TW": "柱狀背景"
              }
            }
          ]
        }
      }
    },
    "tooltip": {
      "trigger": "axis",
      "triggerOn": "mousemove",
      "show": true,
      "showDelay": 0,
      "hideDelay": 0,
      "confine": true,
      "enterable": false,
      "position": null,
      "padding": 10,
      "extraCssText": "border-width:1px;border-style:solid;border-color:#666;border-radius:0;background:#fff;transform:translateZ(10px);",
      "formatter": null,
      "textStyle": {
        "color": "#999",
        "fontStyle": "normal",
        "fontWeight": "normal",
        "fontFamily": "Arial",
        "fontSize": 12,
        "lineHeight": null,
        "backgroundColor": "transparent",
        "borderColor": "transparent",
        "borderWidth": 0,
        "borderRadius": 0,
        "padding": 0,
        "shadowColor": "transparent",
        "shadowBlur": 0,
        "shadowOffsetX": 0,
        "shadowOffsetY": 0,
        "width": null,
        "height": null,
        "rich": null
      }
    },
    "version": 3500,
    "axes": [
      {
        "fieldName": "area_code",
        "datasetId": 10,
        "axisName": "group",
        "labelOrigin": "area_code",
        "fieldType": "string",
        "uid": "u_a3c0ff2a6d9051ad_0",
        "parentUid": null,
        "keyChain": [
          "group",
          "none"
        ],
        "scaleRange": {
          "minAuto": true,
          "min": 0,
          "maxAuto": true,
          "max": 0
        },
        "kind": "function",
        "op": "group",
        "args": [
          {
            "kind": "field",
            "op": "area_code",
            "dataset": 10
          }
        ],
        "_controlLabel": false
      },
      {
        "formatterOrigin": {
          "prefix": "",
          "suffix": "",
          "percent": "",
          "unit": "",
          "thousands": false,
          "decimal": 2,
          "scientificNotation": false
        },
        "fieldName": "id",
        "datasetId": 10,
        "axisName": "y",
        "labelOrigin": "id",
        "fieldType": "number",
        "uid": "u_32a8edf1946cd3c3_1",
        "parentUid": null,
        "keyChain": [
          "sum",
          "none"
        ],
        "scaleRange": {
          "minAuto": true,
          "min": 0,
          "maxAuto": true,
          "max": 0
        },
        "kind": "function",
        "op": "sum",
        "args": [
          {
            "kind": "field",
            "op": "id",
            "dataset": 10
          }
        ],
        "formatter": {
          "prefix": "",
          "suffix": "",
          "percent": "",
          "unit": "",
          "thousands": false,
          "decimal": 2,
          "scientificNotation": false
        },
        "_controlLabel": true
      }
    ],
    "where": [],
    "having": [],
    "sort": [
      {
        "direction": "asc",
        "kind": "reference",
        "op": "u_a3c0ff2a6d9051ad_0",
        "sortByValue": "dataSource",
        "baseUid": "u_a3c0ff2a6d9051ad_0"
      }
    ],
    "titleStyle": {
      "show": true,
      "mode": "auto",
      "fontFamily": "Arial",
      "fontSize": 16,
      "fontWeight": "normal",
      "textAlign": "left",
      "color": "#4A4A4A"
    },
    "timebar": {
      "current": "dateExp",
      "dateExp": "All Avaliable Date",
      "dateRange": [],
      "show": false
    },
    "limit": 1000,
    "autoRefresh": {
      "start": false,
      "time": 30
    },
    "padding": {
      "left": 10,
      "top": 10,
      "right": 10,
      "bottom": 10
    },
    "mouseAction": {
      "trigger": "menu",
      "javascript": "",
      "menuAction": [
        "zoomIn",
        "exclude",
        "showDetail"
      ],
      "axisName": "group",
      "getClickEventData": "return BuiltIn.carryGetClickEventData({ group: 'event.name' })"
    },
    "setDefaultSort": "return BuiltIn.carrySetDefaultSort({ group: { direction: 'asc', axisType: 'Dimension'}})",
    "migrateMakalu": "return BuiltIn.migrateBar",
    "i18nPath": [
      "custom.other"
    ],
    "locale": {
      "zh-CN": {
        "title": "柱状图",
        "axes": {
          "group": "维度",
          "y": "度量"
        }
      },
      "zh-TW": {
        "title": "柱狀圖",
        "axes": {
          "group": "維度",
          "y": "度量"
        }
      },
      "en-US": {
        "title": "Bar",
        "axes": {
          "group": "Dimension",
          "y": "Metric"
        }
      }
    },
    "mapConf": {
      "theme": "light"
    }
  }
}

返回:

{
  "version": "4.0-SNAPSHOT@@git.commit.id.abbrev@#7c54292",
  "code": 0,
  "msg": "success",
  "data": [
    "SELECT (TO_CHAR(\"dataset_10\".\"area_code\")) AS \"u_a3c0ff2a6d9051ad_0\", sum(cast(\"dataset_10\".\"id\" as decimal(38, 10))) AS \"u_32a8edf1946cd3c3_1\" FROM \"DM\".\"map_china_area\" \"dataset_10\" GROUP BY (TO_CHAR(\"dataset_10\".\"area_code\")) ORDER BY \"u_a3c0ff2a6d9051ad_0\" ASC NULLS LAST LIMIT 1000"
  ]
}

1.2.20. 通过Options获取图表SQL执行计划

通过Options获取图表SQL执行计划

请求URL

GET /api/apps/{appId}/sql-explain

请求参数

URL 参数
字段 类型 说明
appId INTEGER 图表所在的应用 Id
RequestBody 参数

图表数据 chart

接口示例1:

GET /api/apps/15/sql-explain

返回:

{
   "version": "4.0-SNAPSHOT@@git.commit.id.abbrev@#7c54292",
   "code": 0,
   "msg": "success",
   "data": [
      []
   ]
}

1.2.21. 异步导出图表PNG/PDF

请求URL

POST /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/async-export

请求参数

URL 参数
字段 类型 是否必须 说明
appId LONG 图表所在的应用id
dashboardId LONG 图表所在的仪表盘id
chartId LONG 图表id
type STRING 传png或者pdf
timeout INTEGER 导出超时时间,timeout内完成,直解返回二进制流下载,timeout未完成或出现异常,返回json信息
width INTEGER 宽度
height INTEGER 单页的高度
totalHeight INTEGER 整个页面的总高度
request body 参数

DownloadDto

字段 类型 是否必须 说明
app OBJECT 全局过滤器 见应用结构
dashboard OBJECT 仪表盘过滤器 见仪表盘结构

返回对象的格式说明

如果导出任务没有完成,返回PENDING状态;若任务已完成,返回png/pdf格式文件流下载,文件名是图表的名称

接口示例1: 导出图表PDF

POST /api/apps/41589/dashboards/1/charts/2/async-export?type=pdf&width=1215&height=980&&timeout=170000

{
   "app": {
      "id": 41589,
      "options": {
         "filters": []
      }
   },
   "dashboard": {
      "id": 1,
      "options": {
         "filters": []
      }
   }
}

接口示例2: 导出图表PNG

POST /api/apps/41589/dashboards/1/charts/2/async-export?type=png&width=1215&height=980&timeout=170000

{
   "app": {
      "id": 41589,
      "options": {
         "filters": []
      }
   },
   "dashboard": {
      "id": 1,
      "options": {
         "filters": []
      }
   }
}

results matching ""

    No results matching ""

    授权 API授权