当前位置: 首页>>代码示例>>Python>>正文


Python SimpleLineChart.get_url方法代码示例

本文整理汇总了Python中pygooglechart.SimpleLineChart.get_url方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleLineChart.get_url方法的具体用法?Python SimpleLineChart.get_url怎么用?Python SimpleLineChart.get_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygooglechart.SimpleLineChart的用法示例。


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

示例1: report

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
def report(request):
    # data report
    if Invoice.objects.all().count() == 0:
        return redirect("/openbook")
    min_year = Invoice.objects.order_by("date")[0].date.year
    max_year = Invoice.objects.order_by("-date")[0].date.year
    report = []
    for year in range(min_year,max_year+1):
        year_report = []
        for month in range(1,13):
            total = get_total(year, month)
            year_report.append(total)
        s = sum(year_report)
        tax = round((s * (0.13 / 1.13)), 2)
        year_report.append(tax)
        year_report.append(s)
        year_report.insert(0, year)
        report.append(year_report)
        
    # graphical data year report
    year_total_data = [i[-1] for i in report]
    max_y = max(year_total_data)
    min_y = min(year_total_data)
    gr = SimpleLineChart(800, 300, y_range=[0,max_y])
    gr.add_data(year_total_data)
    gr.set_grid(0, 25, 5, 5)
    left_axis = range(min_y, max_y + 1, (max_y/10))
    left_axis[0] = ''
    gr.set_axis_labels(Axis.LEFT, left_axis)
    gr.set_axis_labels(Axis.BOTTOM, \
    [str(i) for i in range(min_year, max_year+1)])
    
    # yearly report
    gs = []
    months = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"]
    for data in report:
        max_y = max(data[1:-2]) # excluding the first and the last 2 entries
        g = SimpleLineChart(800, 300, y_range=[0, max_y])
        g.add_data(data[1:-2]) # excluding the frist and the last 2 entries
        g.set_grid(0, 25, 5, 5)
        left_axis = range(0, max_y + 1, (max_y/10))
        left_axis[0] = ''
        g.set_axis_labels(Axis.LEFT, left_axis)
        g.set_axis_labels(Axis.BOTTOM, \
        months)
        gs.append((data[0], g.get_url()))
    gs.reverse()
    grurl = gr.get_url()
    if max_year == min_year:
        grurl = None
    return render_to_response(
        "admin/invoice/report.html",
        {'report' : report, 'gr': grurl, 'gs':gs},
        RequestContext(request, {}),
    )
开发者ID:maximmai,项目名称:openbook,代码行数:57,代码来源:admin_views.py

示例2: lineGraphFeed

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
def lineGraphFeed(feed):
    name = feed.getAttribute("name")
    observations = feed.getElementsByTagName("observation")
    print "  Feed %s has %d observations" % (name,len(observations))
    data = []
    for obs in observations:
        value = int(obs.getAttribute("value"))
        #print "   val:%s (%s)" % (value, type(value))
        data.insert(0,value/10)

    #data.reverse  # remeber the feed is reversed
    print "Max Data: %s" % max(data)

    max_y = int(math.ceil(max(data)/100.0))*100
    print "Max_y : %s" % max_y
    chart = SimpleLineChart(180, 120, y_range=[0, max_y])
    chart.add_data(data)

    lftAxisMax = max_y/100;
    print "lftAxisMax %s"%lftAxisMax
    #left_axis = range(0, lftAxisMax,(lftAxisMax/4.0))
    left_axis = []
    right_axis = []
    for i in range(0,4+1):
        kw = (i*lftAxisMax/4.0)
        left_axis.append(kw)
        right_axis.append(kw*24)

    left_axis[0] = 'kW' # remove the first label
    right_axis[0] = 'kWh/d' # remove the first label
    chart.set_axis_labels(Axis.LEFT, left_axis)
    #chart.set_axis_labels(Axis.RIGHT, right_axis)

    chart.set_title(name)

    # facebook colors
    chart.set_title_style('7f93bc',16)
    #chart.set_colours(['7f93bc'])
    chart.set_colours(['3b5998']) #darker blue

    #Colors
    colors=False
    if (colors):
        # Set the line colour to ...
        chart.set_colours(['FFFFFF'])
        # 0 here is the axis index ? 0 works for now
        chart.set_title_style('FFFFFF',16)
        chart.set_axis_style(0,'FFFFFF')
        chart.set_axis_style(1,'FFFFFF')
        chart.fill_linear_gradient(Chart.BACKGROUND,90,'000000',0.9,'007700',0.1)


    print chart.get_url()
    chart.download('%s-line.png'%name)
