How to use the leather.Axis function in leather

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_chart.py View on Github external
def test_set_axes(self):
        chart = leather.Chart()
        chart.set_x_axis(leather.Axis(ticks=[0, 4, 8]))
        chart.set_y_axis(leather.Axis(ticks=[3, 6, 9]))
        chart.add_dots(self.data1)

        svg = self.render_chart(chart)

        self.assertTickLabels(svg, 'left', ['3', '6', '9'])
        self.assertTickLabels(svg, 'bottom', ['4', '8', '0'])
github wireservice / leather / tests / test_axis.py View on Github external
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'])
github wireservice / leather / tests / test_axis.py View on Github external
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+'])
github wireservice / leather / tests / test_chart.py View on Github external
def test_set_axes(self):
        chart = leather.Chart()
        chart.set_x_axis(leather.Axis(ticks=[0, 4, 8]))
        chart.set_y_axis(leather.Axis(ticks=[3, 6, 9]))
        chart.add_dots(self.data1)

        svg = self.render_chart(chart)

        self.assertTickLabels(svg, 'left', ['3', '6', '9'])
        self.assertTickLabels(svg, 'bottom', ['4', '8', '0'])
github OpenNewsLabs / onechart-twelvechartinglibraries / leather / scatterplot.py View on Github external
def size_dot_by_area(x, y, i):
        return math.sqrt(int(data[i]['population'])) / 1000

    dots = leather.Dots('rgba(0,0,0,0.5)', radius=size_dot_by_area)

    series = leather.Series(
        data,
        dots,
        x=lambda row, i: math.log(float(row['income'])),
        y=lambda row, i: float(row['health']))

    chart.add_series(series)

chart.set_x_axis(leather.Axis(name='Log GDP per capita'))
chart.set_y_axis(leather.Axis(name='Life expectancy in years'))
chart.to_svg('chart.svg')
github OpenNewsLabs / onechart-twelvechartinglibraries / leather / scatterplot.py View on Github external
data = list(reader)
    
    def size_dot_by_area(x, y, i):
        return math.sqrt(int(data[i]['population'])) / 1000

    dots = leather.Dots('rgba(0,0,0,0.5)', radius=size_dot_by_area)

    series = leather.Series(
        data,
        dots,
        x=lambda row, i: math.log(float(row['income'])),
        y=lambda row, i: float(row['health']))

    chart.add_series(series)

chart.set_x_axis(leather.Axis(name='Log GDP per capita'))
chart.set_y_axis(leather.Axis(name='Life expectancy in years'))
chart.to_svg('chart.svg')