• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.decorate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pygal.util.decorate函数的典型用法代码示例。如果您正苦于以下问题:Python decorate函数的具体用法?Python decorate怎么用?Python decorate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了decorate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _plot

    def _plot(self):
        map = etree.fromstring(MAP)
        map.set('width', str(self.view.width))
        map.set('height', str(self.view.height))

        for i, serie in enumerate(self.series):
            safe_vals = list(filter(
                lambda x: x is not None, cut(serie.values, 1)))
            if not safe_vals:
                continue
            min_ = min(safe_vals)
            max_ = max(safe_vals)
            for j, (country_code, value) in enumerate(serie.values):
                if value is None:
                    continue
                if max_ == min_:
                    ratio = 1
                else:
                    ratio = .3 + .7 * (value - min_) / (max_ - min_)

                try:
                    country = map.find('.//*[@id="%s"]' % country_code)
                except SyntaxError:
                    # Python 2.6 (you'd better install lxml)
                    country = None
                    for e in map:
                        if e.attrib.get('id', '') == country_code:
                            country = e

                if country is None:
                    continue
                cls = country.get('class', '').split(' ')
                cls.append('color-%d' % i)
                country.set('class', ' '.join(cls))
                country.set(
                    'style', 'fill-opacity: %f' % (
                        ratio))

                metadata = serie.metadata.get(j)
                if metadata:
                    node = decorate(self.svg, country, metadata)
                    if node != country:
                        country.remove(node)
                        index = list(map).index(country)
                        map.remove(country)
                        node.append(country)
                        map.insert(index, node)

                last_node = len(country) > 0 and country[-1]
                if last_node is not None and last_node.tag == 'title':
                    title_node = last_node
                    text = title_node.text + '\n'
                else:
                    title_node = self.svg.node(country, 'title')
                    text = ''
                title_node.text = text + '[%s] %s: %s' % (
                    serie.title,
                    self.country_names[country_code], self._format(value))

        self.nodes['plot'].append(map)
开发者ID:AlanRun,项目名称:UiAutoTest,代码行数:60,代码来源:worldmap.py


示例2: dot

    def dot(self, serie, r_max):
        """Draw a dot line"""
        serie_node = self.svg.serie(serie)
        view_values = list(map(self.view, serie.points))
        for i, value in safe_enumerate(serie.values):
            x, y = view_values[i]

            if self.logarithmic:
                log10min = log10(self._min) - 1
                log10max = log10(self._max or 1)

                if value != 0:
                    size = r_max * (
                        (log10(abs(value)) - log10min) /
                        (log10max - log10min)
                    )
                else:
                    size = 0
            else:
                size = r_max * (abs(value) / (self._max or 1))

            metadata = serie.metadata.get(i)
            dots = decorate(
                self.svg,
                self.svg.node(serie_node['plot'], class_="dots"),
                metadata)
            alter(self.svg.node(
                dots, 'circle',
                cx=x, cy=y, r=size,
                class_='dot reactive tooltip-trigger' + (
                    ' negative' if value < 0 else '')), metadata)

            value = self._format(value)
            self._tooltip_data(dots, value, x, y, classes='centered')
            self._static_value(serie_node, value, x, y)
开发者ID:anasrazeq,项目名称:pygal,代码行数:35,代码来源:dot.py


示例3: bar

    def bar(self, serie, rescale=False):
        """Draw a bar graph for a serie"""
        serie_node = self.svg.serie(serie)
        bars = self.svg.node(serie_node['plot'], class_="bars")
        if rescale and self.secondary_series:
            points = self._rescale(serie.points)
        else:
            points = serie.points
        total = sum(list(filter(None, serie.values)))
        for i, (x, y) in enumerate(points):
            if None in (x, y) or (self.logarithmic and y <= 0):
                continue
            metadata = serie.metadata.get(i)
            val = self._format(serie, i)

            bar = decorate(
                self.svg,
                self.svg.node(bars, class_='bar'),
                metadata)

            x_, y_, width, height = self._bar(
                serie, bar, x, y, i, self.zero, secondary=rescale)

            self._confidence_interval(
                serie_node['overlay'], x_ + width / 2, y_, serie.values[i],
                metadata)

            self._tooltip_and_print_values(
                serie_node, serie, bar, i, val, metadata,
                x_, y_, width, height, total)
