Changeset 45
- Timestamp:
- 23/08/08 06:46:04 (3 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
pygooglechart.py (modified) (4 diffs)
-
test/test.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pygooglechart.py
r44 r45 499 499 return ExtendedData 500 500 501 def _filter_none(self, data): 502 return [r for r in data if r is not None] 503 501 504 def data_x_range(self): 502 505 """Return a 2-tuple giving the minimum and maximum x-axis … … 504 507 """ 505 508 try: 506 lower = min([min(s) for type, s in self.annotated_data() 509 lower = min([min(self._filter_none(s)) 510 for type, s in self.annotated_data() 507 511 if type == 'x']) 508 upper = max([max(s) for type, s in self.annotated_data() 512 upper = max([max(self._filter_none(s)) 513 for type, s in self.annotated_data() 509 514 if type == 'x']) 510 515 return (lower, upper) … … 517 522 """ 518 523 try: 519 lower = min([min(s) for type, s in self.annotated_data() 524 lower = min([min(self._filter_none(s)) 525 for type, s in self.annotated_data() 520 526 if type == 'y']) 521 upper = max([max(s) + 1 for type, s in self.annotated_data() 527 upper = max([max(self._filter_none(s)) + 1 528 for type, s in self.annotated_data() 522 529 if type == 'y']) 523 530 return (lower, upper) … … 563 570 elif type == 'marker-size': 564 571 scale_range = (0, max(dataset)) 565 scaled_data.append([data_class.scale_value(v, scale_range) 566 for v in dataset]) 572 scaled_dataset = [] 573 for v in dataset: 574 if v is None: 575 scaled_dataset.append(None) 576 else: 577 scaled_dataset.append( 578 data_class.scale_value(v, scale_range)) 579 scaled_data.append(scaled_dataset) 567 580 return scaled_data 568 581 -
trunk/test/test.py
r44 r45 33 33 34 34 def assertChartURL(self, url, query): 35 return url.endswith(query)35 self.assertTrue(url.endswith(query)) 36 36 37 37 … … 99 99 100 100 101 class TestChartQR(TestBase): 101 class TestLineChart(TestBase): 102 103 def test_none_data(self): 104 chart = gc.SimpleLineChart(300, 100) 105 chart.add_data([1, 2, 3, None, 5]) 106 self.assertChartURL(chart.get_url(), \ 107 '?cht=lc&chs=300x100&chd=e:KrVVgA__1V') 108 109 class TestQRChart(TestBase): 102 110 103 111 def assertQRImage(self, chart, text):