tslab-widgets 1.0.0 → 1.2.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/README.md +100 -0
- package/dist/barchart/barchart.d.ts +44 -0
- package/dist/barchart/barchart.d.ts.map +1 -0
- package/dist/barchart/barchart.js +201 -0
- package/dist/barchart/barchart.js.map +1 -0
- package/dist/chart/chart.d.ts.map +1 -1
- package/dist/chart/chart.js +5 -7
- package/dist/chart/chart.js.map +1 -1
- package/dist/chart/plugins/tooltip.d.ts.map +1 -1
- package/dist/chart/plugins/tooltip.js +2 -70
- package/dist/chart/plugins/tooltip.js.map +1 -1
- package/dist/config/versions.d.ts +14 -23
- package/dist/config/versions.d.ts.map +1 -1
- package/dist/config/versions.js +17 -19
- package/dist/config/versions.js.map +1 -1
- package/dist/gauge/gauge.d.ts +20 -6
- package/dist/gauge/gauge.d.ts.map +1 -1
- package/dist/gauge/gauge.js +378 -39
- package/dist/gauge/gauge.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/json/json.d.ts +7 -0
- package/dist/json/json.d.ts.map +1 -1
- package/dist/json/json.js +26 -9
- package/dist/json/json.js.map +1 -1
- package/dist/layout/row.d.ts +48 -0
- package/dist/layout/row.d.ts.map +1 -0
- package/dist/layout/row.js +65 -0
- package/dist/layout/row.js.map +1 -0
- package/dist/pie/pie.d.ts +25 -0
- package/dist/pie/pie.d.ts.map +1 -0
- package/dist/pie/pie.js +171 -0
- package/dist/pie/pie.js.map +1 -0
- package/dist/scatter/scatter.d.ts +36 -0
- package/dist/scatter/scatter.d.ts.map +1 -0
- package/dist/scatter/scatter.js +193 -0
- package/dist/scatter/scatter.js.map +1 -0
- package/dist/table/table.d.ts +16 -0
- package/dist/table/table.d.ts.map +1 -0
- package/dist/table/table.js +56 -0
- package/dist/table/table.js.map +1 -0
- package/package.json +10 -6
- package/dist/csv/csv.d.ts +0 -6
- package/dist/csv/csv.d.ts.map +0 -1
- package/dist/csv/csv.js +0 -85
- package/dist/csv/csv.js.map +0 -1
- package/readme.md +0 -77
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
export type { BarchartVariation, IBarConfig, IBarchartConfig, IYAxisConfig, } from "./barchart/barchart";
|
|
2
|
+
export { barchart } from "./barchart/barchart";
|
|
1
3
|
export { chart } from "./chart/chart";
|
|
2
4
|
export type { IPoint } from "./chart/plugins/trendLine";
|
|
3
5
|
export type { IVertLineOptions } from "./chart/plugins/verticalLine";
|
|
4
6
|
export type { IVolumeProfileData } from "./chart/plugins/volumeProfile";
|
|
5
|
-
export { csv } from "./csv/csv";
|
|
6
7
|
export { gauge } from "./gauge/gauge";
|
|
7
8
|
export { json } from "./json/json";
|
|
9
|
+
export type { IRowOptions, IRowWidget } from "./layout/row";
|
|
10
|
+
export { row } from "./layout/row";
|
|
11
|
+
export type { IPieConfig, IPieDataItem } from "./pie/pie";
|
|
12
|
+
export { pie } from "./pie/pie";
|
|
13
|
+
export type { IScatterConfig, IScatterSeriesConfig } from "./scatter/scatter";
|
|
14
|
+
export { scatter } from "./scatter/scatter";
|
|
15
|
+
export { table } from "./table/table";
|
|
8
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,YAAY,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,YAAY,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,YAAY,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.json = exports.gauge = exports.
|
|
3
|
+
exports.table = exports.scatter = exports.pie = exports.row = exports.json = exports.gauge = exports.chart = exports.barchart = void 0;
|
|
4
|
+
var barchart_1 = require("./barchart/barchart");
|
|
5
|
+
Object.defineProperty(exports, "barchart", { enumerable: true, get: function () { return barchart_1.barchart; } });
|
|
4
6
|
var chart_1 = require("./chart/chart");
|
|
5
7
|
Object.defineProperty(exports, "chart", { enumerable: true, get: function () { return chart_1.chart; } });
|
|
6
|
-
var csv_1 = require("./csv/csv");
|
|
7
|
-
Object.defineProperty(exports, "csv", { enumerable: true, get: function () { return csv_1.csv; } });
|
|
8
8
|
var gauge_1 = require("./gauge/gauge");
|
|
9
9
|
Object.defineProperty(exports, "gauge", { enumerable: true, get: function () { return gauge_1.gauge; } });
|
|
10
10
|
var json_1 = require("./json/json");
|
|
11
11
|
Object.defineProperty(exports, "json", { enumerable: true, get: function () { return json_1.json; } });
|
|
12
|
+
var row_1 = require("./layout/row");
|
|
13
|
+
Object.defineProperty(exports, "row", { enumerable: true, get: function () { return row_1.row; } });
|
|
14
|
+
var pie_1 = require("./pie/pie");
|
|
15
|
+
Object.defineProperty(exports, "pie", { enumerable: true, get: function () { return pie_1.pie; } });
|
|
16
|
+
var scatter_1 = require("./scatter/scatter");
|
|
17
|
+
Object.defineProperty(exports, "scatter", { enumerable: true, get: function () { return scatter_1.scatter; } });
|
|
18
|
+
var table_1 = require("./table/table");
|
|
19
|
+
Object.defineProperty(exports, "table", { enumerable: true, get: function () { return table_1.table; } });
|
|
12
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAMA,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AAId,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,oCAAmC;AAA1B,4FAAA,IAAI,OAAA;AAEb,oCAAmC;AAA1B,0FAAA,GAAG,OAAA;AAEZ,iCAAgC;AAAvB,0FAAA,GAAG,OAAA;AAEZ,6CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,uCAAsC;AAA7B,8FAAA,KAAK,OAAA"}
|
package/dist/json/json.d.ts
CHANGED
|
@@ -3,5 +3,12 @@ declare function json<T extends object>(opts: {
|
|
|
3
3
|
height?: number;
|
|
4
4
|
width?: number;
|
|
5
5
|
}): void;
|
|
6
|
+
declare namespace json {
|
|
7
|
+
var html: <T extends object>(opts: {
|
|
8
|
+
data: T;
|
|
9
|
+
height?: number | undefined;
|
|
10
|
+
width?: number | undefined;
|
|
11
|
+
}) => string;
|
|
12
|
+
}
|
|
6
13
|
export { json };
|
|
7
14
|
//# sourceMappingURL=json.d.ts.map
|
package/dist/json/json.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/json/json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/json/json.ts"],"names":[],"mappings":"AA+CA,iBAAS,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE;IACrC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CAGP;kBAPQ,IAAI;;;;;;;AAeb,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/json/json.js
CHANGED
|
@@ -4,31 +4,48 @@ exports.json = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const tslab = tslib_1.__importStar(require("tslab"));
|
|
6
6
|
const versions_1 = require("../config/versions");
|
|
7
|
-
function
|
|
7
|
+
function generateJsonHtml(opts) {
|
|
8
8
|
const width = opts.width || 400;
|
|
9
|
-
const height = opts.height ||
|
|
9
|
+
const height = opts.height || 150;
|
|
10
10
|
const reactComponentId = `_json_widget${Math.random().toString(36).substring(2, 9)}`;
|
|
11
|
-
|
|
11
|
+
return `
|
|
12
12
|
<div
|
|
13
13
|
id="${reactComponentId}"
|
|
14
|
-
style="width:${width +
|
|
14
|
+
style="width:${width + 20}px;height:${height + 20}px;max-height:${height + 20}px;overflow:scroll;padding: 8px;margin: auto;">
|
|
15
15
|
</div>
|
|
16
16
|
<script type="module">
|
|
17
17
|
import React from "${versions_1.CDN_URLS.react}";
|
|
18
18
|
import ReactDOM from "${versions_1.CDN_URLS.reactDom}";
|
|
19
|
-
import
|
|
19
|
+
import {JSONTree} from "${versions_1.CDN_URLS.reactJsonTree}";
|
|
20
20
|
|
|
21
21
|
const reactJupyterLabComponentId = "${reactComponentId}";
|
|
22
22
|
const jupyterLabReactComponentContainer = document.getElementById("${reactComponentId}");
|
|
23
23
|
const args = JSON.parse('${JSON.stringify(opts.data)}');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const h = React.createElement;
|
|
25
|
+
|
|
26
|
+
if (jupyterLabReactComponentContainer) {
|
|
27
|
+
const root = ReactDOM.createRoot(jupyterLabReactComponentContainer);
|
|
28
|
+
root.render(
|
|
29
|
+
h(
|
|
30
|
+
'div',
|
|
31
|
+
{ style: { display: 'flex', flex: 1, flexDirection: 'column', alignSelf: 'flex-start' } },
|
|
32
|
+
[
|
|
33
|
+
h(
|
|
34
|
+
JSONTree,
|
|
35
|
+
{ data: args },
|
|
36
|
+
)
|
|
37
|
+
]
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
}
|
|
28
41
|
|
|
29
42
|
</script>
|
|
30
43
|
`;
|
|
44
|
+
}
|
|
45
|
+
function json(opts) {
|
|
46
|
+
const html = generateJsonHtml(opts);
|
|
31
47
|
tslab.display.html(html);
|
|
32
48
|
}
|
|
33
49
|
exports.json = json;
|
|
50
|
+
json.html = (opts) => generateJsonHtml(opts);
|
|
34
51
|
//# sourceMappingURL=json.js.map
|
package/dist/json/json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/json/json.ts"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAE/B,iDAA8C;AAE9C,SAAS,
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/json/json.ts"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAE/B,iDAA8C;AAE9C,SAAS,gBAAgB,CAAmB,IAI3C;IACA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC;IAChC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC;IAClC,MAAM,gBAAgB,GAAG,eAAe,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACrF,OAAO;;YAEI,gBAAgB;qBACP,KAAK,GAAG,EAAE,aAAa,MAAM,GAAG,EAAE,iBAAiB,MAAM,GAAG,EAAE;;;2BAGxD,mBAAQ,CAAC,KAAK;8BACX,mBAAQ,CAAC,QAAQ;gCACf,mBAAQ,CAAC,aAAa;;4CAEV,gBAAgB;2EACe,gBAAgB;iCAC1D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;GAoBvD,CAAC;AACJ,CAAC;AAED,SAAS,IAAI,CAAmB,IAI/B;IACA,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAQQ,oBAAI;AANb,IAAI,CAAC,IAAI,GAAG,CAAmB,IAI9B,EAAU,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget renderer function type - returns HTML string instead of calling tslab.display.html
|
|
3
|
+
*/
|
|
4
|
+
export type WidgetRenderer = () => string;
|
|
5
|
+
/**
|
|
6
|
+
* Widget configuration for row layout
|
|
7
|
+
*/
|
|
8
|
+
export interface IRowWidget {
|
|
9
|
+
/** HTML content to render */
|
|
10
|
+
html: string;
|
|
11
|
+
/** Optional flex grow factor (default: 1) */
|
|
12
|
+
flex?: number;
|
|
13
|
+
/** Optional width constraint */
|
|
14
|
+
width?: string;
|
|
15
|
+
/** Optional minimum width */
|
|
16
|
+
minWidth?: string;
|
|
17
|
+
/** Optional maximum width */
|
|
18
|
+
maxWidth?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Row layout options
|
|
22
|
+
*/
|
|
23
|
+
export interface IRowOptions {
|
|
24
|
+
/** Vertical alignment of widgets (default: "flex-start") */
|
|
25
|
+
alignItems?: "flex-start" | "center" | "flex-end" | "stretch";
|
|
26
|
+
/** Horizontal alignment when widgets don't fill row (default: "flex-start") */
|
|
27
|
+
justifyContent?: "flex-start" | "center" | "flex-end" | "space-between" | "space-around" | "space-evenly";
|
|
28
|
+
/** Minimum height for the row */
|
|
29
|
+
minHeight?: string;
|
|
30
|
+
/** Allow wrapping to multiple lines (default: false) */
|
|
31
|
+
wrap?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Renders multiple widgets in a horizontal row layout
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { row } from 'tslab-widgets';
|
|
39
|
+
* import { gauge, table } from 'tslab-widgets';
|
|
40
|
+
*
|
|
41
|
+
* row([
|
|
42
|
+
* { html: gauge.html({ value: 75, size: 'M' }) },
|
|
43
|
+
* { html: table.html({ options: { rowData: [...] } }), flex: 2 }
|
|
44
|
+
* ]);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function row(widgets: IRowWidget[], options?: IRowOptions): void;
|
|
48
|
+
//# sourceMappingURL=row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row.d.ts","sourceRoot":"","sources":["../../src/layout/row.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,4DAA4D;IAC5D,UAAU,CAAC,EAAE,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAC9D,+EAA+E;IAC/E,cAAc,CAAC,EACZ,YAAY,GACZ,QAAQ,GACR,UAAU,GACV,eAAe,GACf,cAAc,GACd,cAAc,CAAC;IAClB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAqD1E"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.row = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const tslab = tslib_1.__importStar(require("tslab"));
|
|
6
|
+
/**
|
|
7
|
+
* Renders multiple widgets in a horizontal row layout
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { row } from 'tslab-widgets';
|
|
12
|
+
* import { gauge, table } from 'tslab-widgets';
|
|
13
|
+
*
|
|
14
|
+
* row([
|
|
15
|
+
* { html: gauge.html({ value: 75, size: 'M' }) },
|
|
16
|
+
* { html: table.html({ options: { rowData: [...] } }), flex: 2 }
|
|
17
|
+
* ]);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function row(widgets, options = {}) {
|
|
21
|
+
const { alignItems = "center", justifyContent = "center", minHeight, wrap = false, } = options;
|
|
22
|
+
// Generate unique container ID
|
|
23
|
+
const containerId = `_row_layout${Math.random().toString(36).substring(2, 9)}`;
|
|
24
|
+
// Build individual widget containers with flex properties
|
|
25
|
+
const widgetContainers = widgets
|
|
26
|
+
.map((widget, idx) => {
|
|
27
|
+
const widgetId = `${containerId}_widget_${idx}`;
|
|
28
|
+
const styles = [
|
|
29
|
+
widget.minWidth ? `min-width: ${widget.minWidth}` : "",
|
|
30
|
+
widget.maxWidth ? `max-width: ${widget.maxWidth}` : "",
|
|
31
|
+
widget.flex ? "flex: 1" : "",
|
|
32
|
+
"display: flex",
|
|
33
|
+
"flex-direction: row",
|
|
34
|
+
"align-items: center",
|
|
35
|
+
"justify-content: center",
|
|
36
|
+
"min-height: 150px",
|
|
37
|
+
]
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
.join("; ");
|
|
40
|
+
return `
|
|
41
|
+
<div id="${widgetId}" style="${styles}">
|
|
42
|
+
${widget.html}
|
|
43
|
+
</div>
|
|
44
|
+
`;
|
|
45
|
+
})
|
|
46
|
+
.join("");
|
|
47
|
+
// Compose final HTML with flexbox row
|
|
48
|
+
const html = `
|
|
49
|
+
<div id="${containerId}" style="
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: row;
|
|
52
|
+
align-items: ${alignItems};
|
|
53
|
+
justify-content: ${justifyContent};
|
|
54
|
+
${wrap ? "flex-wrap: wrap;" : "flex-wrap: nowrap;"}
|
|
55
|
+
${minHeight ? `min-height: ${minHeight};` : ""}
|
|
56
|
+
width: 100%;
|
|
57
|
+
gap: 20px;
|
|
58
|
+
">
|
|
59
|
+
${widgetContainers}
|
|
60
|
+
</div>
|
|
61
|
+
`;
|
|
62
|
+
tslab.display.html(html);
|
|
63
|
+
}
|
|
64
|
+
exports.row = row;
|
|
65
|
+
//# sourceMappingURL=row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row.js","sourceRoot":"","sources":["../../src/layout/row.ts"],"names":[],"mappings":";;;;AAAA,qDAA+B;AA2C/B;;;;;;;;;;;;;GAaG;AACH,SAAgB,GAAG,CAAC,OAAqB,EAAE,UAAuB,EAAE;IACnE,MAAM,EACL,UAAU,GAAG,QAAQ,EACrB,cAAc,GAAG,QAAQ,EACzB,SAAS,EACT,IAAI,GAAG,KAAK,GACZ,GAAG,OAAO,CAAC;IAEZ,+BAA+B;IAC/B,MAAM,WAAW,GAAG,cAAc,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IAE/E,0DAA0D;IAC1D,MAAM,gBAAgB,GAAG,OAAO;SAC9B,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QACpB,MAAM,QAAQ,GAAG,GAAG,WAAW,WAAW,GAAG,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG;YACd,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE;YACtD,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE;YACtD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;YAC5B,eAAe;YACf,qBAAqB;YACrB,qBAAqB;YACrB,yBAAyB;YACzB,mBAAmB;SACnB;aACC,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,CAAC;QAEb,OAAO;iBACO,QAAQ,YAAY,MAAM;UACjC,MAAM,CAAC,IAAI;;KAEhB,CAAC;IACJ,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;IAEX,sCAAsC;IACtC,MAAM,IAAI,GAAG;eACC,WAAW;;;qBAGL,UAAU;yBACN,cAAc;QAC/B,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,oBAAoB;QAChD,SAAS,CAAC,CAAC,CAAC,eAAe,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE;;;;QAI5C,gBAAgB;;GAErB,CAAC;IAEH,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AArDD,kBAqDC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type IPieDataItem = {
|
|
2
|
+
name: string;
|
|
3
|
+
value: number;
|
|
4
|
+
fill?: string;
|
|
5
|
+
};
|
|
6
|
+
export type IPieConfig = {
|
|
7
|
+
data: IPieDataItem[];
|
|
8
|
+
innerData?: IPieDataItem[];
|
|
9
|
+
innerRadius?: number;
|
|
10
|
+
outerRadius?: number;
|
|
11
|
+
showLabels?: boolean;
|
|
12
|
+
useCustomLabels?: boolean;
|
|
13
|
+
showLabelLines?: boolean;
|
|
14
|
+
animate?: boolean;
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
title?: string;
|
|
18
|
+
colors?: string[];
|
|
19
|
+
};
|
|
20
|
+
declare function pie(config: IPieConfig): void;
|
|
21
|
+
declare namespace pie {
|
|
22
|
+
var html: (config: IPieConfig) => string;
|
|
23
|
+
}
|
|
24
|
+
export { pie };
|
|
25
|
+
//# sourceMappingURL=pie.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie.d.ts","sourceRoot":"","sources":["../../src/pie/pie.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E,MAAM,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA+KF,iBAAS,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAGrC;kBAHQ,GAAG;;;AAOZ,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
package/dist/pie/pie.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pie = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const tslab = tslib_1.__importStar(require("tslab"));
|
|
6
|
+
const versions_1 = require("../config/versions");
|
|
7
|
+
function generatePieHtml(config) {
|
|
8
|
+
const reactComponentId = `_pie_widget${Math.random().toString(36).substring(2, 9)}`;
|
|
9
|
+
const { data, innerData, innerRadius = 0, outerRadius = 80, showLabels = false, useCustomLabels = false, showLabelLines = true, animate = true, width = 500, height = 500, title = "", colors = [
|
|
10
|
+
"#0088FE",
|
|
11
|
+
"#00C49F",
|
|
12
|
+
"#FFBB28",
|
|
13
|
+
"#FF8042",
|
|
14
|
+
"#8884d8",
|
|
15
|
+
"#82ca9d",
|
|
16
|
+
"#ffc658",
|
|
17
|
+
"#ff7c7c",
|
|
18
|
+
], } = config;
|
|
19
|
+
return `
|
|
20
|
+
<div id="${reactComponentId}" />
|
|
21
|
+
<script type="module">
|
|
22
|
+
import React from "${versions_1.CDN_URLS.react}";
|
|
23
|
+
import ReactDOM from "${versions_1.CDN_URLS.reactDom}";
|
|
24
|
+
import { Cell, Pie, PieChart } from "${versions_1.CDN_URLS.recharts}";
|
|
25
|
+
|
|
26
|
+
const h = React.createElement;
|
|
27
|
+
|
|
28
|
+
const RADIAN = Math.PI / 180;
|
|
29
|
+
const DEFAULT_COLORS = ${JSON.stringify(colors)};
|
|
30
|
+
|
|
31
|
+
// Custom label renderer for percentage display
|
|
32
|
+
function renderCustomizedLabel({ cx, cy, midAngle, innerRadius, outerRadius, percent }) {
|
|
33
|
+
if (cx == null || cy == null || innerRadius == null || outerRadius == null) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
|
|
37
|
+
const ncx = Number(cx);
|
|
38
|
+
const x = ncx + radius * Math.cos(-(midAngle ?? 0) * RADIAN);
|
|
39
|
+
const ncy = Number(cy);
|
|
40
|
+
const y = ncy + radius * Math.sin(-(midAngle ?? 0) * RADIAN);
|
|
41
|
+
|
|
42
|
+
return h(
|
|
43
|
+
"text",
|
|
44
|
+
{
|
|
45
|
+
x: x,
|
|
46
|
+
y: y,
|
|
47
|
+
fill: "white",
|
|
48
|
+
textAnchor: x > ncx ? "start" : "end",
|
|
49
|
+
dominantBaseline: "central",
|
|
50
|
+
style: { fontSize: "14px", fontWeight: "600" }
|
|
51
|
+
},
|
|
52
|
+
((percent ?? 1) * 100).toFixed(0) + "%"
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function PieChartComponent() {
|
|
57
|
+
const data = ${JSON.stringify(data)};
|
|
58
|
+
const innerData = ${JSON.stringify(innerData || null)};
|
|
59
|
+
const hasInnerData = innerData && innerData.length > 0;
|
|
60
|
+
const showLabels = ${showLabels};
|
|
61
|
+
const useCustomLabels = ${useCustomLabels};
|
|
62
|
+
const showLabelLines = ${showLabelLines};
|
|
63
|
+
const animate = ${animate};
|
|
64
|
+
const innerRadiusPercent = ${innerRadius};
|
|
65
|
+
const outerRadiusPercent = ${outerRadius};
|
|
66
|
+
const title = "${title}";
|
|
67
|
+
|
|
68
|
+
return h(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
style: {
|
|
72
|
+
width: "100%",
|
|
73
|
+
maxWidth: "${width}px",
|
|
74
|
+
margin: "8px auto",
|
|
75
|
+
backgroundColor: "#1F1826",
|
|
76
|
+
padding: title ? "20px" : "10px",
|
|
77
|
+
borderRadius: "8px",
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[
|
|
81
|
+
title && h(
|
|
82
|
+
"h3",
|
|
83
|
+
{
|
|
84
|
+
style: {
|
|
85
|
+
margin: "0 0 15px 0",
|
|
86
|
+
color: "#fff",
|
|
87
|
+
textAlign: "center",
|
|
88
|
+
fontSize: "18px",
|
|
89
|
+
fontWeight: "600",
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
title
|
|
93
|
+
),
|
|
94
|
+
h(
|
|
95
|
+
PieChart,
|
|
96
|
+
{
|
|
97
|
+
width: ${width},
|
|
98
|
+
height: ${height},
|
|
99
|
+
style: {
|
|
100
|
+
width: "100%",
|
|
101
|
+
maxWidth: "${width}px",
|
|
102
|
+
maxHeight: "${height}px",
|
|
103
|
+
aspectRatio: 1,
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
[
|
|
107
|
+
// Outer pie (or main pie if no inner data)
|
|
108
|
+
h(
|
|
109
|
+
Pie,
|
|
110
|
+
{
|
|
111
|
+
data: data,
|
|
112
|
+
dataKey: "value",
|
|
113
|
+
cx: "50%",
|
|
114
|
+
cy: "50%",
|
|
115
|
+
innerRadius: hasInnerData ? innerRadiusPercent + "%" : innerRadiusPercent + "%",
|
|
116
|
+
outerRadius: hasInnerData ? "50%" : outerRadiusPercent + "%",
|
|
117
|
+
fill: "#8884d8",
|
|
118
|
+
isAnimationActive: animate,
|
|
119
|
+
label: showLabels && !hasInnerData ? (useCustomLabels ? renderCustomizedLabel : true) : false,
|
|
120
|
+
labelLine: showLabelLines && showLabels && !hasInnerData,
|
|
121
|
+
},
|
|
122
|
+
data.map((entry, index) =>
|
|
123
|
+
h(Cell, {
|
|
124
|
+
key: "cell-" + index,
|
|
125
|
+
fill: entry.fill || DEFAULT_COLORS[index % DEFAULT_COLORS.length],
|
|
126
|
+
})
|
|
127
|
+
)
|
|
128
|
+
),
|
|
129
|
+
// Inner pie (for two-level charts)
|
|
130
|
+
hasInnerData && h(
|
|
131
|
+
Pie,
|
|
132
|
+
{
|
|
133
|
+
data: innerData,
|
|
134
|
+
dataKey: "value",
|
|
135
|
+
cx: "50%",
|
|
136
|
+
cy: "50%",
|
|
137
|
+
innerRadius: "60%",
|
|
138
|
+
outerRadius: outerRadiusPercent + "%",
|
|
139
|
+
fill: "#82ca9d",
|
|
140
|
+
isAnimationActive: animate,
|
|
141
|
+
label: showLabels ? (useCustomLabels ? renderCustomizedLabel : true) : false,
|
|
142
|
+
labelLine: showLabelLines && showLabels,
|
|
143
|
+
},
|
|
144
|
+
innerData.map((entry, index) =>
|
|
145
|
+
h(Cell, {
|
|
146
|
+
key: "cell-inner-" + index,
|
|
147
|
+
fill: entry.fill || DEFAULT_COLORS[index % DEFAULT_COLORS.length],
|
|
148
|
+
})
|
|
149
|
+
)
|
|
150
|
+
),
|
|
151
|
+
]
|
|
152
|
+
),
|
|
153
|
+
]
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const reactJupyterLabComponentId = "${reactComponentId}";
|
|
158
|
+
const jupyterLabReactComponentContainer = document.getElementById("${reactComponentId}");
|
|
159
|
+
const root = ReactDOM.createRoot(jupyterLabReactComponentContainer);
|
|
160
|
+
|
|
161
|
+
root.render(h(PieChartComponent));
|
|
162
|
+
</script>
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
165
|
+
function pie(config) {
|
|
166
|
+
const html = generatePieHtml(config);
|
|
167
|
+
tslab.display.html(html);
|
|
168
|
+
}
|
|
169
|
+
exports.pie = pie;
|
|
170
|
+
pie.html = (config) => generatePieHtml(config);
|
|
171
|
+
//# sourceMappingURL=pie.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie.js","sourceRoot":"","sources":["../../src/pie/pie.ts"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAC/B,iDAA8C;AAmB9C,SAAS,eAAe,CAAC,MAAkB;IAC1C,MAAM,gBAAgB,GAAG,cAAc,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,EACL,IAAI,EACJ,SAAS,EACT,WAAW,GAAG,CAAC,EACf,WAAW,GAAG,EAAE,EAChB,UAAU,GAAG,KAAK,EAClB,eAAe,GAAG,KAAK,EACvB,cAAc,GAAG,IAAI,EACrB,OAAO,GAAG,IAAI,EACd,KAAK,GAAG,GAAG,EACX,MAAM,GAAG,GAAG,EACZ,KAAK,GAAG,EAAE,EACV,MAAM,GAAG;QACR,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACT,GACD,GAAG,MAAM,CAAC;IAEX,OAAO;eACO,gBAAgB;;2BAEJ,mBAAQ,CAAC,KAAK;8BACX,mBAAQ,CAAC,QAAQ;6CACF,mBAAQ,CAAC,QAAQ;;;;;+BAK/B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4B9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;4BACf,IAAI,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC;;6BAEhC,UAAU;kCACL,eAAe;iCAChB,cAAc;0BACrB,OAAO;qCACI,WAAW;qCACX,WAAW;yBACvB,KAAK;;;;;;;2BAOH,KAAK;;;;;;;;;;;;;;;;;;;;;;;;yBAwBP,KAAK;0BACJ,MAAM;;;+BAGD,KAAK;gCACJ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CAuDM,gBAAgB;2EACe,gBAAgB;;;;;GAKxF,CAAC;AACJ,CAAC;AAED,SAAS,GAAG,CAAC,MAAkB;IAC9B,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACrC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAIQ,kBAAG;AAFZ,GAAG,CAAC,IAAI,GAAG,CAAC,MAAkB,EAAU,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface IScatterSeriesConfig {
|
|
2
|
+
title?: string;
|
|
3
|
+
data: Record<string, string | number>[];
|
|
4
|
+
xKey: string;
|
|
5
|
+
xName?: string;
|
|
6
|
+
yKey: string;
|
|
7
|
+
yName?: string;
|
|
8
|
+
fill?: string;
|
|
9
|
+
size?: number;
|
|
10
|
+
shape?: "circle" | "square" | "diamond" | "cross" | "plus" | "triangle";
|
|
11
|
+
}
|
|
12
|
+
export interface IScatterConfig {
|
|
13
|
+
series: IScatterSeriesConfig[];
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
title?: string;
|
|
17
|
+
subtitle?: string;
|
|
18
|
+
showLegend?: boolean;
|
|
19
|
+
showTooltip?: boolean;
|
|
20
|
+
xAxisTitle?: string;
|
|
21
|
+
yAxisTitle?: string;
|
|
22
|
+
xAxisFormatter?: string;
|
|
23
|
+
yAxisFormatter?: string;
|
|
24
|
+
margin?: {
|
|
25
|
+
top?: number;
|
|
26
|
+
right?: number;
|
|
27
|
+
left?: number;
|
|
28
|
+
bottom?: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
declare function scatter(config: IScatterConfig): void;
|
|
32
|
+
declare namespace scatter {
|
|
33
|
+
var html: (config: IScatterConfig) => string;
|
|
34
|
+
}
|
|
35
|
+
export { scatter };
|
|
36
|
+
//# sourceMappingURL=scatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scatter.d.ts","sourceRoot":"","sources":["../../src/scatter/scatter.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,oBAAoB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;CACxE;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACF;AAoMD,iBAAS,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAG7C;kBAHQ,OAAO;;;AAOhB,OAAO,EAAE,OAAO,EAAE,CAAC"}
|