开发者ID:ConnorMooreLUC,项目名称:pygal,代码行数:30,代码来源:bar.py


示例4: needle

    def needle(self, serie_node, serie,):
        thickness = .05
        for i, value in enumerate(serie.values):
            if not value:
                continue
            theta = self.arc_pos(value)
            fmt = lambda x: '%f %f' % x
            value = self._format(serie.values[i])
            metadata = serie.metadata.get(i)
            gauges = decorate(
                self.svg,
                self.svg.node(serie_node['plot'], class_="dots"),
                metadata)

            self.svg.node(
                gauges, 'polygon', points=' '.join([
                    fmt(self.view((0, 0))),
                    fmt(self.view((.75, theta + thickness))),
                    fmt(self.view((.8, theta))),
                    fmt(self.view((.75, theta - thickness)))]),
                class_='line reactive tooltip-trigger')

            x, y = self.view((.75, theta))
            self._tooltip_data(gauges, value, x, y)
            self._static_value(serie_node, value, x, y)
开发者ID:Zanarh,项目名称:pygal,代码行数:25,代码来源:gauge.py


示例5: bar

    def bar(self, serie_node, serie, index, rescale=False):
        """Draw a bar graph for a serie"""
        bars = self.svg.node(serie_node["plot"], class_="bars")
        if rescale and self.secondary_series:
            points = [
                (x, self._scale_diff + (y - self._scale_min_2nd) * self._scale)
                for x, y in serie.points
                if y is not None
            ]
        else:
            points = serie.points

        for i, (x, y) in enumerate(points):
            if None in (x, y) or (self.logarithmic and y <= 0):
                continue
            metadata = serie.metadata.get(i)

            bar = decorate(self.svg, self.svg.node(bars, class_="bar"), metadata)
            val = self._format(serie.values[i])

            x_center, y_center = self._bar(
                bar, x, y, index, i, self.zero, secondary=rescale, rounded=serie.rounded_bars
            )
            self._tooltip_data(bar, val, x_center, y_center, classes="centered")
            self._static_value(serie_node, val, x_center, y_center)
开发者ID:Cortana-,项目名称:pygal,代码行数:25,代码来源:bar.py


示例6: line

    def line(self, serie_node, serie):
        """Draw the line serie"""
        view_values = map(self.view, serie.points)
        if self.show_dots:
            for i, (x, y) in enumerate(view_values):
                if None in (x, y):
                    continue

                metadata = serie.metadata.get(i)
                classes = []
                if x > self.view.width / 2:
                    classes.append("left")
                if y > self.view.height / 2:
                    classes.append("top")
                classes = " ".join(classes)

                dots = decorate(self.svg, self.svg.node(serie_node["overlay"], class_="dots"), metadata)
                val = self._get_value(serie.points, i)
                self.svg.node(dots, "circle", cx=x, cy=y, r=2.5, class_="dot reactive tooltip-trigger")
                self._tooltip_data(dots, val, x, y)
                self._static_value(serie_node, val, x + self.value_font_size, y + self.value_font_size)

        if self.stroke:
            if self.interpolate:
                view_values = map(self.view, serie.interpolated)
            if self.fill:
                view_values = self._fill(view_values)
            self.svg.line(
                serie_node["plot"],
                view_values,
                close=self._self_close,
                class_="line reactive" + (" nofill" if not self.fill else ""),
            )
开发者ID:ebolwidt,项目名称:pygal,代码行数:33,代码来源:line.py


示例7: bar

    def bar(self, serie, rescale=False):
        """Draw a bar graph for a serie"""
        serie_node = self.svg.serie(serie)
        bars = self.svg.node(serie_node['plot'], class_="bars")
        if rescale and self.secondary_series:
            points = self._rescale(serie.points)
        else:
            points = serie.points

        for i, (x, y) in enumerate(points):
            if None in (x, y) or (self.logarithmic and y <= 0):
                continue
            metadata = serie.metadata.get(i)

            bar = decorate(
                self.svg,
                self.svg.node(bars, class_='bar'),
                metadata)
            val = self._format(serie.values[i])

            x_center, y_center = self._bar(
                serie, bar, x, y, self.zero, secondary=rescale)
            self._tooltip_data(
                bar, val, x_center, y_center, classes="centered")
            self._static_value(serie_node, val, x_center, y_center)
