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
125
126
127
128
129
| --[[
| 编码: JX-800-02
| 名称: 巷道料箱空满状态
| 作者:HAN
| 日期:2025-1-29
|
| 级别: 固定 (说明本段代码在项目中不太会变化)
|
| 函数: GenChartJson
|
| 功能:
| 统计作业各种状态的数量(测试一下用)
|
| 更改记录:
|
| --]]
|
| json = require ("json")
| mobox = require ("OILua_JavelinExt")
| m3 = require("oi_base_mobox")
|
| function GenChartJson(strLuaDEID)
| local nRet, strRetInfo
| --[[ 标题颜色 ]]
| local strTitle = "巷道料箱空满"
| --[[ 文字颜色 ]]
| local strColor = "#fff"
| --[[ 柱状图柱子名称,对应 series 下name ]]
| local tabLegendData = {'满', '空'}
| --[[ X轴数据 从左向右 ]]
| local tabXAxis = {'巷道1', '巷道2', '巷道3', '巷道4'}
| --[[ Y轴 最上方显示文字 ]]
| local strYAxisName = "货位数量"
| --[[ 满仓颜色 ]]
| local strMCColor = '#45A048'
| --[[ 空仓颜色 ]]
| local strKCColor = '#FE9700'
| --[[ 柱状图数据 对应X轴数据 ]]
| --[[ 满 ]]
| local tabSeriesMCData = {400, 360, 350, 340, 330, 325, 324, 300}
| --[[ 空 ]]
| local tabSeriesKCData = {180, 170, 160, 150, 130, 120, 110, 100}
|
| local option = {
| title = {
| text = strTitle,
| left = 20,
| textStyle = {
| color = strColor
| },
| top = 10
| },
| legend = {
| data = tabLegendData,
| textStyle = {
| color = strColor
| },
| top = 10
| },
| grid = {
| left = '5%',
| right = '5%',
| bottom = '5%',
| top = '22%',
| containLabel = true
| },
| xAxis = {
| type = 'category',
| data = tabXAxis,
| axisLabel = {
| textStyle = {
| color = strColor
| }
| }
| },
| yAxis = {
|
| type = 'value',
| nameTextStyle = {
| color = strColor
| },
| axisLabel = {
| textStyle = {
| color = strColor
| }
| }
| },
| series = {
| {
| name = '满',
| type = 'bar',
| stack = 'total',
| label = { show = true },
| color = strMCColor,
| data = tabSeriesMCData
| },
| {
| name = '空',
| type = 'bar',
| stack = 'total',
| label = { show = true },
| color = strKCColor,
| data = tabSeriesKCData
| }
| }
| }
|
| local action = {
| {
| action_type = "chart",
| value = {
| graphicType = "echart",
| title = {
| text = strTitle,
| align = "center",
| color = "#515a6e",
| 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
|
|