Create visualizer.pyfile
Browse files- visualizer.pyfile +17 -0
visualizer.pyfile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import plotly.express as px
|
| 2 |
+
|
| 3 |
+
def create_plot(df, chart_type, x_col, y_col):
|
| 4 |
+
if chart_type == "Bar Chart":
|
| 5 |
+
fig = px.bar(df, x=x_col, y=y_col)
|
| 6 |
+
elif chart_type == "Line Chart":
|
| 7 |
+
fig = px.line(df, x=x_col, y=y_col)
|
| 8 |
+
elif chart_type == "Scatter Plot":
|
| 9 |
+
fig = px.scatter(df, x=x_col, y=y_col)
|
| 10 |
+
elif chart_type == "Pie Chart":
|
| 11 |
+
fig = px.pie(df, names=x_col, values=y_col)
|
| 12 |
+
elif chart_type == "Box Plot":
|
| 13 |
+
fig = px.box(df, x=x_col, y=y_col)
|
| 14 |
+
else:
|
| 15 |
+
raise ValueError("Invalid chart type")
|
| 16 |
+
return fig
|
| 17 |
+
|