Deepa Shalini commited on
Commit
90f6d44
·
1 Parent(s): b89c575

updated tab option placement

Browse files
Files changed (2) hide show
  1. app.py +55 -36
  2. gallery_data.py +3 -3
app.py CHANGED
@@ -37,43 +37,61 @@ app.layout = dmc.MantineProvider(
37
  ],
38
  className="brand"
39
  ),
40
- # Tab switcher (added before New Chart button)
41
  html.Div(
42
  [
43
  html.Button(
44
- "VISUALIZER",
45
- id="tab-visualizer",
46
- className="tab active",
47
- type="button",
48
- **{
49
- "role": "tab",
50
- "aria-selected": "true"
 
51
  }
52
  ),
53
- html.Button(
54
- "GALLERY",
55
- id="tab-gallery",
56
- className="tab",
57
- type="button",
58
- **{
59
- "role": "tab",
60
- "aria-selected": "false"
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  )
63
  ],
64
- className="tabs",
65
- role="tablist",
66
- **{"aria-label": "ChaRtBot pages"}
67
- ),
68
- html.Button(
69
- "New Chart",
70
- id="new-chart-button",
71
- className="pill",
72
- n_clicks=0,
73
  style={
74
- "cursor": "pointer",
75
- "border": "none",
76
- "fontFamily": "inherit"
77
  }
78
  )
79
  ]
@@ -488,11 +506,12 @@ def reset_chat(n_clicks):
488
 
489
  # Callback for tab switching
490
  @callback(
491
- Output("tab-visualizer", "className"),
492
  Output("tab-gallery", "className"),
493
  Output("visualizer-page", "style"),
494
  Output("gallery-page", "style"),
495
- Input("tab-visualizer", "n_clicks"),
 
496
  Input("tab-gallery", "n_clicks"),
497
  prevent_initial_call=True
498
  )
@@ -500,16 +519,16 @@ def switch_tabs(visualizer_clicks, gallery_clicks):
500
  """Handle tab switching between Visualizer and Gallery."""
501
  ctx = dash.callback_context
502
  if not ctx.triggered:
503
- return "tab active", "tab", {"marginTop": "10px"}, {"display": "none"}
504
 
505
  button_id = ctx.triggered[0]["prop_id"].split(".")[0]
506
 
507
- if button_id == "tab-visualizer":
508
- return "tab active", "tab", {"marginTop": "10px"}, {"display": "none"}
509
  elif button_id == "tab-gallery":
510
- return "tab", "tab active", {"display": "none"}, {"marginTop": "10px"}
511
 
512
- return "tab active", "tab", {"marginTop": "10px"}, {"display": "none"}
513
 
514
  if __name__ == "__main__":
515
  app.run(debug=True)
 
37
  ],
38
  className="brand"
39
  ),
40
+ # Container for tabs and button
41
  html.Div(
42
  [
43
  html.Button(
44
+ "New Chart",
45
+ id="new-chart-button",
46
+ className="pill",
47
+ n_clicks=0,
48
+ style={
49
+ "cursor": "pointer",
50
+ "border": "none",
51
+ "fontFamily": "inherit"
52
  }
53
  ),
54
+ # Tab switcher
55
+ html.Div(
56
+ [
57
+ html.Button(
58
+ "CREATE",
59
+ id="tab-create",
60
+ className="tab active",
61
+ type="button",
62
+ style={
63
+ "height": "30px",
64
+ "padding": "0 16px",
65
+ },
66
+ **{
67
+ "role": "tab",
68
+ "aria-selected": "true"
69
+ }
70
+ ),
71
+ html.Button(
72
+ "GALLERY",
73
+ id="tab-gallery",
74
+ className="tab",
75
+ type="button",
76
+ style={
77
+ "height": "30px",
78
+ "padding": "0 16px",
79
+ },
80
+ **{
81
+ "role": "tab",
82
+ "aria-selected": "false"
83
+ }
84
+ )
85
+ ],
86
+ className="tabs",
87
+ role="tablist",
88
+ **{"aria-label": "ChaRtBot pages"}
89
  )
90
  ],
 
 
 
 
 
 
 
 
 
91
  style={
92
+ "display": "flex",
93
+ "alignItems": "center",
94
+ "gap": "12px"
95
  }
96
  )
97
  ]
 
506
 
507
  # Callback for tab switching
508
  @callback(
509
+ Output("tab-create", "className"),
510
  Output("tab-gallery", "className"),
511
  Output("visualizer-page", "style"),
512
  Output("gallery-page", "style"),
513
+ Output("new-chart-button", "style"),
514
+ Input("tab-create", "n_clicks"),
515
  Input("tab-gallery", "n_clicks"),
516
  prevent_initial_call=True
517
  )
 
