Exemplo n.º 1
0
def displayrankedItemwithBidsPieChart(request):
    page_title='Pie Chart on Ranked Item'
    year=stat.getYear()
    itemBidDict, bidtotalSum = stat.createItemIDBidCountDict()
    top_ten_dict = stat.sortedItemDictionary(itemBidDict)
    itemobjDict = {}	
    for key,value in top_ten_dict:
        itemObj = get_object_or_404(Item, pk=key)
        itemobjDict[itemObj.name] = value

    fig=Figure()
    ax=fig.add_subplot(111)

    title='Top Ten ranked items with the highest bids ({0})'.format(year)
    fig.suptitle(title, fontsize=14)
    try:
        x = itemobjDict.values()
        labels = itemobjDict.keys()
        ax.pie(x, labels=labels);
    except ValueError:
        pass
    canvas = FigureCanvas(fig)
    response = HttpResponse(content_type='image/png')
    canvas.print_png(response)
    return response
Exemplo n.º 2
0
def rankingItemBasedOnBids(request, template_name="stats/bidsonitems.html"):
    page_title="Ranking Item based on Bids Report"
    itemBidDict, bidtotalSum = stat.createItemIDBidCountDict()
    top_ten_dict = stat.sortedItemDictionary(itemBidDict)
    bidSum=0
    valuelist=[]
    itemobjDict = {}	
    mean ="N/A"
    variance="N/A"
    for key,value in top_ten_dict:
        itemObj = get_object_or_404(Item, pk=key)
        itemobjDict[itemObj] = value
        bidSum+=value
        valuelist.append(value)
    percentTotal= 0.00
    try:
        percentTotal= (bidSum / bidtotalSum) * 100
        mean = "{0:.2f}".format(thinkstats.Mean(valuelist))
        variance= "{0:.2f}".format(thinkstats.Var(valuelist))
    except 	ZeroDivisionError:
        pass
    percentTotalString="{0:.2f}".format(percentTotal)
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))