Fix bug when no options included in chart function
Browse files- functions/chart_functions.py +10 -7
functions/chart_functions.py
CHANGED
@@ -15,6 +15,7 @@ root_url = os.getenv("ROOT_URL")
|
|
15 |
def chart_generation_func(data: List[str], x_column: str, y_column: str, graph_type: str, session_hash: str, layout: Dict[str,str]={}, category: str=""):
|
16 |
print("CHART GENERATION")
|
17 |
print(data)
|
|
|
18 |
print(x_column)
|
19 |
print(y_column)
|
20 |
print(category)
|
@@ -24,10 +25,6 @@ def chart_generation_func(data: List[str], x_column: str, y_column: str, graph_t
|
|
24 |
chart_path = f'{dir_path}/chart.html'
|
25 |
csv_query_path = f'{dir_path}/query.csv'
|
26 |
|
27 |
-
#Processing data to account for variation from LLM
|
28 |
-
data_list = []
|
29 |
-
layout_dict = {}
|
30 |
-
|
31 |
df = pd.read_csv(csv_query_path)
|
32 |
|
33 |
if graph_type == "bar":
|
@@ -54,9 +51,15 @@ def chart_generation_func(data: List[str], x_column: str, y_column: str, graph_t
|
|
54 |
if isinstance(data, list):
|
55 |
data_list = data
|
56 |
else:
|
57 |
-
data_list.append(data)
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
if isinstance(data_obj, str):
|
61 |
data_obj = data_obj.replace("\n", "")
|
62 |
if not data_obj.startswith('{') and not data_obj.endswith('}'):
|
|
|
15 |
def chart_generation_func(data: List[str], x_column: str, y_column: str, graph_type: str, session_hash: str, layout: Dict[str,str]={}, category: str=""):
|
16 |
print("CHART GENERATION")
|
17 |
print(data)
|
18 |
+
print(graph_type)
|
19 |
print(x_column)
|
20 |
print(y_column)
|
21 |
print(category)
|
|
|
25 |
chart_path = f'{dir_path}/chart.html'
|
26 |
csv_query_path = f'{dir_path}/query.csv'
|
27 |
|
|
|
|
|
|
|
|
|
28 |
df = pd.read_csv(csv_query_path)
|
29 |
|
30 |
if graph_type == "bar":
|
|
|
51 |
if isinstance(data, list):
|
52 |
data_list = data
|
53 |
else:
|
54 |
+
data_list.append(data)
|
55 |
+
|
56 |
+
|
57 |
+
#Processing data to account for variation from LLM
|
58 |
+
data_list = []
|
59 |
+
layout_dict = {}
|
60 |
+
|
61 |
+
data_dict = {}
|
62 |
+
for data_obj in data_list:
|
63 |
if isinstance(data_obj, str):
|
64 |
data_obj = data_obj.replace("\n", "")
|
65 |
if not data_obj.startswith('{') and not data_obj.endswith('}'):
|