Py.Cafe

SmartDvi/

dash-interactive-coloring

Dash Interactive Coloring

DocsPricing
  • assets/
  • pages/
  • NYT Fiction Bestsellers.xlsx
  • app.py
  • requirements.txt
  • utils.py
pages/homw_page.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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"}
    )
)