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
import gradio as gr
|
2 |
|
3 |
from concept_map_generator import generate_concept_map
|
@@ -5,8 +247,10 @@ from synoptic_chart_generator import generate_synoptic_chart
|
|
5 |
from radial_diagram_generator import generate_radial_diagram
|
6 |
from process_flow_generator import generate_process_flow_diagram
|
7 |
from wbs_diagram_generator import generate_wbs_diagram
|
|
|
|
|
8 |
|
9 |
-
from sample_data import CONCEPT_MAP_JSON, SYNOPTIC_CHART_JSON, RADIAL_DIAGRAM_JSON, PROCESS_FLOW_JSON, WBS_DIAGRAM_JSON
|
10 |
|
11 |
if __name__ == "__main__":
|
12 |
DEFAULT_BASE_COLOR = '#19191a'
|
@@ -232,6 +476,66 @@ if __name__ == "__main__":
|
|
232 |
with gr.Row(elem_classes=["example-images"]):
|
233 |
gr.Image(value="./images/wd1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
234 |
gr.Image(value="./images/wd2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
demo.launch(
|
237 |
mcp_server=True,
|
|
|
1 |
+
# import gradio as gr
|
2 |
+
|
3 |
+
# from concept_map_generator import generate_concept_map
|
4 |
+
# from synoptic_chart_generator import generate_synoptic_chart
|
5 |
+
# from radial_diagram_generator import generate_radial_diagram
|
6 |
+
# from process_flow_generator import generate_process_flow_diagram
|
7 |
+
# from wbs_diagram_generator import generate_wbs_diagram
|
8 |
+
|
9 |
+
# from sample_data import CONCEPT_MAP_JSON, SYNOPTIC_CHART_JSON, RADIAL_DIAGRAM_JSON, PROCESS_FLOW_JSON, WBS_DIAGRAM_JSON
|
10 |
+
|
11 |
+
# if __name__ == "__main__":
|
12 |
+
# DEFAULT_BASE_COLOR = '#19191a'
|
13 |
+
|
14 |
+
# with gr.Blocks(
|
15 |
+
# title="Advanced Graph Generator",
|
16 |
+
# css="""
|
17 |
+
# .gradio-container {
|
18 |
+
# font-family: 'Inter', sans-serif !important;
|
19 |
+
# }
|
20 |
+
# .gr-tab-item {
|
21 |
+
# padding: 10px 20px;
|
22 |
+
# font-size: 1.1em;
|
23 |
+
# font-weight: bold;
|
24 |
+
# }
|
25 |
+
# .gr-button {
|
26 |
+
# border-radius: 8px;
|
27 |
+
# box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
28 |
+
# background-color: #FFA500;
|
29 |
+
# color: white;
|
30 |
+
# padding: 10px 20px;
|
31 |
+
# font-size: 1.1em;
|
32 |
+
# }
|
33 |
+
# .gr-button:hover {
|
34 |
+
# background-color: #FF8C00;
|
35 |
+
# }
|
36 |
+
# .gr-textbox {
|
37 |
+
# border-radius: 8px;
|
38 |
+
# padding: 10px;
|
39 |
+
# }
|
40 |
+
# .example-images img {
|
41 |
+
# max-width: 100%;
|
42 |
+
# height: auto;
|
43 |
+
# min-height: 400px;
|
44 |
+
# object-fit: contain;
|
45 |
+
# }
|
46 |
+
# /* Dark mode styles */
|
47 |
+
# .gradio-container.dark {
|
48 |
+
# --tw-bg-opacity: 1;
|
49 |
+
# background-color: rgb(24 24 27 / var(--tw-bg-opacity));
|
50 |
+
# color: #d4d4d8;
|
51 |
+
# }
|
52 |
+
# .gradio-container.dark .gr-textbox {
|
53 |
+
# background-color: rgb(39 39 42 / var(--tw-bg-opacity));
|
54 |
+
# color: #d4d4d8;
|
55 |
+
# border-color: #52525b;
|
56 |
+
# }
|
57 |
+
# .gradio-container.dark .gr-tab-item {
|
58 |
+
# color: #d4d4d8;
|
59 |
+
# }
|
60 |
+
# .gradio-container.dark .gr-tab-item.selected {
|
61 |
+
# background-color: rgb(39 39 42 / var(--tw-bg-opacity));
|
62 |
+
# color: #fff;
|
63 |
+
# }
|
64 |
+
# """
|
65 |
+
# ) as demo:
|
66 |
+
# gr.Markdown(
|
67 |
+
# """
|
68 |
+
# # Graphify: generate diagrams from JSON super fast and easy ⚡!
|
69 |
+
# Choose a graph type and provide your JSON data to generate a visual representation.
|
70 |
+
# All graphs maintain a consistent, elegant style with rounded boxes,
|
71 |
+
# a dark-to-light color gradient, and a clean white background.
|
72 |
+
# """
|
73 |
+
# )
|
74 |
+
|
75 |
+
# with gr.Row(variant="panel"):
|
76 |
+
# output_format_radio = gr.Radio(
|
77 |
+
# choices=["png", "svg"],
|
78 |
+
# value="png",
|
79 |
+
# label="Output Format",
|
80 |
+
# interactive=True
|
81 |
+
# )
|
82 |
+
|
83 |
+
# with gr.Tabs():
|
84 |
+
# with gr.TabItem("Concept Map"):
|
85 |
+
# with gr.Row():
|
86 |
+
# with gr.Column(scale=1):
|
87 |
+
# json_input_cm = gr.Textbox(
|
88 |
+
# value=CONCEPT_MAP_JSON,
|
89 |
+
# placeholder="Paste JSON following the documented format",
|
90 |
+
# label="JSON Input",
|
91 |
+
# lines=20
|
92 |
+
# )
|
93 |
+
# submit_btn_cm = gr.Button("Generate Concept Map", variant="primary")
|
94 |
+
|
95 |
+
# with gr.Column(scale=2):
|
96 |
+
# output_cm = gr.Image(
|
97 |
+
# label="Generated Diagram",
|
98 |
+
# type="filepath",
|
99 |
+
# show_download_button=True,
|
100 |
+
# height=500
|
101 |
+
# )
|
102 |
+
|
103 |
+
# submit_btn_cm.click(
|
104 |
+
# fn=generate_concept_map,
|
105 |
+
# inputs=[json_input_cm, output_format_radio],
|
106 |
+
# outputs=output_cm
|
107 |
+
# )
|
108 |
+
|
109 |
+
# gr.Markdown("## Examples")
|
110 |
+
# with gr.Row(elem_classes=["example-images"]):
|
111 |
+
# gr.Image(value="./images/cm1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
112 |
+
# gr.Image(value="./images/cm2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
113 |
+
|
114 |
+
# with gr.TabItem("Synoptic Chart"):
|
115 |
+
# with gr.Row():
|
116 |
+
# with gr.Column(scale=1):
|
117 |
+
# json_input_sc = gr.Textbox(
|
118 |
+
# value=SYNOPTIC_CHART_JSON,
|
119 |
+
# placeholder="Paste JSON following the documented format",
|
120 |
+
# label="JSON Input",
|
121 |
+
# lines=20
|
122 |
+
# )
|
123 |
+
# submit_btn_sc = gr.Button("Generate Synoptic Chart", variant="primary")
|
124 |
+
|
125 |
+
# with gr.Column(scale=2):
|
126 |
+
# output_sc = gr.Image(
|
127 |
+
# label="Generated Diagram",
|
128 |
+
# type="filepath",
|
129 |
+
# show_download_button=True,
|
130 |
+
# height=500
|
131 |
+
# )
|
132 |
+
|
133 |
+
# submit_btn_sc.click(
|
134 |
+
# fn=generate_synoptic_chart,
|
135 |
+
# inputs=[json_input_sc, output_format_radio],
|
136 |
+
# outputs=output_sc
|
137 |
+
# )
|
138 |
+
|
139 |
+
# gr.Markdown("## Examples")
|
140 |
+
# with gr.Row(elem_classes=["example-images"]):
|
141 |
+
# gr.Image(value="./images/sc1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
142 |
+
# gr.Image(value="./images/sc2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
143 |
+
|
144 |
+
# with gr.TabItem("Radial Diagram"):
|
145 |
+
# with gr.Row():
|
146 |
+
# with gr.Column(scale=1):
|
147 |
+
# json_input_rd = gr.Textbox(
|
148 |
+
# value=RADIAL_DIAGRAM_JSON,
|
149 |
+
# placeholder="Paste JSON following the documented format",
|
150 |
+
# label="JSON Input",
|
151 |
+
# lines=20
|
152 |
+
# )
|
153 |
+
# submit_btn_rd = gr.Button("Generate Radial Diagram", variant="primary")
|
154 |
+
|
155 |
+
# with gr.Column(scale=2):
|
156 |
+
# output_rd = gr.Image(
|
157 |
+
# label="Generated Diagram",
|
158 |
+
# type="filepath",
|
159 |
+
# show_download_button=True,
|
160 |
+
# height=500
|
161 |
+
# )
|
162 |
+
|
163 |
+
# submit_btn_rd.click(
|
164 |
+
# fn=generate_radial_diagram,
|
165 |
+
# inputs=[json_input_rd, output_format_radio],
|
166 |
+
# outputs=output_rd
|
167 |
+
# )
|
168 |
+
|
169 |
+
# gr.Markdown("## Examples")
|
170 |
+
# with gr.Row(elem_classes=["example-images"]):
|
171 |
+
# gr.Image(value="./images/rd1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
172 |
+
# gr.Image(value="./images/rd2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
173 |
+
# gr.Image(value="./images/rd3.svg", label="Sample 3", show_label=True, interactive=False, height="auto", width="100%")
|
174 |
+
# gr.Image(value="./images/rd4.svg", label="Sample 4", show_label=True, interactive=False, height="auto", width="100%")
|
175 |
+
|
176 |
+
# with gr.TabItem("Process Flow"):
|
177 |
+
# with gr.Row():
|
178 |
+
# with gr.Column(scale=1):
|
179 |
+
# json_input_pf = gr.Textbox(
|
180 |
+
# value=PROCESS_FLOW_JSON,
|
181 |
+
# placeholder="Paste JSON following the documented format",
|
182 |
+
# label="JSON Input",
|
183 |
+
# lines=20
|
184 |
+
# )
|
185 |
+
# submit_btn_pf = gr.Button("Generate Process Flow", variant="primary")
|
186 |
+
|
187 |
+
# with gr.Column(scale=2):
|
188 |
+
# output_pf = gr.Image(
|
189 |
+
# label="Generated Diagram",
|
190 |
+
# type="filepath",
|
191 |
+
# show_download_button=True,
|
192 |
+
# height=500
|
193 |
+
# )
|
194 |
+
|
195 |
+
# submit_btn_pf.click(
|
196 |
+
# fn=generate_process_flow_diagram,
|
197 |
+
# inputs=[json_input_pf, output_format_radio],
|
198 |
+
# outputs=output_pf
|
199 |
+
# )
|
200 |
+
|
201 |
+
# gr.Markdown("## Examples")
|
202 |
+
# with gr.Row(elem_classes=["example-images"]):
|
203 |
+
# gr.Image(value="./images/pf1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
204 |
+
# gr.Image(value="./images/pf2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
205 |
+
|
206 |
+
# with gr.TabItem("WBS Diagram"):
|
207 |
+
# with gr.Row():
|
208 |
+
# with gr.Column(scale=1):
|
209 |
+
# json_input_wbs = gr.Textbox(
|
210 |
+
# value=WBS_DIAGRAM_JSON,
|
211 |
+
# placeholder="Paste JSON following the documented format",
|
212 |
+
# label="JSON Input",
|
213 |
+
# lines=20
|
214 |
+
# )
|
215 |
+
# submit_btn_wbs = gr.Button("Generate WBS Diagram", variant="primary")
|
216 |
+
|
217 |
+
# with gr.Column(scale=2):
|
218 |
+
# output_wbs = gr.Image(
|
219 |
+
# label="Generated Diagram",
|
220 |
+
# type="filepath",
|
221 |
+
# show_download_button=True,
|
222 |
+
# height=500
|
223 |
+
# )
|
224 |
+
|
225 |
+
# submit_btn_wbs.click(
|
226 |
+
# fn=generate_wbs_diagram,
|
227 |
+
# inputs=[json_input_wbs, output_format_radio],
|
228 |
+
# outputs=output_wbs
|
229 |
+
# )
|
230 |
+
|
231 |
+
# gr.Markdown("## Examples")
|
232 |
+
# with gr.Row(elem_classes=["example-images"]):
|
233 |
+
# gr.Image(value="./images/wd1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
234 |
+
# gr.Image(value="./images/wd2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
235 |
+
|
236 |
+
# demo.launch(
|
237 |
+
# mcp_server=True,
|
238 |
+
# share=False,
|
239 |
+
# server_port=7860,
|
240 |
+
# server_name="0.0.0.0"
|
241 |
+
# )
|
242 |
+
|
243 |
import gradio as gr
|
244 |
|
245 |
from concept_map_generator import generate_concept_map
|
|
|
247 |
from radial_diagram_generator import generate_radial_diagram
|
248 |
from process_flow_generator import generate_process_flow_diagram
|
249 |
from wbs_diagram_generator import generate_wbs_diagram
|
250 |
+
from timeline_generator import generate_timeline_diagram
|
251 |
+
from binary_tree_generator import generate_binary_tree_diagram
|
252 |
|
253 |
+
from sample_data import CONCEPT_MAP_JSON, SYNOPTIC_CHART_JSON, RADIAL_DIAGRAM_JSON, PROCESS_FLOW_JSON, WBS_DIAGRAM_JSON, TIMELINE_JSON, BINARY_TREE_JSON
|
254 |
|
255 |
if __name__ == "__main__":
|
256 |
DEFAULT_BASE_COLOR = '#19191a'
|
|
|
476 |
with gr.Row(elem_classes=["example-images"]):
|
477 |
gr.Image(value="./images/wd1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
478 |
gr.Image(value="./images/wd2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
479 |
+
|
480 |
+
with gr.TabItem("Timeline"):
|
481 |
+
with gr.Row():
|
482 |
+
with gr.Column(scale=1):
|
483 |
+
json_input_tl = gr.Textbox(
|
484 |
+
value=TIMELINE_JSON,
|
485 |
+
placeholder="Paste JSON following the documented format",
|
486 |
+
label="JSON Input",
|
487 |
+
lines=20
|
488 |
+
)
|
489 |
+
submit_btn_tl = gr.Button("Generate Timeline", variant="primary")
|
490 |
+
|
491 |
+
with gr.Column(scale=2):
|
492 |
+
output_tl = gr.Image(
|
493 |
+
label="Generated Diagram",
|
494 |
+
type="filepath",
|
495 |
+
show_download_button=True,
|
496 |
+
height=500
|
497 |
+
)
|
498 |
+
|
499 |
+
submit_btn_tl.click(
|
500 |
+
fn=generate_timeline_diagram,
|
501 |
+
inputs=[json_input_tl, output_format_radio],
|
502 |
+
outputs=output_tl
|
503 |
+
)
|
504 |
+
|
505 |
+
gr.Markdown("## Examples")
|
506 |
+
#with gr.Row(elem_classes=["example-images"]):
|
507 |
+
#gr.Image(value="./images/tl1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
508 |
+
#gr.Image(value="./images/tl2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
509 |
+
|
510 |
+
with gr.TabItem("Binary Tree"):
|
511 |
+
with gr.Row():
|
512 |
+
with gr.Column(scale=1):
|
513 |
+
json_input_bt = gr.Textbox(
|
514 |
+
value=BINARY_TREE_JSON,
|
515 |
+
placeholder="Paste JSON following the documented format",
|
516 |
+
label="JSON Input",
|
517 |
+
lines=20
|
518 |
+
)
|
519 |
+
submit_btn_bt = gr.Button("Generate Binary Tree", variant="primary")
|
520 |
+
|
521 |
+
with gr.Column(scale=2):
|
522 |
+
output_bt = gr.Image(
|
523 |
+
label="Generated Diagram",
|
524 |
+
type="filepath",
|
525 |
+
show_download_button=True,
|
526 |
+
height=500
|
527 |
+
)
|
528 |
+
|
529 |
+
submit_btn_bt.click(
|
530 |
+
fn=generate_binary_tree_diagram,
|
531 |
+
inputs=[json_input_bt, output_format_radio],
|
532 |
+
outputs=output_bt
|
533 |
+
)
|
534 |
+
|
535 |
+
gr.Markdown("## Examples")
|
536 |
+
#with gr.Row(elem_classes=["example-images"]):
|
537 |
+
#gr.Image(value="./images/bt1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
538 |
+
#gr.Image(value="./images/bt2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
539 |
|
540 |
demo.launch(
|
541 |
mcp_server=True,
|