开发者ID:dzejar,项目名称:pygal,代码行数:25,代码来源:bar.py


示例8: _rect

    def _rect(self, serie, serie_node, rects, val, x, y, w, h, i):
        rx, ry = self.view((x, y))
        rw, rh = self.view((x + w, y + h))
        rw -= rx
        rh -= ry

        metadata = serie.metadata.get(i)
        value = self._format(val)

        rect = decorate(
            self.svg,
            self.svg.node(rects, class_="rect"),
            metadata)

        self.svg.node(rect, 'rect',
                      x=rx,
                      y=ry,
                      width=rw,
                      height=rh,
                      class_='rect reactive tooltip-trigger')

        self._tooltip_data(rect, value,
                           rx + rw / 2,
                           ry + rh / 2,
                           classes='centered')
        self._static_value(serie_node, value,
                           rx + rw / 2,
                           ry + rh / 2)
开发者ID:Mengxinqian,项目名称:pygal,代码行数:28,代码来源:treemap.py


示例9: funnel

    def funnel(self, serie):
        """Draw a funnel slice"""
        serie_node = self.svg.serie(serie)
        fmt = lambda x: '%f %f' % x
        for i, poly in enumerate(serie.points):
            metadata = serie.metadata.get(i)
            val = self._format(serie, i)

            funnels = decorate(
                self.svg,
                self.svg.node(serie_node['plot'], class_="funnels"),
                metadata)

            alter(self.svg.node(
                funnels, 'polygon',
                points=' '.join(map(fmt, map(self.view, poly))),
                class_='funnel reactive tooltip-trigger'), metadata)

            # Poly center from label
            x, y = self.view((
                self._center(self._x_pos[serie.index]),
                sum([point[1] for point in poly]) / len(poly)))
            self._tooltip_data(
                funnels, val, x, y, 'centered',
                self._get_x_label(serie.index))
            self._static_value(serie_node, val, x, y, metadata)
开发者ID:Frankie-666,项目名称:pygal,代码行数:26,代码来源:funnel.py


示例10: needle

    def needle(self, serie):
        serie_node = self.svg.serie(serie)
        for i, theta in enumerate(serie.values):
            if theta is None:
                continue
            fmt = lambda x: '%f %f' % x
            value = self._format(serie.values[i])
            metadata = serie.metadata.get(i)
            gauges = decorate(
                self.svg,
                self.svg.node(serie_node['plot'], class_="dots"),
                metadata)

            alter(self.svg.node(
                gauges, 'polygon', points=' '.join([
                    fmt(self.view((0, 0))),
                    fmt(self.view((.75, theta))),
                    fmt(self.view((.8, theta))),
                    fmt(self.view((.75, theta)))]),
                class_='line reactive tooltip-trigger'),
                  metadata)

            x, y = self.view((.75, theta))
            self._tooltip_data(gauges, value, x, y)
            self._static_value(serie_node, value, x, y)
开发者ID:anasrazeq,项目名称:pygal,代码行数:25,代码来源:gauge.py


示例11: bar

    def bar(self, serie, rescale=False):
        """Draw a bar graph for a serie"""
        serie_node = self.svg.serie(serie)
        bars = self.svg.node(serie_node['plot'], class_="bars")
        if rescale and self.secondary_series:
            points = self._rescale(serie.points)
        else:
            points = serie.points

        for i, (x, y) in enumerate(points):
            if None in (x, y) or (self.logarithmic and y <= 0):
                continue
            metadata = serie.metadata.get(i)
            val = self._format(serie.values[i])

            bar = decorate(
                self.svg,
                self.svg.node(bars, class_='bar'),
                metadata)

            bounds = self._bar(
                serie, bar, x, y, i, self.zero, secondary=rescale)

            self._tooltip_and_print_values(
                serie_node, serie, bar, i, val, metadata, *bounds)
