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

figpack/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
  figpack - A Python package for creating shareable, interactive visualizations in the browser
3
3
  """
4
4
 
5
- __version__ = "0.2.11"
5
+ __version__ = "0.2.12"
6
6
 
7
7
  from .cli import view_figure
8
8
  from .core import FigpackView, FigpackExtension, ExtensionRegistry, ExtensionView
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Plotly Extension for figpack
3
+ * Provides interactive graph visualization using Plotly library
4
+ */
5
+
6
+ const loadFigureData = async (zarrGroup) => {
7
+ // Get the figure data from the zarr array
8
+ const data = await zarrGroup.file.getDatasetData(
9
+ joinPath(zarrGroup.path, "figure_data"),
10
+ {},
11
+ );
12
+ if (!data || data.length === 0) {
13
+ throw new Error("Empty figure data");
14
+ }
15
+
16
+ // Convert the uint8 array back to string
17
+ const uint8Array = new Uint8Array(data);
18
+ const decoder = new TextDecoder("utf-8");
19
+ const jsonString = decoder.decode(uint8Array);
20
+
21
+ // Parse the JSON string
22
+ const parsedData = JSON.parse(jsonString);
23
+
24
+ return parsedData;
25
+ };
26
+
27
+ (function() {
28
+ window.figpackExtensions = window.figpackExtensions || {};
29
+
30
+ window.figpackExtensions['figpack_plotly'] = {
31
+ render: async function(container, zarrGroup, width, height, onResize) {
32
+ container.innerHTML = '';
33
+
34
+ try {
35
+ const figureData = await loadFigureData(zarrGroup);
36
+
37
+ const makePlot = () => {
38
+ window.Plotly.newPlot(
39
+ container,
40
+ figureData.data || [],
41
+ {
42
+ ...figureData.layout,
43
+ width: width,
44
+ height: height,
45
+ margin: { l: 50, r: 50, t: 50, b: 50 },
46
+ },
47
+ {
48
+ responsive: true,
49
+ displayModeBar: true,
50
+ displaylogo: false,
51
+ },
52
+ )
53
+ };
54
+
55
+ makePlot();
56
+
57
+ // Handle resize events
58
+ onResize((newWidth, newHeight) => {
59
+ window.Plotly.relayout(container, {width: newWidth, height: newHeight});
60
+ });
61
+
62
+ return {
63
+ destroy: () => {
64
+ window.Plotly.purge(container);
65
+ }
66
+ };
67
+
68
+ } catch (error) {
69
+ console.error('Error rendering plotly figure:', error);
70
+ this.renderError(container, width, height, error.message);
71
+ return { destroy: () => {} };
72
+ }
73
+ },
74
+
75
+ renderError: function(container, width, height, message) {
76
+ container.innerHTML = `
77
+ <div style="
78
+ width: ${width}px;
79
+ height: ${height}px;
80
+ display: flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ background-color: #f8f9fa;
84
+ border: 1px solid #dee2e6;
85
+ color: #6c757d;
86
+ font-family: system-ui, -apple-system, sans-serif;
87
+ font-size: 14px;
88
+ text-align: center;
89
+ padding: 20px;
90
+ box-sizing: border-box;
91
+ ">
92
+ <div>
93
+ <div style="margin-bottom: 10px; font-weight: 500;">Force Graph Error</div>
94
+ <div style="font-size: 12px;">${message}</div>
95
+ </div>
96
+ </div>
97
+ `;
98
+ }
99
+ };
100
+ })();
101
+
102
+ const joinPath = function(p1, p2) {
103
+ if (p1.endsWith('/')) p1 = p1.slice(0, -1);
104
+ if (p2.startsWith('/')) p2 = p2.slice(1);
105
+ return p1 + '/' + p2;
106
+ };
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: figpack
3
- Version: 0.2.11
3
+ Version: 0.2.12
4
4
  Summary: A Python package for creating shareable, interactive visualizations in the browser
5
5
  Author-email: Jeremy Magland <jmagland@flatironinstitute.org>
6
6
  License: Apache-2.0
@@ -1,4 +1,4 @@
1
- figpack/__init__.py,sha256=dkV99qgN1ALjjQzp923hMJXVKIivfruPrK_ptSCt7oM,360
1
+ figpack/__init__.py,sha256=Cb1XSVRMpZegRqP62Tcld-PGzOpS2AO413SnbaziETg,360
2
2
  figpack/cli.py,sha256=xWF7J2BxUqOLvPu-Kje7Q6oGukTroXsLq8WN8vJgyw0,8321
3
3
  figpack/core/__init__.py,sha256=V4wVdyBJ80mi9Rz8HjDSQNkqhqYB6sq4vWH3xQ10kaE,232
4
4
  figpack/core/_bundle_utils.py,sha256=16hgTExPLkJCtGjVUCLlnbs_qgns6v01egVr3CEnUXE,6082
@@ -51,9 +51,10 @@ figpack/views/TimeseriesGraph.py,sha256=OAaCjO8fo86u_gO_frNfRGxng3tczxGDGKcJEvZo
51
51
  figpack/views/__init__.py,sha256=nyd3Ot2x702W4j9oBN0lK6i0DZzg9Ai41XoYCm5DeQ8,546
52
52
  figpack/views/PlotlyExtension/PlotlyExtension.py,sha256=_-GiqzHFb9uF1O6RNKEkd85SX8z9z5kFOh8tO_9aAbk,3778
53
53
  figpack/views/PlotlyExtension/__init__.py,sha256=80Wy1mDMWyagjuR99ECxJePIYpRQ6TSyHkB0uZoBZ_0,70
54
- figpack-0.2.11.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
55
- figpack-0.2.11.dist-info/METADATA,sha256=N8ftHEAJCS8R_5lHx6DxHSr5QQCWqdDAMPjQ6F084JI,3617
56
- figpack-0.2.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
57
- figpack-0.2.11.dist-info/entry_points.txt,sha256=l6d3siH2LxXa8qJGbjAqpIZtI5AkMSyDeoRDCzdrUto,45
58
- figpack-0.2.11.dist-info/top_level.txt,sha256=lMKGaC5xWmAYBx9Ac1iMokm42KFnJFjmkP2ldyvOo-c,8
59
- figpack-0.2.11.dist-info/RECORD,,
54
+ figpack/views/PlotlyExtension/plotly_view.js,sha256=gCsZS0IaYGTN5a3DC2c4NmzoOxZi1xGfCAYI6WSoFpM,3596
55
+ figpack-0.2.12.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
+ figpack-0.2.12.dist-info/METADATA,sha256=IyjYIuqCQXp3_TFeUyfEI7XV6Ac6oJum5wq5Qo_lqN8,3617
57
+ figpack-0.2.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
58
+ figpack-0.2.12.dist-info/entry_points.txt,sha256=l6d3siH2LxXa8qJGbjAqpIZtI5AkMSyDeoRDCzdrUto,45
59
+ figpack-0.2.12.dist-info/top_level.txt,sha256=lMKGaC5xWmAYBx9Ac1iMokm42KFnJFjmkP2ldyvOo-c,8
60
+ figpack-0.2.12.dist-info/RECORD,,