Esempio n. 1
0
 def get_multi_line_plot(self, df: pd.DataFrame, width, height, title):
     """
     This function design a plot with the structure of Parallel Coordinates graph.
     For that, it uses the function multi_line from bokeh module. And then, it calls the
     function add_annotation_for_categorical_data in order to add a label where there are the code-category
     from the categorical data
     :param df: Data frame which we want to plot
     :param width: The width measure for the figure
     :param height: The height measure for the figure
     :param title: The tittle  for the figure
     :return: The corresponding plot completed
     """
     plot = bk.figure(plot_width=width,
                      plot_height=height,
                      title=title,
                      x_range=list(self.my_df))
     ys_list = list()
     xs_list = list()
     for i in range(0, len(df)):
         aux_ys_list = df.iloc[i].tolist()
         ys_list.append(aux_ys_list.copy())
         xs_list.append(list(range(0, len(df.columns))))
     try:
         my_palette = viridis(len(df.index))
         plot.multi_line(xs=xs_list, ys=ys_list, line_color=my_palette)
     except ValueError:
         plot.multi_line(xs=xs_list, ys=ys_list)
     plot.xaxis.major_tick_line_color = None
     plot.xgrid.visible = False
     plot.ygrid.visible = False
     TextAlign = enumeration("left", "right", "center")
     plot.xaxis.major_label_text_align = TextAlign.left
     plot.xaxis.major_label_orientation = pi / 6
     plot = self.add_annotation_for_categorical_data(plot, width)
     return plot
Esempio n. 2
0
 def test_quote(self) -> None:
     e = bce.enumeration("foo", "bar", "baz", quote=True)
     assert isinstance(e, bce.Enumeration)
     assert str(e) == 'Enumeration("foo", "bar", "baz")' or str(e) == "Enumeration('foo', 'bar', 'baz')"
     assert [x for x in e] == ["foo", "bar", "baz"]
     for x in ["foo", "bar", "baz"]:
         assert x in e
     assert "junk" not in e
Esempio n. 3
0
 def test_basic(self):
     e = bce.enumeration("foo", "bar", "baz")
     assert isinstance(e, bce.Enumeration)
     assert str(e) == "Enumeration(foo, bar, baz)"
     assert [x for x in e] == ["foo", "bar", "baz"]
     for x in ["foo", "bar", "baz"]:
         assert x in e
     assert "junk" not in e
Esempio n. 4
0
def test_enumeration_case():
    e = enums.enumeration("foo", "bar", "baz", case_sensitive=False)
    assert isinstance(e, enums.Enumeration)
    assert str(e) == "Enumeration(foo, bar, baz)"
    assert [x for x in e] == ["foo", "bar", "baz"]
    for x in ["foo", "FOO", "bar", "bAr", "baz", "BAZ"]:
        assert x in e
    assert "junk" not in e
Esempio n. 5
0
def test_enumeration_basic():
    e = enums.enumeration("foo", "bar", "baz")
    assert isinstance(e, enums.Enumeration)
    assert str(e) == "Enumeration(foo, bar, baz)"
    assert [x for x in e] == ["foo", "bar", "baz"]
    for x in ["foo", "bar", "baz"]:
        assert x in e
    assert "junk" not in e
Esempio n. 6
0
 def test_case(self):
     e = bce.enumeration("foo", "bar", "baz", case_sensitive=False)
     assert isinstance(e, bce.Enumeration)
     assert str(e) == "Enumeration(foo, bar, baz)"
     assert [x for x in e] == ["foo", "bar", "baz"]
     for x in ["foo", "FOO", "bar", "bAr", "baz", "BAZ"]:
         assert x in e
     assert "junk" not in e
Esempio n. 7
0
 def test_quote(self):
     e = bce.enumeration("foo", "bar", "baz", quote=True)
     assert isinstance(e, bce.Enumeration)
     assert str(e) == 'Enumeration("foo", "bar", "baz")' or str(e) == "Enumeration('foo', 'bar', 'baz')"
     assert [x for x in e] == ["foo", "bar", "baz"]
     for x in ["foo", "bar", "baz"]:
         assert x in e
     assert "junk" not in e
Esempio n. 8
0
 def deprecated_vendors():
     deprecated((3, 0, 0), "tile_providers module", "add_tile directly")
     return enumeration('CARTODBPOSITRON',
                        'CARTODBPOSITRON_RETINA',
                        'STAMEN_TERRAIN',
                        'STAMEN_TERRAIN_RETINA',
                        'STAMEN_TONER',
                        'STAMEN_TONER_BACKGROUND',
                        'STAMEN_TONER_LABELS',
                        'OSM',
                        'ESRI_IMAGERY',
                        case_sensitive=True)
Esempio n. 9
0
class VTKVolumePlot(AbstractVTKPlot):
    """
    Bokeh model dedicated to plot a volumetric object with the help of vtk-js
    """

    ambient = Float(default=0.2)

    colormap = String(help="Colormap Name")

    controller_expanded = Bool(default=True,
                               help="""
        If True the volume controller panel options is expanded in the view""")

    data = Nullable(Dict(String, Any))

    diffuse = Float(default=0.7)

    display_slices = Bool(default=False)

    display_volume = Bool(default=True)

    edge_gradient = Float(default=0.2)

    interpolation = Enum(enumeration('fast_linear', 'linear', 'nearest'))

    mapper = Dict(String, Any)

    nan_opacity = Float(default=1)

    render_background = String(default='#52576e')

    rescale = Bool(default=False)

    sampling = Float(default=0.4)

    shadow = Bool(default=True)

    slice_i = Int(default=0)

    slice_j = Int(default=0)

    slice_k = Int(default=0)

    specular = Float(default=0.3)

    specular_power = Float(default=8.)
