Example #1
0
def bars_data(request):
    url = 'https://api.bitbucket.org/1.0/repositories/lukaszb/django-richtemplates/changesets/'
    response = urllib2.urlopen(url)
    jdata = loads(response.read())
    changesets = jdata['changesets']

    added = pyofc2.bar()
    modified = pyofc2.bar()
    removed = pyofc2.bar()
    added.values, modified.values, removed.values = [], [], []
    added.colour = '#00c700'
    added.text = 'Added'
    modified.colour = '#ffaa00'
    modified.text = 'Modified'
    removed.colour = '#f27474'
    removed.text = 'Removed'

    x = pyofc2.x_axis()
    y = pyofc2.y_axis(steps=5)
    y_max = 0
    labels = []

    for changeset in changesets:
        labels.append(pyofc2.x_axis_label(text='%s:%s' %
            (changeset['revision'], changeset['node'])))
        files = changeset['files']
        tip = '#val#<br>Date: %s<br>Revision: %s:%s<br>Author: %s<br>Message: %s'
        tip = tip % tuple([changeset[key] for key in (
            'timestamp', 'revision', 'node', 'author', 'message')])
        tip = '%s: ' + tip
        # Added files
        added_count = len([f for f in files if f['type'] == 'added'])
        added.values.append(pyofc2.barvalue(top=added_count, tip=tip % 'Added'))
        # Modified files
        modified_count = len([f for f in files if f['type'] == 'modified'])
        modified.values.append(pyofc2.barvalue(top=modified_count,
            tip=tip % 'Modified'))
        # Removed files
        removed_count = len([f for f in files if f['type'] == 'removed'])
        removed.values.append(pyofc2.barvalue(top=removed_count,
            tip=tip % 'Removed'))
        y_max = max([y_max, added_count, modified_count, removed_count])

    y.min = 0
    y.max = y_max

    title = pyofc2.title(text='django-richtemplates changesets')
    chart = pyofc2.open_flash_chart()
    chart.title = title
    chart.add_element(added)
    chart.add_element(modified)
    chart.add_element(removed)
    chart.bg_colour = '#ffffff'
    x.labels = pyofc2.x_axis_labels(steps=1, rotate=25.0)
    x.labels.labels = labels
    chart.x_axis = x
    chart.y_axis = y
    return HttpResponse(chart.render(), mimetype='application/json')
 def response(self, request, username, project_slug):
     import random
     import pyofc2
     t = pyofc2.title(text=_("Tasks"))
     b1 = pyofc2.bar()
     b1.values = range(10)
     b2 = pyofc2.bar()
     b2.values = [random.randint(0, 9) for i in range(9)]
     b2.colour = '#56acde'
     chart = pyofc2.open_flash_chart()
     chart.title = t
     chart.add_element(b1)
     chart.add_element(b2)
     return HttpResponse(chart.render())
Example #3
0
 def response(self, request, username, project_slug):
     import random
     import pyofc2
     t = pyofc2.title(text=_("Tasks"))
     b1 = pyofc2.bar()
     b1.values = range(10)
     b2 = pyofc2.bar()
     b2.values = [random.randint(0,9) for i in range(9)]
     b2.colour = '#56acde'
     chart = pyofc2.open_flash_chart()
     chart.title = t
     chart.add_element(b1)
     chart.add_element(b2)
     return HttpResponse(chart.render())
Example #4
0
def bars_data(request):
    url = 'https://api.bitbucket.org/1.0/repositories/lukaszb/django-richtemplates/changesets/'
    response = urllib2.urlopen(url)
    jdata = loads(response.read())
    changesets = jdata['changesets']

    added = pyofc2.bar()
    modified = pyofc2.bar()
    removed = pyofc2.bar()
    added.values, modified.values, removed.values = [], [], []
    added.colour = '#00c700'
    added.text = 'Added'
    modified.colour = '#ffaa00'
    modified.text = 'Modified'
    removed.colour = '#f27474'
    removed.text = 'Removed'

    x = pyofc2.x_axis()
    y = pyofc2.y_axis(steps=5)
    y_max = 0
    labels = []

    for changeset in changesets:
        labels.append(
            pyofc2.x_axis_label(text='%s:%s' %
                                (changeset['revision'], changeset['node'])))
        files = changeset['files']
        tip = '#val#<br>Date: %s<br>Revision: %s:%s<br>Author: %s<br>Message: %s'
        tip = tip % tuple([
            changeset[key]
            for key in ('timestamp', 'revision', 'node', 'author', 'message')
        ])
        tip = '%s: ' + tip
        # Added files
        added_count = len([f for f in files if f['type'] == 'added'])
        added.values.append(pyofc2.barvalue(top=added_count,
                                            tip=tip % 'Added'))
        # Modified files
        modified_count = len([f for f in files if f['type'] == 'modified'])
        modified.values.append(
            pyofc2.barvalue(top=modified_count, tip=tip % 'Modified'))
        # Removed files
        removed_count = len([f for f in files if f['type'] == 'removed'])
        removed.values.append(
            pyofc2.barvalue(top=removed_count, tip=tip % 'Removed'))
        y_max = max([y_max, added_count, modified_count, removed_count])

    y.min = 0
    y.max = y_max

    title = pyofc2.title(text='django-richtemplates changesets')
    chart = pyofc2.open_flash_chart()
    chart.title = title
    chart.add_element(added)
    chart.add_element(modified)
    chart.add_element(removed)
    chart.bg_colour = '#ffffff'
    x.labels = pyofc2.x_axis_labels(steps=1, rotate=25.0)
    x.labels.labels = labels
    chart.x_axis = x
    chart.y_axis = y
    return HttpResponse(chart.render(), mimetype='application/json')