@mdgs/pivotjet 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +628 -3
- package/bin/pivotjet.mjs +122 -0
- package/dist/core.cjs +4926 -0
- package/dist/core.cjs.map +7 -0
- package/dist/index.cjs +7277 -0
- package/dist/index.cjs.map +7 -0
- package/dist/pivotjet.min.js +334 -0
- package/dist/pivotjet.min.js.map +7 -0
- package/docs/images/cell-formats.png +0 -0
- package/docs/images/chart.png +0 -0
- package/docs/images/configure-fields.png +0 -0
- package/docs/images/designer.png +0 -0
- package/docs/images/large-dataset.png +0 -0
- package/package.json +108 -4
- package/src/cellfmt.js +218 -0
- package/src/chart.js +595 -0
- package/src/core.d.ts +424 -0
- package/src/core.js +18 -0
- package/src/csv.js +198 -0
- package/src/dataset.js +404 -0
- package/src/designer.js +995 -0
- package/src/elements.js +50 -0
- package/src/engine.js +778 -0
- package/src/errors.js +2 -0
- package/src/export.js +775 -0
- package/src/expr.js +180 -0
- package/src/format.js +42 -0
- package/src/holistic.js +237 -0
- package/src/index.d.ts +155 -0
- package/src/index.js +6 -0
- package/src/layouts.js +105 -0
- package/src/node.d.ts +10 -0
- package/src/node.js +29 -0
- package/src/pdffont.js +361 -0
- package/src/remote.js +164 -0
- package/src/report-render.js +31 -0
- package/src/report.js +103 -0
- package/src/reportstore.js +135 -0
- package/src/server.d.ts +20 -0
- package/src/server.js +272 -0
- package/src/stream.js +285 -0
- package/src/styles.js +162 -0
- package/src/util.js +73 -0
- package/src/viewer.js +632 -0
package/src/elements.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Custom elements: <pivotjet-viewer> and <pivotjet-designer>.
|
|
2
|
+
// Importing this module registers them; they work unchanged in React, Vue, Angular, Svelte, plain HTML.
|
|
3
|
+
//
|
|
4
|
+
// const el = document.querySelector('pivotjet-designer');
|
|
5
|
+
// el.dataset_ = ds; // property (a Dataset instance) -- also settable as el.data
|
|
6
|
+
// el.spec = {...}; // property or JSON in the `spec` attribute
|
|
7
|
+
// el.addEventListener('change', e => e.detail) // new spec
|
|
8
|
+
|
|
9
|
+
import { PivotViewer } from './viewer.js';
|
|
10
|
+
import { PivotDesigner } from './designer.js';
|
|
11
|
+
|
|
12
|
+
function define(tag, Impl, events) {
|
|
13
|
+
if (typeof customElements === 'undefined' || customElements.get(tag)) return;
|
|
14
|
+
customElements.define(tag, class extends HTMLElement {
|
|
15
|
+
static get observedAttributes() { return ['spec', 'theme']; }
|
|
16
|
+
constructor() { super(); this._data = null; this._spec = null; this._impl = null; }
|
|
17
|
+
connectedCallback() {
|
|
18
|
+
if (this._impl) return;
|
|
19
|
+
if (!this.style.display) this.style.display = 'block';
|
|
20
|
+
if (!this.style.height && !this.offsetHeight) this.style.height = '480px';
|
|
21
|
+
const host = document.createElement('div');
|
|
22
|
+
host.style.cssText = 'height:100%;width:100%';
|
|
23
|
+
this.appendChild(host);
|
|
24
|
+
const specAttr = this.getAttribute('spec');
|
|
25
|
+
this._spec = this._spec || (specAttr ? JSON.parse(specAttr) : undefined);
|
|
26
|
+
this._impl = new Impl(host, { dataset: this._data, spec: this._spec, theme: this.getAttribute('theme') || 'auto' });
|
|
27
|
+
for (const ev of events) this._impl.on(ev, (detail) => this.dispatchEvent(new CustomEvent(ev, { detail, bubbles: true })));
|
|
28
|
+
}
|
|
29
|
+
disconnectedCallback() { if (this._impl) { this._impl.destroy(); this._impl = null; this.textContent = ''; } }
|
|
30
|
+
attributeChangedCallback(name, _o, v) {
|
|
31
|
+
if (!this._impl) return;
|
|
32
|
+
if (name === 'spec' && v) this.spec = JSON.parse(v);
|
|
33
|
+
}
|
|
34
|
+
get data() { return this._data; }
|
|
35
|
+
set data(ds) {
|
|
36
|
+
this._data = ds;
|
|
37
|
+
if (this._impl) (this._impl.setDataset ? this._impl.setDataset(ds) : this._impl.setData(ds));
|
|
38
|
+
}
|
|
39
|
+
get spec() { return this._impl ? (this._impl.getSpec ? this._impl.getSpec() : this._impl.spec) : this._spec; }
|
|
40
|
+
set spec(s) {
|
|
41
|
+
this._spec = s;
|
|
42
|
+
if (this._impl) this._impl.setSpec(s);
|
|
43
|
+
}
|
|
44
|
+
/** underlying PivotViewer / PivotDesigner instance */
|
|
45
|
+
get instance() { return this._impl; }
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
define('pivotjet-viewer', PivotViewer, ['compute-end', 'cellclick', 'drill', 'error', 'sort']);
|
|
50
|
+
define('pivotjet-designer', PivotDesigner, ['change', 'compute-end', 'cellclick', 'drill', 'error']);
|