0% found this document useful (0 votes)
10 views55 pages

Is Dash Framework Still Relevant?

Uploaded by

vikranthviki083
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views55 pages

Is Dash Framework Still Relevant?

Uploaded by

vikranthviki083
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

You said:

is dash an outdated framework for data visualization and dashboard web apps?
ChatGPT said:

Great question 👍

No, Dash is not outdated, but its position has shifted a bit in the data
visualization ecosystem. Let me break it down clearly for you:

✅ Why Dash is still relevant

Active development: Dash (by Plotly) is still maintained and updated regularly. It
has a strong user base in enterprise analytics.

Python-first approach: Unlike frameworks like React or Angular, Dash lets you build
full dashboards and web apps using pure Python — no JavaScript required.

Rich visualizations: Since it’s tightly integrated with Plotly, you get interactive
and beautiful charts out of the box.

Used in industry: Many companies still rely on Dash for internal dashboards,
prototypes, and production-grade apps.

⚠️ Why some people call it "outdated"

Streamlit’s rise: Streamlit has become very popular because it’s simpler, faster to
prototype with, and feels more "Pythonic." Many new learners and companies adopt
Streamlit first.

Shiny for Python: RStudio introduced Shiny for Python, which also competes in the
same space.

Full-stack competition: For highly customized production apps, developers often


choose React, Vue, or Flask + React instead of Dash.

Learning curve: Dash requires more boilerplate code compared to Streamlit.

🔍 When to choose Dash over newer frameworks

If you want fine-grained control over the layout and callbacks (e.g., multiple
interactive elements talking to each other).

If you’re already comfortable with Plotly and want seamless integration.

If your project needs enterprise-level deployment and scaling (Plotly Enterprise


adds extra support).

👉 So in short:

Dash is not outdated — it’s still powerful, actively maintained, and used in real
projects.

But for faster prototyping and ease of use, many people now prefer Streamlit.

The choice depends on your goal:

Prototyping & quick demos → Streamlit

Complex, production-ready dashboards → Dash


Do you want me to give you a side-by-side comparison of Dash vs Streamlit (code
example of the same dashboard in both), so you can see which feels better for your
interview prep?

You said:
Can you help learn dash framework?
ChatGPT said:

Perfect timing 🚀 Yes, I can definitely help you learn the Dash framework step by
step — especially since you have that project call coming up where they want to
evaluate you on Dash.

Here’s how we can approach it:

Learning Plan for Dash

We’ll go from basics → intermediate → mini-projects.

1. Basics of Dash

What Dash is and why it’s used.

Installing Dash.

Basic app structure ([Link]).

Layouts and components.

Running your first app.

2. Dash Components

Core components (dcc, html).

Inputs & outputs.

Callbacks (the heart of Dash).

Updating charts and text dynamically.

3. Styling and Layouts

Using HTML tags.

Adding CSS for design.

Dash Bootstrap Components.

4. Data Visualization

Integrating Plotly charts (line, bar, pie, scatter, etc.).

Adding interactivity (hover, select, filter).

5. Real-World Features

Uploading & downloading files.


Filtering data with dropdowns, sliders, and checkboxes.

Multiple pages (Dash Pages).

6. Mini Projects

Sales dashboard.

COVID-19 data tracker.

Stock price visualizer.

⚡ Step 1: Installing Dash and Running a Simple App

First, install Dash:

pip install dash

Now create a file [Link] with this code:

import dash
from dash import html

# Initialize the app


app = [Link](__name__)

# Layout of the app


[Link] = [Link](children=[
html.H1("Hello, Dash!"),
html.P("This is my first Dash app.")
])

# Run the app


if __name__ == "__main__":
app.run_server(debug=True)

👉 Run it:

python [Link]

You’ll see something like:

Dash is running on [Link]

Open that link in your browser — 🎉 your first Dash app is live.

Would you like me to teach you Dash hands-on (step by step with practice tasks), or
should I prepare a quick interview crash course so you can explain it confidently
in your upcoming project call?

You said:
Do i need to learn the plotly library first?
ChatGPT said:

That’s a really good doubt 👍


Here’s the straight answer:

You don’t need to master Plotly first to start with Dash.

But since Dash uses Plotly for all its charts, having at least a basic
understanding of Plotly will make learning Dash much smoother.

🔗 How Plotly and Dash are connected

Plotly → A Python library for creating interactive charts ([Link], [Link],


etc.).

Dash → A web framework that hosts those Plotly charts inside interactive
dashboards.

Example:

import [Link] as px
import dash
from dash import dcc, html

# Create a simple chart with Plotly


fig = [Link](x=[1, 2, 3, 4], y=[10, 20, 15, 30], title="Simple Line Chart")

# Use it inside Dash


app = [Link](__name__)

[Link] = [Link]([
html.H1("Dash with Plotly"),
[Link](figure=fig)
])

if __name__ == "__main__":
app.run_server(debug=True)

👉 Here, Plotly builds the chart, and Dash displays it in a web app.

📌 Recommendation for you

Since you have an interview evaluation on Dash soon:

Don’t go too deep into Plotly now.

Learn just the basics (line chart, bar chart, scatter, pie, etc.).

Focus on how to embed those charts in Dash and make them interactive with
callbacks.

⚡ I can give you a short Plotly crash course (only the essentials needed for Dash)
before we dive into Dash fully.

Do you want me to prepare that mini Plotly crash course for you first?

You said:
Plotly basics
ChatGPT said:
Perfect ⚡ Let’s do a mini Plotly crash course — just enough to make you comfortable
when using it inside Dash apps.

📊 Plotly Basics (Python)

Plotly has two main interfaces:

Plotly Express (px) → High-level, quick plotting.

Graph Objects (go) → More control, advanced customization.

For your Dash interview prep, most of the time Plotly Express is enough.

1. Installation
pip install plotly

2. Import
import [Link] as px

3. Create Basic Charts


📈 Line Chart
import [Link] as px

fig = [Link](x=[1, 2, 3, 4], y=[10, 20, 15, 30], title="Simple Line Chart")
[Link]()

📊 Bar Chart
fig = [Link](x=["A", "B", "C"], y=[10, 20, 15], title="Bar Chart Example")
[Link]()

🟢 Scatter Plot
fig = [Link](x=[5, 10, 15, 20], y=[3, 6, 9, 12], title="Scatter Plot Example")
[Link]()

🥧 Pie Chart
fig = [Link](names=["Apples", "Bananas", "Cherries"], values=[30, 40, 30],
title="Pie Chart Example")
[Link]()

4. Using a Dataset

Plotly has sample datasets:

import [Link] as px

df = [Link]().query("year == 2007") # Filter for year 2007

fig = [Link](
df, x="gdpPercap", y="lifeExp",
size="pop", color="continent",
hover_name="country", log_x=True, size_max=60,
title="GDP vs Life Expectancy (2007)"
)
[Link]()

5. Customizing a Chart
fig.update_layout(
title="Customized Chart",
xaxis_title="X Axis Label",
yaxis_title="Y Axis Label",
template="plotly_dark" # dark theme
)
[Link]()

🔑 Key Takeaways

px (Plotly Express) = quick charts.

[Link]() = display in Jupyter Notebook or browser.

Customize with update_layout() for styling.

In Dash, instead of [Link](), you pass fig into [Link](figure=fig).

👉 Now you know the basics of Plotly. Next, we’ll take these charts and embed them
into Dash apps with interactivity.

Would you like me to show you your first Dash app using a Plotly chart next?

You said:
what about [Link] module?
ChatGPT said:

Good question 🙌 — you’ve probably seen [Link] mentioned in older tutorials.


Let me clear this up for you.

🔎 What is [Link]?

In older versions of Plotly, you had two ways to render charts:

Online mode → charts are hosted on Plotly’s cloud.

Offline mode → charts are rendered locally (in Jupyter Notebook or a browser).

The [Link] module was used for offline rendering before Plotly Express
became the standard.

Example (old way):

import plotly.graph_objs as go
from [Link] import plot

fig = [Link](data=[[Link](x=["A", "B", "C"], y=[10, 20, 15])])


plot(fig) # Opens chart in browser offline

⚡ Current Situation (Plotly ≥ v4)

Starting with Plotly v4 (2019):

Plotly works offline by default.

You don’t need [Link] anymore.

You just call .show(), and it opens in your browser or Jupyter Notebook.

Example (new way, recommended):

import [Link] as px
fig = [Link](x=["A", "B", "C"], y=[10, 20, 15], title="Bar Chart")
[Link]() # Works offline by default

📝 When is [Link] still used?

If you’re working with older codebases (pre-v4).

If you need static HTML export without using .show().

Example:

from [Link] import plot


import [Link] as px

fig = [Link](x=[1, 2, 3], y=[10, 20, 30])


plot(fig, filename="[Link]") # Saves chart to HTML file

✅ For your Dash learning:

You don’t need [Link].

Just use [Link] (px) + .show() for standalone charts.

Inside Dash, you’ll use:

[Link](figure=fig)

👉 Do you want me to show you how to embed the Plotly charts you just learned (bar,
line, scatter) into a basic Dash app so you see the connection directly?

You said:
go ahead with current situation only
ChatGPT said:

Perfect 👍 let’s stick with the current Plotly (v4+) workflow — no [Link],
only the modern way.

Now, I’ll show you how to take the Plotly charts we just built and embed them into
a Dash app.

🚀 Dash with Plotly (Current Way)


Step 1: Install (if not already done)
pip install dash plotly

Step 2: Basic Dash App with Plotly Chart


