Skip to content

Commit

Permalink
Add gva-sectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Haider8 committed Mar 2, 2019
1 parent 47d31b5 commit 5cc97a4
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 54 deletions.
84 changes: 84 additions & 0 deletions apps/gva_sectors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from collections import OrderedDict


import pandas as pd

from app import app

data = pd.read_excel('data/2018/economic-aggregates/S1.6.xlsx')
years = data.iloc[5:6,2:-2]
year_set = list(OrderedDict.fromkeys(years.values[0]).keys())
process = data[7:]
sections = process.iloc[:,0]
main_sections = [index for index in sections.index if sections[index].isdigit()]
rows = [data.iloc[idx] for idx in main_sections]

def app_layout():
children = [dcc.Tab(label=year, value=year) for year in year_set]
return(
html.Div([
dcc.Tabs(id="tabs", value=year_set[-1], children=children),
html.Div(id='output-tab')
])
)

layout=app_layout()

@app.callback(Output('output-tab', 'children'),
[Input('tabs', 'value')])
def display_content(value):
cu_index, co_index = [index for index in years.transpose().index if years[index].iloc[0] == value]
cu_values = [row[cu_index] for row in rows[0:-1]]
co_values = [row[co_index] for row in rows[0:-1]]
labels = [row.iloc[-1] for row in rows[0:-1]]
data_cu = [
{
'values':cu_values,
'type': 'pie',
'labels': labels
},
]
data_co = [
{
'values':co_values,
'type': 'pie',
'labels': labels
},
]

return html.Div([
dcc.Graph(
id='cp-graph',
figure={
'data': data_cu,
'layout': {
'margin': {
'l': 30,
'r': 0,
'b': 30,
't': 0
},
'name': 'Current Price'
}
}
),
dcc.Graph(
id='co-graph',
figure={
'data': data_co,
'layout': {
'margin': {
'l': 30,
'r': 0,
'b': 30,
't': 0
},
'name': 'Cost Price'
}
}
)
])
2 changes: 1 addition & 1 deletion apps/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

layout = html.Div([
html.Div([
dcc.Link('Go to App stock', href='/stock')
dcc.Link('Go to GVA Sector', href='/gva-sectors')
])

])
52 changes: 0 additions & 52 deletions apps/stock.py

This file was deleted.

Loading

0 comments on commit 5cc97a4

Please sign in to comment.