@peter.prib/renderengine 0.2.0 → 0.2.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.
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ Open an Archi model, edit it the way you would in Archi, and save it back to the
|
|
|
7
7
|
installing anything. Or put the same editor in your own app: it's a JavaScript library and a set of workbench parts,
|
|
8
8
|
not a desktop application.
|
|
9
9
|
|
|
10
|
+

|
|
11
|
+
|
|
10
12
|
---
|
|
11
13
|
|
|
12
14
|
## Try it
|
|
@@ -121,6 +123,8 @@ of them for its own palettes:
|
|
|
121
123
|
|
|
122
124
|
Each model can hold several diagrams, with line styles inherited from the diagram, then the model, then the tool.
|
|
123
125
|
|
|
126
|
+

|
|
127
|
+
|
|
124
128
|
## The chart library
|
|
125
129
|
|
|
126
130
|
The engine underneath draws 24 chart types: bar, line, area, pie, scatter, bubble, heatmap, candlestick,
|
|
@@ -128,6 +132,10 @@ waterfall, histogram, box plot, violin, radar, funnel, treemap, sunburst, gauges
|
|
|
128
132
|
draws graph and railroad diagrams, all to SVG or Canvas. `test/charts.html` is the full gallery, and
|
|
129
133
|
`examples/csv-chart-builder.html` builds a chart from a CSV file without code.
|
|
130
134
|
|
|
135
|
+

|
|
136
|
+
|
|
137
|
+

