chartout 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/README.md +66 -39
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -1,56 +1,83 @@
1
- # chartout-app
1
+ # chartout
2
2
 
3
- Builds and publishes the **chartout** npm package — the interactive 3D widget used by the Python package and JavaScript reference implementation.
3
+ **Print Your Insights, Anytime, Anywhere**
4
4
 
5
- ## Role in the ecosystem
5
+ <sub><sup>With every purchase, we donate 10% to NumFOCUS to support open-source scientific software.</sup></sub>
6
6
 
7
- | Repo | Role |
8
- |------|------|
9
- | **chartout** | Python package + JavaScript reference implementation |
10
- | **chartout-api** | Backend API |
11
- | **chartout-app** | This repo — widget bundle + npm package |
12
- | **chartout-web** | Checkout web app |
7
+ Chartout turns data visualizations into beautiful, printed products — canvas prints, mugs, mousepads and more. You create a chart, pick a product, and chartout handles everything from interactive 3D preview to order fulfilment.
13
8
 
14
- ## What gets built
9
+ ## Python / Jupyter
15
10
 
16
- | Output | Purpose |
17
- |--------|---------|
18
- | `bundle/Widget.js` | Self-contained Jupyter widget (loaded by the Python package) |
19
- | `bundle/lib.js` | `createChartoutModel()` — state bridge for JS apps |
20
- | `bundle/render.js` | `widgetRender` — anywidget render function for React apps |
21
- | `bundle/types/` | TypeScript declarations |
11
+ ```bash
12
+ pip install chartout
13
+ ```
14
+
15
+ ```python
16
+ import matplotlib.pyplot as plt
17
+ import chartout
18
+
19
+ # matplotlib
20
+ fig, ax = plt.subplots()
21
+ ax.plot(x, y)
22
+ store = chartout.Store(fig)
23
+
24
+ # or Altair
25
+ import altair as alt
26
+ chart = alt.Chart(data).mark_point().encode(x='x', y='y')
27
+ store = chartout.Store(chart)
28
+
29
+ store # renders the interactive widget in Jupyter
30
+ ```
22
31
 
23
- ## Development setup
32
+ ## JavaScript / React
24
33
 
25
34
  ```bash
26
- git clone https://github.com/hoekinsights/chartout-app.git
27
- cd chartout-app
28
- pixi install
29
- pixi run npm-install
30
- pixi run npm-dev
35
+ npm install chartout
31
36
  ```
32
37
 
33
- `npm-dev` runs four watchers concurrently: `devwidget`, `devlib`, `devrender`, and `serve` (serves `bundle/` at `http://localhost:3000`).
38
+ Three steps connect your chart to the widget:
34
39
 
35
- To run the full ecosystem (API, Python, web app) alongside the widget:
40
+ ```ts
41
+ import { createChartoutModel } from 'chartout';
42
+ import type { CartItem, ActiveItem } from 'chartout';
36
43
 
37
- ```bash
38
- ./scripts/start-dev.sh
44
+ // 1. Create the state bridge
45
+ const model = createChartoutModel({});
46
+
47
+ // 2. Rasterise your chart at print resolution
48
+ const bytes = svgToBytes(mySvgElement, 3900, 3900);
49
+
50
+ // 3. Push to the widget
51
+ model.set('active_item', {
52
+ id: 'canvas_10x10',
53
+ name: 'Canvas (10″×10″)',
54
+ placements: [{ id: 'default', content: bytes }],
55
+ } satisfies ActiveItem);
56
+
57
+ // Listen to cart changes
58
+ model.on('change:cart', () => {
59
+ const cart = model.get('cart'); // CartItem[]
60
+ });
39
61
  ```
40
62
 
41
- ## Build scripts
63
+ ### Embedding in React
64
+
65
+ ```tsx
66
+ import { useEffect, useRef } from 'react';
67
+ import { widgetRender } from 'chartout/render';
68
+
69
+ function ChartoutWidget({ model, style }) {
70
+ const ref = useRef(null);
71
+ useEffect(() => {
72
+ const cleanup = widgetRender({ model, el: ref.current, experimental: {} });
73
+ return () => typeof cleanup === 'function' && cleanup();
74
+ }, [model]);
75
+ return <div ref={ref} style={{ width: '100%', ...style }} />;
76
+ }
77
+ ```
42
78
 
43
- | Script | Output |
44
- |--------|--------|
45
- | `npm run build` | Full production build (widget + lib + render + types) |
46
- | `npm run buildwidget` | `bundle/Widget.js` |
47
- | `npm run buildlib` | `bundle/lib.js` |
48
- | `npm run buildrender` | `bundle/render.js` |
49
- | `npm run buildtypes` | `bundle/types/` |
50
- | `npm run dev` | Watch all outputs + serve |
51
79
 
52
- ## Related repositories
80
+ ## Links
53
81
 
54
- - **chartout** — Python package and JavaScript reference implementation: https://github.com/hoekinsights/chartout
55
- - **chartout-api** — Backend API: https://github.com/hoekinsights/chartout-api
56
- - **chartout-web** — Checkout web app: https://github.com/hoekinsights/chartout-web
82
+ - [chartout.io](https://chartout.io)
83
+ - [npm](https://www.npmjs.com/package/chartout)
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "chartout",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
+ "license": "GPL-3.0",
4
5
  "type": "module",
5
6
  "exports": {
6
7
  ".": {