專案

一般

配置概況

工作單 #200 » P9701007-每日熱門的交易時段分析.json

marlboro chu, 2025-06-30 01:58

 
{
"result" : {
"id" : 627,
"orgId" : 1,
"folderId" : 143,
"folderUid" : "bempo37hjqtq8d",
"uid" : "fenx13foqurcwa",
"name" : "P9701007-每日熱門的交易時段分析",
"kind" : 1,
"type" : "volkovlabs-echarts-panel",
"description" : "",
"model" : {
"datasource" : {
"type" : "elasticsearch",
"uid" : "f45b49c9-ba56-43c8-b278-a87adffdb57c"
},
"description" : "",
"fieldConfig" : {
"defaults" : { },
"overrides" : [ ]
},
"gridPos" : {
"h" : 9,
"w" : 24,
"x" : 0,
"y" : 10
},
"id" : 9701007,
"options" : {
"baidu" : {
"callback" : "bmapReady",
"key" : ""
},
"editor" : {
"format" : "auto",
"height" : 903
},
"editorMode" : "code",
"gaode" : {
"key" : "",
"plugin" : "AMap.Scale,AMap.ToolBar"
},
"getOption" : "let sHour = [], sauth_return_code = [], sCount = [];\n\n// 从 context.panel 获取数据\nconst data = context.panel.data;\nif (data && Array.isArray(data.series) && data.series.length > 0) {\n data.series.forEach((s) => {\n const field1 = s.fields.find(f => f.name === 'serverHour');\n if (field1) {\n sHour = field1.values; // 使用 values\n }\n const field2 = s.fields.find(f => f.name === 'feedbackInfo__authResult');\n if (field2) {\n sauth_return_code = field2.values; // 使用 values\n }\n const field3 = s.fields.find(f => f.name === 'Count');\n if (field3) {\n sCount = field3.values; // 使用 values\n }\n });\n\n // 更新 sauth_return_code,将 '0' 改为 'Y', '1' 改为 'N'\n const updatedArray = sauth_return_code.map(function (code) {\n if (code === '0') {\n return 'Y';\n } else if (code === '1') {\n return 'N';\n } else {\n return code;\n }\n });\n sauth_return_code = updatedArray;\n\n const arrayRange = (start, stop, step) =>\n Array.from(\n { length: (stop - start) / step + 1 },\n (value, index) => start + index * step\n );\n\n const result = {};\n const return_obj = {};\n const time_range = arrayRange(0, 23, 1);\n const zero_array = new Array(24).fill(0);\n const tbl_arry = [];\n const mapping_tbl = {}; // 用于存储 sauth_return_code 和 Count 总和\n const series_array = [];\n const dec_lis = [...new Set(sauth_return_code)]; // 获取去重后的返回码\n let yAxisMax = 10;\n\n // 初始化 mapping_tbl\n dec_lis.forEach((val) => {\n mapping_tbl[val] = 0;\n });\n\n // 构建 tbl_arry 数据\n sHour.forEach((val, key) => {\n tbl_arry[key] = [parseInt(val), sauth_return_code[key], sCount[key]]; // 将时间、返回码、Count 关联起来\n });\n\n // 根据 sauth_return_code 累加 Count 数据\n sauth_return_code.forEach((val, key) => {\n mapping_tbl[val] += sCount[key];\n });\n\n // 排序 sauth_return_code\n const sortOrder = [\"Y\", \"N\", \"nan\"];\n const mapping_tbl_sortable = Object.fromEntries(\n Object.entries(mapping_tbl).sort(([keyA], [keyB]) => sortOrder.indexOf(keyA) - sortOrder.indexOf(keyB))\n );\n\n const dec_lis_sorted = Object.keys(mapping_tbl_sortable);\n\n\n\n // 构建 result 数据\n dec_lis_sorted.forEach((dec, i) => {\n const obj = {};\n time_range.forEach((val) => {\n obj[val] = zero_array[val]; // 初始化每个小时的数据为 0\n });\n\n tbl_arry.forEach((val) => {\n if (val[1] === dec) {\n obj[val[0]] = val[2]; // 设置对应小时的 Count 数据\n }\n });\n\n result[i] = obj;\n });\n\n // 设置颜色\n const color_list = [];\n dec_lis_sorted.forEach((value) => {\n if (value === 'Y') {\n color_list.push('rgb(86, 166, 75)');\n } else if (value === 'N') {\n color_list.push('rgb(224, 47, 68)');\n } else if (value === 'nan') {\n color_list.push('rgb(143, 143, 145)');\n } else {\n color_list.push('#' + Math.floor(Math.random() * 16777215).toString(16)); // 随机颜色\n }\n });\n\n return_obj['color'] = color_list;\n\n // 配置 legend\n return_obj['legend'] = {\n data: dec_lis_sorted,\n left: 6,\n bottom: 0,\n itemWidth: 15,\n itemHeight: 5,\n padding: [10, 20, 16, 20]\n };\n\n // 配置 series 数据\n Object.entries(result).forEach((val, key) => {\n\n const values = Object.values(val[1]);\n let max = Math.max(...values);\n if (max > yAxisMax) yAxisMax = Math.ceil(max * 1.1); \n\n const tmp_obj = {};\n tmp_obj['name'] = dec_lis_sorted[key];\n tmp_obj['data'] = Object.values(val[1]); // 提取每个决策码对应的值\n tmp_obj['type'] = 'bar'; // 设置为柱状图\n tmp_obj['stack'] = 'x'; // 堆叠\n series_array[key] = tmp_obj;\n\n });\n\n // 配置 x 轴\n return_obj['xAxis'] = {\n data: time_range\n };\n // 配置 y 轴\n return_obj['yAxis'] = {\n min: 1,\n max: yAxisMax\n };\n\n // 将 series 加入返回对象\n return_obj['series'] = series_array;\n\n // 配置 tooltip\n return_obj['tooltip'] = {\n trigger: 'axis',\n axisPointer: {\n type: 'shadow'\n }\n };\n\n //console.log(return_obj); // 查看生成的返回对象\n return return_obj; // 返回最终结果\n}",
"google" : {
"callback" : "gmapReady",
"key" : ""
},
"map" : "json",
"renderer" : "canvas",
"themeEditor" : {
"config" : "{}",
"height" : 400,
"name" : "default"
},
"visualEditor" : {
"code" : "return {\n dataset: context.editor.dataset,\n series: context.editor.series,\n xAxis: {\n type: 'time',\n },\n yAxis: {\n type: 'value',\n min: 'dataMin',\n },\n}\n",
"dataset" : [ ],
"series" : [ ]
}
},
"pluginVersion" : "6.6.0",
"targets" : [ {
"alias" : "",
"bucketAggs" : [ {
"field" : "serverHour",
"id" : "2",
"settings" : {
"min_doc_count" : "0",
"order" : "asc",
"orderBy" : "_term",
"size" : "0"
},
"type" : "terms"
}, {
"field" : "feedbackInfo__authResult",
"id" : "3",
"settings" : {
"min_doc_count" : "0",
"order" : "asc",
"orderBy" : "_term",
"size" : "0"
},
"type" : "terms"
} ],
"datasource" : {
"type" : "elasticsearch",
"uid" : "f45b49c9-ba56-43c8-b278-a87adffdb57c"
},
"metrics" : [ {
"id" : "1",
"type" : "count"
} ],
"query" : "${decision_query:raw} AND diiaInfo__deviceInfo__udid:*",
"refId" : "A",
"timeField" : "create_datetime"
} ],
"title" : "A-07. 每日熱門的交易時段分析",
"type" : "volkovlabs-echarts-panel"
},
"version" : 12,
"meta" : {
"folderName" : "R97-Library",
"folderUid" : "bempo37hjqtq8d",
"connectedDashboards" : 2,
"created" : "2025-06-04T14:22:37+08:00",
"updated" : "2025-06-10T11:58:36+08:00",
"createdBy" : {
"avatarUrl" : "/avatar/ce6412d58e966caaa26cac12eb99734b",
"id" : 1,
"name" : "admin"
},
"updatedBy" : {
"avatarUrl" : "/avatar/ce6412d58e966caaa26cac12eb99734b",
"id" : 1,
"name" : "admin"
}
}
}
}
(14-14/26)