How to use the cartoframes.viz.helpers function in cartoframes

To help you get started, we’ve selected a few cartoframes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CartoDB / cartoframes / tests / unit / viz / helpers / test_color_continuous_layer.py View on Github external
def test_helpers(self):
        "should be defined"
        assert helpers.color_continuous_layer is not None
github CartoDB / cartoframes / test / viz / helpers / test_size_category_layer.py View on Github external
def test_size_category_layer(self):
        "should create a layer with the proper attributes"
        Source._get_geom_type = Mock(return_value='point')

        layer = helpers.size_category_layer(
            source='sf_neighborhoods',
            value='name',
            title='Neighborhoods'
        )

        self.assertNotEqual(layer.style, None)
        self.assertEqual(layer.style._style['point']['width'], 'ramp(top($name, 5), [2, 20])')
        self.assertEqual(layer.style._style['line']['width'], 'ramp(top($name, 5), [1, 10])')
        self.assertEqual(layer.style._style['point']['color'], 'opacity(#F46D43, 0.8)')
        self.assertEqual(layer.style._style['line']['color'], 'opacity(#4CC8A3, 0.8)')
        self.assertNotEqual(layer.popup, None)
        self.assertEqual(layer.popup._hover, [{
            'title': 'Neighborhoods',
            'value': '$name'
        }])
github CartoDB / cartoframes / test / viz / helpers / test_color_continuous_layer.py View on Github external
def test_color_continuous_layer_popup(self):
        "should show/hide the popup"
        layer = helpers.color_continuous_layer(
            'sf_neighborhoods',
            'name',
            popup=False
        )

        self.assertEqual(layer.popup._hover, [])

        layer = helpers.color_continuous_layer(
            'sf_neighborhoods',
            'name',
            popup=True
        )

        self.assertEqual(layer.popup._hover, [{
            'title': 'name',
            'value': '$name'
        }])
github CartoDB / cartoframes / tests / unit / viz / helpers / test_size_category_layer.py View on Github external
def test_size_category_layer_animate(self, mocker):
        "should animate a property and disable the popups"
        setup_mocks(mocker)
        layer = helpers.size_category_layer(
            self.source,
            'name',
            animate='time'
        )

        assert layer.popup._hover == []
        assert layer.widgets._widgets[0]._type == 'time-series'
        assert layer.widgets._widgets[0]._title == 'Animation'
        assert layer.widgets._widgets[0]._value == 'time'
github CartoDB / cartoframes / test / viz / helpers / test_size_continuous_layer.py View on Github external
def test_size_continuous_layer_popup(self):
        "should show/hide the popup"
        layer = helpers.size_continuous_layer(
            'sf_neighborhoods',
            'name',
            popup=False
        )

        self.assertEqual(layer.popup._hover, [])

        layer = helpers.size_continuous_layer(
            'sf_neighborhoods',
            'name',
            popup=True
        )

        self.assertEqual(layer.popup._hover, [{
            'title': 'name',
            'value': '$name'
        }])
github CartoDB / cartoframes / tests / unit / viz / helpers / test_color_continuous_layer.py View on Github external
def test_color_continuous_layer_point(self, mocker):
        "should create a point type layer"
        setup_mocks(mocker)
        layer = helpers.color_continuous_layer(
            self.source,
            'name',
            'Neighborhoods',
            palette='prism'
        )

        assert layer.style._style['point']['color'] == 'opacity(ramp(linear($name, ' + \
            'globalMIN($name), globalMAX($name)), prism), 1)'
github CartoDB / cartoframes / tests / unit / viz / helpers / test_color_bins_layer.py View on Github external
def test_helpers(self):
        "should be defined"
        assert helpers.color_bins_layer is not None
github CartoDB / cartoframes / test / viz / helpers / test_cluster_size_layer.py View on Github external
def test_cluster_size_layer(self):
        "should create a layer with the proper attributes"
        Source._get_geom_type = Mock(return_value='point')

        layer = helpers.cluster_size_layer(
            source='sf_neighborhoods',
            value='name'
        )

        self.assertNotEqual(layer.style, None)
        self.assertEqual(
            layer.style._style['point']['width'],
            'ramp(linear(clusterCount(), viewportMIN(clusterCount()), viewportMAX(clusterCount())), [4.0, 16.0, 32])'
        )
        self.assertEqual(layer.style._style['point']['color'],
                         'opacity(#FFB927, 0.8)')
        self.assertEqual(layer.style._style['point']['strokeColor'],
                         'opacity(#222,ramp(linear(zoom(),0,18),[0,0.6]))')
        self.assertEqual(layer.style._style['point']['filter'], '1')
        self.assertEqual(layer.style._style['point']['resolution'], '32')
        self.assertNotEqual(layer.popup, None)
github CartoDB / cartoframes / test / viz / helpers / test_size_continuous_layer.py View on Github external
def test_helpers(self):
        "should be defined"
        self.assertNotEqual(helpers.size_continuous_layer, None)
github CartoDB / cartoframes / tests / unit / viz / helpers / test_cluster_size_layer.py View on Github external
def test_helpers(self):
        "should be defined"
        assert helpers.cluster_size_layer is not None