# server.py import matplotlib.pyplot as plt from shiny import render, ui import faicons as fa #from fontawesomefree import icons import numpy as np from utils import conlogo, vendorlogo from utils import create_pie_chart, create_bar_chart, create_bar_chart, create_stacked_bar_chart def create_server(app_dir): def server(input, output, session): @render.image def rsglogo(): return conlogo() @render.image def clientlogo(): return vendorlogo() @render.plot def bar_chart(): # Sample data for bar chart categories = ["Category A", "Category B", "Category C"] values = [10, 20, 30] return create_bar_chart(categories, values, plottitle = "Bar Chart Example") @render.plot def pie_chart(): # Data for pie chart labels = ["Home-Based Work", "Home-Based Other", "Non-Home-Based"] #labels = [f"{icons['fa-car']} Cars", f"{icons['fa-bicycle']} Bikes", f"{icons['fa-bus']} Buses"] #labels = [f"{fa.icon_svg("briefcase")} Cars", f"{fa.icon_svg("briefcase")} Bikes", f"{fa.icon_svg("briefcase")} Buses"] sizes = [22, 41, 37] colors = ["#00b3b3", "#70d281", "#ff7f0e"] explode = (0.1, 0, 0) # Explode the first slice for emphasis return create_pie_chart(labels, sizes, plottitle ="What Types of Trips are Occuring within Napa County on a Weekday?") @render.plot def stacked_bar_chart(): # Data for the stacked bar chart categories = ["Early AM", "AM Peak", "Mid-Day", "PM Peak", "Evening"] intra_napa = [2000, 16000, 14000, 12000, 5000] into_napa = [1000, 8000, 2000, 3000, 2000] out_napa = [2000, 4000, 2000, 5000, 1000] return create_stacked_bar_chart(categories, intra_napa, into_napa, out_napa) return server