Update app.py
Browse files
app.py
CHANGED
|
@@ -245,23 +245,23 @@ def interact_with_salesforce(mode, entry_type, quantity, extracted_text):
|
|
| 245 |
|
| 246 |
excel_path = "salesforce_data.xlsx"
|
| 247 |
df.to_excel(excel_path, index=False)
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
|
| 266 |
# Unified function to handle image processing and Salesforce interaction
|
| 267 |
def process_image(image, mode, entry_type, quantity):
|
|
|
|
| 245 |
|
| 246 |
excel_path = "salesforce_data.xlsx"
|
| 247 |
df.to_excel(excel_path, index=False)
|
| 248 |
+
|
| 249 |
+
# Generate interactive vertical bar graph using Matplotlib
|
| 250 |
+
fig, ax = plt.subplots(figsize=(12, 8))
|
| 251 |
+
df.plot(kind='bar', x="Product Name", y="Current Stocks", ax=ax, legend=False)
|
| 252 |
+
ax.set_title("Stock Distribution by Product Name")
|
| 253 |
+
ax.set_xlabel("Product Name")
|
| 254 |
+
ax.set_ylabel("Current Stocks")
|
| 255 |
+
plt.xticks(rotation=45, ha="right", fontsize=10)
|
| 256 |
+
plt.tight_layout()
|
| 257 |
+
buffer = BytesIO()
|
| 258 |
+
plt.savefig(buffer, format="png")
|
| 259 |
+
buffer.seek(0)
|
| 260 |
+
img = Image.open(buffer)
|
| 261 |
+
|
| 262 |
+
return "Data successfully retrieved.", df, excel_path, img
|
| 263 |
+
except Exception as e:
|
| 264 |
+
return f"Error fetching data: {str(e)}", None, None, None
|
| 265 |
|
| 266 |
# Unified function to handle image processing and Salesforce interaction
|
| 267 |
def process_image(image, mode, entry_type, quantity):
|