예제 #1
0
def dashboard():
    #Getting all projects
    projects = Project.select()
    #Creating a pie chart
    pie_chart = Pie()
    #adding title to pie chart
    pie_chart.title = 'Project Type'
    #instatiating two variables internal and external
    internal = 0
    external = 0
    for project in projects:
        if (project.type == 'Internal'):
            internal += 1
        else:
            external += 1

    pie_chart.add('Internal', internal)
    pie_chart.add('External', external)

    pie_chart.render()
    chart = pie_chart.render_data_uri()

    return render_template('index.html',
                           projects_to_send=projects,
                           chart=chart)
예제 #2
0
파일: test_pie.py 프로젝트: young-0/pygal
def test_half_pie():
    pie = Pie()
    pie.add('IE', 19.5)
    pie.add('Firefox', 36.6)
    pie.add('Chrome', 36.3)
    pie.add('Safari', 4.5)
    pie.add('Opera', 2.3)

    half = Pie(half_pie=True)
    half.add('IE', 19.5)
    half.add('Firefox', 36.6)
    half.add('Chrome', 36.3)
    half.add('Safari', 4.5)
    half.add('Opera', 2.3)
    assert pie.render() != half.render()
예제 #3
0
def test_half_pie():
    pie = Pie()
    pie.add("IE", 19.5)
    pie.add("Firefox", 36.6)
    pie.add("Chrome", 36.3)
    pie.add("Safari", 4.5)
    pie.add("Opera", 2.3)

    half = Pie(half_pie=True)
    half.add("IE", 19.5)
    half.add("Firefox", 36.6)
    half.add("Chrome", 36.3)
    half.add("Safari", 4.5)
    half.add("Opera", 2.3)
    assert pie.render() != half.render()
예제 #4
0
def test_half_pie():
    pie = Pie()
    pie.add('IE', 19.5)
    pie.add('Firefox', 36.6)
    pie.add('Chrome', 36.3)
    pie.add('Safari', 4.5)
    pie.add('Opera', 2.3)

    half = Pie(half_pie=True)
    half.add('IE', 19.5)
    half.add('Firefox', 36.6)
    half.add('Chrome', 36.3)
    half.add('Safari', 4.5)
    half.add('Opera', 2.3)
    assert pie.render() != half.render()
예제 #5
0
def node_apply_end(repo, node, duration=None, interactive=None, result=None, **kwargs):
    if environ.get('TERM_PROGRAM', None) != "iTerm.app" or not interactive:
        LOG.debug("skipping iTerm stats (wrong terminal)")
        return

    if not IMPORTS:
        LOG.error("failed to import dependencies of itermstats plugin")
        return

    css_file = NamedTemporaryFile(delete=False)
    css_file.write(".text-overlay { display: none; }")
    css_file.close()

    config = Config(
        height=150,
        style=STYLE,
        width=350,
    )
    config.css.append(css_file.name)

    chart = Pie(config)
    chart.add('correct', result.correct)
    chart.add('fixed', result.fixed)
    chart.add('skipped', result.skipped)
    chart.add('failed', result.failed)

    png_data = cairosvg.svg2png(bytestring=chart.render())
    png_data_b64 = b64encode(png_data)

    remove(css_file.name)

    print("\033]1337;File=inline=1:{}\007".format(png_data_b64))
예제 #6
0
파일: test_pie.py 프로젝트: young-0/pygal
def test_donut():
    chart = Pie(inner_radius=.3, pretty_print=True)
    chart.title = 'Browser usage in February 2012 (in %)'
    chart.add('IE', 19.5)
    chart.add('Firefox', 36.6)
    chart.add('Chrome', 36.3)
    chart.add('Safari', 4.5)
    chart.add('Opera', 2.3)
    assert chart.render()
예제 #7
0
def test_donut():
    chart = Pie(inner_radius=0.3, pretty_print=True)
    chart.title = "Browser usage in February 2012 (in %)"
    chart.add("IE", 19.5)
    chart.add("Firefox", 36.6)
    chart.add("Chrome", 36.3)
    chart.add("Safari", 4.5)
    chart.add("Opera", 2.3)
    assert chart.render()
예제 #8
0
def test_donut():
    chart = Pie(inner_radius=.3, pretty_print=True)
    chart.title = 'Browser usage in February 2012 (in %)'
    chart.add('IE', 19.5)
    chart.add('Firefox', 36.6)
    chart.add('Chrome', 36.3)
    chart.add('Safari', 4.5)
    chart.add('Opera', 2.3)
    assert chart.render()
