Пример #1
0
    def __init__(self,
                 blank_labels=options.get_option('chart.blank_labels'),
                 layout='slide_50%'):
        """Create a Radar Chart instance.

        Note:
            Radar charts plot each vertex in counter-clockwise order starting
            from the top.

        Args:
            blank_labels (bool): When true removes the title,
                subtitle, axes, and source labels from the chart.
                Default False.
            layout (str): Change size & aspect ratio of the chart for
                fitting into slides.
                - 'slide_100%'
                - 'slide_75%'
                - 'slide_50%' (Suggested for Radar Charts)
                - 'slide_25%'
        """
        # Validate axis type input
        valid_axis_types = ['linear', 'log']
        self._axis_type = 'linear'
        self._x_axis_type, self._y_axis_type = self._axis_type, self._axis_type
        if self._axis_type not in valid_axis_types:
            raise ValueError('axis_type must be one of {options}'.format(
                options=valid_axis_types))
        self._blank_labels = options._get_value(blank_labels)
        self.style = Style(self, layout)
        self.figure = self._initialize_figure(self._axis_type, self._axis_type)
        self.style._apply_settings('chart')
        self.callout = Callout(self)
        self.axes = BaseAxes._get_axis_class(self._axis_type,
                                             self._axis_type)(self)
        self.plot = PlotRadar(self)
        self._source = self._add_source_to_figure()
        self._subtitle_glyph = self._add_subtitle_to_figure()
        self.figure.toolbar.logo = None  # Remove bokeh logo from toolbar.
        # Reverse the order of vertical legends. Used with stacked plot types
        # to ensure that the stack order is consistent with the legend order.
        self._reverse_vertical_legend = False
        # Logos disabled for now.
        # self.logo = Logo(self)
        # Set default for title
        title = """ch.set_title('Takeaway')"""
        if self._blank_labels:
            title = ""
        self.set_title(title)
Пример #2
0
    def __init__(self,
                 blank_labels=options.get_option('chart.blank_labels'),
                 layout='slide_100%',
                 x_axis_type='linear',
                 y_axis_type='linear',
                 second_y_axis=False):
        """Create a chart instance.

        Args:
            blank_labels (bool): When true removes the title,
                subtitle, axes, and source labels from the chart.
                Default False.
            layout (str): Change size & aspect ratio of the chart for
                fitting into slides.
                - 'slide_100%'
                - 'slide_75%'
                - 'slide_50%'
                - 'slide_25%'
            x_axis_type (enum, str): Type of data plotted on the X-axis.
                - 'linear':
                - 'log':
                - 'datetime': Use for datetime formatted data.
                - 'categorical':
                - 'density'

            y_axis_type (enum, str): Type of data plotted on the Y-axis.
                - 'linear':
                - 'log':
                - 'categorical':
                - 'density'
        Note:
            Combination of x_axis_type and y_axis_type will determine the
            plotting methods available.
        """
        # Validate axis type input
        valid_x_axis_types = [
            'linear', 'log', 'datetime', 'categorical', 'density'
        ]
        valid_y_axis_types = ['linear', 'log', 'categorical', 'density']
        valid_second_y_axis_types = ['linear', 'log']
        if x_axis_type not in valid_x_axis_types:
            raise ValueError('x_axis_type must be one of {options}'.format(
                options=valid_x_axis_types))
        if y_axis_type not in valid_y_axis_types:
            raise ValueError('y_axis_type must be one of {options}'.format(
                options=valid_y_axis_types))

        self._second_y_axis_type = None
        if second_y_axis:
            self._second_y_axis_type = y_axis_type
            if self._second_y_axis_type not in valid_second_y_axis_types:
                raise ValueError('second_y_axis can only be used when \
                    y_axis_type is one of {options}'.format(
                    options=valid_second_y_axis_types))

        self._x_axis_type, self._y_axis_type = x_axis_type, y_axis_type

        self._blank_labels = options._get_value(blank_labels)
        self.style = Style(self, layout)
        self.figure = self._initialize_figure(self._x_axis_type,
                                              self._y_axis_type)
        self.style._apply_settings('chart')
        self.plot = BasePlot._get_plot_class(self._x_axis_type,
                                             self._y_axis_type)(self)
        self.callout = Callout(self)
        self.axes = BaseAxes._get_axis_class(self._x_axis_type,
                                             self._y_axis_type)(self)

        if self._second_y_axis_type in valid_second_y_axis_types:
            self.second_axis = SecondAxis()
            self.second_axis.axes = SecondYNumericalAxis(self)
            self.second_axis.plot = BasePlot._get_plot_class(
                self._x_axis_type,
                self._second_y_axis_type)(self,
                                          self.second_axis.axes._y_range_name)
        self._source = self._add_source_to_figure()
        self._subtitle_glyph = self._add_subtitle_to_figure()
        self.figure.toolbar.logo = None  # Remove bokeh logo from toolbar.
        # Reverse the order of vertical legends. Used with stacked plot types
        # to ensure that the stack order is consistent with the legend order.
        self._reverse_vertical_legend = False
        # Logos disabled for now.
        # self.logo = Logo(self)
        # Set default for title
        title = """ch.set_title('Takeaway')"""
        if self._blank_labels:
            title = ""
        self.set_title(title)