Build a Dashboard
Welcome to our tutorial on building an interactive dashboard showcasing essential metrics from wind turbine manufacturers.
We'll demonstrate how to leverage a variety of components such as sliders, dropdowns, plots, indicators, tables and layouts to craft a visually stunning and functional application.
By following along, you'll gain insights into how these components can be seamlessly combined to present data in a meaningful way.
Our objective is to empower you to replicate this process for your own datasets and use cases, enabling you to create impactful dashboards tailored to your specific needs.
Click the dropdowns below to see the requirements or the full code.
:::::{dropdown} Requirements
::::{tab-set}
:::{tab-item} pip :sync: pip
:::
:::{tab-item} conda :sync: conda
:::
::::
:::::
:::{dropdown} Code
:::
Explanation
Importing Libraries
hvplot.pandas
: This library provides a high-level plotting interface for Pandas DataFrames using HoloViews.pandas
: This library is used for data manipulation and analysis.panel
: This is the Panel library used for creating interactive dashboards and apps.
Extension
pn.extension("tabulator")
: This line enables the Tabulator widget, which provides a high-performance interactive table widget in Panel.
Styles
ACCENT
: This variable stores the color teal, which will be used as the accent color throughout the dashboard.styles
: This dictionary contains CSS styles to be applied to various components in the dashboard for consistent styling, including box shadow, border radius, and padding.
Data Extraction
get_data()
: This function is decorated with@pn.cache()
, which ensures that the data is only downloaded once, improving performance by caching the result.source_data
: This variable stores the downloaded CSV data as a Pandas DataFrame.
Data Transformation
min_year
,max_year
: These variables store the minimum and maximum values of the "p_year" column in the DataFrame, representing the earliest and latest years.top_manufacturers
: This variable stores the top 10 manufacturers based on the sum of their turbine capacities.filter_data()
: This function filters the source data based on the selected manufacturer and year.
Widgets
t_manu
: This widget is a select dropdown for choosing the manufacturer.p_year
: This widget is an integer slider for selecting the year.
Data Transformation 2
df
: This variable stores the filtered DataFrame based on the selected manufacturer and year.count
,total_capacity
,avg_capacity
,avg_rotor_diameter
: These variables calculate various statistics from the filtered DataFrame, such as count, total capacity, average capacity, and average rotor diameter.
Plotting Data
fig
: This variable stores a bar plot of the total turbine capacity over the years.
Displaying Data
image
: This variable stores an image pane displaying a background image for the dashboard.indicators
: This variable stores a collection of indicator widgets displaying various statistics.
Creating Components
plot
: This variable stores a HoloViews plot pane displaying the bar plot.table
: This variable stores a Tabulator widget displaying the filtered DataFrame as a table.
Layout
tabs
: This variable stores a Tabs widget containing the plot and table, allowing users to switch between them.
Creating the Dashboard
This code creates a
FastListTemplate
dashboard with a sidebar containing the image, manufacturer select dropdown, and year slider, and a main section containing the indicators and tabs.
Conclusion
This code sets up a dynamic dashboard for exploring wind turbine data, including filtering, data transformation, visualization, and statistics display. It leverages various Panel widgets, HoloViews plots, and CSS styling to create an interactive and informative dashboard.