import dash
from dash import dcc, html
import [Link] as px

# Create a sample chart with Plotly


fig = [Link](x=["A", "B", "C"], y=[10, 20, 15], title="Bar Chart Example")

# Initialize Dash app


app = [Link](__name__)

# Define layout
[Link] = [Link]([
html.H1("My First Dash App with Plotly"),
[Link](figure=fig) # Embed Plotly chart here
])

# Run app
if __name__ == "__main__":
app.run_server(debug=True)

👉 Run it:

python [Link]

Open [Link] in your browser → you’ll see your interactive Plotly


bar chart inside Dash 🎉.

Step 3: Add More Charts (Line + Scatter)

You can add multiple charts inside the layout:

fig1 = [Link](x=[1, 2, 3, 4], y=[10, 20, 15, 30], title="Line Chart")


fig2 = [Link](x=[5, 10, 15, 20], y=[3, 6, 9, 12], title="Scatter Plot")

[Link] = [Link]([
html.H1("Multiple Charts in Dash"),
[Link](figure=fig), # Bar
[Link](figure=fig1), # Line
[Link](figure=fig2) # Scatter
])

🔑 Key Takeaways (Current Way)

Plotly Express (px) → Build charts.

Dash ([Link]) → Display charts in a web app.

No [Link] needed → .show() works for standalone charts,


[Link](figure=fig) for Dash.

✅ Now you’ve officially connected Plotly → Dash.

Do you want me to go next into Dash Callbacks (where you make charts interactive —
like dropdowns filtering data), since that’s the heart of Dash and often asked in
interviews?

You said:
Can you give me what to learn in an order or like schedule or syllabus to learn
this library or what all should learn?
ChatGPT said:

Got it ✅ You want a structured syllabus/learning roadmap for Dash (with Plotly
integration). That’s smart because Dash has a lot of pieces, and without order it
feels scattered.

Here’s a step-by-step learning path you can follow 👇

📚 Dash Learning Roadmap (with Plotly)


1. Prerequisites (very quick)
Python basics (functions, lists, dicts).

Pandas basics (loading CSV, filtering, grouping).

Plotly basics (line, bar, scatter, pie).

2. Dash Foundations

🔹 Learn the building blocks of a Dash app.

Installing Dash

App structure (app = [Link](__name__))

Layout basics ([Link], html.H1, [Link])

Running app (app.run_server)

👉 Mini-task: Create a simple app with an H1 title and a Plotly chart.

3. Layouts and Components

🔹 Learn how to arrange UI elements.

HTML components ([Link], html.H1, html.P, etc.)

Core components ([Link], [Link], [Link], [Link])

Styling with CSS (inline styles & external CSS)

Dash Bootstrap Components (optional, for nicer UI)

👉 Mini-task: Create a layout with 2 charts, a dropdown, and a paragraph.

4. Callbacks (the heart of Dash)

🔹 This is the most important concept.

Inputs, Outputs, and States

How @[Link] works

Updating text dynamically

Updating charts dynamically

Multiple inputs & multiple outputs

👉 Mini-task: Dropdown to choose a country → show its GDP chart.

5. Working with Data

🔹 Connect data to your dashboards.

Using Pandas with Dash

Filtering data with dropdowns/sliders


Displaying tables (dash.dash_table)

Uploading CSV files ([Link])

👉 Mini-task: Upload a CSV → show table and chart.

6. Multi-Page Apps

🔹 For larger dashboards.

Dash Pages (dash.register_page)

Navigation between pages

Passing data between pages

👉 Mini-task: Page 1 (overview chart), Page 2 (detailed chart).

7. Styling & Deployment

🔹 Make it look nice and shareable.

CSS styling & Bootstrap themes

Adding navigation bars

Exporting charts as images

Deployment (Heroku, Render, or internal servers)

👉 Mini-task: Deploy your dashboard online.

8. Advanced Features (Optional but Good for Interviews)

Live updates ([Link])

Real-time data streaming

Authentication (basic security)

Performance optimizations (caching, large datasets)

🎯 Suggested Learning Schedule (2–3 weeks)

If you have limited time (e.g., for your project call), follow this timeline:

Day 1–2: Plotly basics + Dash foundations.

Day 3–5: Layouts + components.

Day 6–10: Callbacks (spend most time here).

Day 11–13: Data handling (CSV upload, tables, filtering).

Day 14–15: Multi-page apps + styling.

Day 16–17: Mini project (e.g., Sales Dashboard).

Day 18–20: Deployment + polish.


✅ By the end, you’ll be confident to:

Explain what Dash is.

Show how to build dashboards with Plotly charts.

Implement interactive filtering with callbacks.

Deploy a working dashboard app.

Do you want me to design a hands-on mini project syllabus (like “build this
dashboard step by step”) along this roadmap, so you’ll practice while learning?

You said:
Can we start with Pandas basics
ChatGPT said:

Perfect move ✅ Dharani — before we dive deep into Dash, getting comfortable with
Pandas basics will help you handle real-world datasets (CSV/Excel) in dashboards.

Let’s build this step by step 👇

📚 Pandas Basics for Dash


1. Installation
pip install pandas

2. Import
import pandas as pd

3. Creating DataFrames
From a dictionary
data = {
"Name": ["Alice", "Bob", "Charlie"],
"Age": [24, 27, 22],
"City": ["New York", "London", "Paris"]
}
df = [Link](data)
print(df)

Output:

Name Age City


0 Alice 24 New York
1 Bob 27 London
2 Charlie 22 Paris

4. Reading Data

From CSV:

df = pd.read_csv("[Link]")

From Excel:

df = pd.read_excel("[Link]")
5. Inspecting Data
[Link]() # first 5 rows
[Link]() # last 5 rows
[Link] # (rows, columns)
[Link]() # summary
[Link]() # statistics

6. Selecting Data

Column:

df["Name"] # single column


df[["Name", "Age"]] # multiple columns

Row by index:

[Link][0] # first row


[Link][0:2] # first 2 rows

Row by condition:

df[df["Age"] > 23]

7. Modifying Data

Add new column:

df["Country"] = ["USA", "UK", "France"]

Update values:

[Link][0, "Age"] = 25 # update first row’s Age

8. Grouping and Aggregation


[Link]("City")["Age"].mean()

9. Sorting
df.sort_values("Age", ascending=False)

10. Saving Data


df.to_csv("[Link]", index=False)

✅ That’s the Pandas starter toolkit — enough to load, explore, filter, and prepare
data for Dash visualizations.

👉 Next step for you:


Do you want me to create a mini dataset + practice exercises (like filtering sales
by region, average by category, etc.) so you can get hands-on Pandas before we jump
into Dash?

You said:
| Empid | Name | Role | Salary |
| ----- | ------- | --------------------------- | ------ |
| 1001 | Dharani | GenAI Developer | 20LPA |
| 1002 | Jay | SDE | 40LPA |
| 1003 | Vassu | Software Engineer | 15LPA |
| 1004 | Suresh | Assistant Software Engineer | 7LPA |
| 1005 | Harsha | Web Developer | 30LPA |
| 1006 | Ramesh | Data Scientist | 28LPA |
| 1007 | Priya | Cloud Engineer | 22LPA |
| 1008 | Kiran | Business Analyst | 18LPA |
| 1009 | Anjali | Machine Learning Engineer | 35LPA |
| 1010 | Rohit | System Administrator | 12LPA |
| 1011 | Sneha | DevOps Engineer | 25LPA |
| 1012 | Arjun | Backend Developer | 19LPA |
| 1013 | Kavya | Frontend Developer | 16LPA |
| 1014 | Manoj | AI Researcher | 45LPA |
| 1015 | Deepa | Database Administrator | 14LPA |
| 1016 | Naveen | Network Engineer | 13LPA |
| 1017 | Swathi | Mobile App Developer | 17LPA |
| 1018 | Akash | Product Manager | 50LPA |
| 1019 | Varun | UI/UX Designer | 21LPA |
| 1020 | Meena | Cybersecurity Specialist | 32LPA |

This is the data excel i'm using to practice. Please tell me according to this

ChatGPT said:

Awesome 👌 Dharani — that’s a great practice dataset (Employee Info). We’ll use it
to practice Pandas basics step by step, exactly on this data.

First, let’s assume your Excel file is named:


📂 [Link] (with a sheet named Sheet1).

📊 Pandas with Your Employee Dataset


1. Load the Excel File
import pandas as pd

df = pd.read_excel("[Link]")
print([Link]())

2. Inspect Data
[Link] # (20, 4) → 20 rows, 4 columns
[Link]() # column types
[Link]() # works only for numeric columns (Salary is text now)

⚠️ Notice: Salary column has values like 20LPA, 40LPA.


We should convert Salary to numbers (remove "LPA").

3. Clean Salary Column


df["Salary"] = df["Salary"].[Link]("LPA", "").astype(int)
print([Link]())

Now Salary is numeric → much easier for calculations.

4. Selecting Data

Get all employee names:

df["Name"]
Get Names and Roles:

df[["Name", "Role"]]

Get first 5 employees:

[Link](5)

5. Filtering Data

Employees with Salary > 30 LPA:

df[df["Salary"] > 30]

All Developers:

df[df["Role"].[Link]("Developer")]

6. Sorting

Sort employees by Salary (descending):

df.sort_values("Salary", ascending=False)

7. Aggregation

Average Salary:

df["Salary"].mean()

Highest Paid Employee:

df[df["Salary"] == df["Salary"].max()]

Count of each Role:

df["Role"].value_counts()

8. Grouping

