wei
2021-05-23 6aae0b4d094c54cd5d7d27cda7b439d9d62d0bc7
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using System;
using System.Collections.Generic;
 
namespace HDL_ON.UI
{
    /// <summary>
    /// 曲线图
    /// </summary>
    public class EchartsOption_BrokenLine
    {
        /// <summary>
        /// x轴数据
        /// </summary>
        public string XvalueText = "";
 
        /// <summary>
        /// Y轴数据
        /// </summary>
        public string YvalueText = "";
        /// <summary>
        /// x轴标题
        /// </summary>
        public string xTitle = "";
        /// <summary>
        /// y轴标题
        /// </summary>
        public string yTitle = "";
 
 
        /// <summary>
        /// 组装Option数据
        /// </summary>
        /// <returns></returns>
        public string InitOption()
        {
            //组装Value
            var newstring = optionString.Replace("{0}", XvalueText);
            newstring = newstring.Replace("{1}", YvalueText);
            newstring = newstring.Replace("{10}", xTitle);
            newstring = newstring.Replace("{20}", yTitle);
            return newstring;
        }
 
        /// <summary>
        /// 组装x轴文本
        /// </summary>
        /// <param name="xData"></param>
        public void InitXdataText(List<string> xData)
        {
            XvalueText = "";
            foreach (var data in xData)
            {
                XvalueText += "'" + data + "',";
            }
        }
 
        /// <summary>
        /// 组装y轴文本
        /// </summary>
        /// <param name="yData"></param>
        public string InitYdataText(string name, List<EnvironmentalSensorHistor> yData, string color)
        {
            //组装Value
            string valueText = string.Empty;
            var YvalueTextItem = @"{name:'{0}',
                            data:[{1}],
                            type:'line',
                            smooth:0.6,
                            symbol:'none',
                            color:'{2}'}
            ";
            YvalueTextItem = YvalueTextItem.Replace("{0}", name);
 
            foreach (var data in yData)
            {
                valueText += "'" + data.fieldValue + "',";
            }
            YvalueTextItem = YvalueTextItem.Replace("{1}", valueText);
            YvalueTextItem = YvalueTextItem.Replace("{2}", color);
 
            if (YvalueText == "")
            {
                YvalueText = YvalueTextItem;
            }
            else
            {
                YvalueText += "," + YvalueTextItem;
            }
 
            return YvalueTextItem;
        }
 
 
#if __IOS__
        public string optionString = @"{
                 tooltip: {
                    trigger: 'axis'
                    },
                    grid: {
                         top: '10%',
                        left: '10%',
                        right: '10%',
                        bottom: '10%',
                    },
                    xAxis: {
                        name: '{10}',
                        type: 'category',
                        boundaryGap: false,
                        data: [{0}],
                        axisLabel : {
                            fontSize:30,
                        },
                    },
                    yAxis: {
                        name: '{20}',
                        type: 'value',
                        axisLabel : {
                            fontSize:30,
                        },
                    },
                    series: [  
                        {1}
                    ]
            }";
#else
 public string optionString = @"{
                 tooltip: {
                    trigger: 'axis'
                    },
                    grid: {
                         top: '10%',
                        left: '10%',
                        right: '10%',
                        bottom: '10%',
                    },
                    xAxis: {
                        type: 'category',
                        boundaryGap: false,
                        data: [{0}],
                    },
                    yAxis: {
                        type: 'value',
                    },
                    series: [  
                        {1}
                    ]
            }";
#endif
 
        /// <summary>
        /// 颜色列表
        /// </summary>
        /// <returns></returns>
        public List<string> ColorList()
        {
            var list = new List<string>();
            return list;
        }
    }
 
}