Exemplo n.º 1
0
    def interpolation():
        width, height = 600, 400
        config = Config()
        config.width = width
        config.height = height
        config.fill = True
        config.style = styles['neon']
        data = random.randrange(1, 10)
        order = random.randrange(1, 10)
        series = b64encode(pickle.dumps(_random_series(type, data, order)))
        svgs = []
        for interpolation in 'quadratic', 'cubic', 'lagrange', 'trigonometric':
            config.title = "%s interpolation" % interpolation
            config.interpolate = interpolation
            svgs.append({
                'type': 'pygal.StackedLine',
                'series': series,
                'config': b64encode(pickle.dumps(config))
            })

        for params in [{'type': 'catmull_rom'}, {'type': 'finite_difference'},
                       {'type': 'cardinal',
                        'c': .25}, {'type': 'cardinal',
                                    'c': .5}, {'type': 'cardinal', 'c': .75},
                       {'type': 'cardinal',
                        'c': 1.5}, {'type': 'cardinal',
                                    'c': 2}, {'type': 'cardinal', 'c': 5},
                       {'type': 'kochanek_bartels', 'b': 1, 'c': 1,
                        't': 1}, {'type': 'kochanek_bartels', 'b': -1, 'c': 1,
                                  't': 1}, {'type': 'kochanek_bartels', 'b': 1,
                                            'c': -1, 't': 1},
                       {'type': 'kochanek_bartels', 'b': 1, 'c': 1, 't': -1}, {
                           'type': 'kochanek_bartels', 'b': -1, 'c': 1, 't': -1
                       }, {'type': 'kochanek_bartels', 'b': -1, 'c': -1,
                           't': 1}, {'type': 'kochanek_bartels', 'b': -1,
                                     'c': -1, 't': -1}]:
            config.title = "Hermite interpolation with params %r" % params
            config.interpolate = 'hermite'
            config.interpolation_parameters = params
            svgs.append({
                'type': 'pygal.StackedLine',
                'series': series,
                'config': b64encode(pickle.dumps(config))
            })

        return render_template(
            'svgs.jinja2', svgs=svgs, width=width, height=height
        )
Exemplo n.º 2
0
    def all(style='default', color=None, interpolate=None, base_style=None):
        width, height = 600, 400
        data = random.randrange(1, 10)
        order = random.randrange(1, 10)
        if color is None:
            style = styles[style]
        else:
            style = parametric_styles[style](
                color, base_style=styles[base_style or 'default'])
        xy_series = _random(data, order)
        other_series = []
        for title, values in xy_series:
            other_series.append(
                (title, cut(values, 1)))
        xy_series = b64encode(pickle.dumps(xy_series))
        other_series = b64encode(pickle.dumps(other_series))
        config = Config()
        config.width = width
        config.height = height
        config.fill = bool(random.randrange(0, 2))
        config.human_readable = True
        config.interpolate = interpolate
        config.style = style
        config.x_labels = [random_label() for i in range(data)]
        svgs = []
        for chart in pygal.CHARTS:
            type = chart.__name__
            svgs.append({'type': type,
                         'series': xy_series if type == 'XY' else other_series,
                         'config': b64encode(pickle.dumps(config))})

        return render_template('svgs.jinja2',
                               svgs=svgs,
                               width=width,
                               height=height)
Exemplo n.º 3
0
    def interpolation():
        width, height = 600, 400
        config = Config()
        config.width = width
        config.height = height
        config.fill = True
        config.style = styles['neon']
        data = random.randrange(1, 10)
        order = random.randrange(1, 10)
        series = b64encode(pickle.dumps(_random_series(type, data, order)))
        svgs = []
        for interpolation in ('linear', 'slinear', 'nearest', 'zero',
                              'quadratic', 'cubic', 'krogh', 'barycentric',
                              'univariate', 4, 5, 6, 7, 8):
            config.title = "%s interpolation" % interpolation
            config.interpolate = interpolation
            svgs.append({
                'type': 'StackedLine',
                'series': series,
                'config': b64encode(pickle.dumps(config))
            })

        return render_template('svgs.jinja2',
                               svgs=svgs,
                               width=width,
                               height=height)
