13693261870
2024-04-02 2a1b873b4b78b508d5d53c57992e734c56619df8
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
var first = "", second = "";
window.onload = function () {
    first = decodeURI(getUrlParam("first"));
    second = decodeURI(getUrlParam("second"));
    GetData(first, second);
 
    btnClick();
    new CusScrollBar({
        contentSelector: '.scroll_cont1', //滚动内容区
        barSelector: '.scroll_bar1', //滚动条
        sliderSelector: '.scroll_slider1' //滚动滑块
    });
    var title = localStorage.getItem("typeName");
    $(".ttitle").empty();
    $(".ttitle").append(title);
}
 
 
function GetData(first,second) {
    var color = [];
    var dataLegend = [];
    var dataY = [];
    var TableName = localStorage.getItem("type");
    var TableColor = GetCmpareTable(TableName);
    var html = "";
    $.ajax({
        url: "../../../Ashx/DataQH.ashx",
        type: "post",
        data: { Action: "GetFZDataChoose", firstLevel: first, secondLevel: second, dataTable: TableName, colorTable: TableColor },
        dataType: "json",
        async: false,
        success: function (result) {
            if (first == ""|second=="") {
                DanxuanChart(result);
            } else {
                DuoxuanChart(result);
            }
            
 
        }
    });
 
}
 
function DanxuanChart(result) {
    var dataLegend = [];
    var  color = [];
    var dataY = [];
    var html = "";
    $.each(result, function (index, value) {
        html += "<tr style='background-color:rgb(" + value.R + "," + value.G + "," + value.B + ");'><td>" + value.Name + "</td><td>" + parseFloat(value.Area).toFixed(2) + "</td><td>" + parseFloat(value.ZhouChang).toFixed(2) + "</td></tr>";
        dataLegend.push(value.Name);
        color.push("rgb("+value.R+","+value.G+","+value.B+")");
        dataY.push(value.Area);
    })
 
    
    
 
    var dom = document.getElementById("container");
    var myChart = echarts.init(dom);
    option = {
        grid: {
            top: '5%',
            left: '23%',
            bottom: '15%'
        },
       // color: color,
        tooltip: {
            trigger: 'axis',
            confine: 'hidden',
            axisPointer: {
                type: 'shadow'
            }
        },
        legend: {
            show: false,
            data: dataLegend
        },
 
        xAxis: [
            {
                type: 'category',
                axisTick: { show: false },
                axisLine: {
                    lineStyle: {
                        color: '#fff'
                    }
                },
                axisLabel: {
                    formatter: '{value}',
                    textStyle: { //改变刻度字体样式
                        color: '#fff'
                    }
                },
                data: dataLegend
            }
        ],
        yAxis: [
            {
                type: 'value',
                splitLine: {
                    show: false,
 
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff'
                    }
                },
                axisLabel: {
                    formatter: '{value}',
                    textStyle: { //改变刻度字体样式
                        color: '#fff'
                    }
                }
            }
        ],
        series: [{
            data: dataY,
            type: 'bar',
            itemStyle: {
                normal: {
                    //每根柱子颜色设置
                    color: function (params) {
                        let colorList =color;
                        return colorList[params.dataIndex];
                    }
                }
            }
        }]
    };;
    if (option && typeof option === "object") {
        myChart.setOption(option, true);
    }
   //表格添加数据
 
    $(".scroll_cont1 table").empty();
    $(".scroll_cont1 table").append("<tr><td>名称</td><td>面积</td><td>周长</td></tr>" + html);
}
 
