MCPcopy Create free account
hub / github.com/alpha2phi/python-apps / update_graph

Function update_graph

sagemaker-dash/tutorials/app15.py:106–133  ·  view source on GitHub ↗
(xaxis_column_name, yaxis_column_name, xaxis_type, yaxis_type,
                 year_value)

Source from the content-addressed store, hash-verified

104 dash.dependencies.Input('crossfilter-year--slider', 'value')
105 ])
106def update_graph(xaxis_column_name, yaxis_column_name, xaxis_type, yaxis_type,
107 year_value):
108 dff = df[df['Year'] == year_value]
109
110 fig = px.scatter(
111 x=dff[dff['Indicator Name'] == xaxis_column_name]['Value'],
112 y=dff[dff['Indicator Name'] == yaxis_column_name]['Value'],
113 hover_name=dff[dff['Indicator Name'] ==
114 yaxis_column_name]['Country Name'])
115
116 fig.update_traces(customdata=dff[dff['Indicator Name'] ==
117 yaxis_column_name]['Country Name'])
118
119 fig.update_xaxes(title=xaxis_column_name,
120 type='linear' if xaxis_type == 'Linear' else 'log')
121
122 fig.update_yaxes(title=yaxis_column_name,
123 type='linear' if yaxis_type == 'Linear' else 'log')
124
125 fig.update_layout(margin={
126 'l': 40,
127 'b': 40,
128 't': 10,
129 'r': 0
130 },
131 hovermode='closest')
132
133 return fig
134
135
136def create_time_series(dff, axis_type, title):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected