figpack 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of figpack might be problematic. Click here for more details.

@@ -2,11 +2,11 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
5
+ <link rel="icon" type="image/png" href="./assets/neurosift-logo-CLsuwLMO.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Vite + React + TS</title>
8
- <script type="module" crossorigin src="./assets/index-BrKvMWud.js"></script>
9
- <link rel="stylesheet" crossorigin href="./assets/index-CeWL3OeJ.css">
7
+ <title>figpack figure</title>
8
+ <script type="module" crossorigin src="./assets/index-CMzZutX1.js"></script>
9
+ <link rel="stylesheet" crossorigin href="./assets/index-BA_v5Jep.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="root"></div>
figpack/views/Box.py ADDED
@@ -0,0 +1,68 @@
1
+ """
2
+ Box view for figpack - a layout container that handles other views
3
+ """
4
+
5
+ import zarr
6
+ from typing import List, Literal, Optional, Dict, Any
7
+ from ..core.figpack_view import FigpackView
8
+ from .LayoutItem import LayoutItem
9
+
10
+
11
+ class Box(FigpackView):
12
+ """
13
+ A layout container view that arranges other views in horizontal or vertical layouts
14
+ """
15
+
16
+ def __init__(
17
+ self,
18
+ *,
19
+ direction: Literal["horizontal", "vertical"] = "vertical",
20
+ show_titles: bool = True,
21
+ items: List[LayoutItem],
22
+ ):
23
+ """
24
+ Initialize a Box layout view
25
+
26
+ Args:
27
+ direction: Layout direction - "horizontal" or "vertical"
28
+ show_titles: Whether to show titles for layout items
29
+ items: List of LayoutItem objects containing the child views
30
+ """
31
+ self.direction = direction
32
+ self.show_titles = show_titles
33
+ self.items = items
34
+
35
+ def _write_to_zarr_group(self, group: zarr.Group) -> None:
36
+ """
37
+ Write the Box layout data to a Zarr group
38
+
39
+ Args:
40
+ group: Zarr group to write data into
41
+ """
42
+ # Set the view type
43
+ group.attrs["view_type"] = "Box"
44
+
45
+ # Set layout properties
46
+ group.attrs["direction"] = self.direction
47
+ group.attrs["show_titles"] = self.show_titles
48
+
49
+ # Create a list to store item metadata
50
+ items_metadata = []
51
+
52
+ # Process each layout item
53
+ for i, item in enumerate(self.items):
54
+ item_name = f"item_{i}"
55
+
56
+ # Store item metadata
57
+ item_metadata = item.to_dict()
58
+ item_metadata["name"] = item_name
59
+ items_metadata.append(item_metadata)
60
+
61
+ # Create a subgroup for this item's view
62
+ item_group = group.create_group(item_name)
63
+
64
+ # Recursively write the child view to the subgroup
65
+ item.view._write_to_zarr_group(item_group)
66
+
67
+ # Store the items metadata
68
+ group.attrs["items"] = items_metadata
@@ -0,0 +1,55 @@
1
+ """
2
+ LayoutItem class for figpack Box view - represents an item in a layout container
3
+ """
4
+
5
+ from typing import Optional, Union
6
+ from ..core.figpack_view import FigpackView
7
+
8
+
9
+ class LayoutItem:
10
+ """
11
+ Represents an item in a Box layout with positioning and sizing constraints
12
+ """
13
+
14
+ def __init__(
15
+ self,
16
+ view: FigpackView,
17
+ *,
18
+ stretch: Optional[float] = None,
19
+ min_size: Optional[float] = None,
20
+ max_size: Optional[float] = None,
21
+ title: Optional[str] = None,
22
+ collapsible: bool = False,
23
+ ):
24
+ """
25
+ Initialize a LayoutItem
26
+
27
+ Args:
28
+ view: The figpack view to be contained in this layout item
29
+ stretch: Stretch factor for flexible sizing (relative to other stretch items)
30
+ min_size: Minimum size in pixels
31
+ max_size: Maximum size in pixels
32
+ title: Title to display for this item
33
+ collapsible: Whether this item can be collapsed
34
+ """
35
+ self.view = view
36
+ self.stretch = stretch
37
+ self.min_size = min_size
38
+ self.max_size = max_size
39
+ self.title = title
40
+ self.collapsible = collapsible
41
+
42
+ def to_dict(self) -> dict:
43
+ """
44
+ Convert the LayoutItem to a dictionary for serialization
45
+
46
+ Returns:
47
+ Dictionary representation of the LayoutItem
48
+ """
49
+ return {
50
+ "stretch": self.stretch,
51
+ "min_size": self.min_size,
52
+ "max_size": self.max_size,
53
+ "title": self.title,
54
+ "collapsible": self.collapsible,
55
+ }
@@ -0,0 +1,66 @@
1
+ """
2
+ Splitter view for figpack - a resizable split layout container
3
+ """
4
+
5
+ import zarr
6
+ from typing import Literal
7
+ from ..core.figpack_view import FigpackView
8
+ from .LayoutItem import LayoutItem
9
+
10
+
11
+ class Splitter(FigpackView):
12
+ """
13
+ A resizable split layout container that divides space between two items
14
+ """
15
+
16
+ def __init__(
17
+ self,
18
+ *,
19
+ direction: Literal["horizontal", "vertical"] = "vertical",
20
+ item1: LayoutItem,
21
+ item2: LayoutItem,
22
+ split_pos: float = 0.5,
23
+ ):
24
+ """
25
+ Initialize a Splitter layout view
26
+
27
+ Args:
28
+ direction: Split direction - "horizontal" or "vertical"
29
+ item1: First LayoutItem (left/top)
30
+ item2: Second LayoutItem (right/bottom)
31
+ split_pos: Initial split position as fraction (0.0 to 1.0)
32
+ """
33
+ self.direction = direction
34
+ self.item1 = item1
35
+ self.item2 = item2
36
+ self.split_pos = max(0.1, min(0.9, split_pos)) # Clamp between 0.1 and 0.9
37
+
38
+ def _write_to_zarr_group(self, group: zarr.Group) -> None:
39
+ """
40
+ Write the Splitter layout data to a Zarr group
41
+
42
+ Args:
43
+ group: Zarr group to write data into
44
+ """
45
+ # Set the view type
46
+ group.attrs["view_type"] = "Splitter"
47
+
48
+ # Set layout properties
49
+ group.attrs["direction"] = self.direction
50
+ group.attrs["split_pos"] = self.split_pos
51
+
52
+ # Store item metadata
53
+ item1_metadata = self.item1.to_dict()
54
+ item1_metadata["name"] = "item1"
55
+ item2_metadata = self.item2.to_dict()
56
+ item2_metadata["name"] = "item2"
57
+
58
+ group.attrs["item1_metadata"] = item1_metadata
59
+ group.attrs["item2_metadata"] = item2_metadata
60
+
61
+ # Create subgroups for each item's view
62
+ item1_group = group.create_group("item1")
63
+ self.item1.view._write_to_zarr_group(item1_group)
64
+
65
+ item2_group = group.create_group("item2")
66
+ self.item2.view._write_to_zarr_group(item2_group)
@@ -0,0 +1,66 @@
1
+ """
2
+ TabLayout view for figpack - a tabbed layout container that handles other views
3
+ """
4
+
5
+ import zarr
6
+ from typing import List, Optional, Dict, Any
7
+ from ..core.figpack_view import FigpackView
8
+ from .TabLayoutItem import TabLayoutItem
9
+
10
+
11
+ class TabLayout(FigpackView):
12
+ """
13
+ A tabbed layout container view that arranges other views in tabs
14
+ """
15
+
16
+ def __init__(
17
+ self,
18
+ *,
19
+ items: List[TabLayoutItem],
20
+ initial_tab_index: int = 0,
21
+ ):
22
+ """
23
+ Initialize a TabLayout view
24
+
25
+ Args:
26
+ items: List of TabLayoutItem objects containing the child views
27
+ initial_tab_index: Index of the initially selected tab (default: 0)
28
+ """
29
+ self.items = items
30
+ self.initial_tab_index = (
31
+ max(0, min(initial_tab_index, len(items) - 1)) if items else 0
32
+ )
33
+
34
+ def _write_to_zarr_group(self, group: zarr.Group) -> None:
35
+ """
36
+ Write the TabLayout data to a Zarr group
37
+
38
+ Args:
39
+ group: Zarr group to write data into
40
+ """
41
+ # Set the view type
42
+ group.attrs["view_type"] = "TabLayout"
43
+
44
+ # Set layout properties
45
+ group.attrs["initial_tab_index"] = self.initial_tab_index
46
+
47
+ # Create a list to store item metadata
48
+ items_metadata = []
49
+
50
+ # Process each tab item
51
+ for i, item in enumerate(self.items):
52
+ item_name = f"tab_{i}"
53
+
54
+ # Store item metadata
55
+ item_metadata = item.to_dict()
56
+ item_metadata["name"] = item_name
57
+ items_metadata.append(item_metadata)
58
+
59
+ # Create a subgroup for this tab's view
60
+ item_group = group.create_group(item_name)
61
+
62
+ # Recursively write the child view to the subgroup
63
+ item.view._write_to_zarr_group(item_group)
64
+
65
+ # Store the items metadata
66
+ group.attrs["items"] = items_metadata
@@ -0,0 +1,39 @@
1
+ """
2
+ TabLayoutItem class for figpack TabLayout view - represents a tab in a tab layout container
3
+ """
4
+
5
+ from typing import Optional
6
+ from ..core.figpack_view import FigpackView
7
+
8
+
9
+ class TabLayoutItem:
10
+ """
11
+ Represents a tab item in a TabLayout with a label and view
12
+ """
13
+
14
+ def __init__(
15
+ self,
16
+ view: FigpackView,
17
+ *,
18
+ label: str,
19
+ ):
20
+ """
21
+ Initialize a TabLayoutItem
22
+
23
+ Args:
24
+ view: The figpack view to be contained in this tab
25
+ label: The label text to display on the tab
26
+ """
27
+ self.view = view
28
+ self.label = label
29
+
30
+ def to_dict(self) -> dict:
31
+ """
32
+ Convert the TabLayoutItem to a dictionary for serialization
33
+
34
+ Returns:
35
+ Dictionary representation of the TabLayoutItem
36
+ """
37
+ return {
38
+ "label": self.label,
39
+ }
@@ -6,7 +6,7 @@ import numpy as np
6
6
  from typing import Optional, List, Dict, Any
