Create visualizer.py
Browse files- visualizer.py +14 -0
visualizer.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import plotly.express as px
|
| 2 |
+
|
| 3 |
+
class Visualizer:
|
| 4 |
+
def create_plot(self, df, x_axis, y_axis, chart_type):
|
| 5 |
+
if chart_type == "Scatter":
|
| 6 |
+
fig = px.scatter(df, x=x_axis, y=y_axis)
|
| 7 |
+
elif chart_type == "Line":
|
| 8 |
+
fig = px.line(df, x=x_axis, y=y_axis)
|
| 9 |
+
elif chart_type == "Bar":
|
| 10 |
+
fig = px.bar(df, x=x_axis, y=y_axis)
|
| 11 |
+
else:
|
| 12 |
+
raise ValueError("Invalid chart type")
|
| 13 |
+
|
| 14 |
+
return fig
|