开发者ID:daneroo,项目名称:im-ted1k,代码行数:56,代码来源:getFeed.py

示例3: getRollingAverageGraph

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
def getRollingAverageGraph(cursor, colName, rollingWindowDays, title=""):
    sqlCMD = "SELECT pDate, %s from %s" %(colName, N.JOBS_SUMMARY_TABLENAME)
    cursor.execute(sqlCMD)
    results = cursor.fetchall()
    beginWindowIndex = 0
    endWindowIndex = 0
    xData = []
    yData = []
    while endWindowIndex < len(results):
        while endWindowIndex < len(results) and (results[endWindowIndex][0] - results[beginWindowIndex][0]).days <= rollingWindowDays:
            endWindowIndex += 1
        yData.append( sum(results[i][1] for i in xrange(beginWindowIndex, endWindowIndex, 1)) / float(endWindowIndex - beginWindowIndex))
        xData.append(results[endWindowIndex-1][0])
        beginWindowIndex = endWindowIndex
    chart = SimpleLineChart(680, 400, y_range = (min(yData)-1, max(yData)+1))
    chart.add_data(yData)
    
    yLabels = range(0, int(max(yData)+1), 5)
    yLabels[0] = ''
    xLabels = [str(xData[-i]) for i in xrange(1, len(xData)-1, int(0.2*len(xData)))]
    xLabels.reverse()
    chart.set_axis_labels(Axis.LEFT, yLabels)
    chart.set_axis_labels(Axis.BOTTOM, xLabels)
    chart.set_title("Rolling %i-Day Average %s" % (rollingWindowDays, title))
    imgbin = chart.download()
    toReturn = cStringIO.StringIO(imgbin)
    toReturn.seek(0)
    return chart.get_url(), toReturn
开发者ID:willwade,项目名称:emailJobParser,代码行数:30,代码来源:MakeCharts.py

示例4: show

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
def show(request, isa_id):
    isa = get_object_or_404(ISA, pk=isa_id)
    isafunds = isa.isafund_set.all()
    start_date = isa.created
    end_date = date.today()
    current_date = start_date
    data = []
    while current_date <= end_date:
        value = 0
        for isafund in isafunds:
            try:
                fundprice = isafund.fund.fundprice_set.get(date=current_date)
                value += fundprice.price * isafund.quantity
            except FundPrice.DoesNotExist:
                pass
        data.append(value)
        current_date += timedelta(1)
    chart = SimpleLineChart(500, 200, y_range=[min(data), max(data)])
    chart.add_data(data)
    chart.add_data([data[0], data[0]])
    chart.set_colours(['0000FF', 'AAAAAA'])
    chart.fill_solid('bg', 'DDDDFF')
    chart.set_axis_labels(Axis.LEFT, [int(min(data)), int(max(data))])
    chart.set_axis_labels(Axis.BOTTOM, [start_date, end_date])
    url = chart.get_url()
    return render_to_response('isas/show.html', {'isa': isa, 'chart_url': url})
开发者ID:adamgreig,项目名称:isatracker,代码行数:28,代码来源:views.py

