Add a formula widget

Formula widgets calculate aggregated values (Avg, Max, Min, Sum) from numeric columns or counts of features (Count) in a dataset. A formula widget's aggregations can be calculated on global or viewport based values. If you want the values in a formula widget to update on zoom and/or pan, use viewport based aggregations.

To see available parameters run help(formula_widget).

In this example, the formula widget displays the sum of people involved in the map's current viewport. Since the calculations are viewport based (the default), the count of collisions will update any time the map is zoomed or panned.


In [1]:
from cartoframes.auth import set_default_credentials
from cartoframes.viz import Layer, formula_widget

set_default_credentials('cartoframes')

In [2]:
Layer(
    'seattle_collisions',
    widgets=[
        formula_widget(
            'personcount',
            operation='sum',
            title='Number of people Involved',
            description='Zoom and/or pan the map to update count',
            format='.3s'
        )
    ]
)


Out[2]:
:
StackTrace
    ">