开发者ID:pebermyntelars,项目名称:pygal,代码行数:25,代码来源:bar.py


示例12: gaugify

    def gaugify(self, serie, squares, sq_dimensions, current_square):
        serie_node = self.svg.serie(serie)
        if self.half_pie:
            start_angle = 3*pi/2
            center = (
                (current_square[1]*sq_dimensions[0]) - (sq_dimensions[0] / 2.),
                (current_square[0]*sq_dimensions[1]) - (sq_dimensions[1] / 4))
            end_angle = pi / 2
        else:
            start_angle = 0
            center = (
                (current_square[1]*sq_dimensions[0]) - (sq_dimensions[0] / 2.),
                (current_square[0]*sq_dimensions[1]) - (sq_dimensions[1] / 2.))
            end_angle = 2 * pi

        max_value = serie.metadata.get(0, {}).get('max_value', 100)
        radius = min([sq_dimensions[0]/2, sq_dimensions[1]/2]) * .9
        small_radius = radius * serie.inner_radius

        self.svg.gauge_background(
            serie_node, start_angle, center, radius, small_radius, end_angle,
            self.half_pie, self._serie_format(serie, max_value))

        sum_ = 0
        for i, value in enumerate(serie.values):
            if value is None:
                continue
            ratio = min(value, max_value) / max_value
            if self.half_pie:
                angle = 2 * pi * ratio / 2
            else:
                angle = 2 * pi * ratio

            val = self._format(serie, i)
            metadata = serie.metadata.get(i)

            gauge_ = decorate(
                self.svg,
                self.svg.node(serie_node['plot'], class_="gauge"),
                metadata)

            alter(
                self.svg.solid_gauge(
                    serie_node, gauge_, radius, small_radius,
                    angle, start_angle, center, val, i, metadata,
                    self.half_pie, end_angle,
                    self._serie_format(serie, max_value)),
                metadata)
            start_angle += angle
            sum_ += value

        x, y = center
        self.svg.node(
            serie_node['text_overlay'], 'text',
            class_='value gauge-sum',
            x=x,
            y=y + self.style.value_font_size / 3,
            attrib={'text-anchor': 'middle'}
        ).text = self._serie_format(serie, sum_)
开发者ID:aroraumang,项目名称:pygal,代码行数:59,代码来源:solidgauge.py


示例13: line

    def line(self, serie, rescale=False):
        """Draw the line serie"""
        serie_node = self.svg.serie(serie)
        if rescale and self.secondary_series:
            points = [
                (x, self._scale_diff + (y - self._scale_min_2nd) * self._scale)
                for x, y in serie.points if y is not None]
        else:
            points = serie.points
        view_values = list(map(self.view, points))
        if serie.show_dots:
            for i, (x, y) in enumerate(view_values):
                if None in (x, y):
                    continue
                if (serie.show_only_major_dots and
                        self.x_labels and i < len(self.x_labels) and
                        self.x_labels[i] not in self._x_major_labels):
                    continue

                metadata = serie.metadata.get(i)
                classes = []
                if x > self.view.width / 2:
                    classes.append('left')
                if y > self.view.height / 2:
                    classes.append('top')
                classes = ' '.join(classes)
                dots = decorate(
                    self.svg,
                    self.svg.node(serie_node['overlay'], class_="dots"),
                    metadata)
                val = self._get_value(serie.points, i)
                self.svg.node(dots, 'circle', cx=x, cy=y, r=serie.dots_size,
                              class_='dot reactive tooltip-trigger')
                self._tooltip_data(
                    dots, val, x, y)
                self._static_value(
                    serie_node, val,
                    x + self.value_font_size,
                    y + self.value_font_size)

        line_view_values = [[]]
        for view_value in view_values:
            if None in view_value:
                line_view_values.append([])
            else:
                line_view_values[-1].append(view_value)

        if serie.stroke:
            if self.interpolate:
                view_values = list(map(self.view, serie.interpolated))
            if serie.fill:
                view_values = self._fill(view_values)
            for row in line_view_values:
                if not row:
                    continue
                self.svg.line(
                    serie_node['plot'], row, close=self._self_close,
                    class_='line reactive' + (
                        ' nofill' if not serie.fill else ''))