示例5: _partyline

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
    def _partyline(self, party_results):
        if self.request.GET.get('percentages') == 'true':
            key = 'percentage'
        else:
            key = 'count'

        maxcount = 0
        allcounts = []
        granularity = self.request.GET.get('granularity')
        months = []

        for party, results in party_results.iteritems():
            counts = [x.get(key) for x in results['results']]
            allcounts.append(counts)
            if max(counts) > maxcount:
                maxcount = max(counts)

            if granularity == 'month':
                months = [x['month'] for x in results['results']]
                januaries = [x for x in months if x.endswith('01')]
                january_indexes = [months.index(x) for x in januaries]
                january_percentages = [int((x / float(len(months))) * 100) for x in january_indexes]

            #times = [x.get(granularity) for x in results['results']]

        width = int(self.request.GET.get('width', 575))
        height = int(self.request.GET.get('height', 318))
        chart = SimpleLineChart(width, height, y_range=(0, max(counts)))

        chart.fill_solid('bg', '00000000')  # Make the background transparent
        chart.set_grid(0, 50, 2, 5)  # Set gridlines

        if granularity == 'month':
            index = chart.set_axis_labels(Axis.BOTTOM, [x[:4] for x in januaries[::2]])
            chart.set_axis_positions(index, [x for x in january_percentages[::2]])

        if key == 'percentage':
            label = '%.4f' % maxcount
        else:
            label = int(maxcount)
        index = chart.set_axis_labels(Axis.LEFT, [label, ])
        chart.set_axis_positions(index, [100, ])

        for n, counts in enumerate(allcounts):
            chart.add_data(counts)
            chart.set_line_style(n, thickness=2)  # Set line thickness

        colors = {'R': 'bb3110', 'D': '295e72', }
        chart_colors = []
        chart_legend = []
        for k in party_results.keys():
            chart_colors.append(colors.get(k, '000000'))
            chart_legend.append(k)
            chart.legend_position = 'b'

        chart.set_colours(chart_colors)

        if self.request.GET.get('legend', 'true') != 'false':
            chart.set_legend(chart_legend)
        return chart.get_url()
开发者ID:notthatbreezy,项目名称:Capitol-Words,代码行数:62,代码来源:views.py

示例6: process

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
def process (name, date):
    newdate = date[8:10] + "_" + date[5:7] + "_" + date[0:4]
    url = r"http://www.lloydsbankinggroup.com/media/excel/2010/%s_historic_data.xls" % newdate
    print url
    url = r"http://www.lloydsbankinggroup.com/media/excel/2010/04_06_10_historic_data.xls"
    book = xlrd.open_workbook(file_contents=scrape(url))
    sheet = book.sheet_by_name (name)
    months=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']

    data = []
    i = 1
    while i < 500:
        try:
            month = sheet.cell_value (i, 0)
            year  = sheet.cell_value (i, 1)
            level = sheet.cell_value (i, 2)
        except:
            break
        when= "%04d-%02d-01" % (int(year), months.index (month) + 1)
        i = i + 1
        data.append (level)        
        sqlite.save(unique_keys=["Date"], data={"Date":when, "Index":level})

    chart = SimpleLineChart(500, 255, y_range=[0, 700])
    chart.add_data (data)
    metadata.save("chart", chart.get_url())
开发者ID:flyeven,项目名称:scraperwiki-scraper-vault,代码行数:28,代码来源:halifax-hpi.py

示例7: get

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
 def get(self):
     list = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep']
     list2 = []
     for title in list:
         list2.append( int(getdata(title,'funds').custom['amount'].text))
     max_y = 10000
     chart = SimpleLineChart(200, 125, y_range=[0, max_y])
     
     chart.add_data([2000,3000,5000,1200,5000,4000,1000,3000,5900])
     
     # Set the line colour to blue
     chart.set_colours(['0000FF'])
     
     # Set the vertical stripes
     chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
     
     # Set the horizontal dotted lines
     chart.set_grid(0, 25, 5, 5)
     
     # The Y axis labels contains 0 to 100 skipping every 25, but remove the
     # first number because it's obvious and gets in the way of the first X
     # label.
     left_axis = range(0, max_y + 1, 25)
     left_axis[0] = ''
     chart.set_axis_labels(Axis.LEFT, left_axis)
     
     # X axis labels
     chart.set_axis_labels(Axis.BOTTOM, list)
     
     url2 = chart.get_url()
     self.response.out.write(template.render('template/donate.html',{
                                             
                                                              'url2' :url2,                }))
开发者ID:mayankgupta022,项目名称:webwizard-optimus,代码行数:35,代码来源:main.py

