os1187 commited on
Commit
e15f060
·
1 Parent(s): ff0096b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import pandas as pd
2
  import numpy as np
3
  import plotly
4
- import plotly.express as px
5
  import gradio as gr
6
  import json
7
 
@@ -24,10 +24,18 @@ def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, sy
24
  data = pd.concat([data, system_data], axis=0)
25
 
26
  # Create a line plot of the usage volume for each system
27
- fig = px.line(data, x="Month", y="Usage", color="System", title="System Rollout Usage Volume Plot")
 
 
 
 
 
 
 
 
28
 
29
  # Return the plot as a Gradio output
30
- return fig
31
 
32
  # Define the input components
33
  inputs = [
@@ -43,10 +51,11 @@ inputs = [
43
  ]
44
 
45
  # Define the output component
46
- output = gr.outputs.Graph(label="Usage Volume Plot")
47
 
48
  # Create the interface
49
  iface = gr.Interface(fn=plot_usage_volume, inputs=inputs, outputs=output, title="System Rollout Usage Volume Plot")
50
 
51
  # Launch the interface
52
  iface.launch()
 
 
1
  import pandas as pd
2
  import numpy as np
3
  import plotly
4
+ import plotly.graph_objs as go
5
  import gradio as gr
6
  import json
7
 
 
24
  data = pd.concat([data, system_data], axis=0)
25
 
26
  # Create a line plot of the usage volume for each system
27
+ fig = go.Figure()
28
+ for system in data["System"].unique():
29
+ system_data = data[data["System"] == system]
30
+ fig.add_trace(go.Scatter(x=system_data["Month"], y=system_data["Usage"], mode="lines+markers", name=system))
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 plot_json
39
 
40
  # Define the input components
41
  inputs = [
 
51
  ]
52
 
53
  # Define the output component
54
+ output = gr.outputs.Plot(label="Usage Volume Plot")
55
 
56
  # Create the interface
57
  iface = gr.Interface(fn=plot_usage_volume, inputs=inputs, outputs=output, title="System Rollout Usage Volume Plot")
58
 
59
  # Launch the interface
60
  iface.launch()
61
+