Skip to content

图表

图表说明

图表的定义

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

图表结构说明

Chart
字段类型描述
appIdLONG图表所属的应用 id
dataAppIdLONG图表用的数据集所属的应用 id
dashboardIdLONG图表所属的仪表盘 id
titleSTRING图表标题
datasetIdLONG图表所用的主表数据集 id
optionsOBJECT仪表盘配置信息
options.templateSTRING为葡萄城模板转成json字符串后的内容。
options.pageBOOL是否分页,仅对复杂表格生效,为false或者null表示不分页,为true表示分页
options.grapeCityInsertModeSTRING为葡萄城模板扩展模式,值为Cells或者EntireRowColumn。
options.axesHE 数组用于绘图的维度和度量计算方法
options.axes[i].dataAppIdINTEGER非HE部分,用于记录复杂报表相关的信息,轴用到的字段来自的数据集所属的app。
options.axes[i].cellPositionSTRING表示对应的单元格坐标,比如B2。
options.axes[i].cellContextXSTRING表示横向的上下文,比如A2。
options.axes[i].cellContextYSTRING表示纵向的上下文,比如B1。
options.axes[i].cellExpansionSTRING表示扩展方向,比如V表示纵向扩展,H表示横向扩展,N表示无。
options.axes[i].repeatOutputBOOL单元格分页跨页的时候,是否跨页都显示一遍
options.axes[i].keepTogetherSTRING分页时尽量不断开的范围,比如A1:B3
options.axes[i].keepTogetherToggleBOOL是否启用keepTogether
options.axes[i].attachToSTRING指定与某个单元格共同出现,内容为单元格表达式,比如A1
options.axes[i].attachToToggleBOOL是否启用attachTo
options.axes[i].repeatWithGroupSTRING在报表中生成与指定引用单元格重复的单元格,内容为单元格表达式,比如A1
options.axes[i].repeatWithGroupToggleBOOL是否启用repeatWithGroup
options.axes[i].imageToggleBOOL是否显示图片
options.axes[i].barcodeFunctionSTRING生成二维码的函数
options.axes[i].barcodeToggleBOOL是否生成二维码
options.otherCellInfosOBJECT 数组表示非轴的复杂表格中的一些特殊的cell的信息
options.otherCellInfos[i].cellPositionSTRING表示非计算字段单元格对应的单元格坐标,比如B2。
options.otherCellInfos[i].cellContextXSTRING表示非计算字段单元格横向的上下文,比如A2。
options.otherCellInfos[i].cellContextYSTRING表示非计算字段单元格纵向的上下文,比如B1。
options.otherCellInfos[i].cellExpansionSTRING表示非计算字段单元格扩展方向,比如V表示纵向扩展,H表示横向扩展,N表示无。
options.otherCellInfos[i].repeatOutputBOOL单元格分页跨页的时候,是否跨页都显示一遍
options.otherCellInfos[i].keepTogetherSTRING分页时尽量不断开的范围,比如A1:B3
options.otherCellInfos[i].keepTogetherToggleBOOL是否启用keepTogether
options.otherCellInfos[i].attachToSTRING指定与某个单元格共同出现,内容为单元格表达式,比如A1
options.otherCellInfos[i].attachToToggleBOOL是否启用attachTo
options.otherCellInfos[i].repeatWithGroupSTRING在报表中生成与指定引用单元格重复的单元格,内容为单元格表达式,比如A1
options.otherCellInfos[i].repeatWithGroupToggleBOOL是否启用repeatWithGroup
options.otherCellInfos[i].imageToggleBOOL是否显示图片
options.otherCellInfos[i].barcodeFunctionSTRING生成二维码的函数
options.otherCellInfos[i].barcodeToggleBOOL是否生成二维码
options.timebarHE时间轴过滤器
options.whereHE 数组图表的过滤条件,主要是用于原始字段的过滤
options.havingHE 数组图表的过滤条件,主要用户图内指标的过滤
options.sortHE 数组图表的排序条件
options.limitINTEGER数据的行数限制
options.offsetINTEGER数据的偏移量
options.refreshBOOL是否强制刷新。取图表数据时,true表示不会用缓存,false表示可以使用缓存
options.fieldsPolicyENUM取field的规则,详情见下表
options.publishConfigOBJECT图表在发布或者共享时的交互配置
hsVersionINTEGER可选,本次编辑的版本号,从0开始,修改前先GET待修改资源获取当前版本号,修改时带上刚刚获取的版本号,服务端会检查并发冲突。不带版本号不检查并发冲突。
datasetInfosOBJECT 数组专用于复杂表格类型的图表,用到的数据集列表
datasetInfos[i].appIdINTEGER复杂表格用到的数据集的对应的应用id
datasetInfos[i].datasetIdINTEGER复杂表格用到的数据集的id
datasetInfos[i].datasetTitleSTRING复杂表格用到的数据集的名字
datasetInfos[i].datasetIdsINTEGER 数组axes里面用到的数据集字段对应的主表或者从表信息,可用于前端对数据集打勾
datasetInfos[i].relativeDatasetsOBJECT 数组主表下面的所有从表信息
datasetInfos[i].relativeDatasets[i].datasetIdINTEGER从表id
datasetInfos[i].relativeDatasets[i].titleINTEGER从表title
sourceAppIdLONG链接图表的源图表所在应用的 id
sourceIdLONG链接图表的源图表 id
chartCommentSTRING图表的注释信息
ChartDto
字段类型描述
schemaOBJECT图表schema信息,参见数据集结构说明 options.schema
datasetNameSTRING图表用的数据集名称
isCollaboratedBOOLEAN是否协作
targetDashboardIdLONG仪表盘id
dashboardOptionsOBJECT仪表盘配置信息
importTypeSTRINGLINK 表示链接,COPY 表示复制
mapFieldByLabelBOOLEANtrue 表示切换数据集的时候用字段的 label 匹配,否则用字段的 fieldname 匹配

