예제 #1
0
    def __init__(self, backend, dimensions, plots):
        """
        The primary constructor for Dashboard Widgets.

        :param backend:    A dc_dashboard.Backend.Backend object which provides the backing data for
                           the dashboard
        :param dimensions: A list of dc_dashboard.Dimension.Dimension objects describing cross filter
                           dimensions and groups used in the Dashboard
        :param plots:      A list of dc_dashboard.Plot.Plot/Layer objects describing the plots you
                           wish to use
        """
        self._backend = backend
        self._widget = DashboardWidget()

        self._widget.on_trait_change(lambda tmp: self.update_fitlers(),
                                     "filters")
        self._dimensions = {dim.name: dim for dim in dimensions}
        self._widget.dim_code = json.dumps(
            {dim.name: dim.get_json_object()
             for dim in dimensions})
        self._widget.layout = json.dumps(
            [plot.get_json_object() for plot in plots])
        self._filters = {}
        backend.register_dashboard(self)