Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,8 @@
|
|
|
|
|
|
1 |
import pandas as pd
|
2 |
import numpy as np
|
3 |
-
|
4 |
-
import plotly.graph_objs as go
|
5 |
-
import gradio as gr
|
6 |
-
import json
|
7 |
|
8 |
def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, system3, users3, timeline3):
|
9 |
# Create empty dataframe to hold usage data
|
@@ -23,19 +22,15 @@ def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, sy
|
|
23 |
system_data = pd.DataFrame({"System": [system] * len(usage), "Month": months, "Usage": usage})
|
24 |
data = pd.concat([data, system_data], axis=0)
|
25 |
|
26 |
-
# Create a
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
fig.update_layout(title="System Rollout Usage Volume Plot", xaxis_title="Month", yaxis_title="Usage")
|
33 |
-
|
34 |
-
# Convert the plot to a JSON string
|
35 |
-
plot_json = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
|
36 |
|
37 |
# Return the plot as a Gradio output
|
38 |
-
return
|
39 |
|
40 |
# Define the input components
|
41 |
inputs = [
|
@@ -58,4 +53,3 @@ iface = gr.Interface(fn=plot_usage_volume, inputs=inputs, outputs=output, title=
|
|
58 |
|
59 |
# Launch the interface
|
60 |
iface.launch()
|
61 |
-
|
|
|
1 |
+
import altair as alt
|
2 |
+
import gradio as gr
|
3 |
import pandas as pd
|
4 |
import numpy as np
|
5 |
+
|
|
|
|
|
|
|
6 |
|
7 |
def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, system3, users3, timeline3):
|
8 |
# Create empty dataframe to hold usage data
|
|
|
22 |
system_data = pd.DataFrame({"System": [system] * len(usage), "Month": months, "Usage": usage})
|
23 |
data = pd.concat([data, system_data], axis=0)
|
24 |
|
25 |
+
# Create a multiline plot of the usage volume for each system
|
26 |
+
line = alt.Chart(data).mark_line().encode(
|
27 |
+
x='Month:N',
|
28 |
+
y='Usage:Q',
|
29 |
+
color='System:N'
|
30 |
+
).properties(title="System Rollout Usage Volume Plot")
|
|
|
|
|
|
|
|
|
31 |
|
32 |
# Return the plot as a Gradio output
|
33 |
+
return line
|
34 |
|
35 |
# Define the input components
|
36 |
inputs = [
|
|
|
53 |
|
54 |
# Launch the interface
|
55 |
iface.launch()
|
|