Exemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        # pop tools as it is also a property that doesn't match the argument
        # supported types
        tools = kwargs.pop('tools', None)
        for name in ['xgrid', 'ygrid', 'legend']:
            if name in kwargs:
                kwargs["_" + name] = kwargs[name]
                del kwargs[name]

        if 'responsive' in kwargs and 'sizing_mode' in kwargs:
            raise ValueError(
                "Chart initialized with both 'responsive' and 'sizing_mode' supplied, supply only one"
            )
        if 'responsive' in kwargs:
            kwargs['sizing_mode'] = _convert_responsive(kwargs['responsive'])
            del kwargs['responsive']

        self._active_drag = kwargs.pop('active_drag', 'auto')
        self._active_inspect = kwargs.pop('active_inspect', 'auto')
        self._active_scroll = kwargs.pop('active_scroll', 'auto')
        self._active_tap = kwargs.pop('active_tap', 'auto')

        title_text = kwargs.pop("title", None)

        super(Chart, self).__init__(*args, **kwargs)

        self.title.text = title_text

        defaults.apply(self)

        if tools is not None:
            self._tools = tools

        # TODO (fpliger): we do this to still support deprecated document but
        #                 should go away when __deprecated_attributes__ is empty
        for k in self.__deprecated_attributes__:
            if k in kwargs:
                setattr(self, k, kwargs[k])

        self._glyphs = []
        self._built = False

        self._builders = []
        self._renderer_map = []
        self._ranges = defaultdict(list)
        self._labels = defaultdict(list)
        self._scales = defaultdict(list)
        self._tooltips = []

        if hasattr(self, '_tools'):
            self.create_tools(self._tools, self._active_drag,
                              self._active_inspect, self._active_scroll,
                              self._active_tap)
Exemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        # pop tools as it is also a property that doesn't match the argument
        # supported types
        tools = kwargs.pop('tools', None)
        for name in ['xgrid', 'ygrid', 'legend']:
            if name in kwargs:
                kwargs["_" + name] = kwargs[name]
                del kwargs[name]

        if 'responsive' in kwargs and 'sizing_mode' in kwargs:
            raise ValueError("Chart initialized with both 'responsive' and 'sizing_mode' supplied, supply only one")
        if 'responsive' in kwargs:
            kwargs['sizing_mode'] = _convert_responsive(kwargs['responsive'])
            del kwargs['responsive']

        self._active_drag = kwargs.pop('active_drag', 'auto')
        self._active_inspect = kwargs.pop('active_inspect', 'auto')
        self._active_scroll = kwargs.pop('active_scroll', 'auto')
        self._active_tap = kwargs.pop('active_tap', 'auto')

        title_text = kwargs.pop("title", None)

        super(Chart, self).__init__(*args, **kwargs)

        self.title.text = title_text

        defaults.apply(self)

        if tools is not None:
            self._tools = tools

        # TODO (fpliger): we do this to still support deprecated document but
        #                 should go away when __deprecated_attributes__ is empty
        for k in self.__deprecated_attributes__:
            if k in kwargs:
                setattr(self, k, kwargs[k])

        self._glyphs = []
        self._built = False

        self._builders = []
        self._renderer_map = []
        self._ranges = defaultdict(list)
        self._labels = defaultdict(list)
        self._scales = defaultdict(list)
        self._tooltips = []

        if hasattr(self, '_tools'):
            self.create_tools(self._tools, self._active_drag, self._active_inspect, self._active_scroll, self._active_tap)
Exemplo n.º 3
0
def test__convert_responsive_false():
    assert _convert_responsive(False) == 'fixed'
Exemplo n.º 4
0
def test__convert_responsive_true():
    assert _convert_responsive(True) == 'scale_width'
Exemplo n.º 5
0
def test__convert_responsive_error():
    with pytest.raises(ValueError):
        _convert_responsive("foo")
def test__convert_responsive_true():
    assert _convert_responsive(True) == 'scale_width'
def test__convert_responsive_error():
    with pytest.raises(ValueError):
        _convert_responsive("foo")
def test__convert_responsive_false():
    assert _convert_responsive(False) == 'fixed'