Exemplo n.º 4
0
    def all(style='default', interpolate=None):
        width, height = 600, 400
        data = random.randrange(1, 10)
        order = random.randrange(1, 10)
        xy_series = _random(data, order)
        other_series = []
        for title, values in xy_series:
            other_series.append((title, cut(values, 1)))
        xy_series = b64encode(pickle.dumps(xy_series))
        other_series = b64encode(pickle.dumps(other_series))
        config = Config()
        config.width = width
        config.height = height
        config.fill = bool(random.randrange(0, 2))
        config.human_readable = True
        config.interpolate = interpolate
        config.style = styles[style]
        config.x_labels = [random_label() for i in range(data)]
        svgs = []
        for chart in pygal.CHARTS:
            type = chart.__name__
            svgs.append({
                'type': type,
                'series': xy_series if type == 'XY' else other_series,
                'config': b64encode(pickle.dumps(config))
            })

        return render_template('svgs.jinja2',
                               svgs=svgs,
                               width=width,
                               height=height)
Exemplo n.º 5
0
    def interpolation():
        width, height = 600, 400
        config = Config()
        config.width = width
        config.height = height
        config.fill = True
        config.style = styles['neon']
        data = random.randrange(1, 10)
        order = random.randrange(1, 10)
        series = b64encode(pickle.dumps(_random_series(type, data, order)))
        svgs = []
        for interpolation in 'quadratic', 'cubic', 'lagrange', 'trigonometric':
            config.title = "%s interpolation" % interpolation
            config.interpolate = interpolation
            svgs.append({'type': 'StackedLine',
                         'series': series,
                         'config': b64encode(pickle.dumps(config))})

        for params in [
                {'type': 'catmull_rom'},
                {'type': 'finite_difference'},
                {'type': 'cardinal', 'c': .25},
                {'type': 'cardinal', 'c': .5},
                {'type': 'cardinal', 'c': .75},
                {'type': 'cardinal', 'c': 1.5},
                {'type': 'cardinal', 'c': 2},
                {'type': 'cardinal', 'c': 5},
                {'type': 'kochanek_bartels', 'b': 1, 'c': 1, 't': 1},
                {'type': 'kochanek_bartels', 'b': -1, 'c': 1, 't': 1},
                {'type': 'kochanek_bartels', 'b': 1, 'c': -1, 't': 1},
                {'type': 'kochanek_bartels', 'b': 1, 'c': 1, 't': -1},
                {'type': 'kochanek_bartels', 'b': -1, 'c': 1, 't': -1},
                {'type': 'kochanek_bartels', 'b': -1, 'c': -1, 't': 1},
                {'type': 'kochanek_bartels', 'b': -1, 'c': -1, 't': -1}
        ]:
            config.title = "Hermite interpolation with params %r" % params
            config.interpolate = 'hermite'
            config.interpolation_parameters = params
            svgs.append({'type': 'StackedLine',
                         'series': series,
                         'config': b64encode(pickle.dumps(config))})

        return render_template('svgs.jinja2',
                               svgs=svgs,
                               width=width,
                               height=height)
Exemplo n.º 6
0
    def interpolation():
        width, height = 600, 400
        config = Config()
        config.width = width
        config.height = height
        config.fill = True
        config.style = styles["neon"]
        data = random.randrange(1, 10)
        order = random.randrange(1, 10)
        series = b64encode(pickle.dumps(_random_series(type, data, order)))
        svgs = []
        for interpolation in "quadratic", "cubic", "lagrange", "trigonometric":
            config.title = "%s interpolation" % interpolation
            config.interpolate = interpolation
            svgs.append({"type": "StackedLine", "series": series, "config": b64encode(pickle.dumps(config))})

        for params in [
            {"type": "catmull_rom"},
            {"type": "finite_difference"},
            {"type": "cardinal", "c": 0.25},
            {"type": "cardinal", "c": 0.5},
            {"type": "cardinal", "c": 0.75},
            {"type": "cardinal", "c": 1.5},
            {"type": "cardinal", "c": 2},
            {"type": "cardinal", "c": 5},
            {"type": "kochanek_bartels", "b": 1, "c": 1, "t": 1},
            {"type": "kochanek_bartels", "b": -1, "c": 1, "t": 1},
            {"type": "kochanek_bartels", "b": 1, "c": -1, "t": 1},
            {"type": "kochanek_bartels", "b": 1, "c": 1, "t": -1},
            {"type": "kochanek_bartels", "b": -1, "c": 1, "t": -1},
            {"type": "kochanek_bartels", "b": -1, "c": -1, "t": 1},
            {"type": "kochanek_bartels", "b": -1, "c": -1, "t": -1},
        ]:
            config.title = "Hermite interpolation with params %r" % params
            config.interpolate = "hermite"
            config.interpolation_parameters = params
            svgs.append({"type": "StackedLine", "series": series, "config": b64encode(pickle.dumps(config))})

        return render_template("svgs.jinja2", svgs=svgs, width=width, height=height)
