figpack 0.1.0__py3-none-any.whl → 0.1.1__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.

@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Vite + React + TS</title>
8
- <script type="module" crossorigin src="./assets/index-BrKvMWud.js"></script>
8
+ <script type="module" crossorigin src="./assets/index-BW-ONVCL.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="./assets/index-CeWL3OeJ.css">
10
10
  </head>
11
11
  <body>
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: figpack
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A Python package for creating shareable, interactive visualizations
5
5
  Author-email: Jeremy Magland <jmagland@flatironinstitute.org>
6
6
  License: Apache-2.0
@@ -0,0 +1,22 @@
1
+ figpack/__init__.py,sha256=icrazTU8Tl3kP6NADES27gOnuQBLHGX3AuTwpkAjhwE,173
2
+ figpack/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ figpack/core/_bundle_utils.py,sha256=kVdM2aqfAptfAsE23AE0ku6EKPNhzRr8MCL8shMwuHU,1506
4
+ figpack/core/_show_view.py,sha256=uRHMS6Z6BFw2MjMw7pRVgKo6JiD9njDZU2k2ZqGxWjE,3250
5
+ figpack/core/_upload_view.py,sha256=9FSRxM98U-eKY4qQ7UM0zR6GSzs2ahNc_rYSsxSsRRk,11797
6
+ figpack/core/figpack_view.py,sha256=4YJdM97FAmEB45F6db472RPYWqXjxyd-QjccCufeor8,1602
7
+ figpack/figpack-gui-dist/index.html,sha256=84Yq2I7HbyfJDGf9xLjQn_oyp3B8lXY4z8ruxHpWNi8,466
8
+ figpack/figpack-gui-dist/assets/index-BW-ONVCL.js,sha256=Y06aUT27TSgU4930YMfmGgrHDGDdUhrpNNLXzRC8xiE,907414
9
+ figpack/figpack-gui-dist/assets/index-CeWL3OeJ.css,sha256=3ZqkZ-HTvHJ9vxqVBp7LrSjR0bKXlXEB9WduQg8hWew,1431
10
+ figpack/views/Box.py,sha256=6o39JWSls2UscnNFQZXWr_15hdIOCnhanOQgbqMWfVU,2005
11
+ figpack/views/LayoutItem.py,sha256=XOdvyF9S_Ij1IwxIYOqt4Wk9_wddWTSoM2x5W4kZqTQ,1594
12
+ figpack/views/Splitter.py,sha256=E0mek7RgXtgxdGpFM0evCLtplGwAd70EMfmXX0pcd4o,2005
13
+ figpack/views/TabLayout.py,sha256=d2x2zWGKYdvukW14HOCiU-9C7-N1ED-a1HrRIpSM6Jg,1896
14
+ figpack/views/TabLayoutItem.py,sha256=dvNCdPcRDaDr8LDd8D3zfMudQFbkiAMF0Z7XVcpIhLM,879
15
+ figpack/views/TimeseriesGraph.py,sha256=de85xUz22CeQxslXds5tbTJaZ_tyJlXs5GPPEB-8Fh4,7468
16
+ figpack/views/__init__.py,sha256=nDlhgXI1UbkDyf9C0pT3Vc_sIzo6VV7Pisaics9Hciw,206
17
+ figpack-0.1.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
18
+ figpack-gui/node_modules/flatted/python/flatted.py,sha256=UYburBDqkySaTfSpntPCUJRxiBGcplusJM7ECX8FEgA,3860
19
+ figpack-0.1.1.dist-info/METADATA,sha256=u1MDjP_4S9IAm2l-3qVM_aJvImbNROLSIQkhpykgLXA,1316
20
+ figpack-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
+ figpack-0.1.1.dist-info/top_level.txt,sha256=rnjeFJrho76QPJg3q-c9U7uUXz6KK5Ff5PPbPtGrk9s,20
22
+ figpack-0.1.1.dist-info/RECORD,,