I was trying to create a bar chart where i want to drill through district and then see the population of various cities for 3 year ranges. Basically i found this Drill down function for graphs embedded in Dash app - #9 by iTem but i am unable to implement
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
from dash.dependencies import Output, Input, State
import numpy as np
import pandas as pd
import plotly.figure_factory as ff
from pandas import read_excel
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
# app = dash.Dash()
file_name = 'samplePop1.csv'
df = pd.read_csv(file_name)
print(df.head())
colors = {
'black' : '#000000',
'text' : '#696969',
'plot_color' : '#C0C0C0',
'white' : '#FFFFF'
}
app.layout = html.Div ([
dcc.Graph(
id = 'bar-chart',
figure = { 'data' :
[
{'x' : df['Name'],'y':df['Population Census 1991'],'type':'bar','name':'Population Census 1991'},
{'x' : df['Name'],'y':df['Population Census 2001'],'type':'bar','name':'Population Census 2001'},
{'x' : df['Name'],'y':df['Population Census 2011'],'type':'bar','name':'Population Census 2011'}
],
'layout' : {
'plot_bgcolor' : colors['white'],
'paper_bgcolor' : colors['white'],
'font' : {
'color' : colors['white']
},
'title' : 'Bar Chart',
'orientation':'h'
}
}
)
])
if __name__ == '__main__':
app.run_server(port = '8080' , debug ='True')
the bar chart should show population district wise first for 3 year range and when i click on a district it shall show district wise comparison. also another basic chart where their will be 2 click action district wise and city wise to show population for 3 year ranges it should show values clearly more likely it should be scroll-able.
link to the csv file mapbox/samplePop1.csv at master · 9192gks/mapbox · GitHub