1
Jianw
9 天以前 f6f5e6b632d6649386a380558d84003f3de7ec6c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
--[[
    Code: 
    Author:    
    Create Date:  2025-1-29
    Version:V1.0
    功能:
       普通单饼图
    主函数:
        GenChartJson
   
--]] 
 
json = require("json")
mobox = require("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function GenChartJson(strLuaDEID)
    local nRet, strRetInfo
    --[[ 标题 ]]
    local strTitle = "作业状态"
    --[[ 颜色 ]]
    --[[ 标题颜色  黑:#515a6e,白:#fff]]
    local strTitleColor = "#696969"
    --[[ 来源数据 ]]
    local tableData = {{
        name = "正在执行",
        value = 82,
        color = "#5673CC"
    }, {
        name = "完成",
        value = 65,
        color = "#91CC75"
    }, {
        name = "暂停",
        value = 20,
        color = "#F06767"
    }, {
        name = "取消",
        value = 5,
        color = "#FAC858"
    }}
 
    --[[ 饼图数据]]
    local tableSeriesData = {}
    --[[ 饼图块颜色]]
    local tableSeriesColor = {};
    for i = 1, #tableData do
        table.insert(tableSeriesData, {
            value = tableData[i].value,
            name = tableData[i].name
        })
        table.insert(tableSeriesColor, tableData[i].color)
    end
    --[[ 
            1.title = { :echart标题配置
            2. left = 15 :距离右边距离,居中left="center"
            3. tooltip 鼠标焦点展示内容
            4. series 下  formatter = " {b|{b}}{abg|} {c|{c}} ", 饼图显示数据内容
    ]]
    -- 返回
    local option = {
        title = {
            text = strTitle,
            left = 15,
            textStyle = {
                color = strTitleColor
            }
        },
        tooltip = {
            trigger = "item",
            formatter = " {b}: {c} ({d}%) "
        },
        series = {
            name = "",
            type = "pie",
            radius = "50%",
            label = {
                normal = {
                    formatter = " {b|{b}}{abg|} {c|{c}} ",
                    backgroundColor = "#fff",
                    borderColor = "#aaa",
                    borderWidth = 1,
                    borderRadius = 4,
                    shadowBlur = 3,
                    padding = {0, 2},
                    rich = {
                        b = {
                            color = "#7F7F7F",
                            lineHeight = 22,
                            align = "center"
                        },
                        c = {
                            fontSize = 12,
                            lineHeight = 22
                        }
 
                    }
                }
            },
            data = tableSeriesData,
            color = tableSeriesColor
        }
    }
 
    local action = {}
    action[1] = {
        action_type = "chart",
        value = {
            graphicType = "echart",
            title = {
                test = strTitle,
                align = "center",
                color = strTitleColor,
                font = "微软雅黑",
                fontSize = 12
            },
            option = option
        }
    }
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo .. ' action = ' .. strAction)
    end
end