Ejemplo n.º 1
0
def GetGLineUrl(plot_list, width=600, height=500):
  """Get Google line chart url string.

  Args:
    plot_list: Numeric number list.
               A list also can contain negative value elements.
    width: Image width when it is rendered in web browser.
    height: Image height when it is rendered in web browseor.

  Returns:
    An url string that will create chart image in google chart.
  """
  max_y = max(plot_list)
  min_y = min(plot_list)
  
  gchart = GChart()
  gchart.type('line')
  gchart.dataset(plot_list)
  
  gchart.size(width, height)
  
  gchart.axes.type('y')
  gchart.axes.range(0, min_y, max_y)
  gchart.scale(min_y, max_y)
  
  return str(gchart)
Ejemplo n.º 2
0
def simple():
   G = GChart()
   # Set the chart type, either Google API type or regular name
   G.type('pie')
   # Update the chart's dataset, can be two dimensional or contain string data
   G.dataset('helloworld')
   # Set the size of the chart, default is 300x150
   G.size(250, 100) 
   print G
Ejemplo n.º 3
0
 def simple(self):
     # Instantiate the GChart instance, this is all you will need for making charts
     # GChart(type=None, dataset=None), see the doc for more
     G = GChart()
     # Set the chart type, either Google API type or regular name
     G.type('pie')
     # Update the chart's dataset, can be two dimensional and contain string data
     G.dataset('helloworld')
     # Set the size of the chart, default is 300x150
     G.size(250, 100)
     return G
Ejemplo n.º 4
0
def practice_list(request, club = None):

    club = get_object_or_404(Club, Slug = club)
    practices = club.practice_set.all().annotate(NumPeople = Count('person')).order_by('-Date')
    if practices.count() > 10:
        chart = GChart(ctype = 'line')
        data = sliding_window(practices)
        chart.dataset(data[:500]).axes.type('xy')
    

    if request.method == 'POST':
        form = PracticeModelForm(request.POST)
        new_practice = form.save(commit = False)
        new_practice.Club = club
        new_practice.save()
        return HttpResponseRedirect(new_practice.get_absolute_url())
            
    else:
        form = PracticeModelForm()

    return render_to_response('Dojo/Practice_object_list.html', locals(),
                              context_instance = RequestContext(request))