-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1288 from hackforla/combDashboards2
Update plotly dash overview dashboards (combined old dashboards)
- Loading branch information
Showing
10 changed files
with
337 additions
and
895 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,11 @@ | ||
import json | ||
import urllib | ||
|
||
import dash | ||
import dash_core_components as dcc | ||
import dash_html_components as html | ||
import pandas as pd | ||
|
||
from dash import Dash, dcc, html | ||
|
||
external_stylesheets = ['/static/reports.css'] | ||
app = dash.Dash(__name__, external_stylesheets=external_stylesheets) | ||
# Suppress Callback Exceptions due to multi-page Dashboard layout, some callback id may not exist initially. | ||
app = Dash(__name__, external_stylesheets=external_stylesheets, suppress_callback_exceptions=True) | ||
|
||
# set up default layout | ||
app.layout = html.Div([ | ||
dcc.Location(id='url', refresh=False), | ||
html.Div(id='page-content') | ||
]) | ||
|
||
server = app.server | ||
app.config.suppress_callback_exceptions = True | ||
|
||
BATCH_SIZE = 10000 | ||
|
||
|
||
def batch_get_data(url): | ||
# set up your query | ||
if '?' in url: | ||
batch_url = f"{url}&limit={BATCH_SIZE}" | ||
else: | ||
batch_url = f"{url}?limit={BATCH_SIZE}" | ||
|
||
response_size = BATCH_SIZE | ||
result_list = [] | ||
skip = 0 | ||
|
||
# loop through query results and add to a list (better performance!) | ||
while (response_size == BATCH_SIZE): | ||
batch = json.loads(urllib.request.urlopen(f"{batch_url}&skip={skip}").read()) | ||
result_list.extend(batch) | ||
response_size = len(batch) | ||
skip = skip + BATCH_SIZE | ||
|
||
# convert JSON object list to dataframe | ||
df = pd.DataFrame.from_records(result_list) | ||
|
||
return df |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.