From f59731b749e462a51857f792f50b8dd92ff57f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 6 May 2020 08:58:44 +0200 Subject: [PATCH 1/3] Update is_static default to False in Layout --- cartoframes/viz/layout.py | 10 +++++----- tests/unit/viz/test_layout.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cartoframes/viz/layout.py b/cartoframes/viz/layout.py index 4d2d2b225..a703b901f 100644 --- a/cartoframes/viz/layout.py +++ b/cartoframes/viz/layout.py @@ -16,8 +16,8 @@ class Layout: M_SIZE (number, optional): Number of rows of the layout viewport (dict, optional): Properties for display of the maps viewport. Keys can be `bearing` or `pitch`. - is_static (boolean, optional): By default, all the maps in each visualization - are static images due to performance reasons. In order to set them interactive, + is_static (boolean, optional): By default is False. All the maps in each visualization + are interactive. In order to set them static images for performance reasons set `is_static` to True. map_height (number, optional): Height in pixels for each visualization. Default is 250. @@ -66,12 +66,12 @@ class Layout: ... Map(Layer('table_in_your_account')) >>> ], viewport={ 'zoom': 2 }) - Create an interactive layout + Create an static layout >>> Layout([ ... Map(Layer('table_in_your_account')), Map(Layer('table_in_your_account')), ... Map(Layer('table_in_your_account')), Map(Layer('table_in_your_account')) - >>> ], is_static=False) + >>> ], is_static=True) """ def __init__(self, @@ -81,7 +81,7 @@ def __init__(self, viewport=None, map_height=250, full_height=True, - is_static=True, + is_static=False, **kwargs): self._maps = maps diff --git a/tests/unit/viz/test_layout.py b/tests/unit/viz/test_layout.py index 48d7f790d..6d80c57e2 100644 --- a/tests/unit/viz/test_layout.py +++ b/tests/unit/viz/test_layout.py @@ -22,7 +22,7 @@ def test__init(self): assert layout._n_size == 0 assert layout._m_size == 1 assert layout._viewport is None - assert layout._is_static is True + assert layout._is_static is False def test__init_maps(self): """Layout should init properly""" @@ -97,7 +97,7 @@ def test_is_static(self): layout = Layout([ Map(Layer(Source(SOURCE))), Map(Layer(Source(SOURCE))) - ], viewport={'zoom': 5}) + ], is_static=True) assert layout._layout[0].get('is_static') is True assert layout._layout[1].get('is_static') is True From 3f0c9336b9ec63410a96c735fa1905846c6c64e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 6 May 2020 09:17:01 +0200 Subject: [PATCH 2/3] Update examples and guides --- examples/map_layout/custom_layout.ipynb | 300 ++++++++------- examples/map_layout/default_layout.ipynb | 136 +++---- examples/map_layout/interactive_layout.ipynb | 24 +- examples/map_layout/layout_titles.ipynb | 123 +++--- examples/map_layout/layout_viewport.ipynb | 361 ++++++++---------- examples/map_layout/save_image_layout.ipynb | 195 ++++------ .../publish_visualization_layout.ipynb | 2 +- guides/05-Visualization.ipynb | 2 +- 8 files changed, 552 insertions(+), 591 deletions(-) diff --git a/examples/map_layout/custom_layout.ipynb b/examples/map_layout/custom_layout.ipynb index d84542ff4..fd40fd54d 100644 --- a/examples/map_layout/custom_layout.ipynb +++ b/examples/map_layout/custom_layout.ipynb @@ -94,6 +94,11 @@ " max-width: 100%;\n", " height: auto;\n", " }\n", + "\n", + " as-layer-selector-slot .as-layer-selector-slot--wrapper .as-caption { // FIXME\n", + " font-size: 14px;\n", + " line-height: 14px;\n", + " }\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - "\n", - "\n", - "\n", - "
\n", - " \n", - "
\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
\n", - " \n", - "\n", - "
\n", - " "Static\n", - " \n", - "
\n", - "
\n", - "
\n", - " \n", - " \n", - "
\n", - "
\n", - " \n", - "\n", - "
\n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
\n", - " \n", - " \n", - "
\n", - "
\n", - "
\n", - "
\n", - " \n", - "\n", - "
\n", - "
\n", - "
\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
\n", - " \n", - "\n", - "
\n", - " "Static\n", - " \n", - "
\n", - "
\n", - "
\n", - " \n", - " \n", - "
\n", - "
\n", - " \n", - "\n", - "
\n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
\n", - " \n", - " \n", - "
\n", - "
\n", - "
\n", - "
\n", - " \n", - "\n", - "
\n", - "
\n", - "
\n", - " \n", - "
\n", - " \n", - "
\n", - "\n", - " \n", - "\n", - "
\n", - "
\n", - " :\n", - "
\n", - " \n", - " \n", - "
\n", - "
\n", - "\n", - "
\n", - " StackTrace\n", - "
    \n", - "
    \n", - "
    \n", - "\n", - "\n", - "\n", - "\n", - "\">\n", - "\n", - "" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Layout([\n", - " Map(Layer('drought_wk_1', color_bins_style('dm', method='equal', palette='pinkyl'))),\n", - " Map(Layer('drought_wk_4', color_bins_style('dm', method='equal', palette='pinkyl'))),\n", - "], map_height=500, viewport={'zoom': 3, 'lat': 33.4706, 'lng': -98.3457})" - ] - } - ], - "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 -} diff --git a/examples/map_layout/save_image_layout.ipynb b/examples/map_layout/save_image_layout.ipynb deleted file mode 100644 index 74c77ecb7..000000000 --- a/examples/map_layout/save_image_layout.ipynb +++ /dev/null @@ -1,1112 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Save image from Layout" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Use the `Layout` class to create a variety of map views for comparison.\n", - "\n", - "For more information, run `help(Layout)`.\n", - "\n", - "Layouts can be static by using the `is_static=True` flag. To save a layout image, right click and select the option \"Save Image As...\"" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from cartoframes.auth import set_default_credentials\n", - "from cartoframes.viz import Map, Layer, Layout, color_bins_style\n", - "\n", - "set_default_credentials('cartoframes')" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n", - "\n", - " CARTOframes\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "\n", - " \n", - "\n", - " \n", - " \n", - " \n", - " \n", - "\n", - " \n", - " \n", - " \n", - " \n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "\n", - "\n", - "\n", - "
    \n", - " \n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    \n", - " \n", - "\n", - "
    \n", - " "Static\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "\n", - "
    \n", - "
    \n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    \n", - " \n", - "\n", - "
    \n", - " "Static\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "\n", - "
    \n", - "
    \n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    \n", - " \n", - "\n", - "
    \n", - " "Static\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "\n", - "
    \n", - "
    \n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    \n", - " \n", - "\n", - "
    \n", - " "Static\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "\n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - " \n", - "
    \n", - "\n", - " \n", - "\n", - "
    \n", - "
    \n", - " :\n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - "\n", - "
    \n", - " StackTrace\n", - "
      \n", - "
      \n", - "
      \n", - "\n", - "\n", - "\n", - "\n", - "\">\n", - "\n", - "" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "style = color_bins_style('dm', method='equal', palette='pinkyl')\n", - "\n", - "Layout([\n", - " Map(Layer('drought_wk_1', style, title='Week 1', default_legend=False)),\n", - " Map(Layer('drought_wk_2', style, title='Week 2', default_legend=False)),\n", - " Map(Layer('drought_wk_3', style, title='Week 3', default_legend=False)),\n", - " Map(Layer('drought_wk_4', style, title='Week 4', default_legend=False))\n", - "], is_static=True, viewport={'zoom': 3, 'lat': 33.4706, 'lng': -98.3457})" - ] - } - ], - "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 -}