-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
105 lines (88 loc) · 2.42 KB
/
data.py
File metadata and controls
105 lines (88 loc) · 2.42 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2020/8/26 14:48
# @Author : way
# @Site :
# @Describe:
import json
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="719458145",
database="bank_index",
auth_plugin='mysql_native_password'
)
# @property
def echart1(month):
#------------------------雷达图1-----------------
mycursor = mydb.cursor()
#
mycursor.execute("SELECT * FROM radar1 Where MONTH(date)="+month+" order BY name")
#
data1= mycursor.fetchall()
mycursor.execute("SELECT * FROM radar1_industry Where MONTH(date)="+month+" order BY name")
data2 = mycursor.fetchall()
jsonData1 = []
jsonData2 = []
for row in data1:
result = {}
result['value'] = row[2]
jsonData1.append(result)
# print(jsonData1)
for row in data2:
result = {}
result['value'] = row[2]
jsonData2.append(result)
# print(jsonData2)
try:
echart = {
'title1':"本行",
'xAxis1': [i.get("value") for i in jsonData1],
'title2': "行业",
'xAxis2': [i.get("value") for i in jsonData2]
}
return echart
except:
print("Error")
mycursor.close()
return echart
def echart2(month):
# ------------------------1113尝试-----------------
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM radar2 Where MONTH(date)="+month+" order BY name")
data1 = mycursor.fetchall()
mycursor.execute("SELECT * FROM radar2_industry Where MONTH(date)=" + month +" Order by name")
data2 = mycursor.fetchall()
jsonData1 = []
jsonData2 = []
for row in data1:
result = {}
result['value'] = row[2]
jsonData1.append(result)
# print(jsonData1)
for row in data2:
result = {}
result['value'] = row[2]
jsonData2.append(result)
# print(jsonData2)
try:
echart = {
'title1': "本行",
'xAxis1': [i.get("value") for i in jsonData1],
'title2': "参照值",
'xAxis2': [i.get("value") for i in jsonData2]
}
return echart
except:
print("Error")
mycursor.close()
return echart
@property
def map_1(self):
data = self.map_1_data
echart = {
'symbolSize': data.get('symbolSize'),
'data': data.get('data'),
}
return echart