@@ -48,7 +48,7 @@ def get_chart_image(fig):
4848 def main():
4949 # Create a chart:
5050 fig, ax = plt.subplots()
51- ax.plot([ 1, 2, 3, 4], [ 10, 11, 12, 13] )
51+ ax.plot(( 1, 2, 3, 4), ( 10, 11, 12, 13) )
5252
5353 # Render the image bytes in the UI:
5454 hd.image(get_chart_image(fig), width=20)
@@ -82,7 +82,7 @@ def main():
8282 def main():
8383 theme = hd.theme()
8484
85- line_data = ([ 1, 2, 3, 4], [ 10, 11, 12, 13] )
85+ line_data = (( 1, 2, 3, 4), ( 10, 11, 12, 13) )
8686
8787 if theme.is_dark:
8888 # Render the matplotlib chart in dark mode:
@@ -116,7 +116,7 @@ def main():
116116 def chart():
117117 theme = hd.theme()
118118
119- line_data = ([ 1, 2, 3, 4], [ 10, 11, 12, 13] )
119+ line_data = (( 1, 2, 3, 4), ( 10, 11, 12, 13) )
120120
121121 if theme.is_dark:
122122 with plt.style.context("dark_background"):
@@ -162,8 +162,11 @@ def main():
162162
163163 ```py-nodemo
164164 @hd.cached
165- def chart(state ):
165+ def chart():
166166 theme = hd.theme()
167+ state = hd.state(
168+ line_data=((1, 2, 3, 4), (10, 11, 12, 13))
169+ )
167170
168171 if theme.is_dark:
169172 with plt.style.context("dark_background"):
@@ -175,15 +178,8 @@ def chart(state):
175178
176179 hd.image(get_chart_image(fig), width=20)
177180
178- def main():
179- state = hd.state(
180- line_data=([1, 2, 3, 4], [10, 11, 12, 13])
181- )
182-
183- chart(state)
184-
185181 if hd.button("Update Chart").clicked:
186- state.line_data = ([ 1, 2, 3, 4], [ 5, 20, 8, 10] )
182+ state.line_data = (( 1, 2, 3, 4), ( 5, 20, 8, 10) )
187183 ```
188184
189185 In this example, we store the chart's line data in
0 commit comments