Esempio n. 10
0
class _TileProvidersModule(types.ModuleType):
    _MAPBOX_ATTRIBUTION = (
        'Map tiles by <a href="https://mapbox.com">MAPBOX</a>')

    _SERVICE_URLS = dict(
        MAPBOX_DARK=("https://api.mapbox.com/styles/v1/mapbox/"
                     "dark-v10/tiles/{z}/{x}/{y}@2x?access_token="),
        MAPBOX_LIGHT=("https://api.mapbox.com/styles/v1/mapbox/"
                      "light-v10/tiles/{z}/{x}/{y}@2x?access_token="),
    )

    Vendors = enumeration("MAPBOX_DARK", "MAPBOX_LIGHT", case_sensitive=True)

    def get_provider(self, provider_name, access_token=None):
        from bokeh.models.tiles import WMTSTileSource

        if isinstance(provider_name, WMTSTileSource):
            # This allows `get_provider(CARTODBPOSITRON)` to work
            if provider_name.startswith("MAPBOX"):
                if access_token is None:
                    raise ValueError("provide access token for MAPBOX tiles")
                return WMTSTileSource(
                    url=provider_name.url + str(access_token),
                    attribution=provider_name.attribution,
                )

        selected_provider = provider_name.upper()

        if selected_provider not in self.Vendors:
            raise ValueError("Unknown tile provider %s" % provider_name)

        url = self._SERVICE_URLS[selected_provider]
        if selected_provider.startswith("MAPBOX"):
            attribution = self._MAPBOX_ATTRIBUTION
            if access_token is None:
                raise ValueError("provide access token for MAPBOX tiles")
            return WMTSTileSource(url=url + str(access_token),
                                  attribution=attribution)
        else:
            raise ValueError("Can not retrieve attribution for %s" %
                             selected_provider)

    # Properties --------------------------------------------------------------

    MAPBOX_DARK = _make_deprecated_property(Vendors.MAPBOX_DARK)
    MAPBOX_LIGHT = _make_deprecated_property(Vendors.MAPBOX_LIGHT)
Esempio n. 11
0
class VTKVolumePlot(AbstractVTKPlot):
    """
    Bokeh model dedicated to plot a volumetric object with the help of vtk-js
    (3D geometry objects are not suported)
    """

    data = Dict(String, Any)

    colormap = String(help="Colormap Name")

    rescale = Bool(default=False)

    shadow = Bool(default=True)

    sampling = Float(default=0.4)

    edge_gradient = Float(default=0.2)

    ambient = Float(default=0.2)

    diffuse = Float(default=0.7)

    specular = Float(default=0.3)

    specular_power = Float(default=8.)

    slice_i = Int(default=0)

    slice_j = Int(default=0)

    slice_k = Int(default=0)

    display_volume = Bool(default=True)

    display_slices = Bool(default=False)

    render_background = String(default='#52576e')

    interpolation = Enum(enumeration('fast_linear', 'linear', 'nearest'))

    mapper = Dict(String, Any)
Esempio n. 12
0
from __future__ import absolute_import

from bokeh.model import Model
from bokeh.core.enums import enumeration
from bokeh.core.properties import Auto, Either, Enum, Float, Int, List, Tuple

class Foo(Model):
    """ This is a Foo model. """
    index = Either(Auto, Enum('abc', 'def', 'xzy'), help="doc for index")
    value = Tuple(Float, Float, help="doc for value")

class Bar(Model):
    """ This is a Bar model. """
    thing = List(Int, help="doc for thing")

#: This is an enumeration
baz = enumeration("a", "b", "c")
Esempio n. 13
0
class VTKVolumePlot(HTMLBox):
    """
    A Bokeh model that wraps around a vtk-js library and renders it inside
    a Bokeh plot.
    """

    __javascript__ = [vtk_cdn]

    __js_skip__ = {'vtk': [vtk_cdn]}

    __js_require__ = {
        "paths": {
            "vtk": vtk_cdn[:-3]
        },
        "exports": {
            "vtk": None
        },
        "shim": {
            "vtk": {
                "exports": "vtk"
            }
        }
    }

    data = Dict(String, Any)

    colormap = String(help="Colormap Name")

    rescale = Bool(default=False)

    shadow = Bool(default=True)

    sampling = Float(default=0.4)

    edge_gradient = Float(default=0.2)

    ambient = Float(default=0.2)

    diffuse = Float(default=0.7)

    specular = Float(default=0.3)

    specular_power = Float(default=8.)

    slice_i = Int(default=0)

    slice_j = Int(default=0)

    slice_k = Int(default=0)

    display_volume = Bool(default=True)

    display_slices = Bool(default=False)

    render_background = String(default='#52576e')

    interpolation = Enum(enumeration('fast_linear', 'linear', 'nearest'))

    height = Override(default=300)

    width = Override(default=300)
