Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize widget layout and properties #38

Open
3 tasks
DunklesArchipel opened this issue Nov 2, 2023 · 1 comment
Open
3 tasks

Customize widget layout and properties #38

DunklesArchipel opened this issue Nov 2, 2023 · 1 comment

Comments

@DunklesArchipel
Copy link

          Indeed it would be great if it would be possible to
  • adjust the scale of the plot (good to have for integration in a Jupyter Widget GUI, which could be launched via voila)
  • Add a plot title (when multiple time series plots are opened)
    • or at leas have axis labels

I figured that one has to modify by some means the template in the TimeSeries class. So a template, which allows drawing a rescaled plot with a title would look as follows.

template = Unicode(r"""
        <time-series v-slot="{ x, y }">
            <remote-component url="https://unpkg.com/[email protected]/dist/vue-plotly.umd.min.js" integrity="sha384-3YjbENL4Izchmbn7RCdWL5tHYGPP7fy2B/vzCgBd3corbolRfPgjimXK4JEwGpYg" :extract="library => library.Plotly" :props="{
                data: [{ x: [...x], y: [...y], type: 'scatter' }],
                'display-mode-bar': false,
                layout:{'width': 100, 'height': 240, 'title': 'A Fancy Plot'},
                        }" />
        </time-series>
        """).tag(sync=True)

Originally posted by @DunklesArchipel in #6 (comment)

@DunklesArchipel
Copy link
Author

I tried to implement it by adding an __init__ to the Timeseries class, where you could for example define the width and the height.
When you want to show the widget with

ts = TimeSeries() # this line does not throw an error
ts # this one does

one gets the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File C:\Miniconda3\envs\iok\lib\site-packages\IPython\core\formatters.py:973, in MimeBundleFormatter.__call__(self, obj, include, exclude)
    970     method = get_real_method(obj, self.print_method)
    972     if method is not None:
--> 973         return method(include=include, exclude=exclude)
    974     return None
    975 else:

File C:\Miniconda3\envs\iok\lib\site-packages\ipywidgets\widgets\widget.py:811, in Widget._repr_mimebundle_(self, **kwargs)
    799 data = {
    800     'text/plain': plaintext,
    801 }
    802 if self._view_name is not None:
    803     # The 'application/vnd.jupyter.widget-view+json' mimetype has not been registered yet.
    804     # See the registration process and naming convention at
    805     # http://tools.ietf.org/html/rfc6838
    806     # and the currently registered mimetypes at
    807     # http://www.iana.org/assignments/media-types/media-types.xhtml.
    808     data['application/vnd.jupyter.widget-view+json'] = {
    809         'version_major': 2,
    810         'version_minor': 0,
--> 811         'model_id': self._model_id
    812     }
    813     return data

AttributeError: 'TimeSeries' object has no attribute '_model_id'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant