@opendata-ai/openchart-vanilla 6.11.0 → 6.12.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/dist/index.d.ts +8 -0
- package/dist/index.js +31 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/svg-renderer.test.ts +7 -0
- package/src/graph/canvas-renderer.ts +3 -1
- package/src/graph/types.ts +2 -0
- package/src/graph-mount.ts +4 -0
- package/src/mount.ts +3 -0
- package/src/sankey-mount.ts +3 -0
- package/src/sankey-renderer.ts +3 -1
- package/src/svg-renderer.ts +3 -1
- package/src/table-mount.ts +3 -0
- package/src/table-renderer.ts +14 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendata-ai/openchart-vanilla",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.12.0",
|
|
4
4
|
"description": "Vanilla JS renderer for openchart: SVG charts, HTML tables, force-directed graphs",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Riley Hilliard",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@floating-ui/dom": "^1.7.6",
|
|
53
|
-
"@opendata-ai/openchart-core": "6.
|
|
54
|
-
"@opendata-ai/openchart-engine": "6.
|
|
53
|
+
"@opendata-ai/openchart-core": "6.12.0",
|
|
54
|
+
"@opendata-ai/openchart-engine": "6.12.0",
|
|
55
55
|
"d3-force": "^3.0.0",
|
|
56
56
|
"d3-quadtree": "^3.0.1"
|
|
57
57
|
},
|
|
@@ -771,4 +771,11 @@ describe('brand watermark', () => {
|
|
|
771
771
|
const brandLink = svg.querySelector('.oc-chrome-ref');
|
|
772
772
|
expect(brandLink).toBeNull();
|
|
773
773
|
});
|
|
774
|
+
|
|
775
|
+
it('does not render brand when layout.watermark is false', () => {
|
|
776
|
+
const spec: ChartSpec = { ...lineSpec, watermark: false };
|
|
777
|
+
const { svg } = renderSpec(spec);
|
|
778
|
+
const brandLink = svg.querySelector('.oc-chrome-ref');
|
|
779
|
+
expect(brandLink).toBeNull();
|
|
780
|
+
});
|
|
774
781
|
});
|
|
@@ -229,7 +229,9 @@ export class GraphCanvasRenderer {
|
|
|
229
229
|
ctx.restore();
|
|
230
230
|
|
|
231
231
|
// Brand watermark in screen coordinates (unaffected by pan/zoom)
|
|
232
|
-
|
|
232
|
+
if (state.watermark) {
|
|
233
|
+
this.drawBrand(ctx, cssWidth, cssHeight, theme);
|
|
234
|
+
}
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
// -------------------------------------------------------------------------
|
package/src/graph/types.ts
CHANGED
package/src/graph-mount.ts
CHANGED
|
@@ -35,6 +35,8 @@ export interface GraphMountOptions {
|
|
|
35
35
|
theme?: ThemeConfig;
|
|
36
36
|
darkMode?: DarkMode;
|
|
37
37
|
responsive?: boolean;
|
|
38
|
+
/** Show the tryOpenData.ai watermark. Defaults to true. */
|
|
39
|
+
watermark?: boolean;
|
|
38
40
|
/** Show the built-in tooltip on node/edge hover. Defaults to true. */
|
|
39
41
|
tooltip?: boolean;
|
|
40
42
|
/** Show the built-in legend. Defaults to true. */
|
|
@@ -157,6 +159,7 @@ export function createGraph(
|
|
|
157
159
|
height,
|
|
158
160
|
theme: options?.theme,
|
|
159
161
|
darkMode,
|
|
162
|
+
watermark: options?.watermark,
|
|
160
163
|
};
|
|
161
164
|
|
|
162
165
|
return compileGraph(currentSpec, compileOpts);
|
|
@@ -465,6 +468,7 @@ export function createGraph(
|
|
|
465
468
|
theme: compilation.theme,
|
|
466
469
|
searchMatches: searchManager.getMatches(),
|
|
467
470
|
isGesturing,
|
|
471
|
+
watermark: compilation.watermark,
|
|
468
472
|
};
|
|
469
473
|
|
|
470
474
|
renderer.render(state);
|
package/src/mount.ts
CHANGED
|
@@ -57,6 +57,8 @@ export interface MountOptions extends ChartEventHandlers {
|
|
|
57
57
|
onDataPointClick?: (data: Record<string, unknown>) => void;
|
|
58
58
|
/** Enable responsive resizing. Defaults to true. */
|
|
59
59
|
responsive?: boolean;
|
|
60
|
+
/** Show the tryOpenData.ai watermark. Defaults to true. */
|
|
61
|
+
watermark?: boolean;
|
|
60
62
|
/** Initial selected element. */
|
|
61
63
|
selectedElement?: ElementRef;
|
|
62
64
|
}
|
|
@@ -1820,6 +1822,7 @@ export function createChart(
|
|
|
1820
1822
|
height,
|
|
1821
1823
|
theme: options?.theme,
|
|
1822
1824
|
darkMode,
|
|
1825
|
+
watermark: options?.watermark,
|
|
1823
1826
|
measureText,
|
|
1824
1827
|
};
|
|
1825
1828
|
|
package/src/sankey-mount.ts
CHANGED
|
@@ -38,6 +38,8 @@ export interface SankeyMountOptions {
|
|
|
38
38
|
darkMode?: DarkMode;
|
|
39
39
|
/** Enable responsive resizing. Defaults to true. */
|
|
40
40
|
responsive?: boolean;
|
|
41
|
+
/** Show the tryOpenData.ai watermark. Defaults to true. */
|
|
42
|
+
watermark?: boolean;
|
|
41
43
|
/** Show tooltips on hover. Defaults to true. */
|
|
42
44
|
tooltip?: boolean;
|
|
43
45
|
/** Callback when a node is clicked. */
|
|
@@ -140,6 +142,7 @@ export function createSankey(
|
|
|
140
142
|
height,
|
|
141
143
|
theme: options?.theme,
|
|
142
144
|
darkMode,
|
|
145
|
+
watermark: options?.watermark,
|
|
143
146
|
};
|
|
144
147
|
|
|
145
148
|
return compileSankey(currentSpec, compileOpts);
|
package/src/sankey-renderer.ts
CHANGED
package/src/svg-renderer.ts
CHANGED
|
@@ -1331,7 +1331,9 @@ export function renderChartSVG(
|
|
|
1331
1331
|
renderChrome(svg, layout);
|
|
1332
1332
|
|
|
1333
1333
|
// Brand renders as a footer item, right-aligned on the source/footer row
|
|
1334
|
-
|
|
1334
|
+
if (layout.watermark) {
|
|
1335
|
+
renderBrand(svg, layout);
|
|
1336
|
+
}
|
|
1335
1337
|
|
|
1336
1338
|
// Reset module-level state after rendering
|
|
1337
1339
|
currentAnimation = undefined;
|
package/src/table-mount.ts
CHANGED
|
@@ -39,6 +39,8 @@ export interface TableMountOptions {
|
|
|
39
39
|
theme?: ThemeConfig;
|
|
40
40
|
darkMode?: DarkMode;
|
|
41
41
|
responsive?: boolean;
|
|
42
|
+
/** Show the tryOpenData.ai watermark. Defaults to true. */
|
|
43
|
+
watermark?: boolean;
|
|
42
44
|
onRowClick?: (row: Record<string, unknown>) => void;
|
|
43
45
|
onStateChange?: (state: TableState) => void;
|
|
44
46
|
externalState?: { sort?: SortState | null; search?: string; page?: number };
|
|
@@ -175,6 +177,7 @@ export function createTable(
|
|
|
175
177
|
height: 600,
|
|
176
178
|
theme: options?.theme,
|
|
177
179
|
darkMode,
|
|
180
|
+
watermark: options?.watermark,
|
|
178
181
|
sort: state.sort ?? undefined,
|
|
179
182
|
search: state.search || undefined,
|
|
180
183
|
page: state.page,
|
package/src/table-renderer.ts
CHANGED
|
@@ -390,18 +390,20 @@ export function renderTable(
|
|
|
390
390
|
wrapper.appendChild(liveRegion);
|
|
391
391
|
|
|
392
392
|
// Brand watermark
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
393
|
+
if (layout.watermark) {
|
|
394
|
+
const brandColor = theme ? theme.colors.axis : '#999999';
|
|
395
|
+
const brand = document.createElement('div');
|
|
396
|
+
brand.className = 'oc-table-ref';
|
|
397
|
+
brand.style.cssText = 'text-align: right; padding: 4px 8px;';
|
|
398
|
+
const brandLink = document.createElement('a');
|
|
399
|
+
brandLink.href = BRAND_URL;
|
|
400
|
+
brandLink.target = '_blank';
|
|
401
|
+
brandLink.rel = 'noopener';
|
|
402
|
+
brandLink.style.cssText = `font-size: ${BRAND_FONT_SIZE}px; font-weight: 600; color: ${brandColor}; opacity: 0.55; text-decoration: none; font-family: ${theme ? theme.fonts.family : 'sans-serif'};`;
|
|
403
|
+
brandLink.textContent = 'tryOpenData.ai';
|
|
404
|
+
brand.appendChild(brandLink);
|
|
405
|
+
wrapper.appendChild(brand);
|
|
406
|
+
}
|
|
405
407
|
|
|
406
408
|
// Animation: stamp CSS custom properties and add oc-animate class BEFORE
|
|
407
409
|
// DOM insertion to avoid a flash of final state.
|