Esempio n. 14
0
class _TileProvidersModule(types.ModuleType):
    _CARTO_ATTRIBUTION = (
        '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors,'
        '&copy; <a href="https://cartodb.com/attributions">CartoDB</a>')

    _STAMEN_ATTRIBUTION = (
        'Map tiles by <a href="https://stamen.com">Stamen Design</a>, '
        'under <a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. '
        'Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, '
        'under %s.')

    _SERVICE_URLS = dict(
        CARTODBPOSITRON=
        'https://tiles.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
        CARTODBPOSITRON_RETINA=
        'https://tiles.basemaps.cartocdn.com/light_all/{z}/{x}/{y}@2x.png',
        STAMEN_TERRAIN='http://tile.stamen.com/terrain/{Z}/{X}/{Y}.png',
        STAMEN_TERRAIN_RETINA=
        'http://tile.stamen.com/terrain/{Z}/{X}/{Y}@2x.png',
        STAMEN_TONER='http://tile.stamen.com/toner/{Z}/{X}/{Y}.png',
        STAMEN_TONER_BACKGROUND=
        'http://tile.stamen.com/toner-background/{Z}/{X}/{Y}.png',
        STAMEN_TONER_LABELS=
        'http://tile.stamen.com/toner-labels/{Z}/{X}/{Y}.png',
    )

    _STAMEN_ATTRIBUTION_URLS = dict(
        STAMEN_TERRAIN=
        '<a href="https://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>',
        STAMEN_TERRAIN_RETINA=
        '<a href="https://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>',
        STAMEN_TONER=
        '<a href="https://www.openstreetmap.org/copyright">ODbL</a>',
        STAMEN_TONER_BACKGROUND=
        '<a href="https://www.openstreetmap.org/copyright">ODbL</a>',
        STAMEN_TONER_LABELS=
        '<a href="https://www.openstreetmap.org/copyright">ODbL</a>',
    )

    Vendors = enumeration('CARTODBPOSITRON',
                          'CARTODBPOSITRON_RETINA',
                          'STAMEN_TERRAIN',
                          'STAMEN_TERRAIN_RETINA',
                          'STAMEN_TONER',
                          'STAMEN_TONER_BACKGROUND',
                          'STAMEN_TONER_LABELS',
                          case_sensitive=True)

    def get_provider(self, provider_name):
        from bokeh.models.tiles import WMTSTileSource

        if isinstance(provider_name, WMTSTileSource):
            # This allows `get_provider(CARTODBPOSITRON)` to work
            return WMTSTileSource(url=provider_name.url,
                                  attribution=provider_name.attribution)

        selected_provider = provider_name.upper()

        if selected_provider not in self.Vendors:
            raise ValueError('Unknown tile provider %s' % provider_name)

        url = self._SERVICE_URLS[selected_provider]
        if selected_provider.startswith('CARTO'):
            attribution = self._CARTO_ATTRIBUTION
        elif selected_provider.startswith('STAMEN'):
            attribution = self._STAMEN_ATTRIBUTION % self._STAMEN_ATTRIBUTION_URLS[
                selected_provider]
        else:
            raise ValueError('Can not retrieve attribution for %s' %
                             selected_provider)
        return WMTSTileSource(url=url, attribution=attribution)

    # Properties --------------------------------------------------------------

    CARTODBPOSITRON = Vendors.CARTODBPOSITRON
    CARTODBPOSITRON_RETINA = Vendors.CARTODBPOSITRON_RETINA
    STAMEN_TERRAIN = Vendors.STAMEN_TERRAIN
    STAMEN_TERRAIN_RETINA = Vendors.STAMEN_TERRAIN_RETINA
    STAMEN_TONER = Vendors.STAMEN_TONER
    STAMEN_TONER_BACKGROUND = Vendors.STAMEN_TONER_BACKGROUND
    STAMEN_TONER_LABELS = Vendors.STAMEN_TONER_LABELS
Esempio n. 15
0
from __future__ import absolute_import

from bokeh.model import Model
from bokeh.core.enums import enumeration
from bokeh.core.properties import Auto, Either, Enum, Float, Int, List, Tuple


class Foo(Model):
    """ This is a Foo model. """
    index = Either(Auto, Enum('abc', 'def', 'xzy'), help="doc for index")
    value = Tuple(Float, Float, help="doc for value")


class Bar(Model):
    """ This is a Bar model. """
    thing = List(Int, help="doc for thing")