options.fieldsPolicy 枚举说明说明

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

接口说明

创建图表

创建图表。

请求URL

http
POST /api/apps/{appId}/dashboards/{dashboardId}/charts HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

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

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

返回对象的格式说明

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

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

http
POST /api/apps/1/dashboards/1/charts HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "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": "新建探索"
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "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: 在应用中创建业务指标

http
POST /api/apps/1/charts HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "options": {
    "name": "Table",
    "version": 3000
  },
  "title": "新建探索"
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "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": []
  }
}

获取仪表盘中的图表

获取仪表盘中的图表。

请求URL

http
GET /api/apps/{appId}/dashboards/{dashboardId}/charts HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
dashboardIdINTEGER图表所在的仪表盘 Id

返回对象的格式说明

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

获取数据包中的图表库

获取数据包中的图表库

请求URL

http
GET /api/apps/{appId}/charts HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
orderBySTRING用来排序的字段
orderTypeSTRING排序的方向,可选值为 asc、desc
chartNamesSTRING要搜索的图表类型,多个用 , 分隔,比如 bar,table
excludeLinkChartBOOL是否包含链接图表

返回对象的格式说明

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

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

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

请求URL

http
GET /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId} HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
dashboardIdINTEGER图表所在的仪表盘 Id
chartIdINTEGER图表的 Id

返回对象的格式说明

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

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

通过 ID 获取图表库中的图表信息

通过 ID 获取图表库中的图表信息

请求URL

http
GET /api/apps/{appId}/charts/{chartId} HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
chartIdINTEGER图表的 Id

返回对象的格式说明

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

更新仪表盘中的图表信息

更新仪表盘中的图表信息

请求URL

http
PUT /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId} HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
dashboardIdINTEGER图表所在的仪表盘 Id
chartIdINTEGER图表的 Id
request body 参数

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

返回对象的格式说明

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

接口示例1: 更新图表

http
PUT /api/apps/1/dashboards/charts/1 HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "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
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
   "version": "version@9a5e106#6730f0d",
   "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
      ]
   }
}

接口示例2: 切换图表使用的数据源,并使用数据集字段label匹配

http
PUT /api/apps/1/dashboards/charts/1 HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
   "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": 4,
   "mapFieldByLabel": true
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
   "version": "version@9a5e106#6730f0d",
   "code": 0,
   "msg": "success",
   "data": {
      "id": 2,
      "updatedBy": 1,
      "updatedAt": "2020-07-06 10:38:58",
      "appId": 4662,
      "datasetId": 4,
      "options": {
         "name": "Pie",
         "axes": [
            {
               "fieldName": "director",
               "datasetId": 4,
               "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": 4
                  }
               ]
            }
         ],
         "zoomPath": [],
         "marks": [
            {
               "color": {
                  "schema": [
                     "#4479EC",
                     "#A3B9ED",
                     "#7759CA",
                     "#53BBEC",
                     "#ACD667",
                     "#868F90",
                     "#6071C6",
                     "#6ADAC2",
                     "#339BEB",
                     "#72B15E"
                  ]
               }
            }
         ],
         "sort": [],
         "version": 3200
      },
      "dashboardId": 1,
      "dataAppId": 4662,
      "datasetIds": [
         4
      ]
   }
}

更新图表库中的图表信息

更新图表库中的图表信息

请求URL

http
PUT /api/apps/{appId}/charts/{chartId} HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
chartIdINTEGER图表的 Id
request body 参数

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

返回对象的格式说明

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

接口示例1: 更新图表库中的图表信息

http
PUT /api/apps/charts/1 HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "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
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "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
    ]
  }
}

删除仪表盘中的图表

删除仪表盘中的图表

请求URL

http
DELETE /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId} HTTP/1.1

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
dashboardIdINTEGER图表所在的仪表盘 Id
chartIdINTEGER图表的 Id

返回对象的格式说明

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

删除图表库中的图表

删除图表库中的图表

请求URL

http
DELETE /api/apps/{appId}/charts/{chartId} HTTP/1.1

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
chartIdINTEGER图表的 Id

返回对象的格式说明

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

批量导入图表

批量导入图表

请求URL

http
POST /api/apps/{appId}/dashboards/{dashboardId}/charts/import HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

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

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

返回对象的格式说明

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

接口示例1: 以链接方式导入数据包图表库中的图表

