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: Count the frequency of each unique product
product_counts = bookcases_data['Product Name'].value_counts().reset_index()
product_counts.columns = ['Product Name', 'Count']

# Step 3: Sort by count in descending order
product_counts = product_counts.sort_values(by='Count', ascending=True)

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

# 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 Count',
    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()