Group by Role (average Salary per Role):

[Link]("Role")["Salary"].mean()

9. Adding New Column

Add a new column for yearly salary in INR (assuming 1 LPA = ₹1,00,000):

df["Salary_INR"] = df["Salary"] * 100000


print([Link]())

10. Save Processed Data


df.to_csv("employees_cleaned.csv", index=False)

✅ Practice Questions for You


Try these on your dataset:

List employees earning more than 25 LPA.

Who is the lowest-paid employee?

Get all employees whose Role contains "Engineer".

Show the top 3 highest salaries.

Calculate the average salary of all Developers (Frontend, Backend, Web, Mobile
App).

👉 Do you want me to solve these practice questions step by step with Pandas code
(so you can verify your answers), or do you want to try them first and I’ll check
your work?

You said:
Can we start with Plotly basics
ChatGPT said:

Perfect ⚡ Dharani — let’s shift gears into Plotly basics now, since you’ll be
embedding these charts inside Dash soon. We’ll keep it hands-on with your employee
dataset instead of generic examples.

📊 Plotly Basics with Employee Dataset

First, make sure:

pip install plotly

1. Import and Load Data


import pandas as pd
import [Link] as px

df = pd.read_excel("[Link]")

# Clean Salary column (remove 'LPA')


df["Salary"] = df["Salary"].[Link]("LPA", "").astype(int)

2. Bar Chart — Salary by Employee


fig = [Link](df, x="Name", y="Salary", title="Salary of Employees")
[Link]()

👉 Shows each employee’s salary.

3. Horizontal Bar Chart — Salary by Role


fig = [Link](df, x="Salary", y="Role", orientation="h", title="Salaries by Role")
[Link]()

👉 Roles on Y-axis, salaries on X-axis.

4. Pie Chart — Salary Share


