Chart

View source code

Check out Code Sample

Analysis chart (Chart) is mainly used to arrange data statistics analysis query logic, supports the use of JavaScript scripts to process the results of each query node, can directly view the analysis chart in the data management background, and can also be used as a process (process), The reference method is charts.<analytical chart name>. Analysis chart (Chart) supports data analysis engines based on ElasticSearch and MySQL for various business scenarios.

Data kanban and data big screen pages can also be written in the same way.

handler list

Data kanban, analysis charts, data screen related processes.

processDescriptionDocumentation
xiang.chart.DataReturns chart query results.-
xiang.chart.SettingRead data table configuration information for front-end interface rendering-

API list

APIDescriptionDocumentation
xiang.chart.XXX.DataRequest chart dataDocumentation
xiang.chart.XXX.SettingRead and formulate data table configuration information for front-end interface renderingDocumentation

Naming conventions

The analysis chart description file is a JSON text file named with lowercase English letters + .chart.json extension, <name>.chart.json; The result processing script file is a JavaScript script file named <name>.<script>.js with the extension of Analysis chart name + . + script name + .js.

The extension of the data kanban is .kan.json, and the extension of the big data screen is .scr.json

Folder (relative to analytic graph root)File nameAnalytic graph nameScript nameProcess (referenced in API/Flow)API route address
/name.chart.jsonnamecharts.name/api/xiang/chart/name/query interface
/name.count.jsnamecount--
/groupname.chart.jsongroup.namecharts.group.name/api/xiang/chart/group.name/query interface
/groupname.count.jsgorup.namecount--
/group1/group2name.chart.jsongroup1.group2.namecharts.group1.group2.name/api/xiang/chart/group1.group2.name/query interface
/group1/group2name.count.jsgroup1.group2.namecount--

Document structure

The analysis chart layout document consists of basic information, query nodes, output data, and analysis page rendering parameters.

{
"lang": "gou",
"label": "Latest Information",
"version": "1.0.0",
"description": "Latest Information",
"nodes": [],
"output": {},
"apis": {},
"filters": {},
"page": {}
}
FieldsTypeDescriptionRequired Fields
langStringData query condition description language. The license value gou applies to a database-based data analysis engine. tai applies to the analysis engine implemented based on ElasticSearch (mounted separately). Default is gouyes
labelStringAnalysis chart rendering name, used for development platform renderingyes
versionStringVersion number, used for dependency check and development platform renderingyes
descriptionStringAnalysis chart introduction, used for development platform presentationNo
nodesArray<Object Node>query nodeyes
outputObject | StringDefinition of output result, same as business logic orchestration (flow) outputyes
apis[key:String]:Object APIAnalysis chart query API, you can set the same key settings to close the interface, set the authentication method and default value options.No
filters[key:String]:Object FilterQuery filter settings. Same as data table (talbe) fliters.No
pageObject PageAnalysis chart query page settings.yes

Example one:

Write a data kanban description file pet.kan.json and place it in the application's kanban directory.

Description file content:

View source code

Application Directory Structure:

├── apis # Used to store interface description files
│ └── pet.http.json
├── models # Used to store data model description files
│ └── pet.mod.json
├── tables # Used to store data table description files
│ └── pet.tab.json
├── kanban # Used to store data kanban description files
│ └── pet.kan.json
├── db
└── ui
└── app.json

Access Kanban interface:

Page route: /xiang/kanban/<Kanban Name>

  1. Enter https://127.0.0.1:5099/xiang/kanban/pet in the address bar

  2. It is recommended to add the /xiang/kanban/pet route as a menu item.

Example 2

{
"nodes": [
{
"name": "Industry Distribution",
"query": {
"model": "service",
"select": ["city", ":COUNT(id) as cnt", "@industries.$ as industry"],
"wheres": [
{ "column": "created_at", "value": "{{$query.from}}", "op": "ge" },
{ "column": "created_at", "value": "{{$query.to}}", "op": "le" }
],
"order": ["cnt.desc"],
"limit": 100,
"group": ["@industries.$", "city"]
}
},
{
"name": "Billing method",
"query": {
"model": "service",
"select": ["city", ":COUNT(id) as cnt", "@price_options.$ as option"],
"wheres": [
{ "column": "created_at", "value": "{{$query.from}}", "op": "ge" },
{ "column": "created_at", "value": "{{$query.to}}", "op": "le" }
],
"order": ["cnt.desc"],
"limit": 100,
"group": ["@price_options.$", "city"]
}
},
{
"name": "Merge result",
"process": "xiang.chart.MergeData",
"args": [
["city", "industry", "billing"],
{
"Industry": {
"key": "city",
"values": "{{$res.Industry distribution[*].industry}}"
},
"Billing": {
"key": "city",
"values": "{{$res.Billing method[*].option}}"
}
}
]
}
]
}