开发者ID:Volshebnyi,项目名称:pygal,代码行数:59,代码来源:line.py


示例14: _plot

    def _plot(self):
        map = etree.fromstring(self.svg_map)
        map.set('width', str(self.view.width))
        map.set('height', str(self.view.height))

        for i, serie in enumerate(self.series):
            safe_vals = list(filter(
                lambda x: x is not None, cut(serie.values, 1)))
            if not safe_vals:
                continue
            min_ = min(safe_vals)
            max_ = max(safe_vals)
            for j, (area_code, value) in enumerate(serie.values):
                if isinstance(area_code, Number):
                    area_code = '%2d' % area_code
                if value is None:
                    continue
                if max_ == min_:
                    ratio = 1
                else:
                    ratio = .3 + .7 * (value - min_) / (max_ - min_)
                areae = map.findall(
                    ".//*[@class='%s%s %s map-element']" % (
                        self.area_prefix, area_code,
                        self.kind))

                if not areae:
                    continue
                for area in areae:
                    cls = area.get('class', '').split(' ')
                    cls.append('color-%d' % i)
                    area.set('class', ' '.join(cls))
                    area.set('style', 'fill-opacity: %f' % (ratio))

                    metadata = serie.metadata.get(j)
                    if metadata:
                        node = decorate(self.svg, area, metadata)
                        if node != area:
                            area.remove(node)
                            for g in map:
                                if area not in g:
                                    continue
                                index = list(g).index(area)
                                g.remove(area)
                                node.append(area)
                                g.insert(index, node)

                    last_node = len(area) > 0 and area[-1]
                    if last_node is not None and last_node.tag == 'title':
                        title_node = last_node
                        text = title_node.text + '\n'
                    else:
                        title_node = self.svg.node(area, 'title')
                        text = ''
                    title_node.text = text + '[%s] %s: %s' % (
                        serie.title,
                        self.area_names[area_code], self._format(value))

        self.nodes['plot'].append(map)
开发者ID:amit1102004,项目名称:pygal,代码行数:59,代码来源:frenchmap.py


示例15: _plot

    def _plot(self):
        map = etree.fromstring(self.svg_map)
        map.set("width", str(self.view.width))
        map.set("height", str(self.view.height))

        for i, serie in enumerate(self.series):
            safe_vals = list(filter(lambda x: x is not None, cut(serie.values, 1)))
            if not safe_vals:
                continue
            min_ = min(safe_vals)
            max_ = max(safe_vals)
            for j, (area_code, value) in enumerate(serie.values):
                if isinstance(area_code, Number):
                    area_code = "%2d" % area_code
                if value is None:
                    continue
                if max_ == min_:
                    ratio = 1
                else:
                    ratio = 0.3 + 0.7 * (value - min_) / (max_ - min_)
                areae = map.xpath(
                    "//*[contains(concat(' ', normalize-space(@class), ' '),"
                    " ' %s%s ')]" % (self.area_prefix, area_code)
                )

                if not areae:
                    continue
                for area in areae:
                    cls = area.get("class", "").split(" ")
                    cls.append("color-%d" % i)
                    area.set("class", " ".join(cls))
                    area.set("style", "fill-opacity: %f" % (ratio))

                    metadata = serie.metadata.get(j)
                    if metadata:
                        parent = area.getparent()
                        node = decorate(self.svg, area, metadata)
                        if node != area:
                            area.remove(node)
                            index = parent.index(area)
                            parent.remove(area)
                            node.append(area)
                            parent.insert(index, node)

                    last_node = len(area) > 0 and area[-1]
                    if last_node is not None and last_node.tag == "title":
                        title_node = last_node
                        text = title_node.text + "\n"
                    else:
                        title_node = self.svg.node(area, "title")
                        text = ""
                    title_node.text = text + "[%s] %s: %s" % (
                        serie.title,
                        self.area_names[area_code],
                        self._format(value),
                    )

        self.nodes["plot"].append(map)
