| |
| import matplotlib.pyplot as plt |
| from shiny import render, ui |
| import faicons as fa |
| |
| 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(): |
| |
| 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(): |
| |
| labels = ["Home-Based Work", "Home-Based Other", "Non-Home-Based"] |
| |
| |
| |
|
|
| sizes = [22, 41, 37] |
| colors = ["#00b3b3", "#70d281", "#ff7f0e"] |
| explode = (0.1, 0, 0) |
| |
| 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(): |
| |
| 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 |
|
|