An analysis chart query orchestration (Chart) can have multiple query nodes, each query node also writes and sets the query query parameters corresponding to the data engine, or calls a process (process), which can specify the result Processing scripts and return values ​​can be used to reference contextual information in query nodes. The context data reference and result processing script are specifically consistent with the business logic orchestration (Flow).

Object Node data structure

FieldsTypeDescriptionRequired Fields
nameStringquery node nameyes
queryQuery DSLQuery LanguageNo
processStringInvoke the process process, query or process. If also present ignore the process setting.No
argsArray<Any>process argument list. Can refer to input/output or context data, same as flow.No
scriptStringResult processing script, supports ES5, same as flow.No
outsArray<String>Query node result output. Use {{$out}} to refer to the process to return the result, same as flow. If not set, the return value is equal to the result returned by the process.No
nextObject NextJump to the specified query node when the query result meets the set conditions (Not yet implemented)No

Analysis chart query interface apis

The data and configuration query interface is enabled by default in the analysis chart. You can disable the interface, set the authentication method and default value options by setting the same key settings.

{
"apis": {
"data": {
"disable": true,
"guard": "bearer-jwt",
"default": {}
},
"setting": {
"guard": "-",
"default": {}
}
}
}
FieldsTypeDescriptionRequired Fields
disableBoolDisables the interface. true closes the interfaceno
guardStringInterface authentication middleware, multiple are separated by ,, set to -, no authentication middleware is set, and no default authentication mode is set.No
defaultObjectParameter table default value, {"from":"2021-08-28"}no

Interface list

management interface (key)request methodroute (relative)description
dataGET/datareturn query result
settingGET/settingRead analysis chart configuration information for front-end interface rendering

complete example

View source code

Chart

View source code

Check out Code Sample

Analysis chart (Chart) is mainly used to arrange data statistics analysis query logic, supports the use of JavaScript scripts to process the results of each query node, can directly view the analysis chart in the data management background, and can also be used as a process (process), The reference method is charts.<analytical chart name>. Analysis chart (Chart) supports data analysis engines based on ElasticSearch and MySQL for various business scenarios.

Data kanban and data big screen pages can also be written in the same way.

handler list

Data kanban, analysis charts, data screen related processes.

processDescriptionDocumentation
xiang.chart.DataReturns chart query results.-
xiang.chart.SettingRead data table configuration information for front-end interface rendering-

API list

APIDescriptionDocumentation
xiang.chart.XXX.DataRequest chart dataDocumentation
xiang.chart.XXX.SettingRead and formulate data table configuration information for front-end interface renderingDocumentation

Naming conventions

The analysis chart description file is a JSON text file named with lowercase English letters + .chart.json extension, <name>.chart.json; The result processing script file is a JavaScript script file named <name>.<script>.js with the extension of Analysis chart name + . + script name + .js.

The extension of the data kanban is .kan.json, and the extension of the big data screen is .scr.json

Folder (relative to analytic graph root)File nameAnalytic graph nameScript nameProcess (referenced in API/Flow)API route address
/name.chart.jsonnamecharts.name/api/xiang/chart/name/query interface
/name.count.jsnamecount--
/groupname.chart.jsongroup.namecharts.group.name/api/xiang/chart/group.name/query interface
/groupname.count.jsgorup.namecount--
/group1/group2name.chart.jsongroup1.group2.namecharts.group1.group2.name/api/xiang/chart/group1.group2.name/query interface
/group1/group2name.count.jsgroup1.group2.namecount--

Document structure

The analysis chart layout document consists of basic information, query nodes, output data, and analysis page rendering parameters.

