import pandas as pd
import plotly.express as px

# Load the dataset
file_path = 'C:\\Users\\loydt\\Downloads\\Superstore Sales Dataset.csv'
data = pd.read_csv(file_path)

# Step 1: Filter for Bookcases
bookcases_data = data[data['Sub-Category'] == 'Bookcases']

# Step 2: Group the bookcases data by "Product Name" and sum their sales
bookcase_sales = bookcases_data.groupby('Product Name')['Sales'].sum().reset_index()

# Step 3: Sort by total sales in descending order
bookcase_sales = bookcase_sales.sort_values(by='Sales', ascending=True)

# Create the horizontal bar chart
fig = px.bar(
    bookcase_sales,
    x='Sales',
    y='Product Name',
    orientation='h',
    title='Total Sales for Each Bookcase Product',
    labels={'Product Name': 'Bookcase Product Names', 'Sales': 'Total Sales'},
)

# Customize the bar plot's color and layout
fig.update_traces(marker_color='slateblue')  # Set bar color

# Update the layout to set a darker background and other enhancements
fig.update_layout(
    xaxis_title='Total Sales',
    yaxis_title='Bookcase Product Names',
    title='Sales Volume',
    paper_bgcolor='rgba(45, 45, 45, 1)',  # Background outside the plot area
    plot_bgcolor='rgba(40, 40, 40, 1)',   # Background inside the plot area
    font=dict(color='snow'),
    height=1000,  # Increase the height of the chart
)

# Show the figure
fig.show()