519
  """Handle tab switching between Visualizer and Gallery."""
520
  ctx = dash.callback_context
521
  if not ctx.triggered:
522
+ return "tab active", "tab", {"marginTop": "10px"}, {"display": "none"}, {"cursor": "pointer", "border": "none", "fontFamily": "inherit"}
523
 
524
  button_id = ctx.triggered[0]["prop_id"].split(".")[0]
525
 
526
+ if button_id == "tab-create":
527
+ return "tab active", "tab", {"marginTop": "10px"}, {"display": "none"}, {"cursor": "pointer", "border": "none", "fontFamily": "inherit"}
528
  elif button_id == "tab-gallery":
529
+ return "tab", "tab active", {"display": "none"}, {"marginTop": "10px"}, {"display": "none"}
530
 
531
+ return "tab active", "tab", {"marginTop": "10px"}, {"display": "none"}, {"cursor": "pointer", "border": "none", "fontFamily": "inherit"}
532
 
533
  if __name__ == "__main__":
534
  app.run(debug=True)
gallery_data.py CHANGED
@@ -12,7 +12,7 @@ GALLERY_DATA = [
12
  },
13
  {
14
  "image": "/assets/gallery/2_image.png",
15
- "prompt": "Create a Manhattan-style plot where purchases are grouped along the x-axis by Category, with each point representing an Order_Value. Alternate colors by Category so each group forms its own block, highlighting large spending spikes.",
16
  "csv_link": "/assets/gallery/datasets/amazon-purchases-2021-sample-5k.csv",
17
  "badge": "Manhattan"
18
  },
@@ -36,7 +36,7 @@ GALLERY_DATA = [
36
  },
37
  {
38
  "image": "/assets/gallery/6_image.png",
39
- "prompt": "Depict the sum of the purchase amount per day of the week using a heatmap. The X-axis should represent the months, labeled with month names, and the Y-axis should represent the days of the week. Use color to depict the purchase amounts, with the X-axis ordered chronologically by both days and months.",
40
  "csv_link": "/assets/gallery/datasets/amazon-purchases-2021-sample-5k.csv",
41
  "badge": "Heatmap"
42
  },
@@ -54,7 +54,7 @@ GALLERY_DATA = [
54
  },
55
  {
56
  "image": "/assets/gallery/9_image.png",
57
- "prompt": "Create a bubble chart that visualizes rocket launch prices over the years Use Date on the x-axis and Price on the y-axis. Size each bubble by Price to reflect the relative cost of each mission. Color the bubbles by Company. Ensure bubbles are semi-transparent to avoid overlap issues. Add detailed hover tooltips showing Company, Rocket, Mission, Location, MissionStatus, and Price.",
58
  "csv_link": "/assets/gallery/datasets/space_missions_data.csv",
59
  "badge": "Bubble"
60
  },
 
12
  },
13
  {
14
  "image": "/assets/gallery/2_image.png",
15
+ "prompt": "Create a Manhattan-style plot where purchases are grouped along the x-axis by Category, with each point representing an Order_Value. Alternate colours by Category so each group forms its own block, highlighting large spending spikes.",
16
  "csv_link": "/assets/gallery/datasets/amazon-purchases-2021-sample-5k.csv",
17
  "badge": "Manhattan"
18
  },
 
36
  },
37
  {
38
  "image": "/assets/gallery/6_image.png",
39
+ "prompt": "Depict the sum of the purchase amount per day of the week using a heatmap. The X-axis should represent the months, labeled with month names, and the Y-axis should represent the days of the week. Use colour to depict the purchase amounts, with the X-axis ordered chronologically by both days and months.",
40
  "csv_link": "/assets/gallery/datasets/amazon-purchases-2021-sample-5k.csv",
41
  "badge": "Heatmap"
42
  },
 
54
  },
55
  {
56
  "image": "/assets/gallery/9_image.png",
57
+ "prompt": "Create a bubble chart that visualizes rocket launch prices over the years Use Date on the x-axis and Price on the y-axis. Size each bubble by Price to reflect the relative cost of each mission. colour the bubbles by Company. Ensure bubbles are semi-transparent to avoid overlap issues. Add detailed hover tooltips showing Company, Rocket, Mission, Location, MissionStatus, and Price.",
58
  "csv_link": "/assets/gallery/datasets/space_missions_data.csv",
59
  "badge": "Bubble"
60
  },