Hello everyone!! I’m trying to creat a char showing the level of the value but I don’t know how to do it. Please help me to solve my problem. The barchart I want to show like this.
When I choose the movie, the bar chart will show the level of each geners like picture
Here is an idea
Code
import streamlit as st
import pandas as pd
def ascii_progress(x: float, solid: bool = False) -> str:
'''
Returns an ascii bar from a number between 0 and 1.
The bar has lenght 10
'''
nbars = int(min(max(x, 0.0), min(x, 1.0), x) * 10)
bar = ((("\u2593","\u2588")[solid])*nbars).ljust(10,"\u2591")
return(bar)
df = pd.DataFrame({"thing":["Python", "C++", "JS"], "x": [0.2, 0.6, 0.9]})
df["bar"] = df["x"].map(ascii_progress)
st.dataframe(df)
Or using a little image in markdown
Code
import streamlit as st
import pandas as pd
def markdown_progress(x: float) -> str:
'''
Returns a bar from a number between 0 and 100.
'''
return(f"""""")
df = pd.DataFrame({"thing":["Python", "C++", "JS"], "x": [20, 50, 90]})
df["bar"] = df["x"].map(markdown_progress)
st.markdown(df.to_markdown())
Thank you @edsaac. I’m very impressed with your solution.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.