Package: jupyterlab-autoplot
# JupyterLab Autoplot - IPython ComponentThis IPython extension is one of the three components that make up the [JupyterLab Autoplot extension](../README.md).## DevelopmentFirst you should follow the instructions [here](../autoplot-display#development) to install the JupyterLab extension component. Then, to apply the changes you have made to the IPython component:`sh cdipython-extension/python-mpip install-e. `You can then reload the extension in your JupyterLab instance with%reload_ext autoplot(you may need to restart the kernel first).### Description of classesEach of the following classes will be initialisedoncein theload_ipython_extension()function, and, where necessary, these instances will be accessible to each other. A diagram showing how these classes interact can be found at the bottom of this section.####ViewManagerThis class is the interface between the ipython interactions and the underlying models. Theredrawmethod is expected to be called in thepost_run_cellIPython hook. All the other methods implement one of the magic commands in autoplot.This class is a proxy for the actual models, which implement theViewinterface and will perform the actual work needed to integrate with dtale or mpd3.Whenredrawis called, the class instance will scan the variables in the notebook’s namespace, and look for pandas variables. The active view’supdate_variablesis called with the filtered variables. Then, thedrawmethod is called. Currently, only the active view’supdate_variablesis called; however, it may be argued that syncing the–freezeand–ignorecommands regardless of the current view is more natural. In that case, it will be useful to callupdate_variablesin all views, rather than just the active one. We need to get more user feedback to decide which is the best approach.####_make_magic(AutoplotMagic)The function_make_magicis a factory for instances ofAutoplotMagic, in fact, it builds the class itself so that it can easily define the list of possible views in the-vargument.AutoplotMagic extends [IPython.core.magic.Magics](https://ipython.readthedocs.io/en/stable/api/generated/IPython.core.magic.html#IPython.core.magic.Magics), and defines the magic commands described [here](../README.md#modifying-the-plot–traces). This class translates the user input into calls to theViewManager.####AutoplotDisplayThis class extends [ipywidgets.Output](https://ipywidgets.readthedocs.io/en/latest/examples/Output%20Widget.html), and defines the output area in which the graph is plotted. By matching the attributes_model_name,_model_module_versionetc. with the equivalents in the JupyterLab extension classAutoplotDisplayModel, the two become linked and the output captured by the IPython component will be displayed wherever the JupyterLab component is rendered.This class also defines thedata_idproperty, which is used by dtale to find out which instance (dataframe) is currently active.####ToastThis class defines some methods to dispatch DOM events that trigger toast notifications in the JupyterLab extension. These toasts change colour depending on their type, which can be one of ‘error’, ‘warning’, ‘success’ or ‘info’.#### Backends#####DtalerThis is the class that implements the View interface for the dtale integration. It’s responsible to keep track of the changed variables and dtale instances.#####PlotterModelandPlotterPlotterModelis the class that implements the View interface. It defines a dictionary of series names to their values, and one of dataframe names to the set of series names that were created from its columns. Thedrawmethod callsplotter.plot(), which initialises a matplotlib figure and axes, adds the defined traces to it and styles the figure.When a series is added, modified or deleted, the dictionaries will be updated and the appropriate calls will be made to thePlotterinstance.ThePlotterclass manages the collection ofTraceclass instances and handles the graph plotting. It has a number of public methods likeupdate_trace_series(),update_trace_colour()etc. which are used by thePlotterModelclass to modify the plot and/or traces.TheTraceclass stores a matplotlibLine2Dinstance and some details about how it should be displayed. Like thePlotterclass, it defines a number of public methods to allow it to be easily updated, likeupdate_series()orupdate_colour(). It also handles the downsampling of long series.