fig = [Link](df, names="Role", values="Salary", title="Salary Distribution by
Role")
[Link]()
👉 Shows how total salaries are distributed across roles.

5. Scatter Plot — Employee ID vs Salary


fig = [Link](df, x="Empid", y="Salary", color="Role", size="Salary",
title="Salary by EmpID")
[Link]()

👉 Bubble size = Salary, color = Role.

6. Line Chart — Sorted Salaries


df_sorted = df.sort_values("Empid")
fig = [Link](df_sorted, x="Empid", y="Salary", title="Employee Salaries (Line
Chart)")
[Link]()

7. Box Plot — Salary Distribution


fig = [Link](df, y="Salary", title="Salary Distribution")
[Link]()

👉 Useful to see median, outliers, spread of salaries.

8. Customize Chart
fig = [Link](df, x="Name", y="Salary", title="Customized Salary Chart")
fig.update_layout(
xaxis_title="Employee Name",
yaxis_title="Salary (in LPA)",
template="plotly_dark"
)
[Link]()

👉 Dark theme + labeled axes.

✅ Practice Tasks for You

Try these with your dataset:

Create a bar chart showing the top 5 highest salaries.

Create a pie chart showing the percentage of employees in each Role category.

Create a scatter plot of Salary vs Empid with Role as color.

Make a box plot of Developer salaries only (Frontend, Backend, Web, Mobile).

👉 Do you want me to walk you through these practice tasks one by one (writing the
code + explanation), or should I give you the questions first and then we solve
them together?

You said:
Also explain the concepts don't just give code
ChatGPT said:

Got it ✅ Dharani — we’ll slow down and go concept + code + explanation so you
actually understand what’s happening under the hood in Plotly, not just run code
blindly.

Let’s start step by step with your employee dataset.

📊 Plotly Basics — With Concepts


Step 1: Import + Data Cleaning
import pandas as pd
import [Link] as px

# Load Excel
df = pd.read_excel("[Link]")

# Clean Salary column (remove "LPA" and convert to integer)


df["Salary"] = df["Salary"].[Link]("LPA", "").astype(int)

🔎 Concepts:

[Link] (px) is the high-level API for quick charting.

Plotly works best when the data is in a Pandas DataFrame (columns = variables, rows
= observations).

Cleaning Salary is important because Plotly expects numeric types for plotting on
axes, not strings like "20LPA".

Step 2: Bar Chart (Salaries of Employees)


fig = [Link](df, x="Name", y="Salary", title="Salary of Employees")
[Link]()

🔎 Concepts:

Bar Chart → best for comparing values between categories.

x="Name" → categories on the X-axis.

y="Salary" → numeric values (heights of bars).

title → chart title.

[Link]() → renders the chart in browser or Jupyter.

👉 Here: Each employee’s salary is shown as a bar, letting you easily see who earns
more.

Step 3: Horizontal Bar Chart (Role vs Salary)


fig = [Link](df, x="Salary", y="Role", orientation="h", title="Salaries by Role")
[Link]()

🔎 Concepts:

Same as bar chart, but flipped (orientation="h").

Useful when category names (like job roles) are long.

Here: It compares salaries across different roles in a horizontal view.


Step 4: Pie Chart (Salary Distribution by Role)
fig = [Link](df, names="Role", values="Salary", title="Salary Distribution by
Role")
[Link]()

🔎 Concepts:

Pie Chart → shows how a total is divided among categories.

names="Role" → each slice = role.

values="Salary" → size of slice proportional to total salary.

Helps answer: “Which roles take up the biggest chunk of salaries?”

Step 5: Scatter Plot (EmpID vs Salary)


fig = [Link](
df, x="Empid", y="Salary", color="Role", size="Salary",
title="Salary by Employee ID"
)
[Link]()

🔎 Concepts:

Scatter Plot → shows relationship between two numeric variables.

x="Empid" → employee IDs (acts like index).

y="Salary" → salaries.

color="Role" → different roles get different colors.

size="Salary" → bigger bubbles = higher salaries.

👉 Lets you see distribution of salaries across IDs and roles.

Step 6: Line Chart (Sorted Salaries by Employee ID)


df_sorted = df.sort_values("Empid")

fig = [Link](df_sorted, x="Empid", y="Salary", title="Employee Salaries (Line


Chart)")
[Link]()

🔎 Concepts:

Line Chart → shows trends or progression across ordered values.

Here: Since EmpIDs are sequential, a line chart shows how salaries vary with
employee IDs.

Step 7: Box Plot (Salary Distribution)


fig = [Link](df, y="Salary", title="Salary Distribution")
[Link]()

🔎 Concepts:
Box Plot → shows distribution of data (min, max, median, quartiles).

Helps detect outliers and spread.

Here: You can see typical salary range, and if some roles are outliers (like 50
LPA).

Step 8: Customizing Charts


fig = [Link](df, x="Name", y="Salary", title="Customized Salary Chart")
fig.update_layout(
xaxis_title="Employee Name",
yaxis_title="Salary (in LPA)",
template="plotly_dark"
)
[Link]()

🔎 Concepts:

update_layout() → modify title, labels, theme, gridlines.

template="plotly_dark" → applies dark theme.

Customization makes dashboards look professional.

✅ Summary of Concepts

Bar/Horizontal Bar → Compare categories.

Pie → Distribution across categories.

Scatter → Relationship between two variables.

Line → Trends over ordered values.

Box → Spread + outliers.

Customization → Titles, labels, themes.

👉 Dharani, here’s a thought:


Do you want me to map each Plotly chart type to a real-world interview-ready use
case (like “bar chart is used for comparing salaries across employees”, “scatter
for salary vs years of experience”), so you’ll know when to use which chart in a
dashboard context?

You said:
I'm confused about some modules, in some documents i could see they mentioned
plotly.graph_objs
ChatGPT said:

That’s a great observation, Dharani 👌 — the confusion is natural because Plotly has
two main ways (APIs) to create visualizations:

🔹 1. Plotly Express ([Link] / px)

High-level API → Quick, simple, and beginner-friendly.

Mostly used for 90% of typical visualizations (bar, scatter, pie, line, box, etc.).
Syntax is short and clean.

✅ Example:

import [Link] as px

fig = [Link](df, x="Name", y="Salary", title="Employee Salaries")


[Link]()

Here, you just tell Plotly which column is x, which is y → Plotly handles the rest.

🔹 2. Plotly Graph Objects (plotly.graph_objs / go)

Low-level API → More flexible, detailed, and customizable.

You build charts piece by piece: data traces, layout, style.

Used when you need fine control or complex dashboards.

✅ Example (same bar chart, but using go):

import plotly.graph_objs as go

fig = [Link](
data=[
[Link](x=df["Name"], y=df["Salary"])
]
)

fig.update_layout(
title="Employee Salaries",
xaxis_title="Name",
yaxis_title="Salary (in LPA)"
)

[Link]()

Notice:

You manually specify [Link]().

[Link]() acts like a container for data + layout.

More verbose, but allows deep customization.

🔹 When to Use Which?


Feature Plotly Express (px) Plotly Graph Objects (go)
Ease of Use Very easy (one-liners) Verbose, step by step
Customization Limited Very powerful
Best for Quick visualizations, learning, simple dashboards Complex
dashboards, fine-tuned control
Example [Link](df, x="Name", y="Salary") [Link](data=[[Link](...)])
✅ How they work together

In reality, Plotly Express is built on top of Graph Objects.


A [Link]() internally creates a [Link]() with a [Link]() trace.

So both are valid and interchangeable — it depends on whether you want simplicity
or control.

👉 Dharani, since you’re just starting out, I recommend:

Begin with [Link] (clean syntax, focus on concepts).

Later, once comfortable, explore plotly.graph_objs for advanced dashboards.

Would you like me to show you side-by-side comparisons (same chart in px vs go)
using your employee dataset? That way you’ll see clearly how both approaches work.

You said:
Are we done with this ? Or there anything i need to learn. If learning about is
plotly till this extent is enough, then we will move to the next phase of the
Learning path
ChatGPT said:

Great question 👍 Dharani — let’s pause and take stock.

✅ What you’ve learned so far in Plotly

Core idea: Plotly = interactive visualization library.

Two APIs:

[Link] (px) → high-level, quick, beginner-friendly.

plotly.graph_objs (go) → low-level, flexible, detailed control.

Basic plots with your dataset: bar, line, pie, scatter, box, etc.

Customization: titles, axis labels, themes.

Understanding: px is built on top of go.

That’s already a solid foundation for moving forward. 🎯

🚦 Do you need to go deeper into Plotly now?

Since your main goal is Dash (for interview & real projects):

You don’t need to master every single Plotly chart (like choropleth maps, 3D
surfaces, ternary plots, etc.).

You just need to know:


✅ How to make basic charts (bar, line, pie, scatter, box).
✅ How to customize charts (title, axis labels, themes).
✅ How to pass those Plotly figures into Dash ([Link]).

👉 That level of Plotly knowledge is enough right now.

📌 Next Phase: Start with Dash Basics

Here’s what we’ll cover in Dash:

Dash App Structure → [Link](), layout, components (html, dcc).


Displaying static Plotly charts inside Dash.

Interactive callbacks → connecting inputs (dropdowns, sliders, buttons) to outputs


(charts, text).

Multi-page apps & layouts (if time permits).

That’s the real power of Dash — turning your charts into interactive dashboards.

👉 So yes, you’re done with Plotly basics (for now) 🎉.


Shall we start Dash Phase 1: Building your very first simple Dash app?

You said:

📌 Next Phase: Start with **Dash Basics** -----------------------------------------


Here’s what we’ll cover in Dash: 1. **Dash App Structure** → `[Link]()`, layout,
components (`html`, `dcc`). 2. **Displaying static Plotly charts** inside Dash. 3.
**Interactive callbacks** → connecting inputs (dropdowns, sliders, buttons) to
outputs (charts, text). 4. **Multi-page apps & layouts** (if time permits). That’s
the real power of Dash — turning your charts into **interactive dashboards**.

yess
ChatGPT said:

Perfect ⚡ Dharani! Let’s kick off Dash Phase 1 step by step.

🚀 Dash Basics — Phase 1


1. Install Dash

First, make sure Dash is installed:

pip install dash

This will install:

dash → the main framework

dash-html-components → HTML tags (like <div>, <h1>)

dash-core-components → interactive components (graphs, dropdowns, sliders)

plotly → charts (we already covered)

2. Dash App Structure

A Dash app always has two main parts:

App Initialization

import dash
from dash import dcc, html

app = [Link](__name__)

Layout → Defines what your app looks like


[Link] = [Link]([
html.H1("My First Dash App"),
html.P("Hello, Dharani! This is a simple Dash app.")
])

Run Server

if __name__ == "__main__":
app.run_server(debug=True)

👉 Save this as [Link], run it with:

python [Link]

Then open [Link] in your browser. 🎉

3. Displaying a Plotly Chart in Dash

Now let’s add a chart from your employee dataset.

import pandas as pd
import [Link] as px
import dash
from dash import dcc, html

# Load Data
df = pd.read_excel("[Link]")
df["Salary"] = df["Salary"].[Link]("LPA", "").astype(int)

# Create Chart
fig = [Link](df, x="Name", y="Salary", title="Employee Salaries")

# Initialize App
app = [Link](__name__)

# Layout
[Link] = [Link]([
html.H1("Employee Dashboard"),
[Link](figure=fig)
])

# Run
if __name__ == "__main__":
app.run_server(debug=True)

👉 This will show an interactive bar chart in your web browser.

✅ Your First Task

Run the above app.

Change the chart to a pie chart (Salary Distribution by Role).

Try adding a second chart below it.


Would you like me to explain the concepts of [Link], html.H1, and [Link] in
detail before we move on to interactivity? That way you’ll know exactly how the
layout system works.

You said:
Can you first tell what is dash. I would like a small intro about this in detail
ChatGPT said:

Absolutely Dharani 👍 Let’s properly introduce Dash before we dive into coding.

🌐 What is Dash?

Dash is a Python framework for building interactive web applications and dashboards
— especially those with data visualizations.

Developed by Plotly (the same company behind Plotly charts).

Lets you create full web apps using only Python — no need to learn HTML, CSS, or
JavaScript separately.

It is open-source and widely used in data science, AI/ML, finance, healthcare, IoT,
etc.

🧩 Why use Dash?

Normally, if you want to build a data dashboard:

You’d use Plotly (for charts),

Plus Flask/Django (for backend),

Plus React/Angular/Vue (for frontend).

⚡ But Dash combines all of this into one simple Python package.

👉 You just write Python code → Dash turns it into a full-fledged web app.

🔑 Key Features of Dash

Built on Plotly → All charts are interactive and beautiful by default.

Pure Python → You don’t need to touch JavaScript, but your app still behaves like a
ReactJS app.

Components

[Link] → HTML elements (like <div>, <h1>, <p>).

[Link] → Interactive UI components (dropdowns, sliders, graphs, input boxes).

Callbacks → Functions that make your app interactive (update a chart when the user
changes a dropdown).

Scalable → Used in production for enterprise dashboards.

Dash App Structure (Conceptual)

Every Dash app has 3 building blocks:


App Initialization

app = [Link](__name__)

Layout → Defines the UI (what users see)


Example: text, graphs, buttons, dropdowns.

Callbacks → Define the logic (how the app reacts to user input).
Example: If a user selects "GenAI Developer", update the salary chart.

📊 Where Dash is Used

Finance → stock dashboards, risk analysis.

AI/ML → model monitoring, prediction dashboards.

Healthcare → patient monitoring dashboards.

Business → KPI dashboards for decision-making.

✅ In short:
👉 Plotly makes beautiful interactive charts.
👉 Dash turns those charts into full web apps with filters, dropdowns, and
interactivity.

⚡ Example in one line:


Think of Dash as a “Python + Plotly + ReactJS + Flask” hybrid framework, but
simplified so you only need Python.

Do you want me to now break down Dash components (html, dcc, and callbacks) in
detail, so you fully understand how an app is structured before writing code?

You said:
Now start we will start with dash tutorial and also explain me about the modules we
will use and why we are using only those modules. I need everything in a good
process.
ChatGPT said:

Got it Dharani ⚡ — we’ll do this like a step-by-step Dash tutorial, and at each
step I’ll explain:

Which module we import

Why we need it

How it fits into the bigger picture

This way, you won’t just “copy code” — you’ll understand the process and purpose.

📘 Dash Tutorial — Phase 1: Basics


1. The Core Modules We Use in Dash

When building Dash apps, we generally use 3 main modules:

🔹 dash

The main framework.


It provides the Dash() class to initialize the app.

It connects everything (layout + callbacks + server).

import dash
app = [Link](__name__)

👉 Without this, you can’t start a Dash app.

🔹 [Link] (HTML Components)

Lets you use HTML tags like <div>, <h1>, <p> directly in Python.

Example:

from dash import html


html.H1("Employee Dashboard")

👉 This creates an H1 heading in your web app.


Instead of writing raw HTML code, we use this Python wrapper.

🔹 [Link] (Dash Core Components)

Contains interactive components:

[Link] → Display Plotly charts

[Link] → Create dropdown menus

[Link] → Create sliders

[Link] → Text inputs

Example:

from dash import dcc


[Link](figure=fig)

👉 This displays your Plotly chart (fig) inside the Dash app.

🔹 [Link] (or plotly.graph_objs)

Dash itself doesn’t create charts → it just displays them.

We use Plotly to build the actual charts.

[Link] → quick one-liner charts.

plotly.graph_objs → more detailed charts (we’ll explore later).

🔹 pandas

Optional, but in real projects data always comes from CSV/Excel/Database.

Pandas is used for loading and manipulating data before passing it to Plotly.
2. First Minimal Dash App

Now let’s build a very simple app — no charts yet.

import dash
from dash import html

# Initialize app
app = [Link](__name__)

# Layout (UI)
[Link] = [Link]([
html.H1("Hello Dharani 👋"),
html.P("This is your very first Dash app!")
])

# Run app
if __name__ == "__main__":
app.run_server(debug=True)

[Link] → A container (like <div> in HTML).

html.H1 → Big heading.

html.P → Paragraph text.

👉 Run this (python [Link]) → Open browser → You’ll see text on a webpage.

3. Dash App with a Plotly Chart

Now let’s bring everything together with your employee dataset.

import dash
from dash import dcc, html
import pandas as pd
import [Link] as px

# Load data
df = pd.read_excel("[Link]")
df["Salary"] = df["Salary"].[Link]("LPA", "").astype(int)

# Create a chart with Plotly


fig = [Link](df, x="Name", y="Salary", title="Employee Salaries")

# Initialize app
app = [Link](__name__)

# Layout
[Link] = [Link]([
html.H1("Employee Dashboard"),
html.P("This dashboard shows employee salaries."),
[Link](figure=fig) # Embed chart here
])

# Run server
if __name__ == "__main__":
app.run_server(debug=True)
👉 Now you have:

Heading (H1)

Paragraph (P)

Interactive bar chart ([Link])

✅ So Phase 1 covers:

What Dash is

Modules (dash, html, dcc, plotly, pandas) and why we need them

A minimal app (text only)

First app with a chart

⚡ Next Phase:
We’ll move into interactivity with callbacks (e.g., dropdown → updates chart).

Do you want me to:

Deep dive into the layout system ([Link], html.H1, [Link], nesting) first,
or

Jump directly to callbacks (making app interactive)?

You said:

**1\. The Core Modules We Use in Dash** ---------------------------------------


When building Dash apps, we generally use 3 main modules:

What are the three main modules


ChatGPT said:

Good question, Dharani 👍 — let’s make this crystal clear.

When we say 3 main modules in Dash, we mean the core building blocks you’ll use in
every Dash app:

🔑 The Three Main Modules


1 dash
1️⃣

The heart of Dash.

Provides the Dash() class to initialize the app and run the server.

Without this, there’s no Dash app at all.

Example:

import dash
app = [Link](__name__)

2️⃣ [Link] (HTML Components)

Lets you create HTML elements (headings, divs, paragraphs, etc.) in Python code.
It’s basically a Python wrapper for HTML tags.

Example:

from dash import html


html.H1("Employee Dashboard") # Equivalent to <h1>Employee Dashboard</h1>

3️⃣ [Link] (Dash Core Components)

Provides interactive components like:

[Link] → Display Plotly charts

[Link] → Dropdown menus

[Link] → Sliders

[Link] → Text boxes

Example:

from dash import dcc


[Link](figure=fig)

📌 Summary

dash → Core app & server

[Link] → Layout with HTML tags

[Link] → Interactive UI components

👉 These three modules together let you build any Dash app.
Everything else (like plotly or pandas) is supporting libraries for data and
charts.

Would you like me to now explain the layout system (how [Link], html.H1,
[Link] fit together like a tree) before we move on to interactivity?

You said:
Start dash from beginning and explain the code also line by line
ChatGPT said:

Perfect Dharani 👍 we’ll start Dash from the very beginning, write the simplest
possible app, and I’ll explain line by line what’s happening.

🚀 Dash App: Step 1 (Hello World Example)


# Step 1: Import the Dash library
import dash
from dash import html

# Step 2: Initialize the Dash app


app = [Link](__name__)

# Step 3: Define the layout (what appears on the webpage)


[Link] = [Link]([
html.H1("Hello Dharani 👋"),
html.P("Welcome to your first Dash app.")
])

# Step 4: Run the Dash app


if __name__ == "__main__":
app.run_server(debug=True)

🔎 Line by Line Explanation


import dash

Imports the main Dash framework.

Needed to create and run the app.

from dash import html

Imports the HTML components module.

Lets us use HTML tags (like <h1>, <p>, <div>) inside Python.

Example:

html.H1("Hello") → <h1>Hello</h1>

html.P("Text") → <p>Text</p>

👉 Without this, you can’t display text/layout on the page.

app = [Link](__name__)

Creates a Dash app instance.

__name__ tells Dash where the app is located (used for server setup).

Think of this like: “Start my app”.

[Link] = [Link]([...])

Defines what the app looks like (the UI).

[Link]() → A container (like <div> in HTML).

Inside it, we place children components (headings, text, charts, etc.).

In our example:

html.H1("Hello Dharani 👋") → Big heading on the page.

html.P("Welcome to your first Dash app.") → Paragraph text.

if __name__ == "__main__":

Standard Python way of saying: “Run this only if this file is executed directly.”

Prevents accidental execution if imported somewhere else.

app.run_server(debug=True)

Runs the Dash server (a mini web server built into Dash).
Opens the app at: [Link]

debug=True → auto-reloads app whenever you save changes, and shows errors clearly.

✅ What Happens When You Run This?

You type python [Link] in terminal.

Dash starts a local web server.

Open browser → go to [Link]

You’ll see:

A big heading: Hello Dharani 👋

A paragraph: Welcome to your first Dash app.

👉 This is the foundation.


From here, we’ll add Plotly charts, interactivity (callbacks), dropdowns, and
multiple components step by step.

⚡ Question for you Dharani:


Do you want me to first expand the layout system (show how to add multiple texts,
sections, charts in [Link]) OR should we jump straight to adding your first
Plotly chart inside Dash?

You said:
With conceptss
ChatGPT said:

Got it Dharani 👍 — we’ll expand slowly with concepts + examples so you understand
how Dash really works under the hood.

🧩 Dash Concepts — Layout System

The layout in Dash defines what your app looks like.


Think of it like a tree of components (just like HTML).

1. The Layout is a Component Tree

Every Dash app needs:

[Link] = <some Dash component>

Usually, we use [Link] as the root container, and inside it we add other
components.

Example:

[Link] = [Link]([
html.H1("Heading"),
html.P("This is a paragraph."),
[Link]([
html.H3("Nested Section"),
html.P("More text inside another Div.")
])
])
🔎 Concept:

[Link]() → like <div> in HTML → a box/container.

children=[...] → inside that box, we put other components.

This forms a hierarchy (tree structure).

👉 This is exactly how websites are built (HTML DOM tree).

2. Basic HTML Components in Dash

Some commonly used:

html.H1, html.H2, … html.H6 → Headings (big → small).

html.P → Paragraph text.

[Link] → Container (can hold multiple components).

[Link] → Display image.

html.A → Link.

[Link] → Button.

Example:

[Link] = [Link]([
html.H1("Employee Dashboard"),
html.H3("Team Salaries Overview"),
html.P("This dashboard shows employee roles and salaries."),
[Link]("Click Me", id="btn")
])

3. Adding a Plotly Chart

To display charts, we use Dash Core Components (dcc).

[Link] → displays any Plotly figure.

Example:

import [Link] as px

# Create a chart
fig = [Link](df, x="Name", y="Salary", title="Employee Salaries")

# Add it to layout
[Link] = [Link]([
html.H1("Employee Dashboard"),
[Link](figure=fig)
])

👉 Concept:

[Link] acts like a chart placeholder.


figure=fig → Passes a Plotly figure object into it.

4. Layout = Static Page (For Now)

Right now:

Whatever we put in [Link] → always appears on the page.

There’s no interactivity yet (we’ll add callbacks later).

So in Phase 1, we focus on:

Learning how to build layouts (text + charts + sections).

Understanding the tree structure (Divs inside Divs).

✅ Mini Exercise for You

Try building this layout (without charts yet):

Employee Dashboard
------------------
[Section 1]
-> A paragraph about employees

[Section 2]
-> A subheading
-> Another paragraph

👉 Use html.H1, html.H3, html.P, and [Link] to structure it.

⚡ Dharani, do you want me to write this exact exercise code with explanation, or
would you like to try it yourself first and then I’ll correct/improve it?

You said:
Can we move to the next phase of this concept?
ChatGPT said:

Perfect Dharani 👍 since you’re clear on layout basics (the static structure with
html + dcc), let’s move to the next phase — which is where Dash really shines:

🚦 Dash Phase 2: Interactivity with Callbacks

Up to now:

Our apps are static → whatever is in [Link] just shows up.

Example: A heading, a paragraph, and a chart.

Next:

We make apps dynamic → components react to user input.

This is done with callbacks.

🔑 Core Concept: Callbacks


A callback in Dash is a Python function that:

Takes input(s) (e.g., dropdown value, button click, slider).

Produces output(s) (e.g., updates a chart, changes text).

1. Import the callback decorator


from [Link] import Input, Output

Input → Something user can change (dropdown, slider, button, etc.).

Output → Something that will update (chart, text, etc.).

2. Callback Structure
@[Link](
Output(component_id="output-div", component_property="children"),
Input(component_id="input-dropdown", component_property="value")
)
def update_output(selected_value):
return f"You selected: {selected_value}"

@[Link](...) → tells Dash: “When this input changes, run this function and
update the output.”

Output("output-div", "children") → update the children of a component with id


"output-div".

Input("input-dropdown", "value") → take the value of a dropdown with id "input-


dropdown".

The function update_output() defines what happens.

3. Example with Your Employee Dataset

Let’s make a dropdown to pick an employee, and display their salary.

import dash
from dash import dcc, html
from [Link] import Input, Output
import pandas as pd

# Load data
df = pd.read_excel("[Link]")
df["Salary"] = df["Salary"].[Link]("LPA", "").astype(int)

# Initialize app
app = [Link](__name__)

# Layout
[Link] = [Link]([
html.H1("Employee Salary Finder"),

# Dropdown to select employee


[Link](
id="employee-dropdown",
options=[{"label": name, "value": name} for name in df["Name"]],
value="Dharani" # default selection
),

# Div to show output


[Link](id="salary-output", style={"marginTop": 20})
])

# Callback
@[Link](
Output("salary-output", "children"),
Input("employee-dropdown", "value")
)
def update_salary(selected_name):
salary = df[df["Name"] == selected_name]["Salary"].values[0]
return f"Salary of {selected_name}: {salary} LPA"

# Run app
if __name__ == "__main__":
app.run_server(debug=True)

🔎 What Happens Here

[Link] → lets user select an employee.

When selection changes → callback runs.

update_salary finds that employee’s salary from dataframe.

[Link](id="salary-output") gets updated with the salary info.

👉 Now the app is interactive 🎉

✅ With this, you’ve entered the real power of Dash: callbacks.


This is the foundation for dashboards with filters, dynamic charts, and live
updates.

⚡ Dharani, do you want me to stay on simple text updates with callbacks first until
you’re comfortable, or should we jump straight to interactive charts (like dropdown
→ updates chart)?

You said:
What is children ? What is specific use of this?
ChatGPT said:

Great question Dharani 🙌 — this is exactly the kind of detail that will make Dash
crystal clear for you.

🔑 What is children in Dash?

In Dash, every component (html or dcc) has properties (attributes).

Example:

html.H1("Hello") → here "Hello" is actually the children property of html.H1.

[Link](value="A") → here "A" is the value property.

So, children is just a property that holds the content inside a component.

📝 Examples
1. Static case
[Link]("Hello World")

is the same as:

[Link](children="Hello World")

Here, "Hello World" is the children of the Div.

2. Multiple children

children can be a list if you want multiple elements inside a parent.

[Link](children=[
html.H1("Dashboard"),
html.P("This is a paragraph"),
[Link](figure=...)
])

Here, the Div contains three children:

H1 heading

P paragraph

Graph

3. In Callbacks

When we say:

Output("salary-output", "children")

We’re telling Dash: “Update the children (inner content) of the component whose id
is salary-output.”

So if salary-output is:

[Link](id="salary-output")

then the callback decides what text (or even HTML) goes inside it.

For example:

def update_salary(selected_name):
return f"Salary of {selected_name}: 20 LPA"

Now the Div becomes:

<div id="salary-output">Salary of Dharani: 20 LPA</div>

🎯 Why do we use children?


To place dynamic content (text, HTML, even charts) inside a component.

It’s the default property of most html.* elements, so you don’t always write
children= explicitly.

👉 In short:

children = the stuff inside a tag/component.

Useful when callbacks need to insert/update content dynamically.

Would you like me to show you a tiny experiment where we update not just children,
but another property (like style or value) — so you see the difference between
updating children vs updating other props?

You said:
callback tutorial with line to line complete explaination
ChatGPT said:

Perfect Dharani 👍
Now let’s go step by step into a Dash callback tutorial, with code + concepts +
line-by-line explanation.
This is the core of Dash — once you master this, you can build powerful interactive
dashboards.

🚦 Dash Callback Tutorial

We’ll build a simple app:


👉 A dropdown to select an employee.
👉 A callback to display their salary dynamically.

🔹 Full Code
# 1. Import required libraries
import dash
from dash import dcc, html
from [Link] import Input, Output
import pandas as pd

# 2. Load data
df = [Link]({
"Name": ["Dharani", "Jay", "Vassu"],
"Salary": [20, 40, 15]
})

# 3. Initialize Dash app


app = [Link](__name__)

# 4. Layout (UI components)


[Link] = [Link]([
html.H1("Employee Salary Finder"),

# Dropdown
[Link](
id="employee-dropdown", # unique ID
options=[{"label": name, "value": name} for name in df["Name"]],
value="Dharani" # default selected value
),

# Placeholder Div for output


[Link](id="salary-output", style={"marginTop": 20})
])

# 5. Callback (define interactivity)


@[Link](
Output("salary-output", "children"), # Output: children of Div
Input("employee-dropdown", "value") # Input: value from Dropdown
)
def update_salary(selected_name): # Function called when input
changes
salary = df[df["Name"] == selected_name]["Salary"].values[0]
return f"Salary of {selected_name}: {salary} LPA"

# 6. Run the app


if __name__ == "__main__":
app.run_server(debug=True)

🔎 Line-by-Line Explanation
Step 1: Imports
import dash
from dash import dcc, html
from [Link] import Input, Output
import pandas as pd

dash → the main framework.

dcc → Dash Core Components (interactive widgets like dropdowns, sliders, graphs).

html → Dash HTML Components (basic HTML tags like Div, H1, P).

Input, Output → special classes used to connect components via callbacks.

pandas → for data handling (we use a DataFrame to store employee salaries).

Step 2: Load Data


df = [Link]({
"Name": ["Dharani", "Jay", "Vassu"],
"Salary": [20, 40, 15]
})

A simple DataFrame with employees and salaries.

In real projects, this can be read from Excel/CSV/SQL.

Step 3: Initialize App


app = [Link](__name__)

Creates a Dash app instance.

__name__ tells Dash where your app lives (needed for correct file structure).

Step 4: Layout
[Link] = [Link]([
html.H1("Employee Salary Finder"),

[Link](
id="employee-dropdown",
options=[{"label": name, "value": name} for name in df["Name"]],
value="Dharani"
),

[Link](id="salary-output", style={"marginTop": 20})


])

[Link]([...]) → container for all components.

html.H1("Employee Salary Finder") → heading.

[Link](...) →

id="employee-dropdown" → unique ID (used in callback).

options=[{"label": name, "value": name} for name in df["Name"]] → creates dropdown


choices dynamically from DataFrame.

value="Dharani" → default selected item.

[Link](id="salary-output") → placeholder where result will appear.

Step 5: Callback
@[Link](
Output("salary-output", "children"),
Input("employee-dropdown", "value")
)
def update_salary(selected_name):
salary = df[df["Name"] == selected_name]["Salary"].values[0]
return f"Salary of {selected_name}: {salary} LPA"

@[Link](...) → special Dash decorator that links UI components.

Output("salary-output", "children") → update the children (content) of the Div with


id "salary-output".

Input("employee-dropdown", "value") → callback listens for changes in dropdown


value.

update_salary(selected_name) →

Function automatically runs whenever user changes dropdown selection.

selected_name is passed from the Input (dropdown value).

We filter DataFrame to find salary.

Return a formatted string → goes directly inside salary-output.

Step 6: Run App


if __name__ == "__main__":
app.run_server(debug=True)

Runs app locally → visit [Link]


debug=True → auto-reload on code changes, shows errors nicely.

Flow of Execution (Concepts)

Page loads → [Link] builds the UI.

User selects a new employee in dropdown.

Callback triggers → Dash passes new value to update_salary.

Function runs → finds salary.

Output updates children of Div → displayed in browser instantly.

⚡ Dharani, do you want me to expand this same example next into:

Multiple Inputs (e.g., Dropdown + Slider both control output), or

Dynamic Charts (Dropdown changes a Plotly graph)?

You said:
another handson for extra quality
ChatGPT said:

Nice 👍 Dharani, I like that you’re aiming for extra quality in learning. Let’s do
another hands-on callback example that builds on the last one.

This time we’ll:


👉 Use two inputs (Dropdown + Slider).
👉 Update both text and a chart.

Hands-on: Employee Salary Chart with Filters


🔹 Goal

A Dropdown → select an employee.

A Slider → apply a multiplier (like performance bonus factor).

A Callback → updates:

Text showing adjusted salary.

A bar chart comparing all employees’ adjusted salaries.

🔹 Full Code
import dash
from dash import dcc, html
from [Link] import Input, Output
import pandas as pd
import [Link] as px

# Data
df = [Link]({
"Name": ["Dharani", "Jay", "Vassu", "Priya"],
"Salary": [20, 40, 15, 22]
})

# Initialize app
app = [Link](__name__)
# Layout
[Link] = [Link]([
html.H1("Employee Salary Dashboard"),

# Dropdown
[Link](
id="employee-dropdown",
options=[{"label": name, "value": name} for name in df["Name"]],
value="Dharani",
style={"width": "50%"}
),

# Slider
[Link]("Performance Multiplier:"),
[Link](
id="multiplier-slider",
min=1,
max=3,
step=0.5,
value=1,
marks={i: str(i) for i in range(1, 4)}
),

# Outputs
[Link](id="salary-output", style={"marginTop": 20}),
[Link](id="salary-chart")
])

# Callback
@[Link](
[Output("salary-output", "children"),
Output("salary-chart", "figure")],
[Input("employee-dropdown", "value"),
Input("multiplier-slider", "value")]
)
def update_dashboard(selected_name, multiplier):
# Adjust salary
base_salary = df[df["Name"] == selected_name]["Salary"].values[0]
adjusted_salary = base_salary * multiplier

# Update text
text_output = f"Adjusted Salary of {selected_name}: {adjusted_salary} LPA"

# Update chart (all employees with multiplier applied)


df_adjusted = [Link]()
df_adjusted["Adjusted Salary"] = df_adjusted["Salary"] * multiplier
fig = [Link](df_adjusted, x="Name", y="Adjusted Salary",
title="Adjusted Salaries of All Employees")

return text_output, fig

# Run
if __name__ == "__main__":
app.run_server(debug=True)

🔎 Explanation
Layout
Dropdown → pick employee.

Slider → set multiplier (1x, 1.5x, 2x, 2.5x, 3x).

Div → shows text output.

Graph → shows bar chart of salaries.

Callback
@[Link](
[Output("salary-output", "children"),
Output("salary-chart", "figure")],
[Input("employee-dropdown", "value"),
Input("multiplier-slider", "value")]
)

Multiple Outputs (text + figure).

Multiple Inputs (dropdown + slider).

Function
def update_dashboard(selected_name, multiplier):
base_salary = df[df["Name"] == selected_name]["Salary"].values[0]
adjusted_salary = base_salary * multiplier

text_output = f"Adjusted Salary of {selected_name}: {adjusted_salary} LPA"

df_adjusted = [Link]()
df_adjusted["Adjusted Salary"] = df_adjusted["Salary"] * multiplier
fig = [Link](df_adjusted, x="Name", y="Adjusted Salary",
title="Adjusted Salaries of All Employees")

return text_output, fig

Reads dropdown + slider values.

Calculates adjusted salary.

Returns text + figure to update UI.

Flow

Page loads → Dharani’s salary shown with multiplier = 1.

Change dropdown → text + chart update.

Change slider → salaries multiply and update instantly.

Both components stay in sync.

👉 This shows the power of callbacks with multiple inputs and outputs.

Do you want me to now push this further into a hands-on with real Excel (your 20-
employee dataset), where dropdown filters employees and chart shows all salaries?
That would simulate a real HR dashboard.
You said:
import dash
from dash import dcc, html
from [Link] import Input, Output
import pandas as pd
import [Link] as px

df = [Link]({
"Name": ["Dharani", "Jay", "Vassu", "Priya"],
"Salary": [20, 40, 15, 22]
})

app = [Link](__name__)

[Link] = [Link]([
html.H1("Employee Salary Dashboard"),

[Link](
id="employee-dropdown",
options=[{"label": name, "value": name} for name in df["Name"]],
value="Dharani",
style={"width": "50%"}
),

[Link]("Performance Multiplayer:"),
[Link](
id="multiplier-slider",
min=1,
max=3,
step=0.5,
value=1,
marks={i: str(i) for i in range(1, 4)}
),

[Link](id="salary-output", style={"marginTop": 20}),


[Link](id="salary-chart")
])

@[Link](
[Output("salary-output", "children"),
Output("salary-chart", "figure")],
[Input("employee-dropdown", "value"),
Input("multiplier-slider", "value")]
)
def update_dashboard(selected_name, multiplier):
base_salary = df[df["Name"] == selected_name]["Salary"].values[0]
adjusted_salary = base_salary * multiplier

text_output = f"Adjusted Salary of {selected_name}: {adjusted_salary} LPA"

df_adjusted = [Link]()
df_adjusted["Adjusted Salary"] = df_adjusted["Salary"] * multiplier
fig = [Link](df_adjusted, x="Name", y="Adjusted Salary",
title="Adjusted Salaries of All Employees")
return text_output, fig

if __name__ == "__main__":
app.run_server(debug=True)
Please explain the code line by line?

ChatGPT said:
Thought for 17s

Nice — I’ll walk through your entire script line-by-line, explaining what each
statement or small block does, why it’s there, and any important behavior or
gotchas to watch for. I’ll keep it practical and note small improvements where
helpful.

✅ Quick summary of what the app does

A Dash web app that shows an employee dashboard.

You pick an employee from a dropdown.

You choose a performance multiplier with a slider.

A callback computes the adjusted salary for the selected employee and updates:

A text message (the adjusted salary)

A bar chart with adjusted salaries for all employees.

🔍 Line-by-line explanation
import dash
from dash import dcc, html
from [Link] import Input, Output
import pandas as pd
import [Link] as px

import dash
Imports the Dash framework — the core package you use to create the web app and run
the server.

from dash import dcc, html

dcc (Dash Core Components) provides interactive widgets (Dropdown, Slider, Graph,
etc.).

html (Dash HTML Components) provides Python wrappers for HTML tags (Div, H1, P,
etc.).
Using these lets you build the app UI in Python.

from [Link] import Input, Output


These classes are used when defining callbacks. Input describes which component
property is the trigger; Output describes which component property will be updated.

import pandas as pd
Pandas for data handling (DataFrame creation/manipulation).

import [Link] as px
Plotly Express for quick creation of Plotly figures (the figure you pass to
[Link]).

df = [Link]({
"Name": ["Dharani", "Jay", "Vassu", "Priya"],
"Salary": [20, 40, 15, 22]
})

Creates a small DataFrame with two columns: Name and Salary.

Salaries are numeric (assumed to be in LPA units in your app context). Using
numeric types is essential for plotting and arithmetic.

app = [Link](__name__)

Initializes the Dash application instance.

__name__ is passed so Dash can resolve relative paths, assets, etc. This object
(app) is used for layout registration and to run the server.

[Link] = [Link]([
html.H1("Employee Salary Dashboard"),

[Link] defines the entire UI of the app — a tree of components.

[Link]([...]) is the top-level container (like <div> in HTML). Everything


displayed lives inside it.

html.H1("Employee Salary Dashboard") adds the page heading.

[Link](
id="employee-dropdown",
options=[{"label": name, "value": name} for name in df["Name"]],
value="Dharani",
style={"width": "50%"}
),

[Link](...) creates a dropdown component.

id="employee-dropdown" assigns a unique id — this id is used in callbacks to


reference this component.

options=[{"label": name, "value": name} for name in df["Name"]] builds the dropdown
options from the DataFrame. Each option is a dict with label (displayed to user)
and value (what the app uses).

value="Dharani" sets the default selected value when the app loads.

style={"width": "50%"} is inline CSS — sets the dropdown width to 50% of its
container.

[Link]("Performance Multiplayer:"),

Adds a label above the slider. (Tiny note: “Multiplayer” is a typo — should be
“Multiplier”. This string is just display text.)

[Link](
id="multiplier-slider",
min=1,
max=3,
step=0.5,
value=1,
marks={i: str(i) for i in range(1, 4)}
),

[Link](...) creates a slider widget.

id="multiplier-slider" unique id for callback linking.

min=1, max=3 define the range of the slider (from 1 to 3).

step=0.5 allows increments of 0.5 (so valid values: 1.0, 1.5, 2.0, 2.5, 3.0).

value=1 default selected value when app loads (no multiplier).

marks={i: str(i) for i in range(1, 4)} shows ticks/labels at 1, 2, 3. (Note: marks


are integers here while slider allows 0.5 steps; you could add fractional marks if
you want visual ticks at 1.5, 2.5, etc.)

[Link](id="salary-output", style={"marginTop": 20}),


[Link](id="salary-chart")
])

[Link](id="salary-output", style={"marginTop": 20})


Placeholder div where the callback will insert text output (the children property).
style gives top margin spacing.

[Link](id="salary-chart")
A Graph component that will render a Plotly figure. Initially empty; the callback
will return a figure and Dash will render it here.

The closing ]) ends [Link].