{
"lang": "gou",
"label": "Latest Information",
"version": "1.0.0",
"description": "Latest Information",
"nodes": [],
"output": {},
"apis": {},
"filters": {},
"page": {}
}
FieldsTypeDescriptionRequired Fields
langStringData query condition description language. The license value gou applies to a database-based data analysis engine. tai applies to the analysis engine implemented based on ElasticSearch (mounted separately). Default is gouyes
labelStringAnalysis chart rendering name, used for development platform renderingyes
versionStringVersion number, used for dependency check and development platform renderingyes
descriptionStringAnalysis chart introduction, used for development platform presentationNo
nodesArray<Object Node>query nodeyes
outputObject | StringDefinition of output result, same as business logic orchestration (flow) outputyes
apis[key:String]:Object APIAnalysis chart query API, you can set the same key settings to close the interface, set the authentication method and default value options.No
filters[key:String]:Object FilterQuery filter settings. Same as data table (talbe) fliters.No
pageObject PageAnalysis chart query page settings.yes

Example one:

Write a data kanban description file pet.kan.json and place it in the application's kanban directory.

Description file content:

View source code

Application Directory Structure:

├── apis # Used to store interface description files
│ └── pet.http.json
├── models # Used to store data model description files
│ └── pet.mod.json
├── tables # Used to store data table description files
│ └── pet.tab.json
├── kanban # Used to store data kanban description files
│ └── pet.kan.json
├── db
└── ui
└── app.json

Access Kanban interface:

Page route: /xiang/kanban/<Kanban Name>

  1. Enter https://127.0.0.1:5099/xiang/kanban/pet in the address bar

  2. It is recommended to add the /xiang/kanban/pet route as a menu item.

Example 2

{
"nodes": [
{
"name": "Industry Distribution",
"query": {
"model": "service",
"select": ["city", ":COUNT(id) as cnt", "@industries.$ as industry"],
"wheres": [
{ "column": "created_at", "value": "{{$query.from}}", "op": "ge" },
{ "column": "created_at", "value": "{{$query.to}}", "op": "le" }
],
"order": ["cnt.desc"],
"limit": 100,
"group": ["@industries.$", "city"]
}
},
{
"name": "Billing method",
"query": {
"model": "service",
"select": ["city", ":COUNT(id) as cnt", "@price_options.$ as option"],
"wheres": [
{ "column": "created_at", "value": "{{$query.from}}", "op": "ge" },
{ "column": "created_at", "value": "{{$query.to}}", "op": "le" }
],
"order": ["cnt.desc"],
"limit": 100,
"group": ["@price_options.$", "city"]
}
},
{
"name": "Merge result",
"process": "xiang.chart.MergeData",
"args": [
["city", "industry", "billing"],
{
"Industry": {
"key": "city",
"values": "{{$res.Industry distribution[*].industry}}"
},
"Billing": {
"key": "city",
"values": "{{$res.Billing method[*].option}}"
}
}
]
}
]
}

An analysis chart query orchestration (Chart) can have multiple query nodes, each query node also writes and sets the query query parameters corresponding to the data engine, or calls a process (process), which can specify the result Processing scripts and return values ​​can be used to reference contextual information in query nodes. The context data reference and result processing script are specifically consistent with the business logic orchestration (Flow).

Object Node data structure

FieldsTypeDescriptionRequired Fields
nameStringquery node nameyes
queryQuery DSLQuery LanguageNo
processStringInvoke the process process, query or process. If also present ignore the process setting.No
argsArray<Any>process argument list. Can refer to input/output or context data, same as flow.No
scriptStringResult processing script, supports ES5, same as flow.No
outsArray<String>Query node result output. Use {{$out}} to refer to the process to return the result, same as flow. If not set, the return value is equal to the result returned by the process.No
nextObject NextJump to the specified query node when the query result meets the set conditions (Not yet implemented)No

Analysis chart query interface apis

The data and configuration query interface is enabled by default in the analysis chart. You can disable the interface, set the authentication method and default value options by setting the same key settings.

{
"apis": {
"data": {
"disable": true,
"guard": "bearer-jwt",
"default": {}
},
"setting": {
"guard": "-",
"default": {}
}
}
}
FieldsTypeDescriptionRequired Fields
disableBoolDisables the interface. true closes the interfaceno
guardStringInterface authentication middleware, multiple are separated by ,, set to -, no authentication middleware is set, and no default authentication mode is set.No
defaultObjectParameter table default value, {"from":"2021-08-28"}no

Interface list

management interface (key)request methodroute (relative)description
dataGET/datareturn query result
settingGET/settingRead analysis chart configuration information for front-end interface rendering

complete example

View source code