添加颜色信息 修改属性

This commit is contained in:
XXAY
2021-09-21 11:47:36 +08:00
parent fd86ceed02
commit 3cf5a291dd
5 changed files with 39 additions and 130 deletions

View File

@@ -9,6 +9,13 @@ from Simple_Drawing.settings import BASE_DIR
url_ = "127.0.0.1:8000"
def random_color():
color_list = ["#009688", '#5FB878', '#393D49',
'#1E9FFF', '#FFB800', '#FF5722',
'#01AAED', '#2F4056']
return random.choice(color_list)
# 保存单个文件
def keep_file(file_data, file_path, file_name=None, ui=0):
if file_name is not None:
@@ -87,7 +94,6 @@ class ChartParameter(object):
if 'Senior' in data:
self.Senior = data['Senior']
self.colors = 0
self.colors_dict = {}
def html_out_Basics(self):
@@ -121,18 +127,18 @@ class ChartParameter(object):
style="height: 25px; width:80px;margin-top: 6px">
"""
if parameter.input_type == "color_name":
self.colors_dict[f"color{self.colors}"] = "color_name"
self.colors_dict[f"{parameter.name}"] = "color_name"
parameter.input_type = f"""
<div style="margin-left: 30px;">
<div id="color{self.colors}" style="margin-left: 30px; display: inline-block"></div>
<div id="{parameter.name}" style="margin-left: 30px; display: inline-block"></div>
</div>
"""
self.colors += 1
if parameter.input_type == "rgb":
self.colors_dict[f"color{self.colors}"] = "rgb"
self.colors_dict[f"{parameter.name}"] = "rgb"
f"""
<div style="margin-left: 30px;">
<div id="color{self.colors}" style="margin-left: 30px; display: inline-block"></div>
<div id="{parameter.name}" style="margin-left: 30px; display: inline-block"></div>
</div>
"""
self.colors += 1
@@ -239,21 +245,21 @@ class="layui-input" style="height: 25px; width:80px;margin-top: 6px">
style="height: 25px; width:80px;margin-top: 6px">
"""
if parameter.input_type == "color_name":
self.colors_dict[f"color{self.colors}"] = "color_name"
self.colors_dict[f"{parameter.name}"] = "color_name"
parameter.input_type = f"""
<div style="margin-left: 30px;">
<div id="color{self.colors}" style="margin-left: 30px; display: inline-block"></div>
<div id="{parameter.name}" style="margin-left: 30px; display: inline-block"></div>
</div>
"""
self.colors += 1
if parameter.input_type == "rgb":
self.colors_dict[f"color{self.colors}"] = "rgb"
self.colors_dict[f"{parameter.name}"] = "rgb"
f"""
<div style="margin-left: 30px;">
<div id="color{self.colors}" style="margin-left: 30px; display: inline-block"></div>
<div id="{parameter.name}" style="margin-left: 30px; display: inline-block"></div>
</div>
"""
self.colors += 1
if parameter.input_type == "palettes":
parameter.input_type = f"""
<select {parameter.astrict} id="{parameter.name}" lay-verify="required" value="{parameter.value}" autocomplete="off"
@@ -330,13 +336,24 @@ class="layui-input" style="height: 25px; width:80px;margin-top: 6px">
for title in self.Basics:
for d in self.Basics[title]:
parameter = ChartParameter(d)
if parameter.input_type in ["rgb","hex",'color_name']:
code += f"""{parameter.name}:{parameter.name},
"""
else:
code += f"""{parameter.name}: (document.getElementById("{parameter.name}").value),
"""
print(parameter.input_type)
for title in self.Senior:
for d in self.Senior[title]:
parameter = ChartParameter(d)
print(parameter.input_type)
if parameter.input_type in ["rgb", "hex",'color_name']:
code += f"""{parameter.name}:{parameter.name},
"""
else:
code += f"""{parameter.name}: (document.getElementById("{parameter.name}").value),
"""
"""
return code
def color_js(self):
@@ -353,16 +370,17 @@ class="layui-input" style="height: 25px; width:80px;margin-top: 6px">
, colorpicker = layui.colorpicker;
colorpicker.render({
elem: '%s'
, color: '#2ec770' //设置默认色
elem: '#%s'
, color: '%s' //设置默认色
, size: "xs"
, format: '%s'
, done: function (color) {
layer.tips('选择了:' + color, this.elem);
var %s = color
}
});
})
""" % (i, fl)
""" % (i, random_color(), fl,i)
return code

