recodehive/Stackoverflow-Analysis

[Bug]: StreamlitDuplicateElementId Error when Plotting with Plotly

Closed this issue · 4 comments

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

When rendering a Plotly chart using st.plotly_chart(fig), the app encounters the following error:
StreamlitDuplicateElementId: This app has encountered an error...

Screenshot from the website

Add ScreenShots

Traceback:

File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
exec(code, module.dict)
File "/mount/src/stackoverflow-analysis/streamlit/home.py", line 139, in
main.main_analysis_2(df2018)
File "/mount/src/stackoverflow-analysis/streamlit/main_analysis.py", line 265, in main_analysis_2
ff.plot_bar_plotly(ds, "Country")
File "/mount/src/stackoverflow-analysis/streamlit/functions.py", line 49, in plot_bar_plotly
return st.plotly_chart(fig)
^^^^^^^^^^^^^^^^^^^^
File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/metrics_util.py", line 410, in wrapped_func
result = non_optional_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/elements/plotly_chart.py", line 506, in plotly_chart
plotly_chart_proto.id = compute_and_register_element_id(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/elements/lib/utils.py", line 226, in compute_and_register_element_id
_register_element_id(ctx, element_type, element_id)
File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/elements/lib/utils.py", line 132, in _register_element_id
raise StreamlitDuplicateElementId(element_type)

What browsers are you seeing the problem on?

Firefox, Chrome

Record

  • I agree to follow this project's Code of Conduct
  • I'm a GSSOC contributor
  • I want to work on this issue
  • I'm willing to provide further clarification or assistance if needed.

Thank you for creating this issue! 🎉 We'll look into it as soon as possible. In the meantime, please make sure to provide all the necessary details and context. If you have any questions or additional information, feel free to add them here. Your contributions are highly appreciated! 😊

You can also check our CONTRIBUTING.md for guidelines on contributing to this project.

Hi there! Thanks for opening this issue. We appreciate your contribution to this open-source project. We aim to respond or assign your issue as soon as possible.

I would like to work on this issue, kindly please assign it to me.
Please add the necessary labels, including the appropriate level @sanjay-kv

Hello @A-Akhil! Your issue #382 has been closed. Thank you for your contribution!