7
7
 
8
8
  import zarr
9
- from .figpack_view import FigpackView
9
+ from ..core.figpack_view import FigpackView
10
10
 
11
11
 
12
12
  class TimeseriesGraph(FigpackView):
@@ -21,6 +21,7 @@ class TimeseriesGraph(FigpackView):
21
21
  y_range: Optional[List[float]] = None,
22
22
  hide_x_gridlines: bool = False,
23
23
  hide_y_gridlines: bool = False,
24
+ y_label: str = "",
24
25
  ):
25
26
  """
26
27
  Initialize a TimeseriesGraph
@@ -30,11 +31,13 @@ class TimeseriesGraph(FigpackView):
30
31
  y_range: Y-axis range as [min, max]
31
32
  hide_x_gridlines: Whether to hide x-axis gridlines
32
33
  hide_y_gridlines: Whether to hide y-axis gridlines
34
+ y_label: Label for the y-axis
33
35
  """
34
36
  self.legend_opts = legend_opts or {}
35
37
  self.y_range = y_range
36
38
  self.hide_x_gridlines = hide_x_gridlines
37
39
  self.hide_y_gridlines = hide_y_gridlines
40
+ self.y_label = y_label
38
41
 
39
42
  # Internal storage for series data
40
43
  self._series = []
