airflow/_vendor/nvd3/NVD3Chart.py
def add_serie(self, y, x, name=None, extra=None, **kwargs):
        """
        add serie - Series are list of data that will be plotted
        y {1, 2, 3, 4, 5} / x {1, 2, 3, 4, 5}

        **Attributes**:

            * ``name`` - set Serie name
            * ``x`` - x-axis data
            * ``y`` - y-axis data

            kwargs:

            * ``shape`` - for scatterChart, you can set different shapes
                          (circle, triangle etc...)
            * ``size`` - for scatterChart, you can set size of different shapes
            * ``type`` - for multiChart, type should be bar
            * ``bar`` - to display bars in Chart
            * ``color_list`` - define list of colors which will be
                               used by pieChart
            * ``color`` - set axis color
            * ``disabled`` -

            extra:

            * ``tooltip`` - set tooltip flag
            * ``date_format`` - set date_format for tooltip if x-axis is in
              date format

        """
        if not name:
            name = "Serie %d" % (self.serie_no)

        # For scatterChart shape & size fields are added in serie
        if 'shape' in kwargs or 'size' in kwargs:
            csize = kwargs.get('size', 1)
            cshape = kwargs.get('shape', 'circle')

            serie = [{
                'x': x[i],
                'y': j,
                'shape': cshape,
                'size': csize[i] if isinstance(csize, list) else csize
            } for i, j in enumerate(y)]
        else:
            if self.model == 'pieChart':
                serie = [{'label': x[i], 'value': y} for i, y in enumerate(y)]
            else:
                serie = [{'x': x[i], 'y': y} for i, y in enumerate(y)]

        data_keyvalue = {'values': serie, 'key': name}

        # multiChart
        # Histogram type='bar' for the series
        if 'type' in kwargs and kwargs['type']:
            data_keyvalue['type'] = kwargs['type']

        # Define on which Y axis the serie is related
        # a chart can have 2 Y axis, left and right, by default only one Y Axis is used
        if 'yaxis' in kwargs and kwargs['yaxis']:
            data_keyvalue['yAxis'] = kwargs['yaxis']
        else:
            if self.model != 'pieChart':
                data_keyvalue['yAxis'] = '1'

        if 'bar' in kwargs and kwargs['bar']:
            data_keyvalue['bar'] = 'true'

        if 'disabled' in kwargs and kwargs['disabled']:
            data_keyvalue['disabled'] = 'true'

        if 'color' in kwargs and kwargs['color']:
            data_keyvalue['color'] = kwargs['color']

        if extra:
            if self.model == 'pieChart':
                if 'color_list' in extra and extra['color_list']:
                    self.color_list = extra['color_list']

            if extra.get('date_format'):
                self.charttooltip_dateformat = extra['date_format']

            if extra.get('tooltip'):
                self.custom_tooltip_flag = True

                if self.model != 'pieChart':
                    _start = extra['tooltip']['y_start']
                    _end = extra['tooltip']['y_end']
                    _start = ("'" + str(_start) + "' + ") if _start else ''
                    _end = (" + '" + str(_end) + "'") if _end else ''

                    if self.model == 'linePlusBarChart':
                        if self.tooltip_condition_string:
                            self.tooltip_condition_string += stab(5)
                        self.tooltip_condition_string += stab(0) + "if(key.indexOf('" + name + "') > -1 ){\n" +\
                            stab(6) + "var y = " + _start + " String(graph.point.y) " + _end + ";\n" +\
                            stab(5) + "}\n"
                    elif self.model == 'cumulativeLineChart':
                        self.tooltip_condition_string += stab(0) + "if(key == '" + name + "'){\n" +\
                            stab(6) + "var y = " + _start + " String(e) " + _end + ";\n" +\
                            stab(5) + "}\n"
                    else:
                        self.tooltip_condition_string += stab(5) + "if(key == '" + name + "'){\n" +\
                            stab(6) + "var y = " + _start + " String(graph.point.y) " + _end + ";\n" +\
                            stab(5) + "}\n"

                if self.model == 'pieChart':
                    _start = extra['tooltip']['y_start']
                    _end = extra['tooltip']['y_end']
                    _start = ("'" + str(_start) + "' + ") if _start else ''
                    _end = (" + '" + str(_end) + "'") if _end else ''
                    self.tooltip_condition_string += "var y = " + _start + " String(y) " + _end + ";\n"

        # Increment series counter & append
        self.serie_no += 1
        self.series.append(data_keyvalue)