#: This is an enumeration
baz = enumeration("a", "b", "c")
Esempio n. 16
0
'''
from __future__ import absolute_import

from collections import defaultdict
import warnings

import numpy as np

from bokeh.core.enums import enumeration
from bokeh.core.properties import Auto, Either, Enum, String, value
from bokeh.models import CategoricalAxis, DatetimeAxis, FactorRange, glyphs, Grid, HoverTool, Legend, LegendItem, LinearAxis, markers, Plot
from bokeh.plotting import DEFAULT_TOOLS
from bokeh.plotting.helpers import _process_tools_arg, _glyph_function, _process_active_tools
from bokeh.util._plot_arg_helpers import _convert_responsive

Scale = enumeration('linear', 'categorical', 'datetime')


class ChartDefaults(object):
    def apply(self, chart):
        """Apply this defaults to a chart."""

        if not isinstance(chart, Chart):
            raise ValueError(
                "ChartsDefaults should be only used on Chart objects but it's being used on %s instead."
                % chart)

        all_props = set(chart.properties_with_values(include_defaults=True))
        dirty_props = set(chart.properties_with_values(include_defaults=False))
        for k in list(all_props.difference(dirty_props)) + \
            list(chart.__deprecated_attributes__):
Esempio n. 17
0
"""
Declares enumerations for various model properties.
"""
from __future__ import absolute_import, division, unicode_literals

from bokeh.core.enums import enumeration

ace_themes = enumeration(
    'ambiance', 'chaos', 'chrome', 'clouds', 'clouds_midnight', 'cobalt',
    'crimson_editor', 'dawn', 'dracula', 'dreamweaver', 'eclipse', 'github', 'gob',
    'gruvbox', 'idle_fingers', 'iplastic', 'katzenmilch', 'kr_theme', 'kuroir',
    'merbivore', 'merbivore_soft', 'mono_industrial', 'monokai', 'pastel_on_dark',
    'solarized_dark', 'solarized_light', 'sqlserver', 'terminal', 'textmate',
    'tomorrow', 'tomorrow_night', 'tomorrow_night_blue', 'tomorrow_night_bright',
    'tomorrow_night_eighties', 'twilight', 'vibrant_ink', 'xcode'
)
def test_enumeration_default():
    # this is private but used by properties
    e = enums.enumeration("foo", "bar", "baz")
    assert e._default == "foo"
Esempio n. 19
0
NamedIcon = enumeration(*[
    "adjust", "adn", "align-center", "align-justify", "align-left", "align-right", "ambulance",
    "anchor", "android", "angellist", "angle-double-down", "angle-double-left", "angle-double-right",
    "angle-double-up", "angle-down", "angle-left", "angle-right", "angle-up", "apple", "archive",
    "area-chart", "arrow-circle-down", "arrow-circle-left", "arrow-circle-o-down", "arrow-circle-o-left",
    "arrow-circle-o-right", "arrow-circle-o-up", "arrow-circle-right", "arrow-circle-up", "arrow-down",
    "arrow-left", "arrow-right", "arrow-up", "arrows", "arrows-alt", "arrows-h", "arrows-v", "asterisk",
    "at", "automobile", "backward", "ban", "bank", "bar-chart", "bar-chart-o", "barcode", "bars", "beer",
    "behance", "behance-square", "bell", "bell-o", "bell-slash", "bell-slash-o", "bicycle", "binoculars",
    "birthday-cake", "bitbucket", "bitbucket-square", "bitcoin", "bold", "bolt", "bomb", "book", "bookmark",
    "bookmark-o", "briefcase", "btc", "bug", "building", "building-o", "bullhorn", "bullseye", "bus", "cab",
    "calculator", "calendar", "calendar-o", "camera", "camera-retro", "car", "caret-down", "caret-left",
    "caret-right", "caret-square-o-down", "caret-square-o-left", "caret-square-o-right", "caret-square-o-up",
    "caret-up", "cc", "cc-amex", "cc-discover", "cc-mastercard", "cc-paypal", "cc-stripe", "cc-visa", "certificate",
    "chain", "chain-broken", "check", "check-circle", "check-circle-o", "check-square", "check-square-o",
    "chevron-circle-down", "chevron-circle-left", "chevron-circle-right", "chevron-circle-up", "chevron-down",
    "chevron-left", "chevron-right", "chevron-up", "child", "circle", "circle-o", "circle-o-notch", "circle-thin",
    "clipboard", "clock-o", "close", "cloud", "cloud-download", "cloud-upload", "cny", "code", "code-fork",
    "codepen", "coffee", "cog", "cogs", "columns", "comment", "comment-o", "comments", "comments-o", "compass",
    "compress", "copy", "copyright", "credit-card", "crop", "crosshairs", "css3", "cube", "cubes", "cut", "cutlery",
    "dashboard", "database", "dedent", "delicious", "desktop", "deviantart", "digg", "dollar", "dot-circle-o",
    "download", "dribbble", "dropbox", "drupal", "edit", "eject", "ellipsis-h", "ellipsis-v", "empire", "envelope",
    "envelope-o", "envelope-square", "eraser", "eur", "euro", "exchange", "exclamation", "exclamation-circle",
    "exclamation-triangle", "expand", "external-link", "external-link-square", "eye", "eye-slash", "eyedropper",
    "facebook", "facebook-square", "fast-backward", "fast-forward", "fax", "female", "fighter-jet", "file",
    "file-archive-o", "file-audio-o", "file-code-o", "file-excel-o", "file-image-o", "file-movie-o", "file-o",
    "file-pdf-o", "file-photo-o", "file-picture-o", "file-powerpoint-o", "file-sound-o", "file-text", "file-text-o",
    "file-video-o", "file-word-o", "file-zip-o", "files-o", "film", "filter", "fire", "fire-extinguisher", "flag",
    "flag-checkered", "flag-o", "flash", "flask", "flickr", "floppy-o", "folder", "folder-o", "folder-open",
    "folder-open-o", "font", "forward", "foursquare", "frown-o", "futbol-o", "gamepad", "gavel", "gbp", "ge",
    "gear", "gears", "gift", "git", "git-square", "github", "github-alt", "github-square", "gittip", "glass",
    "globe", "google", "google-plus", "google-plus-square", "google-wallet", "graduation-cap", "group",
    "h-square", "hacker-news", "hand-o-down", "hand-o-left", "hand-o-right", "hand-o-up", "hdd-o", "header",
    "headphones", "heart", "heart-o", "history", "home", "hospital-o", "html5", "ils", "image", "inbox", "indent",
    "info", "info-circle", "inr", "instagram", "institution", "ioxhost", "italic", "joomla", "jpy", "jsfiddle",
    "key", "keyboard-o", "krw", "language", "laptop", "lastfm", "lastfm-square", "leaf", "legal", "lemon-o",
    "level-down", "level-up", "life-bouy", "life-buoy", "life-ring", "life-saver", "lightbulb-o", "line-chart",
    "link", "linkedin", "linkedin-square", "linux", "list", "list-alt", "list-ol", "list-ul", "location-arrow",
    "lock", "long-arrow-down", "long-arrow-left", "long-arrow-right", "long-arrow-up", "magic", "magnet", "mail-forward",
    "mail-reply", "mail-reply-all", "male", "map-marker", "maxcdn", "meanpath", "medkit", "meh-o", "microphone",
    "microphone-slash", "minus", "minus-circle", "minus-square", "minus-square-o", "mobile", "mobile-phone", "money",
    "moon-o", "mortar-board", "music", "navicon", "newspaper-o", "openid", "outdent", "pagelines", "paint-brush",
    "paper-plane", "paper-plane-o", "paperclip", "paragraph", "paste", "pause", "paw", "paypal", "pencil", "pencil-square",
    "pencil-square-o", "phone", "phone-square", "photo", "picture-o", "pie-chart", "pied-piper", "pied-piper-alt",
    "pinterest", "pinterest-square", "plane", "play", "play-circle", "play-circle-o", "plug", "plus", "plus-circle",
    "plus-square", "plus-square-o", "power-off", "print", "puzzle-piece", "qq", "qrcode", "question", "question-circle",
    "quote-left", "quote-right", "ra", "random", "rebel", "recycle", "reddit", "reddit-square", "refresh", "remove",
    "renren", "reorder", "repeat", "reply", "reply-all", "retweet", "rmb", "road", "rocket", "rotate-left", "rotate-right",
    "rouble", "rss", "rss-square", "rub", "ruble", "rupee", "save", "scissors", "search", "search-minus", "search-plus",
    "send", "send-o", "share", "share-alt", "share-alt-square", "share-square", "share-square-o", "shekel", "sheqel",
    "shield", "shopping-cart", "sign-in", "sign-out", "signal", "sitemap", "skype", "slack", "sliders", "slideshare", "smile-o",
    "soccer-ball-o", "sort", "sort-alpha-asc", "sort-alpha-desc", "sort-amount-asc", "sort-amount-desc", "sort-asc",
    "sort-desc", "sort-down", "sort-numeric-asc", "sort-numeric-desc", "sort-up", "soundcloud", "space-shuttle", "spinner",
    "spoon", "spotify", "square", "square-o", "stack-exchange", "stack-overflow", "star", "star-half", "star-half-empty",
    "star-half-full", "star-half-o", "star-o", "steam", "steam-square", "step-backward", "step-forward", "stethoscope",
    "stop", "strikethrough", "stumbleupon", "stumbleupon-circle", "subscript", "suitcase", "sun-o", "superscript",
    "support", "table", "tablet", "tachometer", "tag", "tags", "tasks", "taxi", "tencent-weibo", "terminal", "text-height",
    "text-width", "th", "th-large", "th-list", "thumb-tack", "thumbs-down", "thumbs-o-down", "thumbs-o-up", "thumbs-up",
    "ticket", "times", "times-circle", "times-circle-o", "tint", "toggle-down", "toggle-left", "toggle-off", "toggle-on",
    "toggle-right", "toggle-up", "trash", "trash-o", "tree", "trello", "trophy", "truck", "try", "tty", "tumblr",
    "tumblr-square", "turkish-lira", "twitch", "twitter", "twitter-square", "umbrella", "underline", "undo", "university",
    "unlink", "unlock", "unlock-alt", "unsorted", "upload", "usd", "user", "user-md", "users", "video-camera", "vimeo-square",
    "vine", "vk", "volume-down", "volume-off", "volume-up", "warning", "wechat", "weibo", "weixin", "wheelchair", "wifi",
    "windows", "won", "wordpress", "wrench", "xing", "xing-square", "yahoo", "yelp", "yen", "youtube", "youtube-play",
    "youtube-square",
])
Esempio n. 20
0
class IonRangeSlider(AbstractSlider):
    # The special class attribute ``__implementation__`` should contain a string
    # of JavaScript (or CoffeeScript) code that implements the JavaScript side
    # of the custom extension model or a string name of a JavaScript (or
    # CoffeeScript) file with the implementation.

    with open(
            os.path.join(os.path.dirname(__file__),
                         '../bokeh-ion-rangesliderjs/src/ion_range_slider.ts')
    ) as file_:
        implementation = file_.readlines()
    __implementation__ = TypeScript(''.join(implementation))
    __javascript__ = [
        "https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js",
        "https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js"
    ]
    __css__ = [
        "https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.css",
        "https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/css/ion.rangeSlider.css",
        "https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/css/ion.rangeSlider.skinFlat.min.css",
        "https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/img/sprite-skin-flat.png"
    ]

    # Below are all the "properties" for this model. Bokeh properties are
    # class attributes that define the fields (and their types) that can be
    # communicated automatically between Python and the browser. Properties
    # also support type validation. More information about properties in
    # can be found here:
    #
    #    http://bokeh.pydata.org/en/latest/docs/reference/core.html#bokeh-core-properties

    start = Float(default=0, help="""
    The minimum allowable value.
    """)

    end = Float(default=1, help="""
    The maximum allowable value.
    """)

    value = Tuple(Float,
                  Float,
                  default=[0, 1],
                  help="""
    Initial or selected range.
    """)

    step = Float(default=0.1,
                 help="""
    The step between consecutive values.
    """)

    #format = String(default="0[.]00") Ignored right now

    #bar_color = Color(default="#e6e6e6", help=""" """) Overwritten default

    slider_type = Enum(enumeration('single', 'double'),
                       default='single',
                       help="""
    Choose slider type, could be single - for one handle, or double for
    two handles.
    """)

    values = List(Any,
                  help="""
    Set up your own array of possible slider values. They could be numbers
    or strings. The following attributes are ignored if you supply values:
    min, max and step.
    """)

    grid = Bool(default=True,
                help="""
    Show the grid beneath the slider.
    """)

    prettify_enabled = Bool(default=True,
                            help="""
    Improve readability of long numbers. 10000000 -> 10 000 000
    """)

    prettify = Instance(Callback,
                        help="""
    Set up your own prettify function. Can be anything. For example, you can
    set up unix time as slider values and than transform them to cool looking
    dates.
    """)

    force_edges = Bool(default=False,
                       help="""
    Slider will be always inside it's container.
    """)

    prefix = String(default="",
                    help="""
    Set prefix for values. Will be set up right before the number: $100
    """)
Esempio n. 21
0
 def test_len(self):
     e = bce.enumeration("foo", "bar", "baz")
     assert len(e) == 3
Esempio n. 22
0
 def test_default(self):
     # this is private but used by properties
     e = bce.enumeration("foo", "bar", "baz")
     assert e._default == "foo"
Esempio n. 23
0
 def test_len(self):
     e = bce.enumeration("foo", "bar", "baz")
     assert len(e) == 3
Esempio n. 24
0
 def test_default(self):
     # this is private but used by properties
     e = bce.enumeration("foo", "bar", "baz")
     assert e._default == "foo"
Esempio n. 25
0
NamedIcon = enumeration(*[
    "adjust",
    "adn",
    "align-center",
    "align-justify",
    "align-left",
    "align-right",
    "ambulance",
    "anchor",
    "android",
    "angellist",
    "angle-double-down",
    "angle-double-left",
    "angle-double-right",
    "angle-double-up",
    "angle-down",
    "angle-left",
    "angle-right",
    "angle-up",
    "apple",
    "archive",
    "area-chart",
    "arrow-circle-down",
    "arrow-circle-left",
    "arrow-circle-o-down",
    "arrow-circle-o-left",
    "arrow-circle-o-right",
    "arrow-circle-o-up",
    "arrow-circle-right",
    "arrow-circle-up",
    "arrow-down",
    "arrow-left",
    "arrow-right",
    "arrow-up",
    "arrows",
    "arrows-alt",
    "arrows-h",
    "arrows-v",
    "asterisk",
    "at",
    "automobile",
    "backward",
    "ban",
    "bank",
    "bar-chart",
    "bar-chart-o",
    "barcode",
    "bars",
    "beer",
    "behance",
    "behance-square",
    "bell",
    "bell-o",
    "bell-slash",
    "bell-slash-o",
    "bicycle",
    "binoculars",
    "birthday-cake",
    "bitbucket",
    "bitbucket-square",
    "bitcoin",
    "bold",
    "bolt",
    "bomb",
    "book",
    "bookmark",
    "bookmark-o",
    "briefcase",
    "btc",
    "bug",
    "building",
    "building-o",
    "bullhorn",
    "bullseye",
    "bus",
    "cab",
    "calculator",
    "calendar",
    "calendar-o",
    "camera",
    "camera-retro",
    "car",
    "caret-down",
    "caret-left",
    "caret-right",
    "caret-square-o-down",
    "caret-square-o-left",
    "caret-square-o-right",
    "caret-square-o-up",
    "caret-up",
    "cc",
    "cc-amex",
    "cc-discover",
    "cc-mastercard",
    "cc-paypal",
    "cc-stripe",
    "cc-visa",
    "certificate",
    "chain",
    "chain-broken",
    "check",
    "check-circle",
    "check-circle-o",
    "check-square",
    "check-square-o",
    "chevron-circle-down",
    "chevron-circle-left",
    "chevron-circle-right",
    "chevron-circle-up",
    "chevron-down",
    "chevron-left",
    "chevron-right",
    "chevron-up",
    "child",
    "circle",
    "circle-o",
    "circle-o-notch",
    "circle-thin",
    "clipboard",
    "clock-o",
    "close",
    "cloud",
    "cloud-download",
    "cloud-upload",
    "cny",
    "code",
    "code-fork",
    "codepen",
    "coffee",
    "cog",
    "cogs",
    "columns",
    "comment",
    "comment-o",
    "comments",
    "comments-o",
    "compass",
    "compress",
    "copy",
    "copyright",
    "credit-card",
    "crop",
    "crosshairs",
    "css3",
    "cube",
    "cubes",
    "cut",
    "cutlery",
    "dashboard",
    "database",
    "dedent",
    "delicious",
    "desktop",
    "deviantart",
    "digg",
    "dollar",
    "dot-circle-o",
    "download",
    "dribbble",
    "dropbox",
    "drupal",
    "edit",
    "eject",
    "ellipsis-h",
    "ellipsis-v",
    "empire",
    "envelope",
    "envelope-o",
    "envelope-square",
    "eraser",
    "eur",
    "euro",
    "exchange",
    "exclamation",
    "exclamation-circle",
    "exclamation-triangle",
    "expand",
    "external-link",
    "external-link-square",
    "eye",
    "eye-slash",
    "eyedropper",
    "facebook",
    "facebook-square",
    "fast-backward",
    "fast-forward",
    "fax",
    "female",
    "fighter-jet",
    "file",
    "file-archive-o",
    "file-audio-o",
    "file-code-o",
    "file-excel-o",
    "file-image-o",
    "file-movie-o",
    "file-o",
    "file-pdf-o",
    "file-photo-o",
    "file-picture-o",
    "file-powerpoint-o",
    "file-sound-o",
    "file-download",
    "file-text",
    "file-text-o",
    "file-video-o",
    "file-word-o",
    "file-zip-o",
    "files-o",
    "film",
    "filter",
    "fire",
    "fire-extinguisher",
    "flag",
    "flag-checkered",
    "flag-o",
    "flash",
    "flask",
    "flickr",
    "floppy-o",
    "folder",
    "folder-o",
    "folder-open",
    "folder-open-o",
    "font",
    "forward",
    "foursquare",
    "frown-o",
    "futbol-o",
    "gamepad",
    "gavel",
    "gbp",
    "ge",
    "gear",
    "gears",
    "gift",
    "git",
    "git-square",
    "github",
    "github-alt",
    "github-square",
    "gittip",
    "glass",
    "globe",
    "google",
    "google-plus",
    "google-plus-square",
    "google-wallet",
    "graduation-cap",
    "group",
    "h-square",
    "hacker-news",
    "hand-o-down",
    "hand-o-left",
    "hand-o-right",
    "hand-o-up",
    "hdd-o",
    "header",
    "headphones",
    "heart",
    "heart-o",
    "history",
    "home",
    "hospital-o",
    "html5",
    "ils",
    "image",
    "inbox",
    "indent",
    "info",
    "info-circle",
    "inr",
    "instagram",
    "institution",
    "ioxhost",
    "italic",
    "joomla",
    "jpy",
    "jsfiddle",
    "key",
    "keyboard-o",
    "krw",
    "language",
    "laptop",
    "lastfm",
    "lastfm-square",
    "leaf",
    "legal",
    "lemon-o",
    "level-down",
    "level-up",
    "life-bouy",
    "life-buoy",
    "life-ring",
    "life-saver",
    "lightbulb-o",
    "line-chart",
    "link",
    "linkedin",
    "linkedin-square",
    "linux",
    "list",
    "list-alt",
    "list-ol",
    "list-ul",
    "location-arrow",
    "lock",
    "long-arrow-down",
    "long-arrow-left",
    "long-arrow-right",
    "long-arrow-up",
    "magic",
    "magnet",
    "mail-forward",
    "mail-reply",
    "mail-reply-all",
    "male",
    "map-marker",
    "maxcdn",
    "meanpath",
    "medkit",
    "meh-o",
    "microphone",
    "microphone-slash",
    "minus",
    "minus-circle",
    "minus-square",
    "minus-square-o",
    "mobile",
    "mobile-phone",
    "money",
    "moon-o",
    "mortar-board",
    "music",
    "navicon",
    "newspaper-o",
    "openid",
    "outdent",
    "pagelines",
    "paint-brush",
    "paper-plane",
    "paper-plane-o",
    "paperclip",
    "paragraph",
    "paste",
    "pause",
    "paw",
    "paypal",
    "pencil",
    "pencil-square",
    "pencil-square-o",
    "phone",
    "phone-square",
    "photo",
    "picture-o",
    "pie-chart",
    "pied-piper",
    "pied-piper-alt",
    "pinterest",
    "pinterest-square",
    "plane",
    "play",
    "play-circle",
    "play-circle-o",
    "plug",
    "plus",
    "plus-circle",
    "plus-square",
    "plus-square-o",
    "power-off",
    "print",
    "puzzle-piece",
    "qq",
    "qrcode",
    "question",
    "question-circle",
    "quote-left",
    "quote-right",
    "ra",
    "random",
    "rebel",
    "recycle",
    "reddit",
    "reddit-square",
    "refresh",
    "remove",
    "renren",
    "reorder",
    "repeat",
    "reply",
    "reply-all",
    "retweet",
    "rmb",
    "road",
    "rocket",
    "rotate-left",
    "rotate-right",
    "rouble",
    "rss",
    "rss-square",
    "rub",
    "ruble",
    "rupee",
    "save",
    "scissors",
    "search",
    "search-minus",
    "search-plus",
    "send",
    "send-o",
    "share",
    "share-alt",
    "share-alt-square",
    "share-square",
    "share-square-o",
    "shekel",
    "sheqel",
    "shield",
    "shopping-cart",
    "sign-in",
    "sign-out",
    "signal",
    "sitemap",
    "skype",
    "slack",
    "sliders",
    "slideshare",
    "smile-o",
    "soccer-ball-o",
    "sort",
    "sort-alpha-asc",
    "sort-alpha-desc",
    "sort-amount-asc",
    "sort-amount-desc",
    "sort-asc",
    "sort-desc",
    "sort-down",
    "sort-numeric-asc",
    "sort-numeric-desc",
    "sort-up",
    "soundcloud",
    "space-shuttle",
    "spinner",
    "spoon",
    "spotify",
    "square",
    "square-o",
    "stack-exchange",
    "stack-overflow",
    "star",
    "star-half",
    "star-half-empty",
    "star-half-full",
    "star-half-o",
    "star-o",
    "steam",
    "steam-square",
    "step-backward",
    "step-forward",
    "stethoscope",
    "stop",
    "strikethrough",
    "stumbleupon",
    "stumbleupon-circle",
    "subscript",
    "suitcase",
    "sun-o",
    "superscript",
    "support",
    "table",
    "tablet",
    "tachometer",
    "tag",
    "tags",
    "tasks",
    "taxi",
    "tencent-weibo",
    "terminal",
    "text-height",
    "text-width",
    "th",
    "th-large",
    "th-list",
    "thumb-tack",
    "thumbs-down",
    "thumbs-o-down",
    "thumbs-o-up",
    "thumbs-up",
    "ticket",
    "times",
    "times-circle",
    "times-circle-o",
    "tint",
    "toggle-down",
    "toggle-left",
    "toggle-off",
    "toggle-on",
    "toggle-right",
    "toggle-up",
    "trash",
    "trash-o",
    "tree",
    "trello",
    "trophy",
    "truck",
    "try",
    "tty",
    "tumblr",
    "tumblr-square",
    "turkish-lira",
    "twitch",
    "twitter",
    "twitter-square",
    "umbrella",
    "underline",
    "undo",
    "university",
    "unlink",
    "unlock",
    "unlock-alt",
    "unsorted",
    "upload",
    "usd",
    "user",
    "user-md",
    "users",
    "video-camera",
    "vimeo-square",
    "vine",
    "vk",
    "volume-down",
    "volume-off",
    "volume-up",
    "warning",
    "wechat",
    "weibo",
    "weixin",
    "wheelchair",
    "wifi",
    "windows",
    "won",
    "wordpress",
    "wrench",
    "xing",
    "xing-square",
    "yahoo",
    "yelp",
    "yen",
    "youtube",
    "youtube-play",
    "youtube-square",
])
Esempio n. 26
0
class _TileProvidersModule(types.ModuleType):
    _CARTO_ATTRIBUTION = (
        '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors,'
        '&copy; <a href="https://cartodb.com/attributions">CartoDB</a>'
    )

    _STAMEN_ATTRIBUTION = (
        'Map tiles by <a href="https://stamen.com">Stamen Design</a>, '
        'under <a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. '
        'Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, '
        'under %s.'
    )

    _OSM_ATTRIBTION = (
        '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    )

    _WIKIMEDIA_ATTRIBUTION = (
        '&copy; <a href="https://foundation.wikimedia.org/wiki/Maps_Terms_of_Use">Wikimedia Maps</a> contributors'
    )

    _ESRI_IMAGERY_ATTRIBUTION = (
        '&copy; <a href="http://downloads.esri.com/ArcGISOnline/docs/tou_summary.pdf">Esri</a>, '
        'Earthstar Geographics'
    )

    _SERVICE_URLS = dict(
        CARTODBPOSITRON='https://tiles.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
        CARTODBPOSITRON_RETINA='https://tiles.basemaps.cartocdn.com/light_all/{z}/{x}/{y}@2x.png',
        STAMEN_TERRAIN='https://stamen-tiles.a.ssl.fastly.net/terrain/{Z}/{X}/{Y}.png',
        STAMEN_TERRAIN_RETINA='https://stamen-tiles.a.ssl.fastly.net/terrain/{Z}/{X}/{Y}@2x.png',
        STAMEN_TONER='https://stamen-tiles.a.ssl.fastly.net/toner/{Z}/{X}/{Y}.png',
        STAMEN_TONER_BACKGROUND='https://stamen-tiles.a.ssl.fastly.net/toner-background/{Z}/{X}/{Y}.png',
        STAMEN_TONER_LABELS='https://stamen-tiles.a.ssl.fastly.net/toner-labels/{Z}/{X}/{Y}.png',
        OSM='https://c.tile.openstreetmap.org/{Z}/{X}/{Y}.png',
        WIKIMEDIA='https://maps.wikimedia.org/osm-intl/{Z}/{X}/{Y}@2x.png',
        ESRI_IMAGERY='https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg'
    )

    _STAMEN_ATTRIBUTION_URLS = dict(
        STAMEN_TERRAIN='<a href="https://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>',
        STAMEN_TERRAIN_RETINA='<a href="https://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>',
        STAMEN_TONER='<a href="https://www.openstreetmap.org/copyright">ODbL</a>',
        STAMEN_TONER_BACKGROUND='<a href="https://www.openstreetmap.org/copyright">ODbL</a>',
        STAMEN_TONER_LABELS='<a href="https://www.openstreetmap.org/copyright">ODbL</a>',
    )

    Vendors = enumeration('CARTODBPOSITRON', 'CARTODBPOSITRON_RETINA',
                          'STAMEN_TERRAIN', 'STAMEN_TERRAIN_RETINA', 'STAMEN_TONER',
                          'STAMEN_TONER_BACKGROUND', 'STAMEN_TONER_LABELS',
                          'OSM','WIKIMEDIA','ESRI_IMAGERY',
                          case_sensitive=True)

    def get_provider(self, provider_name):
        from bokeh.models import WMTSTileSource

        if isinstance(provider_name, WMTSTileSource):
            # This allows `get_provider(CARTODBPOSITRON)` to work
            return WMTSTileSource(url=provider_name.url, attribution=provider_name.attribution)

        if xyzservices and isinstance(provider_name, xyzservices.TileProvider):
            return WMTSTileSource(
                url=provider_name.build_url(scale_factor="@2x"),
                attribution=provider_name.html_attribution,
                min_zoom=provider_name.get("min_zoom", 0),
                max_zoom=provider_name.get("max_zoom", 30),
            )

        selected_provider = provider_name.upper()

        if selected_provider not in self.Vendors:
            raise ValueError('Unknown tile provider %s' % provider_name)

        url = self._SERVICE_URLS[selected_provider]
        if selected_provider.startswith('CARTO'):
            attribution = self._CARTO_ATTRIBUTION
        elif selected_provider.startswith('STAMEN'):
            attribution = self._STAMEN_ATTRIBUTION % self._STAMEN_ATTRIBUTION_URLS[selected_provider]
        elif selected_provider.startswith('OSM'):
            attribution = self._OSM_ATTRIBTION
        elif selected_provider.startswith('WIKIMEDIA'):
            attribution = self._WIKIMEDIA_ATTRIBUTION
        elif selected_provider.startswith('ESRI_IMAGERY'):
            attribution = self._ESRI_IMAGERY_ATTRIBUTION
        else:

            raise RuntimeError('Can not retrieve attribution for %s' % selected_provider)
        return WMTSTileSource(url=url, attribution=attribution)

    # Properties --------------------------------------------------------------

    CARTODBPOSITRON = Vendors.CARTODBPOSITRON
    CARTODBPOSITRON_RETINA = Vendors.CARTODBPOSITRON_RETINA
    STAMEN_TERRAIN = Vendors.STAMEN_TERRAIN
    STAMEN_TERRAIN_RETINA = Vendors.STAMEN_TERRAIN_RETINA
    STAMEN_TONER = Vendors.STAMEN_TONER
    STAMEN_TONER_BACKGROUND = Vendors.STAMEN_TONER_BACKGROUND
    STAMEN_TONER_LABELS = Vendors.STAMEN_TONER_LABELS
    OSM = Vendors.OSM
    WIKIMEDIA = Vendors.WIKIMEDIA
    ESRI_IMAGERY = Vendors.ESRI_IMAGERY
Esempio n. 27
0
'''
from __future__ import absolute_import

from collections import defaultdict
import warnings

import numpy as np

from bokeh.core.enums import enumeration
from bokeh.core.properties import Auto, Either, Enum, String, value
from bokeh.models import CategoricalAxis, DatetimeAxis, FactorRange, glyphs, Grid, HoverTool, Legend, LegendItem, LinearAxis, markers, Plot
from bokeh.plotting import DEFAULT_TOOLS
from bokeh.plotting.helpers import _process_tools_arg, _glyph_function, _process_active_tools
from bokeh.util._plot_arg_helpers import _convert_responsive

Scale = enumeration('linear', 'categorical', 'datetime')

class ChartDefaults(object):
    def apply(self, chart):
        """Apply this defaults to a chart."""

        if not isinstance(chart, Chart):
            raise ValueError(
                "ChartsDefaults should be only used on Chart objects but it's being used on %s instead." % chart
            )

        all_props = set(chart.properties_with_values(include_defaults=True))
        dirty_props = set(chart.properties_with_values(include_defaults=False))
        for k in list(all_props.difference(dirty_props)) + \
            list(chart.__deprecated_attributes__):
            if k == 'tools':