开发者ID:philt2001,项目名称:pygal,代码行数:58,代码来源:frenchmap.py


示例16: line

    def line(self, serie, rescale=False):
        """Draw the line serie"""
        serie_node = self.svg.serie(serie)
        if rescale and self.secondary_series:
            points = self._rescale(serie.points)
        else:
            points = serie.points
        view_values = list(map(self.view, points))
        if serie.show_dots:
            for i, (x, y) in enumerate(view_values):
                if None in (x, y):
                    continue
                if (
                    serie.show_only_major_dots
                    and self.x_labels
                    and i < len(self.x_labels)
                    and self.x_labels[i] not in self._x_labels_major
                ):
                    continue

                metadata = serie.metadata.get(i)
                classes = []
                if x > self.view.width / 2:
                    classes.append("left")
                if y > self.view.height / 2:
                    classes.append("top")
                classes = " ".join(classes)

                self._confidence_interval(serie_node["overlay"], x, y, serie.values[i], metadata)

                dots = decorate(self.svg, self.svg.node(serie_node["overlay"], class_="dots"), metadata)

                val = self._get_value(serie.points, i)
                alter(
                    self.svg.transposable_node(
                        dots, "circle", cx=x, cy=y, r=serie.dots_size, class_="dot reactive tooltip-trigger"
                    ),
                    metadata,
                )
                self._tooltip_data(dots, val, x, y, xlabel=self._get_x_label(i))
                self._static_value(
                    serie_node, val, x + self.style.value_font_size, y + self.style.value_font_size, metadata
                )

        if serie.stroke:
            if self.interpolate:
                points = serie.interpolated
                if rescale and self.secondary_series:
                    points = self._rescale(points)
                view_values = list(map(self.view, points))
            if serie.fill:
                view_values = self._fill(view_values)
            self.svg.line(
                serie_node["plot"],
                view_values,
                close=self._self_close,
                class_="line reactive" + (" nofill" if not serie.fill else ""),
            )
开发者ID:parijatgarg,项目名称:pygal,代码行数:58,代码来源:line.py


示例17: needle

    def needle(self, serie):
        """Draw a needle for each value"""
        serie_node = self.svg.serie(serie)
        for i, theta in enumerate(serie.values):
            if theta is None:
                continue

            def point(x, y):
                if self.clockwise:
                    transform = compose(self.clockwiser, self.view)
                else:
                    transform = self.view
                return '%f %f' % transform((x, y))

            val = self._format(serie, i)
            metadata = serie.metadata.get(i)
            gauges = decorate(
                self.svg,
                self.svg.node(serie_node['plot'], class_="dots"),
                metadata)

            tolerance = 1.15

            if theta < self._min:
                theta = self._min * tolerance

            if theta > self._max:
                theta = self._max * tolerance

            w = (self._box._tmax - self._box._tmin + self.view.aperture) / 4

            if self.logarithmic:
                w = min(w, self._min - self._min * 10 ** -10)

            sweep_flag = '0' if self.clockwise else '1'

            alter(
                self.svg.node(
                    gauges, 'path', d='M %s L %s A %s 1 0 %s %s Z' % (
                        point(.85, theta),
                        point(self.needle_width, theta - w),
                        '%f %f' % (self.needle_width, self.needle_width),
                        sweep_flag,
                        point(self.needle_width, theta + w),
                    ),
                    class_='line reactive tooltip-trigger'),
                metadata)

            x, y = self.view((.75, theta))
            if self.clockwise:
                x, y = self.clockwiser((x, y))
            self._tooltip_data(
                gauges, val, x, y,
                xlabel=self._get_x_label(i))
            self._static_value(serie_node, val, x, y, metadata)
开发者ID:feargswalsh92,项目名称:pygalfork,代码行数:55,代码来源:gauge.py


