예제 #1
0
class App(object):
    CHART_TYPES = (
        VerticalBarChart,
        HorizontalBarChart,
        LineChart,
        PieChart,
        ScatterplotChart,
        StackedVerticalBarChart,
        StackedHorizontalBarChart,
    )

    (VERTICAL_BAR_TYPE, HORIZONTAL_BAR_TYPE, LINE_TYPE, PIE_TYPE, SCATTER_TYPE,
     STACKED_VERTICAL_BAR_TYPE,
     STACKED_HORIZONTAL_BAR_TYPE) = range(len(CHART_TYPES))

    OPTIONS_TYPES = dict(
        axis=dict(
            lineWidth=float,
            lineColor=str,
            tickSize=float,
            labelColor=str,
            labelFont=str,
            labelFontSize=int,
            labelWidth=float,
            tickFont=str,
            tickFontSize=int,
            x=dict(
                hide=bool,
                ticks=list,
                tickCount=int,
                tickPrecision=int,
                range=list,
                rotate=float,
                label=unicode,
                interval=int,
            ),
            y=dict(
                hide=bool,
                ticks=list,
                tickCount=int,
                tickPrecision=int,
                range=list,
                rotate=float,
                label=unicode,
                interval=int,
            ),
        ),
        background=dict(
            hide=bool,
            baseColor=str,
            chartColor=str,
            lineColor=str,
            lineWidth=float,
        ),
        legend=dict(opacity=float,
                    borderColor=str,
                    hide=bool,
                    position=dict(
                        top=int,
                        left=int,
                        bottom=int,
                        right=int,
                    )),
        padding=dict(
            left=int,
            right=int,
            top=int,
            bottom=int,
        ),
        stroke=dict(
            color=str,
            hide=bool,
            shadow=bool,
            width=int,
        ),
        yvals=dict(show=bool, inside=bool, fontSize=int, fontColor=str),
        fillOpacity=float,
        shouldFill=bool,
        barWidthFillFraction=float,
        pieRadius=float,
        colorScheme=dict(
            name=str,
            args=dict(
                initialColor=str,
                colors=list,
            ),
        ),
        title=unicode,
        titleFont=str,
        titleFontSize=int,
    )

    def __init__(self):
        self.gui = GUI(self)

    def run(self):
        self.gui.run()

    def get_default_options(self):
        return DEFAULT_OPTIONS

    def get_chart(self, datasets, options, chart_type, width, height):
        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
        chart_factory = self.CHART_TYPES[chart_type]
        chart = chart_factory(surface, options)
        chart.addDataset(datasets)
        chart.render()
        return chart
예제 #2
0
class App(object):
    CHART_TYPES = (
        VerticalBarChart,
        HorizontalBarChart,
        LineChart,
        PieChart,
        ScatterplotChart,
        StackedVerticalBarChart,
        StackedHorizontalBarChart,
        )

    (VERTICAL_BAR_TYPE,
     HORIZONTAL_BAR_TYPE,
     LINE_TYPE,
     PIE_TYPE,
     SCATTER_TYPE,
     STACKED_VERTICAL_BAR_TYPE,
     STACKED_HORIZONTAL_BAR_TYPE) = range(len(CHART_TYPES))

    OPTIONS_TYPES = dict(
        axis=dict(
            lineWidth=float,
            lineColor=str,
            tickSize=float,
            labelColor=str,
            labelFont=str,
            labelFontSize=int,
            labelWidth=float,
            tickFont=str,
            tickFontSize=int,
            x=dict(
                hide=bool,
                ticks=list,
                tickCount=int,
                tickPrecision=int,
                range=list,
                rotate=float,
                label=unicode,
                interval=int,
            ),
            y=dict(
                hide=bool,
                ticks=list,
                tickCount=int,
                tickPrecision=int,
                range=list,
                rotate=float,
                label=unicode,
                interval=int,
            ),
        ),
        background=dict(
            hide=bool,
            baseColor=str,
            chartColor=str,
            lineColor=str,
            lineWidth=float,
        ),
        legend=dict(
            opacity=float,
            borderColor=str,
            hide=bool,
            position=dict(
                top=int,
                left=int,
                bottom=int,
                right=int,
            )
        ),
        padding=dict(
            left=int,
            right=int,
            top=int,
            bottom=int,
        ),
        stroke=dict(
            color=str,
            hide=bool,
            shadow=bool,
            width=int,
        ),
        yvals=dict(
            show=bool,
            inside=bool,
            fontSize=int,
            fontColor=str
        ),
        fillOpacity=float,
        shouldFill=bool,
        barWidthFillFraction=float,
        pieRadius=float,
        colorScheme=dict(
            name=str,
            args=dict(
                initialColor=str,
                colors=list,
            ),
        ),
        title=unicode,
        titleFont=str,
        titleFontSize=int,
    )

    def __init__(self):
        self.gui = GUI(self)

    def run(self):
        self.gui.run()

    def get_default_options(self):
        return DEFAULT_OPTIONS

    def get_chart(self, datasets, options, chart_type, width, height):
        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
        chart_factory = self.CHART_TYPES[chart_type]
        chart = chart_factory(surface, options)
        chart.addDataset(datasets)
        chart.render()
        return chart
예제 #3
0
 def __init__(self):
     self.gui = GUI(self)
예제 #4
0
 def __init__(self):
     self.gui = GUI(self)