Replicate the app from the image.creat this streamlit
Drop files here
or click to upload
import streamlit as st
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px
import numpy as np
from datetime import datetime, timedelta
# Page config
st.set_page_config(page_title="Sales Dashboard", layout="wide")
# Title
st.title("Sales Dashboard")
# Generate sample data
def generate_sales_data():
dates = pd.date_range(start='2023-01-01', end='2023-12-31', freq='D')
revenue = np.random.normal(15000, 3000, len(dates))
revenue = np.abs(revenue) # Make all values positive
df = pd.DataFrame({
'Date': dates,
'Revenue': revenue
})
return df
# Create metrics data
total_orders = 13,580
revenue = "$103,045"
revenue_change = "+15%"
target_revenue = "$78,000"
target_change = "+8%"
total_expense = "$15,010"
expense_change = "+10%"
total_sales_tax = "$9,090"
tax_change = "+12%"
# Create layout with columns
col1, col2, col3, col4 = st.columns(4)
with col1:
st.metric("Total Orders", total_orders)
with col2:
st.metric("Revenue", revenue, revenue_change)
with col3:
st.metric("Total Expense", total_expense, expense_change)
with col4:
st.metric("Total Sales Tax", total_sales_tax, tax_change)
# Revenue chart
sales_data = generate_sales_data()
fig = px.bar(sales_data, x='Date', y='Revenue',
title='Revenue Chart')
fig.update_layout(
plot_bgcolor='white',
paper_bgcolor='white',
margin=dict(t=40, l=0, r=0, b=0)
)
st.plotly_chart(fig, use_container_width=True)
# Create two columns for the bottom section
col1, col2 = st.columns([1, 2])
with col1:
st.subheader("Best Selling Product")
products = {
"Sports Shoes": "14 items sold",
"Black T-Shirt": "22 items sold",
"Jeans": "47 items sold",
"Red Sneakers": "45 items sold",
"Red Scarf": "28 items sold"
}
for product, sales in products.items():
st.text(f"{product}: {sales}")
with col2:
st.subheader("Track Order Status")
# Sample order data
orders_data = {
'Customer Name': ['Marcus Santos', 'Carter Jacobs', 'Ashley Stevens', 'Emily Brown', 'David Cooper'],
'Qty Items': [2, 3, 1, 4, 2],
'Amount': ['$54.5', '$65.5', '$34.5', '$76.5', '$52.5'],
'Payment Method': ['PayPal', 'Bank Transfer', 'Bank Transfer', 'Credit Card', 'PayPal'],
'Status': ['New Order', 'In Progress', 'On Hold', 'Completed', 'Completed']
}
df_orders = pd.DataFrame(orders_data)
st.dataframe(df_orders, use_container_width=True)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?