Exemplo n.º 7
0
    def all(style='default', color=None, interpolate=None, base_style=None):
        width, height = 600, 400
        data = random.randrange(1, 10)
        order = random.randrange(1, 10)
        if color is None:
            style = styles[style]
        else:
            style = parametric_styles[style](color,
                                             base_style=styles[base_style
                                                               or 'default'])

        xy_series = _random(data, order)
        other_series = []
        for title, values, config in xy_series:
            other_series.append((title, cut(values, 1), config))
        xy_series = b64encode(pickle.dumps(xy_series))
        other_series = b64encode(pickle.dumps(other_series))
        config = Config()
        config.width = width
        config.height = height
        config.fill = bool(random.randrange(0, 2))
        config.interpolate = interpolate
        config.style = style
        svgs = []
        for chart in pygal.CHARTS:
            type = '.'.join((chart.__module__, chart.__name__))
            if chart._dual:
                config.x_labels = None
            else:
                config.x_labels = [random_label() for i in range(data)]
            svgs.append({
                'type': type,
                'series': xy_series if chart._dual else other_series,
                'config': b64encode(pickle.dumps(config))
            })

        return render_template('svgs.jinja2',
                               svgs=svgs,
                               width=width,
                               height=height)
Exemplo n.º 8
0
    def all(style="default", color=None, interpolate=None, base_style=None):
        width, height = 600, 400
        data = random.randrange(1, 10)
        order = random.randrange(1, 10)
        if color is None:
            style = styles[style]
        else:
            style = parametric_styles[style](color, base_style=styles[base_style or "default"])

        xy_series = _random(data, order)
        other_series = []
        for title, values, config in xy_series:
            other_series.append((title, cut(values, 1), config))
        xy_series = b64encode(pickle.dumps(xy_series))
        other_series = b64encode(pickle.dumps(other_series))
        config = Config()
        config.width = width
        config.height = height
        config.fill = bool(random.randrange(0, 2))
        config.interpolate = interpolate
        config.style = style
        svgs = []
        for chart in pygal.CHARTS:
            type = ".".join((chart.__module__, chart.__name__))
            if chart._dual:
                config.x_labels = None
            else:
                config.x_labels = [random_label() for i in range(data)]
            svgs.append(
                {
                    "type": type,
                    "series": xy_series if chart._dual else other_series,
                    "config": b64encode(pickle.dumps(config)),
                }
            )

        return render_template("svgs.jinja2", svgs=svgs, width=width, height=height)
Exemplo n.º 9
0
    def interpolation():
        width, height = 600, 400
        config = Config()
        config.width = width
        config.height = height
        config.fill = True
        config.style = styles['neon']
        data = random.randrange(1, 10)
        order = random.randrange(1, 10)
        series = b64encode(pickle.dumps(_random_series(type, data, order)))
        svgs = []
        for interpolation in (
                'linear', 'slinear', 'nearest', 'zero', 'quadratic', 'cubic',
                'krogh', 'barycentric', 'univariate', 4, 5, 6, 7, 8):
            config.title = "%s interpolation" % interpolation
            config.interpolate = interpolation
            svgs.append({'type': 'StackedLine',
                         'series': series,
                         'config': b64encode(pickle.dumps(config))})

        return render_template('svgs.jinja2',
                               svgs=svgs,
                               width=width,
                               height=height)