@[Link](
[Output("salary-output", "children"),
Output("salary-chart", "figure")],
[Input("employee-dropdown", "value"),
Input("multiplier-slider", "value")]
)

This decorator registers a callback with Dash.

Outputs is a list of two outputs:

Output("salary-output", "children") — update the children (inner content) of the


Div with id salary-output. The callback must return a value compatible with
children (string, or component(s)).

Output("salary-chart", "figure") — update the figure property of [Link] with id


salary-chart. The callback must return a Plotly Figure (e.g., from px or go).

Inputs is a list of inputs that trigger the callback:

Input("employee-dropdown", "value") — the currently selected employee's name from


the dropdown.
Input("multiplier-slider", "value") — current numeric value of the slider.

Order matters: the function arguments correspond to inputs in the same order; the
return values correspond to outputs in the same order.

def update_dashboard(selected_name, multiplier):

The callback function that runs whenever either Input changes.

selected_name receives the value from employee-dropdown.

multiplier receives the value from multiplier-slider.

base_salary = df[df["Name"] == selected_name]["Salary"].values[0]

Filters the DataFrame to the row where Name == selected_name, then selects the
Salary column and gets the first value with .values[0].

This gives the selected employee’s base salary.

Gotcha: .values[0] will throw an error if the filter finds no rows (e.g., invalid
selected_name). In practice, because the dropdown options are built from
df["Name"], this should be safe — but for robustness you might use .iloc[0] with a
check or handle empty results.