@@ -138,6 +141,7 @@ class TimeseriesGraph(FigpackView):
138
141
  group.attrs["y_range"] = self.y_range
139
142
  group.attrs["hide_x_gridlines"] = self.hide_x_gridlines
140
143
  group.attrs["hide_y_gridlines"] = self.hide_y_gridlines
144
+ group.attrs["y_label"] = self.y_label
141
145
 
142
146
  # series names
143
147
  group.attrs["series_names"] = [series.name for series in self._series]
@@ -0,0 +1,6 @@
1
+ from .TimeseriesGraph import TimeseriesGraph
2
+ from .Box import Box
3
+ from .Splitter import Splitter
4
+ from .TabLayout import TabLayout
5
+ from .LayoutItem import LayoutItem
6
+ from .TabLayoutItem import TabLayoutItem
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: figpack
3
+ Version: 0.1.2
4
+ Summary: A Python package for creating shareable, interactive visualizations in the browser
5
+ Author-email: Jeremy Magland <jmagland@flatironinstitute.org>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/magland/figpack
8
+ Project-URL: Repository, https://github.com/magland/figpack
9
+ Project-URL: Documentation, https://github.com/magland/figpack#readme
10
+ Project-URL: Bug Tracker, https://github.com/magland/figpack/issues
11
+ Keywords: visualization,plotting,timeseries,interactive
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Scientific/Engineering :: Visualization
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: numpy
28
+ Requires-Dist: zarr
29
+ Requires-Dist: requests
30
+ Dynamic: license-file
31
+
32
+ # figpack
33
+
34
+ A Python package for creating shareable, interactive visualizations in the browser.
35
+
36
+ ## Overview
37
+
38
+ figpack enables you to create interactive data visualizations that can be displayed in a web browser and optionally shared online. The package focuses on timeseries data visualization with support for complex, nested layouts.
39
+
40
+ ### Key Features
41
+
42
+ - **Interactive timeseries graphs** with line series, markers, and interval plots
43
+ - **Flexible layout system** with boxes, splitters, and tab layouts
44
+ - **Web-based rendering** that works in any modern browser
45
+ - **Shareable visualizations** that can be uploaded and shared via URLs
46
+ - **Zarr-based data storage** for efficient handling of large datasets
47
+
48
+ ## Installation
49
+
50
+ Install figpack using pip:
51
+
52
+ ```bash
53
+ pip install figpack
54
+ ```
55
+
56
+ ## Quick Start
57
+
58
+ ```python
59
+ import numpy as np
60
+ import figpack.views as vv
61
+
62
+ # Create a timeseries graph
63
+ graph = vv.TimeseriesGraph(y_label="Signal")
64
+
65
+ # Add some data
66
+ t = np.linspace(0, 10, 1000)
67
+ y = np.sin(2 * np.pi * t)
68
+ graph.add_line_series(name="sine wave", t=t, y=y, color="blue")
69
+
70
+ # Display the visualization
71
+ graph.show(open_in_browser=True)
72
+ ```
73
+
74
+ ## Examples
75
+
76
+ See the `examples/` directory.
77
+
78
+ ## Usage Modes
79
+
80
+ ### Local Development
81
+
82
+ ```python
83
+ view.show(open_in_browser=True)
84
+ ```
85
+
86
+ ### Sharing Online
87
+
88
+ Set the `FIGPACK_UPLOAD_PASSCODE` environment variable and use:
89
+
90
+ ```python
91
+ view.show(upload=True, open_in_browser=True)
92
+ ```
93
+
94
+ ### Development Mode
95
+
96
+ Set `_dev=True` in the call to show() to enable development mode, which allows for live updates and debugging with figpack-gui.
97
+
98
+ ## License
99
+
100
+ Apache-2.0
101
+
102
+ ## Contributing
103
+
104
+ Visit the [GitHub repository](https://github.com/magland/figpack) for issues, contributions, and the latest updates.
@@ -0,0 +1,23 @@
1
+ figpack/__init__.py,sha256=zhAgQ-c_tHum4Y7LBRlr4GLfEy8q65wgJdZwqGZNm4Y,199
2
+ figpack/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ figpack/core/_bundle_utils.py,sha256=9_-xsswlzweJtr5JqZd0KjsCwlQVGNww02Fk6sz0pU4,1911
4
+ figpack/core/_show_view.py,sha256=AZbo1o9xaTXOMijWaMs6gigaHnt9Lgh_ST7ZS7bvTIE,4269
5
+ figpack/core/_upload_bundle.py,sha256=mja1vDGHfgQjmAkJoAUeUxzeZKPRi43KbSmaYZYComM,15303
6
+ figpack/core/figpack_view.py,sha256=N6MO8LpAU8sZlunOE9Ql1SO0JRWrOKuTkeDEFHD2ZFk,2092
7
+ figpack/figpack-gui-dist/index.html,sha256=08fTqHlw35L4a-cxfzTZqS_5-GE90I91l-6eBc7AyrY,486
8
+ figpack/figpack-gui-dist/assets/index-BA_v5Jep.css,sha256=dMuKMrGiBZpHUW7kWUOqEE9TeFEsxyi-_n_vSNbBi1A,4011
9
+ figpack/figpack-gui-dist/assets/index-CMzZutX1.js,sha256=gJTOpfoYI-d5vF-fl4rbzrqq4v5K2uZMXZhGBpX3BSQ,1029067
10
+ figpack/figpack-gui-dist/assets/neurosift-logo-CLsuwLMO.png,sha256=g5m-TwrGh5f6-9rXtWV-znH4B0nHgc__0GWclRDLUHs,9307
11
+ figpack/views/Box.py,sha256=6o39JWSls2UscnNFQZXWr_15hdIOCnhanOQgbqMWfVU,2005
12
+ figpack/views/LayoutItem.py,sha256=XOdvyF9S_Ij1IwxIYOqt4Wk9_wddWTSoM2x5W4kZqTQ,1594
13
+ figpack/views/Splitter.py,sha256=E0mek7RgXtgxdGpFM0evCLtplGwAd70EMfmXX0pcd4o,2005
14
+ figpack/views/TabLayout.py,sha256=d2x2zWGKYdvukW14HOCiU-9C7-N1ED-a1HrRIpSM6Jg,1896
15
+ figpack/views/TabLayoutItem.py,sha256=dvNCdPcRDaDr8LDd8D3zfMudQFbkiAMF0Z7XVcpIhLM,879
16
+ figpack/views/TimeseriesGraph.py,sha256=de85xUz22CeQxslXds5tbTJaZ_tyJlXs5GPPEB-8Fh4,7468
17
+ figpack/views/__init__.py,sha256=nDlhgXI1UbkDyf9C0pT3Vc_sIzo6VV7Pisaics9Hciw,206
18
+ figpack-0.1.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
19
+ figpack-gui/node_modules/flatted/python/flatted.py,sha256=UYburBDqkySaTfSpntPCUJRxiBGcplusJM7ECX8FEgA,3860
20
+ figpack-0.1.2.dist-info/METADATA,sha256=-4QSoYwoRi7Nhebmj9y44V1PiLGuVbhewfHVEzL7mDc,3039
21
+ figpack-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ figpack-0.1.2.dist-info/top_level.txt,sha256=rnjeFJrho76QPJg3q-c9U7uUXz6KK5Ff5PPbPtGrk9s,20
23
+ figpack-0.1.2.dist-info/RECORD,,