diff --git a/chart/tools.py b/chart/tools.py index 7f58d29..eca836f 100644 --- a/chart/tools.py +++ b/chart/tools.py @@ -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"""
-
+
""" - self.colors += 1 + if parameter.input_type == "rgb": - self.colors_dict[f"color{self.colors}"] = "rgb" + self.colors_dict[f"{parameter.name}"] = "rgb" f"""
-
+
""" 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"""
-
+
""" - self.colors += 1 + if parameter.input_type == "rgb": - self.colors_dict[f"color{self.colors}"] = "rgb" + self.colors_dict[f"{parameter.name}"] = "rgb" f"""
-
+
""" - self.colors += 1 + if parameter.input_type == "palettes": parameter.input_type = f"""