function DuoxuanChart(result) {
    var  code = "",pname="";
    var dataLegned = [];
    var DataY = [];
    var DataYparent = [];
    var DataYSon = [];
    var html = "";
    $.each(result, function (index, value) {
        html += "<tr style='background-color:rgb(" + value.R + "," + value.G + "," + value.B + ");'><td>" + value.Name + "</td><td>" + parseFloat(value.Area).toFixed(2) + "</td><td>" + parseFloat(value.ZhouChang).toFixed(2) + "</td></tr>";
        var rgb = "rgb(" + value.R + "," + value.G + "," + value.B + ")";
        var dv = new dataEve(parseFloat(value.Area).toFixed(2), rgb);
        if (value.Type == "parent") {
            
            code = value.Code;
            pname = value.Name;
            DataYparent.push(dv);
            var itemy = new item();
            itemy.name = value.Name;
            itemy.type = "bar";
            itemy.barMaxWidth = 20;
            itemy.data = DataYparent;
            DataY.push(itemy);
            DataYparent = [];
        } else {
            if (code != "" & ((code == value.code) | code == value.Code.substring(0, code.length)))
            {
                 DataYSon.push(dv);
                 var itemson = new itemSon();
                 itemson.name = value.Name;
                 itemson.type = "bar";
                 itemson.stack = pname;
                 itemson.barMaxWidth = 5;
                 itemson.data = DataYSon;
                 DataY.push(itemson);
                 DataYSon = [];
            } else {
                DataYparent.push(dv);
                var itemy = new item();
                itemy.name = value.Name;
                itemy.type = "bar";
                itemy.barMaxWidth = 20;
                itemy.data = DataYparent;
                DataY.push(itemy);
                DataYparent = [];
            }
 
            
        }
    });
 
    var dom = document.getElementById("container");
    var myChart = echarts.init(dom);
    option = {
        grid: {
            left: '5%',   // 与容器左侧的距离
            //right: '5%', // 与容器右侧的距离
            top: '10%',   // 与容器顶部的距离
            bottom: '5%', // 与容器底部的距离
            containLabel: true
        },
        tooltip: {
            trigger: 'axis',
            confine: 'hidden',
            axisPointer: {            // 坐标轴指示器,坐标轴触发有效
                type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
            }
        },
        legend: {
            data: dataLegned
        },
        xAxis: [
            {
                type: 'category',
                data: [2014],
                axisLine: {
                    lineStyle: {
                        color: '#fff'
                    }
                },
                axisLabel: {
                    formatter: '{value}',
                    textStyle: { //改变刻度字体样式
                        color: '#fff'
                    }
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                splitLine: {
                    show: false,
 
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff'
                    }
                },
                axisLabel: {
                    formatter: '{value}',
                    textStyle: { //改变刻度字体样式
                        color: '#fff'
                    }
                }
            }
        ],
        series:DataY
    };
    if (option && typeof option === "object") {
        myChart.setOption(option, true);
    }
    $(".scroll_cont1 table").empty();
    $(".scroll_cont1 table").append("<tr><td>名称</td><td>面积</td><td>周长</td></tr>" + html);
 
}
 
 
var item = function (name, type, width, dataEve) {
    return {
        name: name,
        type: type,
        barMaxWidth: width,
        data: dataEve
    }
}
 
var itemSon = function (name, type, pname, width,dataEve) {
    return{
        name: name,
        type: type,
        stack: pname,
        barMaxWidth:width,
        data: dataEve
    }
}
 
var dataEve = function (val,rgb) {
   return {
        value:val,
        itemStyle: {
            color: rgb
        }
    }
}
 
 
 
 
function uniq(array) {
    var temp = []; //一个新的临时数组
    for (var i = 0; i < array.length; i++) {
        if (temp.indexOf(array[i]) == -1) {
            temp.push(array[i]);
        }
    }
    return temp;
}
 
 
function btnClick() {
    $(".chartBtn").click(function () {
        $("#container").css("display", "block");
        $("#dataTable").css("display", "none");
        $(".dataBtn").css("color", "#ffffff");
        $(".chartBtn").css("color", "aqua");
    });
 
    $(".dataBtn").click(function () {
        $("#container").css("display", "none");
        $("#dataTable").css("display", "block");
        $(".dataBtn").css("color", "aqua");
        $(".chartBtn").css("color", "#ffffff");
    });
}