1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
import leather
class TestChart(leather.LeatherTestCase):
def setUp(self):
self.data = [
(0, 3),
(4, 5),
(7, 9),
(10, 4)
]
def test_ticks(self):
chart = leather.Chart()
chart.add_dots(self.data)
axis = leather.Axis(ticks=[-12, 0, 17, 44, 87, 99])
chart.set_x_axis(axis)
svg = self.render_chart(chart)
self.assertTickLabels(svg, 'bottom', ['-12', '17', '44', '87', '99', '0'])
def test_tick_formatter(self):
chart = leather.Chart()
chart.add_dots(self.data)
def test_formatter(value, i, count):
return '%i+' % (value * 10)
axis = leather.Axis(tick_formatter=test_formatter)
chart.set_x_axis(axis)
svg = self.render_chart(chart)
self.assertTickLabels(svg, 'bottom', ['25+', '50+', '75+', '100+', '0+'])
|