How to use leather - 10 common examples

To help you get started, we’ve selected a few leather examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wireservice / leather / tests / test_leather.py View on Github external
def test_line(self):
        chart = leather.Chart()
        chart.add_lines(self.data1)
        chart.add_lines(self.data2)
        chart.add_lines(self.data3)

        output = six.StringIO()
        chart.to_svg(output)
github wireservice / leather / tests / test_grid.py View on Github external
def test_add_one(self):
        chart1 = leather.Chart()
        chart1.add_dots(self.data1)

        chart2 = leather.Chart()
        chart2.add_dots(self.data2)

        grid = leather.Grid()
        grid.add_one(chart1)
        grid.add_one(chart2)

        svg = self.render_chart(grid)

        self.assertElementCount(svg, '.axis', 4)
        self.assertElementCount(svg, '.series', 2)
        self.assertElementCount(svg, '.dots', 2)
        self.assertElementCount(svg, 'circle', 9)
github wireservice / leather / tests / test_leather.py View on Github external
def test_column(self):
        chart = leather.Chart()
        chart.add_columns(self.data1)
        chart.add_columns(self.data2)
        chart.add_columns(self.data3)

        output = six.StringIO()
        chart.to_svg(output)
github wireservice / leather / tests / test_leather.py View on Github external
def test_dot(self):
        chart = leather.Chart()
        chart.add_dots(self.data1)
        chart.add_dots(self.data2)
        chart.add_dots(self.data3)

        output = six.StringIO()
        chart.to_svg(output)
github wireservice / leather / tests / test_grid.py View on Github external
def test_to_svg_file_handle(self):
        chart1 = leather.Chart()
        chart1.add_dots(self.data1)

        chart2 = leather.Chart()
        chart2.add_dots(self.data2)

        grid = leather.Grid()
        grid.add_many([chart1, chart2, chart1])

        with open('.test.svg', 'w') as f:
            grid.to_svg(f)

        self.assertTrue(os.path.exists(TEST_SVG))
github wireservice / leather / tests / test_chart.py View on Github external
def test_multiple_series(self):
        chart = leather.Chart()
        chart.add_dots(self.data1)
        chart.add_dots(self.data2)

        svg = self.render_chart(chart)

        self.assertElementCount(svg, '.axis', 2)
        self.assertElementCount(svg, '.series', 2)
        self.assertElementCount(svg, '.dots', 2)
        self.assertElementCount(svg, 'circle', 9)
github wireservice / leather / tests / test_chart.py View on Github external
def test_scale_domain_warning(self):
        chart = leather.Chart()
        chart.add_x_scale(4, 7)
        chart.add_y_scale(0, 20)
        chart.add_dots(self.data1)

        with warnings.catch_warnings():
            warnings.simplefilter('error')

            with self.assertRaises(UserWarning):
                self.render_chart(chart)
github wireservice / leather / tests / test_chart.py View on Github external
def test_to_svg_file_name(self):
        chart = leather.Chart()
        chart.add_dots(self.data1)

        chart.to_svg('.test.svg')

        self.assertTrue(os.path.exists(TEST_SVG))
github wireservice / leather / tests / test_shapes.py View on Github external
def test_linear(self):
        series = leather.Series([
            (0, 0),
            (5, 5),
            (10, 10)
        ])

        group = self.shape.to_svg(200, 100, self.linear, self.linear, series, self.palette)
        circles = list(group)

        self.assertEqual(len(circles), 3)
        self.assertEqual(float(circles[1].get('cx')), 100)
        self.assertEqual(float(circles[1].get('cy')), 50)
github wireservice / leather / tests / test_shapes.py View on Github external
def test_ordinal(self):
        series = leather.Series([
            ('foo', 0),
            ('bar', 5),
            ('bing', 10)
        ])

        group = self.shape.to_svg(200, 100, self.ordinal, self.linear, series, self.palette)
        circles = list(group)

        self.assertEqual(len(circles), 3)
        self.assertEqual(float(circles[1].get('cx')), 100)
        self.assertEqual(float(circles[1].get('cy')), 50)