adjusted_salary = base_salary * multiplier

Applies the multiplier to compute the adjusted salary (float or int depending on
multiplier).

text_output = f"Adjusted Salary of {selected_name}: {adjusted_salary} LPA"

Builds a formatted string (f-string) that will be displayed in the salary-output


Div.

Example output: "Adjusted Salary of Dharani: 25.0 LPA" (if multiplier was 1.25).

df_adjusted = [Link]()
df_adjusted["Adjusted Salary"] = df_adjusted["Salary"] * multiplier

Makes a copy of the original DataFrame to avoid mutating it ([Link]()). Good


practice.

Adds a new column Adjusted Salary computed for every employee: base salary ×
multiplier. This is used to draw the updated chart showing all employees after
applying the multiplier.

fig = [Link](df_adjusted, x="Name", y="Adjusted Salary",


title="Adjusted Salaries of All Employees")

Uses Plotly Express to create a bar chart (fig) with Name on the x-axis and
Adjusted Salary on the y-axis.
fig is a Plotly Figure object suitable to return and set as the figure property of
[Link].

return text_output, fig

Returns two values (a tuple/list).

The first return value maps to the first Output ([Link]) — the text
string.

The second maps to the second Output ([Link]) — the Plotly figure.

Dash will update the UI: the Div receives the text as its children, and [Link]
renders the fig.