예제 #9
0
파일: test_pie.py 프로젝트: young-0/pygal
def test_multiseries_donut():
    # this just demos that the multiseries pie does not respect
    # the inner_radius
    chart = Pie(inner_radius=.3, pretty_print=True)
    chart.title = 'Browser usage by version in February 2012 (in %)'
    chart.add('IE', [5.7, 10.2, 2.6, 1])
    chart.add('Firefox', [.6, 16.8, 7.4, 2.2, 1.2, 1, 1, 1.1, 4.3, 1])
    chart.add('Chrome', [.3, .9, 17.1, 15.3, .6, .5, 1.6])
    chart.add('Safari', [4.4, .1])
    chart.add('Opera', [.1, 1.6, .1, .5])
    assert chart.render()
예제 #10
0
def test_multiseries_donut():
    # this just demos that the multiseries pie does not respect
    # the inner_radius
    chart = Pie(inner_radius=0.3, pretty_print=True)
    chart.title = "Browser usage by version in February 2012 (in %)"
    chart.add("IE", [5.7, 10.2, 2.6, 1])
    chart.add("Firefox", [0.6, 16.8, 7.4, 2.2, 1.2, 1, 1, 1.1, 4.3, 1])
    chart.add("Chrome", [0.3, 0.9, 17.1, 15.3, 0.6, 0.5, 1.6])
    chart.add("Safari", [4.4, 0.1])
    chart.add("Opera", [0.1, 1.6, 0.1, 0.5])
    assert chart.render()
예제 #11
0
def test_multiseries_donut():
    # this just demos that the multiseries pie does not respect
    # the inner_radius
    chart = Pie(inner_radius=.3, pretty_print=True)
    chart.title = 'Browser usage by version in February 2012 (in %)'
    chart.add('IE', [5.7, 10.2, 2.6, 1])
    chart.add('Firefox', [.6, 16.8, 7.4, 2.2, 1.2, 1, 1, 1.1, 4.3, 1])
    chart.add('Chrome', [.3, .9, 17.1, 15.3, .6, .5, 1.6])
    chart.add('Safari', [4.4, .1])
    chart.add('Opera', [.1, 1.6, .1, .5])
    assert chart.render()
예제 #12
0
def pie_route():
    projects = Project.select()
    pie_chart = Pie()
    pie_chart.title = 'Browser usage in February 2012 (in %)'

    # instatiating two variables internal and external
    internal = 0
    external = 0

    for project in projects:
        if (project.type == 'internal'):
            internal += 1
        else:
            external += 1
    pie_chart.add('internal', internal)
    pie_chart.add('external', external)

    pie_chart.render()
    chart = pie_chart.render_data_uri()

    return render_template('index.html',
                           projects_to_send=projects,
                           chart=chart)
예제 #13
0
 def lapspercar_svg(self, curr_url=None):
     if not config.config.HTTP_CONFIG.enable_svg_generation:
         return ""
     stats = self.lastStat
     pie_chart = Pie(pygalConfig)
     pie_chart.title = 'Car usage (% laps driven)'
     tl = stats['numLaps']
     lapsPerTrack = sorted(stats['lapsPerCar'].items(),
                           key=lambda x: x[1],
                           reverse=True)
     valueToItem = {}
     for t, nl in lapsPerTrack:
         v = nl * 100 / tl
         while v in valueToItem:
             v -= 1e-9
         valueToItem[v] = t
         pie_chart.add(t, v)
     pie_chart.value_formatter = lambda x, valueToItem=valueToItem: "%s: %.1f%%" % (
         valueToItem.get(x, '?'), x)
     return pie_chart.render()
예제 #14
0
 def lapspercombo_svg(self, curr_url=None):
     if not config.config.HTTP_CONFIG.enable_svg_generation:
         return ""
     stats = self.lastStat
     pie_chart = Pie(pygalConfig)
     pie_chart.title = 'Combo usage (% laps driven)'
     tl = stats['numLaps']
     lapsPerCombo = sorted(stats['lapsPerCombo'].items(),
                           key=lambda x: x[1]['lapCount'],
                           reverse=True)
     valueToItem = {}
     for t, info in lapsPerCombo:
         nl = info['lapCount']
         name = "+".join(info['cars']) + '@' + info['track']
         v = nl * 100 / tl
         while v in valueToItem:
             v -= 1e-9
         valueToItem[v] = name
         pie_chart.add(name, v)
     pie_chart.value_formatter = lambda x, valueToItem=valueToItem: "%s: %.1f%%" % (
         valueToItem.get(x, '?'), x)
     return pie_chart.render()
예제 #15
0
from pygal import Pie

pie_chart = Pie()
pie_chart.title = 'Browser usage in February 2012 (in %)'
pie_chart.add('IE', 19.5)
pie_chart.add('Firefox', 36.6)
pie_chart.add('Chrome', 36.3)
pie_chart.add('Safari', 4.5)
pie_chart.add('Opera', 2.3)
pie_chart.render()