示例8: group

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
def group(request, group_id):
    group = get_object_or_404(GroupedMessage, pk=group_id)

    message_list = group.message_set.all()
    
    obj = message_list.order_by('-id')[0]
    if '__sentry__' in obj.data:
        module, args, frames = obj.data['__sentry__']['exc']
        obj.class_name = str(obj.class_name)
        # We fake the exception class due to many issues with imports/builtins/etc
        exc_type = type(obj.class_name, (Exception,), {})
        exc_value = exc_type(obj.message)

        exc_value.args = args
    
        reporter = ImprovedExceptionReporter(obj.request, exc_type, exc_value, frames, obj.data['__sentry__'].get('template'))
        traceback = mark_safe(reporter.get_traceback_html())
    elif group.traceback:
        traceback = mark_safe('<pre>%s</pre>' % (group.traceback,))
    
    unique_urls = message_list.filter(url__isnull=False).values_list('url', 'logger', 'view', 'checksum').annotate(times_seen=Count('url')).values('url', 'times_seen').order_by('-times_seen')
    
    unique_servers = message_list.filter(server_name__isnull=False).values_list('server_name', 'logger', 'view', 'checksum').annotate(times_seen=Count('server_name')).values('server_name', 'times_seen').order_by('-times_seen')

    def iter_data(obj):
        for k, v in obj.data.iteritems():
            if k.startswith('_') or k in ['url']:
                continue
            yield k, v
    
    json_data = iter_data(obj)
    
    # TODO: this should be a template tag
    engine = get_db_engine()
    if SimpleLineChart and not engine.startswith('sqlite'):
        today = datetime.datetime.now()

        chart_qs = message_list\
                          .filter(datetime__gte=today - datetime.timedelta(hours=24))\
                          .extra(select={'hour': 'extract(hour from datetime)'}).values('hour')\
                          .annotate(num=Count('id')).values_list('hour', 'num')

        rows = dict(chart_qs)
        if rows:
            max_y = max(rows.values())
        else:
            max_y = 1

        chart = SimpleLineChart(300, 80, y_range=[0, max_y])
        chart.add_data([max_y]*30)
        chart.add_data([rows.get((today-datetime.timedelta(hours=d)).hour, 0) for d in range(0, 24)][::-1])
        chart.add_data([0]*30)
        chart.fill_solid(chart.BACKGROUND, 'eeeeee')
        chart.add_fill_range('eeeeee', 0, 1)
        chart.add_fill_range('e0ebff', 1, 2)
        chart.set_colours(['eeeeee', '999999', 'eeeeee'])
        chart.set_line_style(1, 1)
        chart_url = chart.get_url()
    
    return render_to_response('sentry/group/details.html', locals())
开发者ID:texastribune,项目名称:django-sentry,代码行数:62,代码来源:views.py

示例9: velocity_chart

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
    def velocity_chart(self):

        graph_width = 600
        graph_height = 300

        x_max = self.total_iterations
        y_max = max(max(self.estimate_stories_data()),
                    max(self.estimate_tasks_data()),
                    max(self.work_data()))

        chart = SimpleLineChart(graph_width, graph_height,
                                x_range=(1, x_max + 1), y_range=(0, y_max + 1))

        chart.add_data(self.estimate_stories_data())
        chart.add_data(self.estimate_tasks_data())
        chart.add_data(self.work_data())

        chart.set_grid(0, 100.0 / y_max + 1, 5, 5)
        chart.set_colours(['FF0000', '00FF00', '0000FF'])
        chart.set_legend([_('rough story estimates'),
                          _('task estimates'), _('worked')])
        chart.set_legend_position('b')
        chart.set_axis_labels(Axis.LEFT, ['', '', _('days')])
        chart.set_axis_labels(Axis.BOTTOM, range(1, x_max + 1))
        chart.set_axis_range(Axis.LEFT, 0, y_max + 1)

        return chart.get_url(data_class=ExtendedData)
开发者ID:zestsoftware,项目名称:Products.eXtremeManagement,代码行数:29,代码来源:chart.py

示例10: makeChartOfDay

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
def makeChartOfDay(data):

    max_user = 150
    chart = SimpleLineChart(400, 325, y_range=[0, max_user])
    dataChart = []
    for ore in range(24):
        ore = str(ore)
        if len(ore) == 1:
            ore = '0'+ore
        try:
            dataChart.append(userList[data]['stats']['online'][ore])
        except:
            dataChart.append(0)
    
    chart.add_data(dataChart)

    chart.set_colours(['0000FF'])

    left_axis = range(0, max_user + 1, 25)
    
    left_axis[0] = ''
    chart.set_axis_labels(Axis.LEFT, left_axis)
    
