專案

一般

配置概況

工作單 #200 » P9702003-每日風險預測結果(_) Business Chart.json

marlboro chu, 2025-06-30 01:59

 
{
"result" : {
"id" : 633,
"orgId" : 1,
"folderId" : 143,
"folderUid" : "bempo37hjqtq8d",
"uid" : "aeohp5fe6rr40b",
"name" : "P9702003-每日風險預測結果(%) Business Chart",
"kind" : 1,
"type" : "volkovlabs-echarts-panel",
"description" : "",
"model" : {
"datasource" : {
"type" : "elasticsearch",
"uid" : "f45b49c9-ba56-43c8-b278-a87adffdb57c"
},
"description" : "",
"fieldConfig" : {
"defaults" : { },
"overrides" : [ {
"matcher" : {
"id" : "byName",
"options" : "no_response"
},
"properties" : [ ]
}, {
"matcher" : {
"id" : "byName",
"options" : "mid"
},
"properties" : [ ]
}, {
"matcher" : {
"id" : "byName",
"options" : "low"
},
"properties" : [ ]
}, {
"matcher" : {
"id" : "byName",
"options" : "高風險"
},
"properties" : [ ]
}, {
"matcher" : {
"id" : "byName",
"options" : "02"
},
"properties" : [ ]
}, {
"matcher" : {
"id" : "byName",
"options" : "01"
},
"properties" : [ ]
}, {
"matcher" : {
"id" : "byName",
"options" : "03"
},
"properties" : [ ]
}, {
"matcher" : {
"id" : "byName",
"options" : "No Response"
},
"properties" : [ ]
}, {
"matcher" : {
"id" : "byName",
"options" : "一般風險"
},
"properties" : [ ]
} ]
},
"gridPos" : {
"h" : 9,
"w" : 12,
"x" : 12,
"y" : 28
},
"id" : 9702003,
"options" : {
"baidu" : {
"callback" : "bmapReady",
"key" : ""
},
"editor" : {
"format" : "auto"
},
"editorMode" : "visual",
"gaode" : {
"key" : "",
"plugin" : "AMap.Scale,AMap.ToolBar"
},
"getOption" : "const series = context.panel.data.series.map((s) => {\n const sData = s.fields.find((f) => f.type === 'number').values.buffer || s.fields.find((f) => f.type === 'number').values;\n const sTime = s.fields.find((f) => f.type === 'time').values.buffer || s.fields.find((f) => f.type === 'time').values;\n \n return {\n name: s.refId,\n type: 'line',\n showSymbol: false,\n areaStyle: {\n opacity: 0.1,\n },\n lineStyle: {\n width: 1,\n },\n data: sData.map((d, i) => [sTime[i], d.toFixed(2)]),\n };\n});\n\n/**\n * Enable Data Zoom by default\n */\nsetTimeout(() => context.panel.chart.dispatchAction({\n type: 'takeGlobalCursor',\n key: 'dataZoomSelect',\n dataZoomSelectActive: true,\n}), 500);\n\n/**\n * Update Time Range on Zoom\n */\ncontext.panel.chart.on('datazoom', function (params) {\n const startValue = params.batch[0]?.startValue;\n const endValue = params.batch[0]?.endValue;\n locationService.partial({ from: startValue, to: endValue });\n});\n\nreturn {\n backgroundColor: 'transparent',\n tooltip: {\n trigger: 'axis',\n },\n legend: {\n left: '0',\n bottom: '0',\n data: context.panel.data.series.map((s) => s.refId),\n textStyle: {\n color: 'rgba(128, 128, 128, .9)',\n },\n },\n toolbox: {\n feature: {\n dataZoom: {\n yAxisIndex: 'none',\n icon: {\n zoom: 'path://',\n back: 'path://',\n },\n },\n saveAsImage: {},\n }\n },\n xAxis: {\n type: 'time',\n },\n yAxis: {\n type: 'value',\n min: 'dataMin',\n },\n grid: {\n left: '2%',\n right: '2%',\n top: '2%',\n bottom: 24,\n containLabel: true,\n },\n series,\n};",
"google" : {
"callback" : "gmapReady",
"key" : ""
},
"map" : "none",
"renderer" : "canvas",
"themeEditor" : {
"config" : "{}",
"name" : "default"
},
"visualEditor" : {
"code" : "function extractSeriesData(series) {\n const seriesMap = {};\n const timestampSet = new Set();\n\n series.forEach(serie => {\n const name = serie.name.toLowerCase();\n const timeField = serie.fields.find(f => f.name === 'Time');\n const valueField = serie.fields.find(f => f.name !== 'Time');\n\n const times = timeField.values.toArray();\n const values = valueField.values.toArray();\n\n // 收集 timestamp\n times.forEach(ts => timestampSet.add(ts));\n\n // 建立 timestamp -> value 的 Map\n const valueMap = new Map(times.map((ts, i) => [ts, values[i]]));\n\n seriesMap[name] = valueMap;\n });\n\n return { seriesMap, timestampSet };\n}\n\nfunction formatTimestamps(timestampSet) {\n return Array.from(timestampSet)\n .sort()\n .map(ts => {\n const d = new Date(ts);\n return `${(d.getMonth() + 1).toString().padStart(2, '0')}/${d.getDate().toString().padStart(2, '0')}`;\n });\n}\n\nfunction buildSeriesValues(seriesMap, allTimestamps, name) {\n const valueMap = seriesMap[name] || new Map();\n return allTimestamps.map(ts => valueMap.get(ts) ?? 0);\n}\n\n\nconst { seriesMap, timestampSet } = extractSeriesData(context.panel.data.series);\n\nconst allTimestamps = Array.from(timestampSet).sort();\nconst xAxisData = formatTimestamps(timestampSet);\n\nconst dataMid = buildSeriesValues(seriesMap, allTimestamps, 'mid');\nconst dataLow = buildSeriesValues(seriesMap, allTimestamps, 'low');\nconst dataHigh = buildSeriesValues(seriesMap, allTimestamps, 'high');\n\n\n\nconst dataTotal = dataMid.map((val, idx) => {\n return val + (dataHigh[idx] || 0) + (dataLow[idx] || 0); // 防止 undefined\n});\n\nconst dataNormal = dataMid.map((val, idx) => {\n return val + (dataLow[idx] || 0); // 防止 undefined\n});\n\nconst dataHighPercentage = dataHigh.map((val, idx) => {\n let total = dataTotal[idx] || 1; // 防止除以 0\n return +(val / total * 100).toFixed(2); // 四捨五入兩位\n});\n\nconst dataNormalPercentage = dataNormal.map((val, idx) => {\n let total = dataTotal[idx] || 1; // 防止除以 0\n return +(val / total * 100).toFixed(2); // 四捨五入兩位\n});\n\n\nconst seriesConfig = [\n {\n name: '高風險',\n data: dataHighPercentage,\n color: 'rgb(196, 22, 42)'\n },\n {\n name: '一般風險',\n data: dataNormalPercentage,\n color: 'rgb(55, 135, 45)'\n }\n];\n\nconst seriesData = seriesConfig.map(cfg => ({\n name: cfg.name,\n type: 'bar',\n data: cfg.data,\n stack: 'line',\n itemStyle: {\n color: cfg.color\n }\n}));\n\noption = {\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n type: 'line' // 或 'line',視覺效果不同\n },\n formatter: function (params) {\n let tooltipText = params[0].axisValue + '<br/>';\n params.forEach(item => {\n tooltipText += `${item.marker} ${item.seriesName}: ${item.data}%<br/>`;\n });\n return tooltipText;\n }\n },\n legend: {\n left: 'left',\n bottom: '0%',\n itemHeight: 5,\n itemWidth: 15,\n padding: [10, 20, 16, 20]\n },\n xAxis: {\n type: 'category',\n data: xAxisData\n },\n yAxis: {\n type: 'value',\n min: 0,\n max: 100,\n axisLabel: {\n formatter: value => value + '%'\n }\n },\n series: seriesData\n};\n\nreturn option;",
"dataset" : [ ],
"series" : [ ]
}
},
"pluginVersion" : "6.6.0",
"targets" : [ {
"alias" : "",
"bucketAggs" : [ {
"field" : "resultInfo__decisionCode",
"id" : "2",
"settings" : {
"min_doc_count" : "0",
"missing" : "未回應",
"order" : "desc",
"orderBy" : "1",
"size" : "0"
},
"type" : "terms"
}, {
"field" : "create_datetime",
"id" : "4",
"settings" : {
"interval" : "1d",
"min_doc_count" : "0",
"timeZone" : "Asia/Taipei",
"trimEdges" : "0"
},
"type" : "date_histogram"
} ],
"datasource" : {
"type" : "elasticsearch",
"uid" : "f45b49c9-ba56-43c8-b278-a87adffdb57c"
},
"metrics" : [ {
"id" : "1",
"type" : "count"
} ],
"query" : "${decision_query:raw} AND resultInfo__decisionCode : *",
"refId" : "A",
"timeField" : "create_datetime"
} ],
"title" : "B-03. 高風險交易佔比",
"type" : "volkovlabs-echarts-panel"
},
"version" : 4,
"meta" : {
"folderName" : "R97-Library",
"folderUid" : "bempo37hjqtq8d",
"connectedDashboards" : 3,
"created" : "2025-06-10T09:30:29+08:00",
"updated" : "2025-06-10T15:57:26+08:00",
"createdBy" : {
"avatarUrl" : "/avatar/ce6412d58e966caaa26cac12eb99734b",
"id" : 1,
"name" : "admin"
},
"updatedBy" : {
"avatarUrl" : "/avatar/ce6412d58e966caaa26cac12eb99734b",
"id" : 1,
"name" : "admin"
}
}
}
}
(19-19/26)