Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import pandas as pd
|
2 |
import numpy as np
|
3 |
-
import gradio as gr
|
4 |
import plotly.express as px
|
|
|
5 |
|
6 |
def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, system3, users3, timeline3):
|
7 |
# Create empty dataframe to hold usage data
|
@@ -11,9 +11,9 @@ def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, sy
|
|
11 |
for i, system in enumerate([system1, system2, system3]):
|
12 |
# Calculate the monthly usage volume based on the estimated number of users and timeline
|
13 |
usage = np.concatenate([
|
14 |
-
np.linspace(0, [
|
15 |
-
np.linspace([
|
16 |
-
np.linspace([
|
17 |
])
|
18 |
|
19 |
# Add the usage data to the dataframe
|
@@ -21,11 +21,11 @@ def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, sy
|
|
21 |
system_data = pd.DataFrame({"System": [system] * len(usage), "Month": months, "Usage": usage})
|
22 |
data = pd.concat([data, system_data], axis=0)
|
23 |
|
24 |
-
# Create a
|
25 |
fig = px.line(data, x="Month", y="Usage", color="System", title="System Rollout Usage Volume Plot")
|
26 |
|
27 |
# Return the plot as a Gradio output
|
28 |
-
return gr.outputs.plotly_figure
|
29 |
|
30 |
# Define the input components
|
31 |
inputs = [
|
@@ -40,14 +40,10 @@ inputs = [
|
|
40 |
gr.inputs.Number(label="System 3 Timeline (months)", default=24)
|
41 |
]
|
42 |
|
43 |
-
# Define the
|
44 |
-
|
45 |
-
fn=plot_usage_volume,
|
46 |
-
inputs=inputs,
|
47 |
-
outputs="plot",
|
48 |
-
title="System Rollout Usage Volume Plot",
|
49 |
-
layout="horizontal"
|
50 |
-
)
|
51 |
|
52 |
-
#
|
|
|
53 |
iface.launch()
|
|
|
|
1 |
import pandas as pd
|
2 |
import numpy as np
|
|
|
3 |
import plotly.express as px
|
4 |
+
import gradio as gr
|
5 |
|
6 |
def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, system3, users3, timeline3):
|
7 |
# Create empty dataframe to hold usage data
|
|
|
11 |
for i, system in enumerate([system1, system2, system3]):
|
12 |
# Calculate the monthly usage volume based on the estimated number of users and timeline
|
13 |
usage = np.concatenate([
|
14 |
+
np.linspace(0, users[i], int(timelines[i] * 0.25)),
|
15 |
+
np.linspace(users[i] * 0.5, users[i], int(timelines[i] * 0.5)),
|
16 |
+
np.linspace(users[i], users[i] * 0.75, int(timelines[i] * 0.25))
|
17 |
])
|
18 |
|
19 |
# Add the usage data to the dataframe
|
|
|
21 |
system_data = pd.DataFrame({"System": [system] * len(usage), "Month": months, "Usage": usage})
|
22 |
data = pd.concat([data, system_data], axis=0)
|
23 |
|
24 |
+
# Create a line plot with multiple lines
|
25 |
fig = px.line(data, x="Month", y="Usage", color="System", title="System Rollout Usage Volume Plot")
|
26 |
|
27 |
# Return the plot as a Gradio output
|
28 |
+
return gr.outputs.Json(plotly_figure=fig)
|
29 |
|
30 |
# Define the input components
|
31 |
inputs = [
|
|
|
40 |
gr.inputs.Number(label="System 3 Timeline (months)", default=24)
|
41 |
]
|
42 |
|
43 |
+
# Define the output component
|
44 |
+
output = gr.outputs.Json()
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
+
# Create the interface
|
47 |
+
iface = gr.Interface(fn=plot_usage_volume, inputs=inputs, outputs=output, title="System Rollout Usage Volume Plot", layout="vertical")
|
48 |
iface.launch()
|
49 |
+
|