From fc3b5b73309a3f0d8c1703de3022dc38edf41d3a Mon Sep 17 00:00:00 2001 From: qianming Date: Tue, 8 Aug 2023 13:55:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/docs/guide/chartsLinkage.md | 1 + doc/docs/guide/dataset.md | 100 ++++++++++++++++++++------------ 2 files changed, 65 insertions(+), 36 deletions(-) diff --git a/doc/docs/guide/chartsLinkage.md b/doc/docs/guide/chartsLinkage.md index ad22ea7e..d2918959 100644 --- a/doc/docs/guide/chartsLinkage.md +++ b/doc/docs/guide/chartsLinkage.md @@ -1,6 +1,7 @@ ## 简要说明 现有系统联动的本质是数据集查询参数“示例值”的替换, 现在联动有两种。
+除下文介绍的示例外,还可去数据集、体验地址去查看示例。
- 表单联动
目前支持的有下拉框、时间筛选器。
diff --git a/doc/docs/guide/dataset.md b/doc/docs/guide/dataset.md index 902b9345..d93ff4dc 100644 --- a/doc/docs/guide/dataset.md +++ b/doc/docs/guide/dataset.md @@ -51,26 +51,54 @@ 自定义JS,这里的JS是java的scriptengine执行的,支持ES5的写法。 +- 示例一
+ 返回yyyyy-MM-dd类型的当前时间 + ```js -//返回yyyyy-MM-dd类型的当前时间 -function verification(data){ - //自定义脚本内容 - //获取当前时间 - var date = new Date(); - var year = date.getFullYear(); - var month = date.getMonth() + 1; - var day = date.getDate(); - if (month < 10) { - month = "0" + month; - } - if (day < 10) { - day = "0" + day; - } - var nowDate = year + "-" + month + "-" + day; - return nowDate; +// 返回yyyyy-MM-dd类型的当前时间 +function verification(data) { + //自定义脚本内容 + //获取当前时间 + var date = new Date(); + var year = date.getFullYear(); + var month = date.getMonth() + 1; + var day = date.getDate(); + if (month < 10) { + month = "0" + month; + } + if (day < 10) { + day = "0" + day; + } + var nowDate = year + "-" + month + "-" + day; + return nowDate; } ``` +- 示例二
+ 不传参则查询全部 + +```sql +// sql可以这么写 +SELECT DATE_FORMAT(create_time, '%Y-%m-%d') create_time, sum(nums) sum_nums +FROM aj_report_city ${city_name} +group by create_time; +``` + +```js +// 不传参则查询全部 +function verification(data) { + // 获取示例值 + data = data.sampleItem; + if (data == null || data == '') { + return '' + } + data = 'where city_name = "' + data + '" ' + return data; +} +``` + +**注:** 当前V1.0.0版本示例值是不可为空的,所以实际使用可能会麻烦点 + ### 数据转换 数据转换是在执行完 sql 之后进行的数据清洗操作。 @@ -82,26 +110,26 @@ function verification(data){ ```js // 根据sql查询出的结果进行数据清洗 -function dataTransform(data){ - //自定义脚本内容 - - //1.遍历测试预览中的java.util.ArrayList - for(j = 0, len = data.length; j < len; j++){ - //获取一行数据 - var row = data[j] - //比如对brand字段进行拆分,例如A-100,B-50 - var brand = row['brand'] - var split = brand.split('-') - //新增两个字段 - var model = split[0] - var series = split[1] - - //对原始对象赋值 - data[j]['model'] = model - data[j]['series'] = series - - } - return data; +function dataTransform(data) { + //自定义脚本内容 + + //1.遍历测试预览中的java.util.ArrayList + for (j = 0, len = data.length; j < len; j++) { + //获取一行数据 + var row = data[j] + //比如对brand字段进行拆分,例如A-100,B-50 + var brand = row['brand'] + var split = brand.split('-') + //新增两个字段 + var model = split[0] + var series = split[1] + + //对原始对象赋值 + data[j]['model'] = model + data[j]['series'] = series + + } + return data; } ```