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
File: Vis.py Project: smritim/lux
 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.luxDataFrame.LuxDataframe import LuxDataFrame
         widget = luxWidget.LuxWidget(
             currentVis=LuxDataFrame.current_view_to_JSON([self]),
             recommendations=[],
             intent="")
         display(widget)
Example #3
0
File: View.py Project: 19thyneb/lux
	def _repr_html_(self):
		from IPython.display import display
		check_import_lux_widget()
		import luxWidget
		if (self.data is None):
			raise Exception("No data populated in View. Use the 'load' function (e.g., view.load(df)) to populate the view with a data source.")
		else:
			from lux.luxDataFrame.LuxDataframe import LuxDataFrame
			# widget  = LuxDataFrame.render_widget(input_current_view=self,render_target="viewOnly")
			widget =  luxWidget.LuxWidget(
					currentView= LuxDataFrame.current_view_to_JSON([self]),
					recommendations=[],
					context={}
				)
			display(widget)
Example #4
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)
Example #5
0
 def render_widget(ldf="", renderer: str = "altair", input_current_view=""):
     """
     Generate a LuxWidget based on the LuxDataFrame
     
     Parameters
     ----------
     renderer : str, optional
         Choice of visualization rendering library, by default "altair"
     input_current_view : lux.LuxDataFrame, optional
         User-specified current vis to override default Current Vis, by default 
     """
     check_import_lux_widget()
     import luxWidget
     widgetJSON = ldf.to_JSON(input_current_view=input_current_view)
     return luxWidget.LuxWidget(
         currentVis=widgetJSON["current_vis"],
         recommendations=widgetJSON["recommendation"],
         intent=LuxDataFrame.intent_to_string(ldf.intent))
Example #6
0
	def _repr_html_(self):
		self.widget =  None
		from IPython.display import display
		from lux.luxDataFrame.LuxDataframe import LuxDataFrame
		# widget  = LuxDataFrame.render_widget(input_current_view=self,render_target="viewCollectionOnly")
		recommendation = {"action": "View Collection",
					  "description": "Shows a view collection defined by the context"}
		recommendation["collection"] = self

		check_import_lux_widget()
		import luxWidget
		recJSON = LuxDataFrame.rec_to_JSON([recommendation])
		self.widget =  luxWidget.LuxWidget(
				currentView={},
				recommendations=recJSON,
				context={}
			)
		display(self.widget)	
Example #7
0
    def _ipython_display_(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="",
                config={"plottingScale": lux.config.plotting_scale},
            )
            display(widget)