http
POST /api/apps/10744/dashboards/1/charts/import HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
[
  {
    "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
        }
      }
    }
  }
]
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "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: 以拷贝方式导入数据包图表库中的图表

http
POST /api/apps/10744/dashboards/1/charts/import HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
[
  {
    "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
        }
      }
    }
  }
]
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "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"
  }
}

断开图表链接

断开图表链接

请求URL

http
PUT /api/apps/{appId}/{dashboardId}/charts/{chartId}/break-link HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
dashboardIdINTEGER图表所在的仪表盘 Id
chartIdINTEGER图表的 Id

返回对象的格式说明

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

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

http
PUT /api/apps/10744/dashboards/1/charts/3/break-link HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

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

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

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

请求URL

http
GET /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/data/count HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
dashboardIdINTEGER图表所在的仪表盘 Id
chartIdINTEGER图表的 Id

返回对象的格式说明

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

在仪表盘内使用自定义图表配置获取图表数据

在仪表盘内使用自定义图表配置获取图表数据,衡石会校验指定图表是否在指定的仪表盘内。

请求URL

http
POST /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/data HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
dashboardIdINTEGER图表所在的仪表盘 Id
chartIdINTEGER图表的 Id
request body 参数

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

返回对象的格式说明

数据集数据 datasetResultDto

接口示例1

http
POST /api/apps/1/dashboards/1/charts/1/data HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "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
          }
        ]
      }
    ]
  }
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "data": {
    "data": [
      [
        "Americas",
        2
      ],
      [
        "Middle East and Africa",
        4
      ],
      [
        "Asia",
        3
      ],
      [
        "Europe",
        1
      ]
    ],
    "schema": [
      {
        "fieldName": "u_edbee8adba68e26a_0"
      },
      {
        "fieldName": "u_9f886f9cb7bdf1d2_1"
      }
    ]
  }
}

在仪表盘内使用自定义图表配置获取图表数据总行数

在仪表盘内使用自定义图表配置获取图表数据总行数。

请求URL

http
POST /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/data/count HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
dashboardIdINTEGER图表所在的仪表盘 Id
chartIdINTEGER图表的 Id
request body 参数

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

返回对象的格式说明

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

在应用内使用自定义图表配置获取图表数据

在应用内使用自定义图表配置获取图表数据。

请求URL

http
POST /api/apps/{appId}/chart-data HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER执行数据查询的应用 Id
offsetINTEGER数据量的偏移值
limitINTEGER数据量的上限
request body 参数

{"options":{ "options的详细信息"},"datasetId":要查询的主表id"}

返回对象的格式说明

数据集数据 datasetResultDto

接口示例1: 创建图表

http
POST /api/apps/1/chart-data HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
   "datasetId": 3366,
   "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
  }
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "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
  }
}

通过ID获取图表SQL

通过ID获取图表SQL

请求URL

http
GET /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/sql-debug HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

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

接口示例1:

http
GET /api/apps/15/dashboards/2/charts/1/sql-debug HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
   "version": "version@9a5e106#6730f0d",
   "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:

http
GET /api/apps/15/dashboards/2/charts/1/sql-debug?vendorDesc=mysql HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
   "version": "version@9a5e106#6730f0d",
   "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"
   ]
}

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

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

请求URL

http
GET /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/sql-explain HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型说明
appIdINTEGER图表所在的应用 Id
dashboardIdINTEGER图表所在的仪表盘 Id
chartIdINTEGER图表的 Id

接口示例1:

http
GET /api/apps/15/dashboards/2/charts/1/sql-explain HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "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"
      ]
    ]
  ]
}

通过图表自定义配置获取图表SQL

通过图表自定义配置获取图表SQL

请求URL

http
POST /api/apps/{appId}/sql-debug HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

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

图表数据 chart

接口示例1:

http
POST /api/apps/15/sql-debug HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求:

json
{
  "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"
    }
  }
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "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"
  ]
}

通过图表自定义配置获取图表SQL执行计划

通过图表自定义配置获取图表SQL执行计划

请求URL

http
GET /api/apps/{appId}/sql-explain HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

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

图表数据 chart

异步导出图表PNG/PDF

请求URL

http
POST /api/apps/{appId}/dashboards/{dashboardId}/charts/{chartId}/async-export HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型是否必须说明
appIdLONG图表所在的应用id
dashboardIdLONG图表所在的仪表盘id
chartIdLONG图表id
typeSTRING传png或者pdf
timeoutINTEGER导出超时时间,timeout内完成,直解返回二进制流下载,timeout未完成或出现异常,返回json信息
widthINTEGER宽度
heightINTEGER单页的高度
totalHeightINTEGER整个页面的总高度
request body 参数

DownloadDto

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

返回对象的格式说明

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

接口示例1: 导出图表PDF

http
POST /api/apps/41589/dashboards/1/charts/2/async-export?type=pdf&width=1215&height=980&&timeout=170000 HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

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

接口示例2: 导出图表PNG

http
POST /api/apps/41589/dashboards/1/charts/2/async-export?type=png&width=1215&height=980&timeout=170000 HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

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

HENGSHI SENSE API 使用手册