def GetChart(self, *args, **kwargs):
     return google_chart_api.LineChart(*args, **kwargs)
 def setUp(self):
     self.chart = google_chart_api.LineChart([1, 2, 3])
     self.auto_scale = formatters.AutoScale(buffer=0)
Exemplo n.º 3
0
# See the License for the specific language governing permissions and
# limitations under the License.

from graphy.backends import google_chart_api
from graphy import formatters
from graphy import line_chart

# Average monthly temperature
sunnyvale = [49, 52, 55, 58, 62, 66, 68, 68, 66, 61, 54, 48, 49]
chicago = [25, 31, 39, 50, 60, 70, 75, 74, 66, 55, 42, 30, 25]

print '<html>'
print '<head><title>Yearly temperature in Chicago and Sunnyvale</title></head>'
print '<body>'
print '<h2>Yearly temperature in Chicago and Sunnyvale</h2>'
chart = google_chart_api.LineChart()
chart.AddLine(sunnyvale)
chart.AddLine(chicago, pattern=line_chart.LineStyle.DASHED)
print chart.display.Img(250, 100)

print "<p>But that's hard to understand.  We need labels:</p>"
chart.bottom.min = 0
chart.bottom.max = 12
chart.bottom.labels = ['Jan', 'Apr', 'Jul', 'Sep', 'Jan']
chart.bottom.label_positions = [0, 3, 6, 9, 12]

chart.left.min = 0
chart.left.max = 80
chart.left.labels = [10, 32, 50, 70]
chart.left.label_positions = [10, 32, 50, 70]
chart.data[0].label = 'Sunnyvale'
 def setUp(self):
     self.chart = google_chart_api.LineChart()
     self.chart.formatters.append(formatters.InlineLegend)
     self.chart.AddLine([1, 2, 3], label='A')
     self.chart.AddLine([4, 5, 6], label='B')
     self.chart.auto_scale.buffer = 0
Exemplo n.º 5
0
	if x is 0:
		daycount["Monday"] += 1
	elif x is 1:
		daycount["Tuesday"] += 1
	elif x is 2:
		daycount["Wednesday"] += 1
	elif x is 3:
		daycount["Thursday"] += 1
	elif x is 4:
		daycount["Friday"] += 1
	elif x is 5:
		daycount["Saturday"] += 1
	elif x is 6:
		daycount["Sunday"] += 1
					
day_chart = google_chart_api.LineChart(daycount.values())
day_chart.bottom.labels = daycount.keys()
day_url = day_chart.display.Url(400,100)
print "\nLink to graph of Activity Per Day:"
print day_url

try:
  webbrowser.open_new(day_url)
except:
  print("Couldn't open browser")
 
#plat time of the day
hours = [y.hour for y in dates]
hourcount = OrderedDict()
for x in range(0,24):
	hourcount[str(x)] = 0
Exemplo n.º 6
0
 def setUp(self):
     self.chart = google_chart_api.LineChart()
Exemplo n.º 7
0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from graphy.backends import google_chart_api

print '<html>'
print '<h2>Oh no!  Traffic is dropping off, something must be wrong!</h2>'
traffic = [578, 579, 580, 550, 545, 552]
chart = google_chart_api.LineChart(traffic)
print chart.display.Img(100, 50)

print """<p>But wait, that was automatically scaled to fill the entire
         vertical range.  We should scale from zero instead:</p>"""

chart.left.min = 0
chart.left.max = 600
print chart.display.Img(100, 50)

print """<p>Also, maybe some labels would help out here:</p>"""
chart.left.labels = range(0, 601, 200)
chart.left.label_positions = chart.left.labels
print chart.display.Img(100, 50)
Exemplo n.º 8
0
#!/usr/bin/python2.4
#
# Copyright 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from graphy.backends import google_chart_api

monthly_rainfall = [3.2, 3.2, 2.7, 0.9, 0.4, 0.1, 0.0, 0.0, 0.2, 0.9, 1.8, 2.3]
months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split()

chart = google_chart_api.LineChart(monthly_rainfall)
chart.bottom.labels = months
img = chart.display.Img(400, 100)
print '<html><h1>Monthly Rainfall for Sunnyvale, CA</h1>%s</html>' % img