Skip to content

Commit 04308b4

Browse files
committed
Fix: Add total row and improve table formatting in code1.py
1 parent 1585aa3 commit 04308b4

File tree

1 file changed

+4
-4
lines changed
  • apps/plotly_examples/src/python_code_for_variations/Tables

1 file changed

+4
-4
lines changed

apps/plotly_examples/src/python_code_for_variations/Tables/code1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import plotly.graph_objects as go
21
import json
2+
import plotly.graph_objects as go
33

44
# Create the table
55
products = ["Apples", "Bananas", "Oranges"]
@@ -8,10 +8,10 @@
88
totals = [q * p for q, p in zip(quantities, prices)]
99

1010
fig = go.Figure(data=[go.Table(
11-
header=dict(values=["Product", "Quantity", "Price", "Total"]),
11+
header=dict(values=["<b>Product</b>", "<b>Quantity</b>", "<b>Price</b>", "<b>Total</b>"]),
1212
cells=dict(values=[products + ["Total"],
1313
quantities + [sum(quantities)],
14-
prices + [""],
14+
prices + [None],
1515
totals + [sum(totals)]])
1616
)])
1717

@@ -23,4 +23,4 @@
2323
f.write(fig_json)
2424

2525
# Optional: print preview of JSON (first 300 characters)
26-
print(fig_json[:300])
26+
print("Preview of exported JSON:\n", fig_json[:300], "...")

0 commit comments

Comments
 (0)