Example #1
0
    def render_widget(self, renderer: str = "altair", input_current_vis=""):
        """
        Generate a LuxWidget based on the LuxDataFrame

        Structure of widgetJSON:

        {

            'current_vis': {},
            'recommendation': [

                {

                    'action': 'Correlation',
                    'description': "some description",
                    'vspec': [

                            {Vega-Lite spec for vis 1},
                            {Vega-Lite spec for vis 2},
                            ...

                    ]

                },
                ... repeat for other actions

            ]

        }

        Parameters
        ----------
        renderer : str, optional
                Choice of visualization rendering library, by default "altair"
        input_current_vis : lux.LuxDataFrame, optional
                User-specified current vis to override default Current Vis, by default

        """
        check_import_lux_widget()
        import luxwidget

        widgetJSON = self.to_JSON(self._rec_info,
                                  input_current_vis=input_current_vis)
        return luxwidget.LuxWidget(
            currentVis=widgetJSON["current_vis"],
            recommendations=widgetJSON["recommendation"],
            intent=LuxDataFrame.intent_to_string(self._intent),
            message=self._message.to_html(),
            config={"plottingScale": lux.config.plotting_scale},
        )
Example #2
0
 def _repr_html_(self):
     from IPython.display import display
     check_import_lux_widget()
     import luxwidget
     if (self.data is None):
         raise Exception(
             "No data is populated in Vis. In order to generate data required for the vis, use the 'refresh_source' function to populate the Vis with a data source (e.g., vis.refresh_source(df))."
         )
     else:
         from lux.core.frame import LuxDataFrame
         widget = luxwidget.LuxWidget(
             currentVis=LuxDataFrame.current_vis_to_JSON([self]),
             recommendations=[],
             intent="",
             message="")
         display(widget)
Example #3
0
    def _repr_html_(self):
        self._widget = None
        from IPython.display import display
        from lux.core.frame import LuxDataFrame

        recommendation = {
            "action": "Vis List",
            "description": "Shows a vis list defined by the intent",
        }
        recommendation["collection"] = self._collection

        check_import_lux_widget()
        import luxwidget

        recJSON = LuxDataFrame.rec_to_JSON([recommendation])
        self._widget = luxwidget.LuxWidget(currentVis={}, recommendations=recJSON, intent="", message="")
        display(self._widget)