if __name__ == "__main__":
app.run_server(debug=True)

Standard Python guard to execute the app only when the script is run directly (not
when imported).

app.run_server(debug=True) starts the local development server (default


[Link]

debug=True does two helpful things:

Enables automatic reloading when you change the code (so you don’t need to restart
manually).

Shows helpful error tracebacks in the browser when exceptions occur.

In production you’d set debug=False.

⚠️ Common gotchas & small improvements

Typo: Performance Multiplayer: → should be Performance Multiplier: (just display


text).

Marks on slider: you used integer marks {1,2,3} but step=0.5 allows halves.
Consider adding fractional marks like 1.5 if you want ticks visible for halves.

Safety when retrieving salary: .values[0] will error if the name is missing. You
could safely retrieve like:

row = [Link][df["Name"] == selected_name]


if [Link]:
base_salary = 0
else:
base_salary = row["Salary"].iloc[0]

Type of adjusted_salary: if multiplier is not integer, adjusted_salary will be


float. You may want to format the output string (f"{adjusted_salary:.2f}") for
readability.

Performance: For large datasets, copying the DataFrame each callback ([Link]())
can be expensive. Instead, compute Adjusted Salary on the fly or cache results if
necessary.

Multiple callbacks: If you later add more interactive elements, be mindful of


circular updates (callbacks that update inputs of other callbacks) — avoid cycles
or use dash.callback_context to handle complex logic.

✅ Quick conceptual recap

id ties a component in the layout to the callback system.

Input tells Dash what changes to listen to.

Output tells Dash what component property to update when an input changes.

The callback function receives input values as arguments (in the same order) and
must return values matching the outputs order.

[Link](figure=fig) renders Plotly figures; returning a new figure causes the


chart to update automatically.

If you want, next I can:

Show a version of the callback that handles missing/invalid selections gracefully,


or

Replace .values[0] with safer code and format the salary nicely (e.g., show commas,
two decimals), or

Hook this same UI up to your full 20-record Excel file and demonstrate a few extra
interactive controls (role filter, top-N selector, etc.).

Which of those would you like to see next?

You said:
[Link](id="salary-output", style={"marginTop": 20}),
[Link](id="salary-chart")
])