def add_serie(self, y, x, name=None, extra=None, **kwargs):
        """
        add serie - Series are list of data that will be plotted
        y {1, 2, 3, 4, 5} / x {1, 2, 3, 4, 5}

        **Attributes**:

            * ``name`` - set Serie name
            * ``x`` - x-axis data
            * ``y`` - y-axis data

            kwargs:

            * ``shape`` - for scatterChart, you can set different shapes
                          (circle, triangle etc...)
            * ``size`` - for scatterChart, you can set size of different shapes
            * ``type`` - for multiChart, type should be bar
            * ``bar`` - to display bars in Chart
            * ``color_list`` - define list of colors which will be
                               used by pieChart
            * ``color`` - set axis color
            * ``disabled`` -

            extra:

            * ``tooltip`` - set tooltip flag
            * ``date_format`` - set date_format for tooltip if x-axis is in
              date format

        """
        if not name:
            name = "Serie %d" % (self.serie_no)

        # For scatterChart shape & size fields are added in serie
        if 'shape' in kwargs or 'size' in kwargs:
            csize = kwargs.get('size', 1)
            cshape = kwargs.get('shape', 'circle')

            serie = [{
                'x': x[i],
                'y': j,
                'shape': cshape,
                'size': csize[i] if isinstance(csize, list) else csize
            } for i, j in enumerate(y)]
        else:
            if self.model == 'pieChart':
                serie = [{'label': x[i], 'value': y} for i, y in enumerate(y)]
            else:
                serie = [{'x': x[i], 'y': y} for i, y in enumerate(y)]

        data_keyvalue = {'values': serie, 'key': name}

        # multiChart
        # Histogram type='bar' for the series
        if 'type' in kwargs and kwargs['type']:
            data_keyvalue['type'] = kwargs['type']

        # Define on which Y axis the serie is related
        # a chart can have 2 Y axis, left and right, by default only one Y Axis is used
        if 'yaxis' in kwargs and kwargs['yaxis']:
            data_keyvalue['yAxis'] = kwargs['yaxis']
        else:
            if self.model != 'pieChart':
                data_keyvalue['yAxis'] = '1'

        if 'bar' in kwargs and kwargs['bar']:
            data_keyvalue['bar'] = 'true'

        if 'disabled' in kwargs and kwargs['disabled']:
            data_keyvalue['disabled'] = 'true'

        if 'color' in kwargs and kwargs['color']:
            data_keyvalue['color'] = kwargs['color']

        if extra:
            if self.model == 'pieChart':
                if 'color_list' in extra and extra['color_list']:
                    self.color_list = extra['color_list']

            if extra.get('date_format'):
                self.charttooltip_dateformat = extra['date_format']

            if extra.get('tooltip'):
                self.custom_tooltip_flag = True

                if self.model != 'pieChart':
                    _start = extra['tooltip']['y_start']
                    _end = extra['tooltip']['y_end']
                    _start = ("'" + str(_start) + "' + ") if _start else ''
                    _end = (" + '" + str(_end) + "'") if _end else ''

                    if self.model == 'linePlusBarChart':
                        if self.tooltip_condition_string:
                            self.tooltip_condition_string += stab(5)
                        self.tooltip_condition_string += stab(0) + "if(key.indexOf('" + name + "') > -1 ){\n" +\
                            stab(6) + "var y = " + _start + " String(graph.point.y) " + _end + ";\n" +\
                            stab(5) + "}\n"
                    elif self.model == 'cumulativeLineChart':
                        self.tooltip_condition_string += stab(0) + "if(key == '" + name + "'){\n" +\
                            stab(6) + "var y = " + _start + " String(e) " + _end + ";\n" +\
                            stab(5) + "}\n"
                    else:
                        self.tooltip_condition_string += stab(5) + "if(key == '" + name + "'){\n" +\
                            stab(6) + "var y = " + _start + " String(graph.point.y) " + _end + ";\n" +\
                            stab(5) + "}\n"

                if self.model == 'pieChart':
                    _start = extra['tooltip']['y_start']
                    _end = extra['tooltip']['y_end']
                    _start = ("'" + str(_start) + "' + ") if _start else ''
                    _end = (" + '" + str(_end) + "'") if _end else ''
                    self.tooltip_condition_string += "var y = " + _start + " String(y) " + _end + ";\n"

        # Increment series counter & append
        self.serie_no += 1
        self.series.append(data_keyvalue)
add serie - Series are list of data that will be plotted
        y {1, 2, 3, 4, 5} / x {1, 2, 3, 4, 5}

        **Attributes**:

            * ``name`` - set Serie name
            * ``x`` - x-axis data
            * ``y`` - y-axis data

            kwargs:

            * ``shape`` - for scatterChart, you can set different shapes
                          (circle, triangle etc...)
            * ``size`` - for scatterChart, you can set size of different shapes
            * ``type`` - for multiChart, type should be bar
            * ``bar`` - to display bars in Chart
            * ``color_list`` - define list of colors which will be
                               used by pieChart
            * ``color`` - set axis color
            * ``disabled`` -

            extra:

            * ``tooltip`` - set tooltip flag
            * ``date_format`` - set date_format for tooltip if x-axis is in
              date format