#    chart.set_axis_labels(Axis.BOTTOM, \
#    ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'])

    chart.set_axis_labels(Axis.BOTTOM, \
    range(0, 24))

    return chart.get_url()
开发者ID:SimoneManduchi,项目名称:forumfreeskin,代码行数:32,代码来源:ffutenza.py

示例11: getLineGraph

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
def getLineGraph(data,line1color,line2color):
    # Set the vertical range based on data values
    tweets = [d[0] for d in data]
    retweets = [d[1] for d in data]
    ratio = [str(int(d[1]/d[0]*100))+'%' for d in data]
    hours = [d[2] for d in data]
    mx = max(tweets)
    mn = min(retweets)
    buffer = (mx - mn)/100 # average retweets have consitently been less
    min_y = mn - buffer
    max_y = mx + buffer

    # Chart size of 750x400 pixels and specifying the range for the Y axis
    chart = SimpleLineChart(750, 400, y_range=[min_y, max_y])
    chart.set_legend(['Tweets','Retweets'])
    chart.set_legend_position('t')
    # Add the chart data
    chart.add_data(tweets)
    chart.add_data(retweets)
    # Set the line colour to blue
    chart.set_colours([line1color,line2color])

    # Set the horizontal dotted lines
    chart.set_grid(0, 25, 5, 5)

    #set left axis to values range
    left_axis = range(min_y, max_y, (max_y-min_y)/10)
    chart.set_axis_labels(Axis.BOTTOM, hours)
    chart.set_axis_labels(Axis.BOTTOM, ratio)
    chart.set_axis_labels(Axis.LEFT, left_axis)
    return chart.get_url()
开发者ID:Jlewiswa,项目名称:Twitter100k,代码行数:33,代码来源:graphop.py

示例12: get

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
  def get(self):
    counters = tasks.Counter.all().fetch(10)

    rows = [{'name':c.key().name(), 'count':c.count} for c in counters]

    chart = SimpleLineChart(1000, 300)
    for counter in counters:
      query = counter.snapshots
      query.order('-date')
      snapshots = query.fetch(30)
      counts = [s.count for s in snapshots]
      dates = [s.date.strftime("%d/%m") for s in snapshots]
      for i in xrange(len(counts) - 1):
        counts[i] -= counts[i+1]
      counts.reverse()
      dates.reverse()
      chart.add_data(counts[1:])

    chart.set_axis_labels(pygooglechart.Axis.BOTTOM, dates[1:])
    chart.set_axis_labels(pygooglechart.Axis.LEFT, range(0, chart.data_y_range()[1], 5))

    hsv_colours = [(float(x) / 255, 1, 1) for x in range(0, 255, 255 / len(counters))]
    rgb_colours = [colorsys.hsv_to_rgb(*x) for x in hsv_colours]
    hex_colours = ['%02x%02x%02x' % (int(x[0] * 255), int(x[1] * 255), int(x[2] * 255)) for x in rgb_colours]

    chart.set_colours(hex_colours)
    chart.set_legend([c.key().name() for c in counters])

    path = os.path.join(os.path.dirname(__file__), self.TEMPLATE)
    self.response.out.write(template.render(path,
        { 'url': chart.get_url(),
          'counters': rows }))
开发者ID:clementine-player,项目名称:Website,代码行数:34,代码来源:clementine.py

示例13: get_pace_chart_url

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
    def get_pace_chart_url(self, width, height):
        if len(self.positions()) == 0:
            return ''

        pace = []
        int_dist = []
        s = 0
        last_p = None
        for p in self.positions():
            if last_p != None:
                ds = distance.distance((p.latitude, p.longitude), \
                    (last_p.latitude, last_p.longitude)).kilometers
                s = s + int(ds * 1000)
                dt = (p.time - last_p.time).seconds
                if ds > 0:
                    pace.append(dt / ds)
                    int_dist.append(s)

            last_p = p

        int_pace = [int(p) for p in ema(pace, 20)]

        min_pace = int(min(int_pace) * 0.95)
        max_pace = int(max(int_pace) / 0.95)
        mid_pace = (max_pace + min_pace) / 2

        min_pace_str = '%02d:%02d' % (min_pace / 60, min_pace % 60)
        mid_pace_str = '%02d:%02d' % (mid_pace / 60, mid_pace % 60)
        max_pace_str = '%02d:%02d' % (max_pace / 60, max_pace % 60)

        chart = SimpleLineChart(width, height, y_range = (min_pace, max_pace))
        chart.add_data(int_pace)
        chart.set_axis_labels(Axis.LEFT, [min_pace_str, mid_pace_str, max_pace_str])

        return chart.get_url()
