make charts interactive
#8
by
nolanzandi
- opened
functions/chart_functions.py
CHANGED
|
@@ -1,9 +1,5 @@
|
|
| 1 |
from typing import List
|
| 2 |
-
from haystack import component
|
| 3 |
-
import pandas as pd
|
| 4 |
from quickchart import QuickChart
|
| 5 |
-
import json
|
| 6 |
-
import ast
|
| 7 |
|
| 8 |
def chart_generation_func(queries: List[str], session_hash):
|
| 9 |
print("CHART GENERATION")
|
|
@@ -17,8 +13,11 @@ def chart_generation_func(queries: List[str], session_hash):
|
|
| 17 |
# Config can be set as a string or as a nested dict
|
| 18 |
qc.config = query_dict
|
| 19 |
|
|
|
|
|
|
|
| 20 |
# You can get the chart URL...
|
|
|
|
| 21 |
|
| 22 |
-
iframe = '<iframe\n scrolling="yes"\n width="1000px"\n height="500px"\n src="' +
|
| 23 |
|
| 24 |
return {"reply": iframe}
|
|
|
|
| 1 |
from typing import List
|
|
|
|
|
|
|
| 2 |
from quickchart import QuickChart
|
|
|
|
|
|
|
| 3 |
|
| 4 |
def chart_generation_func(queries: List[str], session_hash):
|
| 5 |
print("CHART GENERATION")
|
|
|
|
| 13 |
# Config can be set as a string or as a nested dict
|
| 14 |
qc.config = query_dict
|
| 15 |
|
| 16 |
+
url_id = qc.get_short_url().rsplit('/', 1)[-1]
|
| 17 |
+
url_base = qc.get_url_base()
|
| 18 |
# You can get the chart URL...
|
| 19 |
+
interactive_url = url_base + '/chart-maker/view/' + url_id
|
| 20 |
|
| 21 |
+
iframe = '<div style=overflow:auto;><iframe\n scrolling="yes"\n width="1000px"\n height="500px"\n src="' + interactive_url + '"\n frameborder="0"\n allowfullscreen\n></iframe>\n</div>'
|
| 22 |
|
| 23 |
return {"reply": iframe}
|