@[Link](
[Output("salary-output", "children"),
Output("salary-chart", "figure")],
[Input("employee-dropdown", "value"),
Input("multiplier-slider", "value")]
)

Where did salary-output , salary-chart came? Did we named it there only?


ChatGPT said:

Exactly Dharani — great observation 👌

Yes, both salary-output and salary-chart are IDs that we assigned earlier in the
layout when creating components. Let’s break it down:

In the Layout
[Link](id="salary-output", style={"marginTop": 20}),
[Link](id="salary-chart")
Here, we are creating:

An empty Div (just a container) and giving it an id = "salary-output".

Initially it has no content (no children), but later we will insert text here
through the callback.

A Graph component with id = "salary-chart".

Initially it’s blank (no figure). The callback will update its figure.

So, the IDs are user-defined labels.


We can name them anything we want — "salary-output", "chart1", "myDiv", etc.
But we must use the same IDs in the callback to connect the logic.

In the Callback
@[Link](
[Output("salary-output", "children"),
Output("salary-chart", "figure")],
[Input("employee-dropdown", "value"),
Input("multiplier-slider", "value")]
)

Output("salary-output", "children")
→ Means: take the Div with id="salary-output" and update its children property (the
text inside).

Output("salary-chart", "figure")
→ Means: take the Graph with id="salary-chart" and update its figure property (the
chart inside).

✅ So the IDs (salary-output, salary-chart) act like bridges between the layout and
the callback.
Without IDs, Dash wouldn’t know which component you want to update.

Would you like me to draw a mapping table (Component → Property → Updated by


Callback) for this app, so it’s easier to visualize?

You said:

* **`Output("salary-output", "children")`** → Means: take the `Div` with


`id="salary-output"` and update its **children property** (the text inside). *
**`Output("salary-chart", "figure")`** → Means: take the `Graph` with `id="salary-
chart"` and update its **figure property** (the chart inside).

How will it know the text inside it? Like salary-output is just assigned. But not
knowing to what it was assigned
ChatGPT said:

Perfect doubt, Dharani 🙌 — this is where Dash’s property system comes into play.
Let’s clear it up step by step:

1️⃣ Every Dash component has properties

Example:
[Link] → has properties like children, style, id

[Link] → has properties like figure, id, style

👉 When you wrote:

[Link](id="salary-output", style={"marginTop": 20})

You only defined an empty Div with no content (so children=None).

2️⃣ children = "content inside a tag"

In plain HTML:

<div> Hello World </div>

3️⃣ Callback tells Dash what to fill in

This line:

Output("salary-output", "children")

means:
➡️ “Find the component with id=salary-output, and replace its children property
with whatever value the callback returns.”

So in your function:

text_output = f"Adjusted Salary of {selected_name}: {adjusted_salary} LPA"

is returned as the first output → goes straight into the children property of the
Div.

Result:

<div id="salary-output">Adjusted Salary of Dharani: 20 LPA</div>

4️⃣ Same idea for Graph


Output("salary-chart", "figure")

tells Dash:
➡️ “Find the component with id=salary-chart, and update its figure property with
the Plotly chart (fig).”

That’s why the chart appears inside the Graph component.

✅ So:

IDs → act like addresses of components.

Properties (children, figure, etc.) → define what part of that component to update.
Callback return values → fill/update those properties dynamically.

Would you like me to make a small table for your app mapping each component →
property → what’s getting updated? That will make it super visual.

You said:
Okay okay, something something only i understood. I don't want to waste my time,
shall we move to the next phase of the Dash concepts?
ChatGPT said:

Got it Dharani 👍 no worries — callbacks and properties feel a bit abstract the
first time, but since you’ve got the big picture, we won’t waste time going in
circles.

👉 Yes, we can move to the next phase of Dash concepts.

Here’s the learning roadmap after basic callbacks:

🟢 Phase 1: Fundamentals (✅ Done)

What Dash is, its modules (dash, html, dcc)

Layout basics (Div, H1, Graph, etc.)

children and component properties

Simple callbacks with one input & one output

Multi-input/multi-output callbacks (✅ you already did with Dropdown + Slider +


Graph)

🔵 Phase 2: Intermediate Dash

Chained Callbacks

One callback’s output becomes another callback’s input.

Example: Select a department → filters employees → updates chart.

State in Callbacks (State vs Input)

Use cases where you don’t want updates every time the user types, but only after
pressing a button.

Styling & Layouts

Using style={} inline

External CSS (Bootstrap, Dash Mantine, etc.)

Multi-column layouts with [Link].

🟣 Phase 3: Advanced Dash

Multiple Pages (Dash Pages)

Create apps with a navigation bar and multiple screens.

Data Storage in Dash


Use [Link] to hold session data without refreshing.

Real-time / Live Updates

[Link] → update charts every n seconds (e.g., live salary tracker, stock
prices).

Deployment

How to run on local server, Docker, or cloud (Heroku, AWS, etc.).

So the next logical step right after callbacks is 👉 Chained Callbacks (to see how
components can depend on each other).

Do you want me to jump directly into Chained Callback hands-on example with your
employee dataset?

You said:

So the **next logical step** right after callbacks is 👉 **Chained Callbacks** (to
see how components can depend on each other). Do you want me to jump directly into
**Chained Callback hands-on example with your employee dataset**?

Okay
ChatGPT said:

Perfect 👌 Let’s dive into Chained Callbacks with your employee dataset.

🔗 What is a Chained Callback?

In Dash, a chained callback means that the output of one callback becomes the input
of another.

This allows you to build step-by-step interactivity.

Example:

First, user selects a Role.

Then, based on that role, a list of Employees is shown.

Finally, the selected employee’s Salary chart is updated.

⚡ Hands-on Example with Your Dataset


import dash
from dash import dcc, html
from [Link] import Input, Output
import pandas as pd
import [Link] as px

# Employee dataset
df = [Link]({
"Empid": [1001, 1002, 1003, 1004, 1005],
"Name": ["Dharani", "Jay", "Vassu", "Suresh", "Harsha"],
"Role": ["GenAI Developer", "SDE", "Software Engineer", "Assistant Software
Engineer", "Web Developer"],
"Salary": [20, 40, 15, 7, 30]
})
app = [Link](__name__)

[Link] = [Link]([
html.H1("Chained Callback Example - Employee Dashboard"),

# Dropdown 1: Select Role


[Link](
id="role-dropdown",
options=[{"label": role, "value": role} for role in df["Role"].unique()],
placeholder="Select a Role"
),

# Dropdown 2: Select Employee (depends on role)


[Link](
id="employee-dropdown",
placeholder="Select an Employee"
),

# Output: Salary of selected employee


[Link](id="salary-output", style={"marginTop": 20}),

# Chart of all employees in that role


[Link](id="role-salary-chart")
])

# Callback 1: Update employee options based on selected role


@[Link](
Output("employee-dropdown", "options"),
Input("role-dropdown", "value")
)
def update_employee_dropdown(selected_role):
if selected_role is None:
return []
filtered = df[df["Role"] == selected_role]
return [{"label": name, "value": name} for name in filtered["Name"]]

# Callback 2: Update salary text and chart based on selected employee


@[Link](
[Output("salary-output", "children"),
Output("role-salary-chart", "figure")],
[Input("employee-dropdown", "value"),
Input("role-dropdown", "value")]
)
def update_salary_and_chart(selected_employee, selected_role):
if selected_employee is None or selected_role is None:
return "", {}

# Salary text
salary = df[df["Name"] == selected_employee]["Salary"].values[0]
text_output = f"Salary of {selected_employee}: {salary} LPA"

# Chart of all employees in that role


filtered = df[df["Role"] == selected_role]
fig = [Link](filtered, x="Name", y="Salary", title=f"Salaries for
{selected_role}")

return text_output, fig


if __name__ == "__main__":
app.run_server(debug=True)

📝 Explanation (Line by Line Key Points)

Dropdown 1 (Role)

Lets user choose a role (e.g., "SDE").

Callback 1

Takes role as input → filters dataset → populates employee dropdown with only those
employees.

Dropdown 2 (Employee)

Shows only employees under the chosen role.

Callback 2

Takes employee + role →

Displays that employee’s salary (text).

Plots a chart of all employees in that role.

✅ This is a classic chained callback:

Role → Employee list (Callback 1)

Role + Employee → Salary + Chart (Callback 2)

Would you like me to extend this with your full 20-employee dataset instead of just
the small sample, so you can test it directly on your Excel-like data?

You might also like