import dash
from dash import Input, html, Output, register_page, State, dcc
import pandas as pd
from dash_iconify import DashIconify
import dash_ag_grid as dag
import dash_mantine_components as dmc
from utils import df
register_page(
__name__,
path='/',
title='Introduction and Dataset Details',
order=0
)
# Define column definitions for the table
columnDefs = [
{'field': 'title', 'headerName': 'Title', 'filter': True, 'floatingFilter': True},
{'field': 'author', 'headerName': 'Author', 'filter': True, 'floatingFilter': True},
{'field': 'publisher', 'headerName': 'Publisher', 'filter': True, 'floatingFilter': True},
{'field': 'desc', 'headerName': 'Book Description', 'filter': True, 'floatingFilter': True},
{'field': 'sentiment_category', 'headerName': 'sentiment category', 'filter': True, 'floatingFilter': True},
{'field': 'rank', 'headerName': 'Rank', 'type': 'numericColumn', 'filter': True, 'floatingFilter': True},
{'field': 'rank_last_week', 'headerName': 'Rank Last Week', 'type': 'numericColumn', 'filter': True, 'floatingFilter': True},
{'field': 'weeks_on_list', 'headerName': 'Weeks on List', 'type': 'numericColumn', 'filter': True, 'floatingFilter': True},
{'field': 'bestsellers_date', 'headerName': 'Bestsellers Date', 'filter': True, 'floatingFilter': True},
{'field': 'published_date', 'headerName': 'Published Date', 'filter': True, 'floatingFilter': True},
{'field': 'published_month', 'headerName': 'Month Year', 'filter': True, 'floatingFilter': True},
{'field': 'isbn_13', 'headerName': 'ISBN-13', 'filter': True, 'floatingFilter': True},
{'field': 'isbn_10', 'headerName': 'ISBN-10', 'filter': True, 'floatingFilter': True},
{'field': 'num_isbns', 'headerName': 'Number of ISBNs', 'type': 'numericColumn', 'filter': True, 'floatingFilter': True},
{'field': 'long_running', 'headerName': 'Long Running', 'filter': True, 'floatingFilter': True},
{'field': 'isbn_count', 'headerName': 'ISBN Count', 'type': 'numericColumn', 'filter': True, 'floatingFilter': True},
{'field': 'publishing_time', 'headerName': 'Publishing Time (Days)', 'type': 'numericColumn', 'filter': True, 'floatingFilter': True},
]
# Define the table
table = dag.AgGrid(
id="project_intro",
columnDefs=columnDefs,
rowData=df.to_dict('records'),
columnSize='autoSize',
defaultColDef={
'editable': False,
'filter': True,
'floatingFilter': True,
'resizable': True,
'sortable': True,
'flex': 1,
},
dashGridOptions={
"suppressFieldDotNotation": True,
"pagination": True,
"paginationPageSize": 10,
},
style={'height': '500px', 'width': '100%'},
)
# Define the layout
layout = dmc.MantineProvider(
dmc.Container(
[
# Hero Section
dmc.Grid(
[
dmc.GridCol(
[
dmc.Title(
"Bestsellers Analysis Dashboard",
order=1,
style={"color": "#2C3E50", "marginBottom": "10px"}
),
dmc.Text(
"Explore insights into the best-selling books, publishers, and trends over time.",
size="lg",
style={"color": "#555", "marginBottom": "30px"}
),
dmc.Group(
[
dmc.Anchor(
dmc.Card(
children=[
dmc.Center(
DashIconify(icon="mdi:account-group", width=50, color="#4CAF50"),
),
dmc.Text("Publishers", fw=500, ta="center", style={"marginTop": "10px"})
],
withBorder=True,
shadow="sm",
radius="md",
style={"height": "150px", "width": "150px", "cursor": "pointer"}
),
href="/publisher"
),
dmc.Anchor(
dmc.Card(
children=[
dmc.Center(
DashIconify(icon="fluent:book-star-24-filled", width=50, color="#2196F3"),
),
dmc.Text("Bestsellers", fw=500, ta="center", style={"marginTop": "10px"})
],
withBorder=True,
shadow="sm",
radius="md",
style={"height": "150px", "width": "150px", "cursor": "pointer"}
),
href="/bestsellers"
),
],
gap="xl",
justify="center"
),
],
span=12
),
],
gutter="xl",
style={"marginBottom": "40px"}
),
# Data Table Section
dmc.Card(
children=[
dmc.Title("Dataset Overview", order=2, style={"color": "#2C3E50", "marginBottom": "20px"}),
table
],
withBorder=True,
shadow="sm",
radius="md",
style={"padding": "20px"}
),
],
fluid=True,
style={"padding": "20px"}
)
)