View File

@@ -46,21 +46,12 @@ def out_page(request, page):
# 处理上传文件 返回颜色列表
def up_file(request):
file = request.FILES.get("file")
col_name = request.POST.get("col_name", "color")
if col_name == "NO":
file_path, file_id = path_out("chart")
keep_file(file, file_path)
data = {"flag": file_id}
return JsonResponse(data)
file_path, file_id = path_out("chart")
keep_file(file, file_path)
col_list = pick_col(file_path, col_name)
data = {"flag": file_id, 'data': [{"title": f"color_{i}", 'name': i, } for i in col_list][:8]}
return JsonResponse(data)

View File

@@ -1,50 +0,0 @@
area,poptotal,color
0.052,66090,AAR
0.014,10626,AAR
0.022,14991,AAR
0.017,30806,AAR
0.018,5836,AAR
0.05,35688,AAR
0.017,5322,AAR
0.027,16805,AAR
0.024,13437,AAR
0.042,34418,AAR
0.03,15921,AAR
0.028,14460,AAR
0.029,33944,AAR
0.03,51644,AAR
0.026,19464,AAR
0.02,10670,AAR
0.038,77932,AAR
0.023,16516,AAR
0.025,19464,AAR
0.036,19595,AAR
0.014,7440,AAR
0.028,31704,AAR
0.044,20893,AAR
0.03,14275,AAR
0.025,40319,LHR
0.052,38080,LHR
0.019,6909,LHR
0.033,15317,LHR
0.026,32337,LHR
0.025,8499,LHR
0.047,21373,LHR
0.009,5189,LHR
0.023,8096,LHR
0.051,51159,AAL
0.067,30787,AAL
0.036,61067,AAL
0.029,10609,AAL
0.033,37020,AAL
0.023,20539,AAL
0.035,21821,AAL
0.02,11347,AAL
0.018,39413,AAL
0.042,56393,AAL
0.022,15972,AAL
0.043,34392,AAL
0.062,39301,AAL
0.036,30798,AAL
0.034,35244,AAL
0.05,47679,AAL

View File

@@ -1,50 +0,0 @@
area,poptotal,color
0.052,66090,AAR
0.014,10626,AAR
0.022,14991,AAR
0.017,30806,AAR
0.018,5836,AAR
0.05,35688,AAR
0.017,5322,AAR
0.027,16805,AAR
0.024,13437,AAR
0.042,34418,AAR
0.03,15921,AAR
0.028,14460,AAR
0.029,33944,AAR
0.03,51644,AAR
0.026,19464,AAR
0.02,10670,AAR
0.038,77932,AAR
0.023,16516,AAR
0.025,19464,AAR
0.036,19595,AAR
0.014,7440,AAR
0.028,31704,AAR
0.044,20893,AAR
0.03,14275,AAR
0.025,40319,LHR
0.052,38080,LHR
0.019,6909,LHR
0.033,15317,LHR
0.026,32337,LHR
0.025,8499,LHR
0.047,21373,LHR
0.009,5189,LHR
0.023,8096,LHR
0.051,51159,AAL
0.067,30787,AAL
0.036,61067,AAL
0.029,10609,AAL
0.033,37020,AAL
0.023,20539,AAL
0.035,21821,AAL
0.02,11347,AAL
0.018,39413,AAL
0.042,56393,AAL
0.022,15972,AAL
0.043,34392,AAL
0.062,39301,AAL
0.036,30798,AAL
0.034,35244,AAL
0.05,47679,AAL

View File

@@ -176,7 +176,7 @@
var upload = layui.upload;
var uploadInst = upload.render({
elem: '#up_file' //绑定元素
elem: '#upload' //绑定元素
, url: url_ip + '/chart/up_file/' // 上传的路径
, accept: 'file' // 类型 可以控制上传文件的类型
// 支持附带上传参数