开发者ID:patsy,项目名称:gypsum,代码行数:37,代码来源:legacy_models.py

示例14: printGoogleCharts

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
    def printGoogleCharts(X, Y, title, min_y, max_y, output):

        # Create a chart object of 750x400 pixels
        chart = SimpleLineChart(750, 400)

        # Add some data
        chart.add_data(Y)

        # Assign the labels to the pie data
#        chart.set_axis_labels(Axis.BOTTOM, X)
        chart.set_axis_labels(Axis.LEFT, range(int(min_y)-1, int(max_y)+1, 5))
        chart.set_title(title)

        # Print the chart URL
        print chart.get_url()

        # Download the chart
        chart.download(output+".png")
开发者ID:MihaiTabara,项目名称:CPU_scheduling,代码行数:20,代码来源:util.py

示例15: generate_freq_chart_url_from_qset

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import get_url [as 别名]
def generate_freq_chart_url_from_qset(qset, sizex, sizey):
    ''' returns url for chart from given queryset '''
    
    end_year = qset.order_by('-publication_date')[0].publication_date.year
    start_year = qset.order_by('publication_date')[0].publication_date.year
    #print "start {0}, end {1}".format(start_year, end_year)

    year_range=range(start_year,end_year + 1)
    month_range=range(1, 13)
    count_rules = []
    count_proprules = []
    count_notices = []
    count_presdocs = []
    count_unknown = []
    count_total = []
    today = datetime.date.today()    
        
    for y in year_range:
        start_date=datetime.date(y,1,1)
        end_date=datetime.date(y,12,31)
        year_qset = qset.filter(publication_date__range=(start_date, end_date))
        count_rules.append(year_qset.filter(document_type='Rule').count())
        count_proprules.append(year_qset.filter(document_type='Proposed Rule').count())
        count_notices.append(year_qset.filter(document_type='Notice').count())
        count_presdocs.append(year_qset.filter(document_type='Presidential Document').count())
        count_unknown.append(year_qset.filter(document_type='Document of Unknown Type').count())
        count_total.append(count_unknown[-1] + count_presdocs[-1] + count_rules[-1] + count_proprules[-1] + count_notices[-1])
    #for i in [count_rules, count_proprules, count_notices, count_presdocs, count_unknown, count_total]:
        #print i

    # set up chart axis parameters
    largest_y = max(count_total)
    left_axis_step = int(pow(10, int(log10(largest_y)))) 
    max_y = (int(largest_y / left_axis_step) * left_axis_step) + (left_axis_step * 2)
    left_axis = range(0, max_y + left_axis_step, left_axis_step)
    left_axis[0] = ""
    bottom_axis = year_range

    # generate chart url
    chart = SimpleLineChart(sizex, sizey, y_range=[0, max_y])
    chart.set_axis_labels(Axis.LEFT, left_axis)
    chart.set_axis_labels(Axis.BOTTOM, bottom_axis)
    chart.set_grid(0, max(10, int(left_axis_step / 10)), 5, 5)
    chart.set_colours(['0000FF', '00FF00', 'FF0000', 'FFFF00', '00FFFF', 'aaaaaa'])
    chart.set_legend(['Rules', 'Proposed Rules', 'Notices', 'Presidential Docs', 'Unknown', 'Total'])
    chart.add_data(count_rules)
    chart.add_data(count_proprules)
    chart.add_data(count_notices)
    chart.add_data(count_presdocs)
    chart.add_data(count_unknown)
    chart.add_data(count_total)
    chart_url = chart.get_url()
       
    return chart_url
开发者ID:esbenson,项目名称:pbearfrfeed,代码行数:56,代码来源:charts.py


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