{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Multiple widgets\n",
"\n",
"CARTOframes provides the ability to add multiple widgets to a Layer. \n",
"\n",
"This example uses two formula widgets to count the number of pedestrians and cyclists involved in collisions and a category widget describing the type of collisions. You can zoom and/or pan the map to update widget values. In addition, if you filter on a category, the formula widgets will update to reflect the values of that category in the current map view."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from cartoframes.auth import set_default_credentials\n",
"\n",
"set_default_credentials('cartoframes')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from cartoframes.viz import Layer, formula_widget, category_widget\n",
"\n",
"Layer(\n",
" 'seattle_collisions',\n",
" widgets=[\n",
" formula_widget(\n",
" 'pedcount',\n",
" 'sum',\n",
" title='Pedestrians Involved'\n",
" ),\n",
" formula_widget(\n",
" 'pedcylcount',\n",
" 'sum',\n",
" title='Cyclists Involved'\n",
" ),\n",
" category_widget(\n",
" 'collisiontype',\n",
" title='Collision Type'\n",
" )\n",
" ]\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}