|
|
138
|
+
|
|
131
139
|
---
|
|
132
140
|
|
|
133
141
|
## Put it in your own page
|
|
@@ -189,6 +197,7 @@ UI at all.
|
|
|
189
197
|
npm install # dev tools only: Rollup
|
|
190
198
|
npm run build # dist/renderengine.umd.js and dist/renderengine-workspace.umd.js
|
|
191
199
|
npm test # Node's built-in test runner, no browser needed
|
|
200
|
+
npm run screenshots # this README's pictures, from the example pages (headless Chrome)
|
|
192
201
|
```
|
|
193
202
|
|
|
194
203
|
There are two bundles:
|
|
@@ -25976,20 +25976,14 @@
|
|
|
25976
25976
|
};
|
|
25977
25977
|
const style = this.textStyle;
|
|
25978
25978
|
const font = TextStyle.svgAttributes(style, { defaultPixels: 12 });
|
|
25979
|
-
const zLine = `Z:${this.zIndex || 0}`;
|
|
25980
25979
|
if (TextStyle.placesText(style)) {
|
|
25981
25980
|
// Placed in the shape's box by its alignment and position (centred, middle where unset).
|
|
25982
25981
|
const at = TextStyle.block(style, this, 1, { pixels: font['font-size'], defaults: { textAlign: 'center', textPosition: 'middle' } });
|
|
25983
25982
|
const placed = { 'text-anchor': at.textAnchor, 'dominant-baseline': 'auto' };
|
|
25984
25983
|
if (this.name) text({ x: at.x, y: at.baseline, ...font, ...placed, fill: this.textColor }, this.name);
|
|
25985
|
-
// Under the name, or over it when the name is at the bottom (so it stays in the shape).
|
|
25986
|
-
const zY = style.textPosition === 'bottom' ? at.baseline - font['font-size'] - 2 : at.baseline + 12;
|
|
25987
|
-
text({ x: at.x, y: zY, 'font-size': 10, fill: '#666', ...placed }, zLine);
|
|
25988
25984
|
return;
|
|
25989
25985
|
}
|
|
25990
25986
|
if (this.name) text({ x, y, ...font, fill: this.textColor }, this.name);
|
|
25991
|
-
// Below the name, however large it is set.
|
|
25992
|
-
text({ x, y: y + Math.max(16, font['font-size'] / 2 + 10), 'font-size': 10, fill: '#666' }, zLine);
|
|
25993
25987
|
}
|
|
25994
25988
|
|
|
25995
25989
|
serialize() {
|
package/dist/renderengine.umd.js
CHANGED
|
@@ -23212,20 +23212,14 @@
|
|
|
23212
23212
|
};
|
|
23213
23213
|
const style = this.textStyle;
|
|
23214
23214
|
const font = TextStyle.svgAttributes(style, { defaultPixels: 12 });
|
|
23215
|
-
const zLine = `Z:${this.zIndex || 0}`;
|
|
23216
23215
|
if (TextStyle.placesText(style)) {
|
|
23217
23216
|
// Placed in the shape's box by its alignment and position (centred, middle where unset).
|
|
23218
23217
|
const at = TextStyle.block(style, this, 1, { pixels: font['font-size'], defaults: { textAlign: 'center', textPosition: 'middle' } });
|
|
23219
23218
|
const placed = { 'text-anchor': at.textAnchor, 'dominant-baseline': 'auto' };
|
|
23220
23219
|
if (this.name) text({ x: at.x, y: at.baseline, ...font, ...placed, fill: this.textColor }, this.name);
|
|
23221
|
-
// Under the name, or over it when the name is at the bottom (so it stays in the shape).
|
|
23222
|
-
const zY = style.textPosition === 'bottom' ? at.baseline - font['font-size'] - 2 : at.baseline + 12;
|
|
23223
|
-
text({ x: at.x, y: zY, 'font-size': 10, fill: '#666', ...placed }, zLine);
|
|
23224
23220
|
return;
|
|
23225
23221
|
}
|
|
23226
23222
|
if (this.name) text({ x, y, ...font, fill: this.textColor }, this.name);
|
|
23227
|
-
// Below the name, however large it is set.
|
|
23228
|
-
text({ x, y: y + Math.max(16, font['font-size'] / 2 + 10), 'font-size': 10, fill: '#666' }, zLine);
|
|
23229
23223
|
}
|
|
23230
23224
|
|
|
23231
23225
|
serialize() {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<script src="../dist/renderengine.umd.js"></script>
|
|
18
18
|
<script src="../dist/renderengine-workspace.umd.js"></script>
|
|
19
19
|
<script>
|
|
20
|
-
const { RectangleTemplate, StadiumTemplate, DiamondTemplate } = window.RenderEngine;
|
|
20
|
+
const { RectangleTemplate, StadiumTemplate, DiamondTemplate, ParallelogramTemplate, Edge } = window.RenderEngine;
|
|
21
21
|
const { el, registerBuiltinParts, DiagramEditorPart } = window.RenderEngineWorkspace;
|
|
22
22
|
|
|
23
23
|
const ws = document.body.appendChild(el({
|
|
@@ -35,16 +35,21 @@
|
|
|
35
35
|
ws.registerPerspective('Diagrams', { type: 'part', partId: 'models' });
|
|
36
36
|
ws.activatePerspective('Diagrams');
|
|
37
37
|
|
|
38
|
-
// A small flowchart to start from.
|
|
38
|
+
// A small flowchart to start from: its shapes, and the lines between them.
|
|
39
39
|
const editorPart = ws.getPart('editor');
|
|
40
|
-
const { templates } = editorPart.model.currentView;
|
|
40
|
+
const { templates, edges } = editorPart.model.currentView;
|
|
41
41
|
for (const t of [
|
|
42
42
|
new StadiumTemplate('start', 'Order received', { x: 160, y: 80, fillColor: '#dcfce7' }),
|
|
43
43
|
new RectangleTemplate('check', 'Check stock', { x: 160, y: 200, fillColor: '#dbeafe' }),
|
|
44
44
|
new DiamondTemplate('decide', 'In stock?', { x: 160, y: 330, fillColor: '#fef9c3' }),
|
|
45
45
|
new RectangleTemplate('ship', 'Ship order', { x: 400, y: 330, fillColor: '#dbeafe' }),
|
|
46
|
-
new
|
|
46
|
+
new ParallelogramTemplate('reorder', 'Reorder stock', { x: 160, y: 470, fillColor: '#ede9fe' }),
|
|
47
|
+
new StadiumTemplate('end', 'Done', { x: 400, y: 470, fillColor: '#dcfce7' }),
|
|
47
48
|
]) templates.set(t.id, t);
|
|
49
|
+
for (const [id, from, to, label = ''] of [
|
|
50
|
+
['e1', 'start', 'check'], ['e2', 'check', 'decide'], ['e3', 'decide', 'ship', 'yes'],
|
|
51
|
+
['e4', 'decide', 'reorder', 'no'], ['e5', 'ship', 'end'], ['e6', 'reorder', 'ship'],
|
|
52
|
+
]) edges.set(id, new Edge(id, from, to, { endMarker: 'arrow', label }));
|
|
48
53
|
editorPart.editor.render();
|
|
49
54
|
</script>
|
|
50
55
|
</body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peter.prib/renderengine",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "ArchiMate modeller, diagram editor and chart library for the browser, with no runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"diagram": "node scripts/open.mjs examples/diagram-editor.html",
|
|
29
29
|
"test": "node --test --test-timeout=10000 ./test/*.js ./test/charting/*.js ./test/charting/charts/*.js ./test/charting/diagrams/*.js ./test/charting/shapes/*.js",
|
|
30
30
|
"build": "rollup -c",
|
|
31
|
-
"prepublishOnly": "npm test && npm run build"
|
|
31
|
+
"prepublishOnly": "npm test && npm run build",
|
|
32
|
+
"screenshots": "node scripts/screenshots/screenshots.mjs"
|
|
32
33
|
},
|
|
33
34
|
"keywords": [
|
|
34
35
|
"archimate",
|
|
@@ -170,20 +170,14 @@ export class Template {
|
|
|
170
170
|
};
|
|
171
171
|
const style = this.textStyle;
|
|
172
172
|
const font = TextStyle.svgAttributes(style, { defaultPixels: 12 });
|
|
173
|
-
const zLine = `Z:${this.zIndex || 0}`;
|
|
174
173
|
if (TextStyle.placesText(style)) {
|
|
175
174
|
// Placed in the shape's box by its alignment and position (centred, middle where unset).
|
|
176
175
|
const at = TextStyle.block(style, this, 1, { pixels: font['font-size'], defaults: { textAlign: 'center', textPosition: 'middle' } });
|
|
177
176
|
const placed = { 'text-anchor': at.textAnchor, 'dominant-baseline': 'auto' };
|
|
178
177
|
if (this.name) text({ x: at.x, y: at.baseline, ...font, ...placed, fill: this.textColor }, this.name);
|
|
179
|
-
// Under the name, or over it when the name is at the bottom (so it stays in the shape).
|
|
180
|
-
const zY = style.textPosition === 'bottom' ? at.baseline - font['font-size'] - 2 : at.baseline + 12;
|
|
181
|
-
text({ x: at.x, y: zY, 'font-size': 10, fill: '#666', ...placed }, zLine);
|
|
182
178
|
return;
|
|
183
179
|
}
|
|
184
180
|
if (this.name) text({ x, y, ...font, fill: this.textColor }, this.name);
|
|
185
|
-
// Below the name, however large it is set.
|
|
186
|
-
text({ x, y: y + Math.max(16, font['font-size'] / 2 + 10), 'font-size': 10, fill: '#666' }, zLine);
|
|
187
181
|
}
|
|
188
182
|
|
|
189
183
|
serialize() {
|