示例18: _plot

    def _plot(self):
        map = etree.fromstring(MAP)
        map.set('width', str(self.view.width))
        map.set('height', str(self.view.height))

        for i, serie in enumerate(self.series):
            safe_vals = list(filter(
                lambda x: x is not None, cut(serie.values, 1)))
            if not safe_vals:
                continue
            min_ = min(safe_vals)
            max_ = max(safe_vals)
            serie.values = self.replace_supranationals(serie.values)
            for j, (country_code, value) in enumerate(serie.values):
                if value is None:
                    continue
                if max_ == min_:
                    ratio = 1
                else:
                    ratio = .3 + .7 * (value - min_) / (max_ - min_)
                country = map.find('.//*[@id="%s"]' % country_code)
                if country is None:
                    continue
                cls = country.get('class', '').split(' ')
                cls.append('color-%d' % i)
                country.set('class', ' '.join(cls))
                country.set(
                    'style', 'fill-opacity: %f' % (
                        ratio))

                metadata = serie.metadata.get(j)
                if metadata:
                    parent = country.getparent()
                    node = decorate(self.svg, country, metadata)
                    if node != country:
                        country.remove(node)
                        index = parent.index(country)
                        parent.remove(country)
                        node.append(country)
                        parent.insert(index, node)

                last_node = len(country) > 0 and country[-1]
                if last_node is not None and last_node.tag == 'title':
                    title_node = last_node
                    text = title_node.text + '\n'
                else:
                    title_node = self.svg.node(country, 'title')
                    text = ''
                title_node.text = text + '[%s] %s: %d' % (
                    serie.title,
                    self.country_names[country_code], value)

        self.nodes['plot'].append(map)
开发者ID:Bouska,项目名称:pygal,代码行数:53,代码来源:supranationalworldmap.py


示例19: dot

    def dot(self, serie_node, serie, r_max):
        """Draw a dot line"""
        view_values = list(map(self.view, serie.points))
        for i, value in safe_enumerate(serie.values):
            x, y = view_values[i]
            size = r_max * value
            value = self._format(value)
            metadata = serie.metadata.get(i)
            dots = decorate(self.svg, self.svg.node(serie_node["plot"], class_="dots"), metadata)
            self.svg.node(dots, "circle", cx=x, cy=y, r=size, class_="dot reactive tooltip-trigger")

            self._tooltip_data(dots, value, x, y)
            self._static_value(serie_node, value, x, y)
开发者ID:psibi,项目名称:pygal,代码行数:13,代码来源:dot.py


示例20: line

    def line(self, serie, rescale=False):
        """Draw the line serie"""
        serie_node = self.svg.serie(serie)
        if rescale and self.secondary_series:
            points = self._rescale(serie.points)
        else:
            points = serie.points
        view_values = list(map(self.view, points))
        if serie.show_dots:
            for i, (x, y) in enumerate(view_values):
                if None in (x, y):
                    continue
                if (serie.show_only_major_dots and
                        self.x_labels and i < len(self.x_labels) and
                        self.x_labels[i] not in self._x_major_labels):
                    continue

                metadata = serie.metadata.get(i)
                classes = []
                if x > self.view.width / 2:
                    classes.append('left')
                if y > self.view.height / 2:
                    classes.append('top')
                classes = ' '.join(classes)
                dots = decorate(
                    self.svg,
                    self.svg.node(serie_node['overlay'], class_="dots"),
                    metadata)
                val = self._get_value(serie.points, i)
                alter(self.svg.transposable_node(
                    dots, 'circle', cx=x, cy=y, r=serie.dots_size,
                    class_='dot reactive tooltip-trigger'), metadata)
                self._tooltip_data(
                    dots, val, x, y,
                    xlabel=self._get_x_label(i))
                self._static_value(
                    serie_node, val,
                    x + self.style.value_font_size,
                    y + self.style.value_font_size)

        if serie.stroke:
            if self.interpolate:
                points = serie.interpolated
                if rescale and self.secondary_series:
                    points = self._rescale(points)
                view_values = list(map(self.view, points))
            if serie.fill:
                view_values = self._fill(view_values)
            self.svg.line(
                serie_node['plot'], view_values, close=self._self_close,
                class_='line reactive' + (' nofill' if not serie.fill else ''))
开发者ID:alex-bender,项目名称:pygal,代码行数:51,代码来源:line.py



注:本文中的pygal.util.decorate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.get_texts_box函数代码示例发布时间:2022-05-25
下一篇:
Python util.cut函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap