@antv/gpt-vis 1.0.0-beta.1 → 1.0.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 +223 -47
- package/README.zh-CN.md +227 -51
- package/dist/cjs/gpt-vis/index.d.ts +8 -1
- package/dist/cjs/gpt-vis/index.js +43 -20
- package/dist/cjs/index.d.ts +15 -2
- package/dist/cjs/index.js +22 -2
- package/dist/cjs/syntax/parser.d.ts +17 -2
- package/dist/cjs/syntax/parser.js +151 -38
- package/dist/cjs/util/container.d.ts +5 -0
- package/dist/cjs/util/container.js +43 -0
- package/dist/cjs/util/theme.d.ts +5 -0
- package/dist/cjs/util/theme.js +9 -2
- package/dist/cjs/vis/area/index.js +2 -1
- package/dist/cjs/vis/bar/index.js +5 -4
- package/dist/cjs/vis/boxplot/index.js +7 -2
- package/dist/cjs/vis/column/index.js +5 -4
- package/dist/cjs/vis/dual-axes/index.js +3 -3
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +35 -0
- package/dist/cjs/vis/fishbone-diagram/index.js +191 -0
- package/dist/cjs/vis/flow-diagram/index.d.ts +27 -0
- package/dist/cjs/vis/flow-diagram/index.js +287 -0
- package/dist/cjs/vis/funnel/index.js +2 -1
- package/dist/cjs/vis/histogram/index.js +3 -7
- package/dist/cjs/vis/indented-tree/index.d.ts +40 -0
- package/dist/cjs/vis/indented-tree/index.js +385 -0
- package/dist/cjs/vis/line/index.js +2 -1
- package/dist/cjs/vis/liquid/index.js +2 -1
- package/dist/cjs/vis/mindmap/index.d.ts +32 -0
- package/dist/cjs/vis/mindmap/index.js +222 -0
- package/dist/cjs/vis/network-graph/index.d.ts +59 -0
- package/dist/cjs/vis/network-graph/index.js +175 -0
- package/dist/cjs/vis/organization-chart/index.d.ts +64 -0
- package/dist/cjs/vis/organization-chart/index.js +200 -0
- package/dist/cjs/vis/pie/index.js +3 -3
- package/dist/cjs/vis/radar/index.d.ts +1 -0
- package/dist/cjs/vis/radar/index.js +10 -9
- package/dist/cjs/vis/sankey/index.js +2 -1
- package/dist/cjs/vis/scatter/index.d.ts +2 -0
- package/dist/cjs/vis/scatter/index.js +9 -4
- package/dist/cjs/vis/summary/index.js +17 -3
- package/dist/cjs/vis/table/index.d.ts +1 -0
- package/dist/cjs/vis/table/index.js +37 -1
- package/dist/cjs/vis/treemap/index.js +2 -1
- package/dist/cjs/vis/venn/index.d.ts +2 -1
- package/dist/cjs/vis/venn/index.js +18 -3
- package/dist/cjs/vis/violin/index.js +2 -1
- package/dist/cjs/vis/waterfall/index.d.ts +6 -9
- package/dist/cjs/vis/waterfall/index.js +29 -6
- package/dist/cjs/vis/word-cloud/index.js +2 -1
- package/dist/cjs/vis-wrapper/icons.js +2 -2
- package/dist/cjs/vis-wrapper/index.d.ts +1 -0
- package/dist/cjs/vis-wrapper/index.js +27 -16
- package/dist/cjs/vis-wrapper/styles.d.ts +1 -1
- package/dist/cjs/vis-wrapper/styles.js +8 -1
- package/dist/esm/gpt-vis/index.d.ts +8 -1
- package/dist/esm/gpt-vis/index.js +47 -26
- package/dist/esm/index.d.ts +15 -2
- package/dist/esm/index.js +7 -1
- package/dist/esm/syntax/parser.d.ts +17 -2
- package/dist/esm/syntax/parser.js +248 -90
- package/dist/esm/util/container.d.ts +5 -0
- package/dist/esm/util/container.js +20 -0
- package/dist/esm/util/theme.d.ts +5 -0
- package/dist/esm/util/theme.js +9 -0
- package/dist/esm/vis/area/index.js +3 -2
- package/dist/esm/vis/bar/index.js +7 -6
- package/dist/esm/vis/boxplot/index.js +17 -4
- package/dist/esm/vis/column/index.js +7 -6
- package/dist/esm/vis/dual-axes/index.js +13 -5
- package/dist/esm/vis/fishbone-diagram/index.d.ts +35 -0
- package/dist/esm/vis/fishbone-diagram/index.js +219 -0
- package/dist/esm/vis/flow-diagram/index.d.ts +27 -0
- package/dist/esm/vis/flow-diagram/index.js +349 -0
- package/dist/esm/vis/funnel/index.js +3 -2
- package/dist/esm/vis/histogram/index.js +6 -7
- package/dist/esm/vis/indented-tree/index.d.ts +40 -0
- package/dist/esm/vis/indented-tree/index.js +569 -0
- package/dist/esm/vis/line/index.js +3 -2
- package/dist/esm/vis/liquid/index.js +3 -2
- package/dist/esm/vis/mindmap/index.d.ts +32 -0
- package/dist/esm/vis/mindmap/index.js +316 -0
- package/dist/esm/vis/network-graph/index.d.ts +59 -0
- package/dist/esm/vis/network-graph/index.js +242 -0
- package/dist/esm/vis/organization-chart/index.d.ts +64 -0
- package/dist/esm/vis/organization-chart/index.js +271 -0
- package/dist/esm/vis/pie/index.js +4 -8
- package/dist/esm/vis/radar/index.d.ts +1 -0
- package/dist/esm/vis/radar/index.js +20 -4
- package/dist/esm/vis/sankey/index.js +3 -2
- package/dist/esm/vis/scatter/index.d.ts +2 -0
- package/dist/esm/vis/scatter/index.js +15 -4
- package/dist/esm/vis/summary/index.js +25 -4
- package/dist/esm/vis/table/index.d.ts +1 -0
- package/dist/esm/vis/table/index.js +9 -2
- package/dist/esm/vis/treemap/index.js +3 -2
- package/dist/esm/vis/venn/index.d.ts +2 -1
- package/dist/esm/vis/venn/index.js +29 -4
- package/dist/esm/vis/violin/index.js +3 -2
- package/dist/esm/vis/waterfall/index.d.ts +6 -9
- package/dist/esm/vis/waterfall/index.js +33 -13
- package/dist/esm/vis/word-cloud/index.js +3 -2
- package/dist/esm/vis-wrapper/icons.js +2 -2
- package/dist/esm/vis-wrapper/index.d.ts +1 -0
- package/dist/esm/vis-wrapper/index.js +15 -10
- package/dist/esm/vis-wrapper/styles.d.ts +1 -1
- package/dist/esm/vis-wrapper/styles.js +1 -1
- package/dist/umd/index.min.js +1 -1
- package/package.json +17 -21
- package/src/gpt-vis/index.ts +0 -283
- package/src/index.ts +0 -44
- package/src/readme.md +0 -37
- package/src/syntax/index.ts +0 -2
- package/src/syntax/parser.ts +0 -411
- package/src/types/index.ts +0 -29
- package/src/util/theme.ts +0 -167
- package/src/vis/area/README.md +0 -143
- package/src/vis/area/index.ts +0 -212
- package/src/vis/bar/README.md +0 -158
- package/src/vis/bar/index.ts +0 -186
- package/src/vis/boxplot/README.md +0 -168
- package/src/vis/boxplot/index.ts +0 -162
- package/src/vis/column/README.md +0 -158
- package/src/vis/column/index.ts +0 -185
- package/src/vis/dual-axes/README.md +0 -191
- package/src/vis/dual-axes/index.ts +0 -218
- package/src/vis/funnel/README.md +0 -143
- package/src/vis/funnel/index.ts +0 -238
- package/src/vis/histogram/README.md +0 -130
- package/src/vis/histogram/index.ts +0 -153
- package/src/vis/line/README.md +0 -138
- package/src/vis/line/index.ts +0 -159
- package/src/vis/liquid/README.md +0 -150
- package/src/vis/liquid/index.ts +0 -130
- package/src/vis/pie/README.md +0 -127
- package/src/vis/pie/index.ts +0 -163
- package/src/vis/radar/README.md +0 -184
- package/src/vis/radar/index.ts +0 -214
- package/src/vis/sankey/README.md +0 -144
- package/src/vis/sankey/index.ts +0 -144
- package/src/vis/scatter/README.md +0 -145
- package/src/vis/scatter/index.ts +0 -147
- package/src/vis/summary/README.md +0 -272
- package/src/vis/summary/index.ts +0 -91
- package/src/vis/table/README.md +0 -174
- package/src/vis/table/index.ts +0 -241
- package/src/vis/treemap/README.md +0 -199
- package/src/vis/treemap/index.ts +0 -167
- package/src/vis/venn/README.md +0 -153
- package/src/vis/venn/index.ts +0 -149
- package/src/vis/violin/README.md +0 -168
- package/src/vis/violin/index.ts +0 -216
- package/src/vis/waterfall/README.md +0 -178
- package/src/vis/waterfall/index.ts +0 -258
- package/src/vis/word-cloud/README.md +0 -137
- package/src/vis/word-cloud/index.ts +0 -137
- package/src/vis-wrapper/README.md +0 -159
- package/src/vis-wrapper/icons.ts +0 -35
- package/src/vis-wrapper/index.ts +0 -276
- package/src/vis-wrapper/styles.ts +0 -195
package/src/vis-wrapper/index.ts
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { snapdom } from '@zumer/snapdom';
|
|
2
|
-
import {
|
|
3
|
-
createCheckIcon,
|
|
4
|
-
createCopyIcon,
|
|
5
|
-
createDownloadIcon,
|
|
6
|
-
createZoomInIcon,
|
|
7
|
-
createZoomOutIcon,
|
|
8
|
-
} from './icons';
|
|
9
|
-
import { injectWrapperStyles } from './styles';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Labels for different locales
|
|
13
|
-
*/
|
|
14
|
-
const DEFAULT_LABELS: Record<
|
|
15
|
-
string,
|
|
16
|
-
{ chartTab: string; codeTab: string; download: string; copy: string; copied: string }
|
|
17
|
-
> = {
|
|
18
|
-
'zh-CN': {
|
|
19
|
-
chartTab: '图表',
|
|
20
|
-
codeTab: '代码',
|
|
21
|
-
download: '下载',
|
|
22
|
-
copy: '复制',
|
|
23
|
-
copied: '完成',
|
|
24
|
-
},
|
|
25
|
-
'en-US': {
|
|
26
|
-
chartTab: 'Chart',
|
|
27
|
-
codeTab: 'Code',
|
|
28
|
-
download: 'Download',
|
|
29
|
-
copy: 'Copy',
|
|
30
|
-
copied: 'Copied',
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* G6 chart types that support zoom functionality
|
|
36
|
-
*/
|
|
37
|
-
const G6_CHART_TYPES: string[] = [];
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Wrapper configuration options
|
|
41
|
-
*/
|
|
42
|
-
export interface WrapperConfig {
|
|
43
|
-
chartType?: string;
|
|
44
|
-
syntax?: string | object;
|
|
45
|
-
locale?: string;
|
|
46
|
-
onChartReady?: (chart: any) => void;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Wrapper instance that provides control over the wrapper UI
|
|
51
|
-
*/
|
|
52
|
-
export interface WrapperInstance {
|
|
53
|
-
chartContainer: HTMLElement;
|
|
54
|
-
destroy: () => void;
|
|
55
|
-
setChartRef: (chart: any) => void;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Create a wrapper container with tabs, buttons, and controls
|
|
60
|
-
* @param container - The parent container element or selector
|
|
61
|
-
* @param config - Wrapper configuration options
|
|
62
|
-
* @returns A wrapper instance with the chart container and controls
|
|
63
|
-
*/
|
|
64
|
-
export function createVisWrapper(
|
|
65
|
-
container: string | HTMLElement,
|
|
66
|
-
config: WrapperConfig = {},
|
|
67
|
-
): WrapperInstance {
|
|
68
|
-
// Inject styles if not already present
|
|
69
|
-
injectWrapperStyles();
|
|
70
|
-
|
|
71
|
-
// Get container element
|
|
72
|
-
const containerElement =
|
|
73
|
-
typeof container === 'string' ? document.querySelector<HTMLElement>(container) : container;
|
|
74
|
-
|
|
75
|
-
if (!containerElement) {
|
|
76
|
-
throw new Error('Container element not found');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const { chartType = '', syntax = '', locale = 'zh-CN' } = config;
|
|
80
|
-
const syntaxString = typeof syntax === 'string' ? syntax : JSON.stringify(syntax, null, 2);
|
|
81
|
-
const labels = DEFAULT_LABELS[locale] || DEFAULT_LABELS['en-US'];
|
|
82
|
-
const isG6Chart = G6_CHART_TYPES.includes(chartType);
|
|
83
|
-
|
|
84
|
-
let chartRef: any = null;
|
|
85
|
-
let copyTimeout: number | undefined;
|
|
86
|
-
|
|
87
|
-
// Build zoom buttons HTML for G6 charts
|
|
88
|
-
const zoomButtonsHTML = isG6Chart
|
|
89
|
-
? `
|
|
90
|
-
<button class="gpt-vis-wrapper-text-button gpt-vis-wrapper-zoom-button"
|
|
91
|
-
data-action="zoom-in"
|
|
92
|
-
aria-label="Zoom in"
|
|
93
|
-
title="Zoom in">
|
|
94
|
-
${createZoomInIcon(18)}
|
|
95
|
-
</button>
|
|
96
|
-
<button class="gpt-vis-wrapper-text-button gpt-vis-wrapper-zoom-button"
|
|
97
|
-
data-action="zoom-out"
|
|
98
|
-
aria-label="Zoom out"
|
|
99
|
-
title="Zoom out">
|
|
100
|
-
${createZoomOutIcon(18)}
|
|
101
|
-
</button>
|
|
102
|
-
<div class="gpt-vis-wrapper-divider"></div>
|
|
103
|
-
`
|
|
104
|
-
: '';
|
|
105
|
-
|
|
106
|
-
// Create wrapper HTML structure using template string
|
|
107
|
-
const wrapperHTML = `
|
|
108
|
-
<div class="gpt-vis-wrapper-container">
|
|
109
|
-
<div class="gpt-vis-wrapper-header">
|
|
110
|
-
<div class="gpt-vis-wrapper-tab-left">
|
|
111
|
-
<button class="gpt-vis-wrapper-tab-button active"
|
|
112
|
-
data-tab="chart"
|
|
113
|
-
role="tab"
|
|
114
|
-
aria-selected="true"
|
|
115
|
-
aria-controls="chart-panel">
|
|
116
|
-
${labels.chartTab}
|
|
117
|
-
</button>
|
|
118
|
-
<button class="gpt-vis-wrapper-tab-button"
|
|
119
|
-
data-tab="code"
|
|
120
|
-
role="tab"
|
|
121
|
-
aria-selected="false"
|
|
122
|
-
aria-controls="code-panel">
|
|
123
|
-
${labels.codeTab}
|
|
124
|
-
</button>
|
|
125
|
-
</div>
|
|
126
|
-
<div class="gpt-vis-wrapper-tab-right">
|
|
127
|
-
${zoomButtonsHTML}
|
|
128
|
-
<button class="gpt-vis-wrapper-text-button"
|
|
129
|
-
data-action="download"
|
|
130
|
-
aria-label="${labels.download}">
|
|
131
|
-
${createDownloadIcon(16)} <span>${labels.download}</span>
|
|
132
|
-
</button>
|
|
133
|
-
<button class="gpt-vis-wrapper-text-button gpt-vis-wrapper-tab-hide"
|
|
134
|
-
data-action="copy"
|
|
135
|
-
aria-label="${labels.copy}">
|
|
136
|
-
${createCopyIcon()} <span>${labels.copy}</span>
|
|
137
|
-
</button>
|
|
138
|
-
</div>
|
|
139
|
-
</div>
|
|
140
|
-
<div class="gpt-vis-wrapper-content">
|
|
141
|
-
<div class="gpt-vis-wrapper-chart">
|
|
142
|
-
<div class="gpt-vis-wrapper-chart-container"></div>
|
|
143
|
-
</div>
|
|
144
|
-
<div class="gpt-vis-wrapper-code gpt-vis-wrapper-tab-hide">${syntaxString}</div>
|
|
145
|
-
</div>
|
|
146
|
-
</div>
|
|
147
|
-
`;
|
|
148
|
-
|
|
149
|
-
// Insert HTML into container
|
|
150
|
-
containerElement.innerHTML = wrapperHTML;
|
|
151
|
-
|
|
152
|
-
// Get references to interactive elements
|
|
153
|
-
const wrapperContainer = containerElement.querySelector('.gpt-vis-wrapper-container')!;
|
|
154
|
-
const chartTabButton = wrapperContainer.querySelector('[data-tab="chart"]') as HTMLButtonElement;
|
|
155
|
-
const codeTabButton = wrapperContainer.querySelector('[data-tab="code"]') as HTMLButtonElement;
|
|
156
|
-
const chartWrapper = wrapperContainer.querySelector('.gpt-vis-wrapper-chart') as HTMLElement;
|
|
157
|
-
const codeContainer = wrapperContainer.querySelector('.gpt-vis-wrapper-code') as HTMLElement;
|
|
158
|
-
const chartContainer = wrapperContainer.querySelector(
|
|
159
|
-
'.gpt-vis-wrapper-chart-container',
|
|
160
|
-
) as HTMLElement;
|
|
161
|
-
const downloadButton = wrapperContainer.querySelector(
|
|
162
|
-
'[data-action="download"]',
|
|
163
|
-
) as HTMLButtonElement;
|
|
164
|
-
const copyButton = wrapperContainer.querySelector('[data-action="copy"]') as HTMLButtonElement;
|
|
165
|
-
const zoomInButton = wrapperContainer.querySelector(
|
|
166
|
-
'[data-action="zoom-in"]',
|
|
167
|
-
) as HTMLButtonElement | null;
|
|
168
|
-
const zoomOutButton = wrapperContainer.querySelector(
|
|
169
|
-
'[data-action="zoom-out"]',
|
|
170
|
-
) as HTMLButtonElement | null;
|
|
171
|
-
const divider = wrapperContainer.querySelector('.gpt-vis-wrapper-divider') as HTMLElement | null;
|
|
172
|
-
|
|
173
|
-
// Event handlers
|
|
174
|
-
function switchTab(tab: 'chart' | 'code') {
|
|
175
|
-
if (tab === 'chart') {
|
|
176
|
-
chartTabButton.classList.add('active');
|
|
177
|
-
chartTabButton.setAttribute('aria-selected', 'true');
|
|
178
|
-
codeTabButton.classList.remove('active');
|
|
179
|
-
codeTabButton.setAttribute('aria-selected', 'false');
|
|
180
|
-
chartWrapper.classList.remove('gpt-vis-wrapper-tab-hide');
|
|
181
|
-
codeContainer.classList.add('gpt-vis-wrapper-tab-hide');
|
|
182
|
-
downloadButton.classList.remove('gpt-vis-wrapper-tab-hide');
|
|
183
|
-
copyButton.classList.add('gpt-vis-wrapper-tab-hide');
|
|
184
|
-
|
|
185
|
-
if (isG6Chart && zoomInButton && zoomOutButton && divider) {
|
|
186
|
-
zoomInButton.classList.remove('gpt-vis-wrapper-tab-hide');
|
|
187
|
-
zoomOutButton.classList.remove('gpt-vis-wrapper-tab-hide');
|
|
188
|
-
divider.classList.remove('gpt-vis-wrapper-tab-hide');
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
chartTabButton.classList.remove('active');
|
|
192
|
-
chartTabButton.setAttribute('aria-selected', 'false');
|
|
193
|
-
codeTabButton.classList.add('active');
|
|
194
|
-
codeTabButton.setAttribute('aria-selected', 'true');
|
|
195
|
-
chartWrapper.classList.add('gpt-vis-wrapper-tab-hide');
|
|
196
|
-
codeContainer.classList.remove('gpt-vis-wrapper-tab-hide');
|
|
197
|
-
downloadButton.classList.add('gpt-vis-wrapper-tab-hide');
|
|
198
|
-
copyButton.classList.remove('gpt-vis-wrapper-tab-hide');
|
|
199
|
-
|
|
200
|
-
if (isG6Chart && zoomInButton && zoomOutButton && divider) {
|
|
201
|
-
zoomInButton.classList.add('gpt-vis-wrapper-tab-hide');
|
|
202
|
-
zoomOutButton.classList.add('gpt-vis-wrapper-tab-hide');
|
|
203
|
-
divider.classList.add('gpt-vis-wrapper-tab-hide');
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function handleZoomIn() {
|
|
209
|
-
if (chartRef && typeof chartRef.zoomTo === 'function') {
|
|
210
|
-
const currentZoom = chartRef.getZoom?.() || 1;
|
|
211
|
-
const newZoom = Math.min(currentZoom * 1.15, 5); // Zoom in: multiply to enlarge
|
|
212
|
-
chartRef.zoomTo(newZoom);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function handleZoomOut() {
|
|
217
|
-
if (chartRef && typeof chartRef.zoomTo === 'function') {
|
|
218
|
-
const currentZoom = chartRef.getZoom?.() || 1;
|
|
219
|
-
const newZoom = Math.max(currentZoom / 1.15, 0.1); // Zoom out: divide to shrink
|
|
220
|
-
chartRef.zoomTo(newZoom);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
async function handleDownload() {
|
|
225
|
-
try {
|
|
226
|
-
if (chartContainer) {
|
|
227
|
-
const result = await snapdom(chartContainer, { scale: 2 });
|
|
228
|
-
await result.download({
|
|
229
|
-
format: 'png',
|
|
230
|
-
filename: `chart-${chartType}-${Date.now()}`,
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
} catch (error) {
|
|
234
|
-
console.error('Download image failed:', error);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
async function handleCopy() {
|
|
239
|
-
try {
|
|
240
|
-
await navigator.clipboard.writeText(syntaxString);
|
|
241
|
-
copyButton.innerHTML = `${createCheckIcon()} <span>${labels.copied}</span>`;
|
|
242
|
-
|
|
243
|
-
if (copyTimeout) {
|
|
244
|
-
clearTimeout(copyTimeout);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
copyTimeout = window.setTimeout(() => {
|
|
248
|
-
copyButton.innerHTML = `${createCopyIcon()} <span>${labels.copy}</span>`;
|
|
249
|
-
}, 1000);
|
|
250
|
-
} catch (error) {
|
|
251
|
-
console.error('Copy failed:', error);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// Attach event listeners
|
|
256
|
-
chartTabButton.onclick = () => switchTab('chart');
|
|
257
|
-
codeTabButton.onclick = () => switchTab('code');
|
|
258
|
-
downloadButton.onclick = handleDownload;
|
|
259
|
-
copyButton.onclick = handleCopy;
|
|
260
|
-
if (zoomInButton) zoomInButton.onclick = handleZoomIn;
|
|
261
|
-
if (zoomOutButton) zoomOutButton.onclick = handleZoomOut;
|
|
262
|
-
|
|
263
|
-
// Return wrapper instance
|
|
264
|
-
return {
|
|
265
|
-
chartContainer,
|
|
266
|
-
setChartRef: (chart: any) => {
|
|
267
|
-
chartRef = chart;
|
|
268
|
-
},
|
|
269
|
-
destroy: () => {
|
|
270
|
-
if (copyTimeout) {
|
|
271
|
-
clearTimeout(copyTimeout);
|
|
272
|
-
}
|
|
273
|
-
containerElement.innerHTML = '';
|
|
274
|
-
},
|
|
275
|
-
};
|
|
276
|
-
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CSS styles for the wrapper component
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export const wrapperStyles = `
|
|
6
|
-
.gpt-vis-wrapper-container {
|
|
7
|
-
border-radius: 8px;
|
|
8
|
-
overflow: hidden;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.gpt-vis-wrapper-header {
|
|
12
|
-
display: flex;
|
|
13
|
-
justify-content: space-between;
|
|
14
|
-
align-items: center;
|
|
15
|
-
background: #f5f5f5;
|
|
16
|
-
padding: 6px 14px 6px 6px;
|
|
17
|
-
gap: 2px;
|
|
18
|
-
position: relative;
|
|
19
|
-
z-index: 10;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.gpt-vis-wrapper-tab-left {
|
|
23
|
-
display: flex;
|
|
24
|
-
gap: 2px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.gpt-vis-wrapper-tab-right {
|
|
28
|
-
display: flex;
|
|
29
|
-
gap: 4px;
|
|
30
|
-
align-items: center;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.gpt-vis-wrapper-tab-button {
|
|
34
|
-
border: none;
|
|
35
|
-
box-shadow: none;
|
|
36
|
-
background: transparent;
|
|
37
|
-
color: #494949;
|
|
38
|
-
border-radius: 8px;
|
|
39
|
-
height: 26px;
|
|
40
|
-
width: 52px;
|
|
41
|
-
font-size: 12px;
|
|
42
|
-
transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
43
|
-
transform: scale(1);
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
outline: none;
|
|
46
|
-
font-family: inherit;
|
|
47
|
-
display: inline-flex;
|
|
48
|
-
align-items: center;
|
|
49
|
-
justify-content: center;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.gpt-vis-wrapper-tab-button.active {
|
|
53
|
-
background: #fff;
|
|
54
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.gpt-vis-wrapper-tab-button:hover,
|
|
58
|
-
.gpt-vis-wrapper-tab-button:focus {
|
|
59
|
-
color: #494949;
|
|
60
|
-
transform: scale(1.02);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.gpt-vis-wrapper-tab-button:not(.active):hover,
|
|
64
|
-
.gpt-vis-wrapper-tab-button:not(.active):focus {
|
|
65
|
-
background: #f0f0f0;
|
|
66
|
-
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.gpt-vis-wrapper-tab-button.active:hover,
|
|
70
|
-
.gpt-vis-wrapper-tab-button.active:focus {
|
|
71
|
-
background: #fff;
|
|
72
|
-
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.gpt-vis-wrapper-tab-button:active {
|
|
76
|
-
transform: scale(0.96);
|
|
77
|
-
transition: all 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.gpt-vis-wrapper-tab-button.active:active {
|
|
81
|
-
background: #fff;
|
|
82
|
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.gpt-vis-wrapper-tab-button:not(.active):active {
|
|
86
|
-
background: #e8e8e8;
|
|
87
|
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.gpt-vis-wrapper-text-button {
|
|
91
|
-
border: none;
|
|
92
|
-
box-shadow: none;
|
|
93
|
-
background: transparent;
|
|
94
|
-
color: #494949;
|
|
95
|
-
height: 26px;
|
|
96
|
-
padding: 0 8px;
|
|
97
|
-
font-size: 12px;
|
|
98
|
-
transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
99
|
-
transform: scale(1);
|
|
100
|
-
border-radius: 8px;
|
|
101
|
-
display: inline-flex;
|
|
102
|
-
align-items: center;
|
|
103
|
-
justify-content: center;
|
|
104
|
-
gap: 4px;
|
|
105
|
-
cursor: pointer;
|
|
106
|
-
outline: none;
|
|
107
|
-
font-family: inherit;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.gpt-vis-wrapper-text-button:hover,
|
|
111
|
-
.gpt-vis-wrapper-text-button:focus {
|
|
112
|
-
color: #666;
|
|
113
|
-
background: #e8e8e8;
|
|
114
|
-
transform: scale(1.02);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.gpt-vis-wrapper-text-button:active {
|
|
118
|
-
background: #e8e8e8;
|
|
119
|
-
transform: scale(0.98);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.gpt-vis-wrapper-zoom-button {
|
|
123
|
-
width: 24px;
|
|
124
|
-
height: 24px;
|
|
125
|
-
padding: 0;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.gpt-vis-wrapper-divider {
|
|
129
|
-
width: 1px;
|
|
130
|
-
height: 16px;
|
|
131
|
-
background-color: #d9d9d9;
|
|
132
|
-
margin: 0 8px;
|
|
133
|
-
flex-shrink: 0;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.gpt-vis-wrapper-content {
|
|
137
|
-
overflow: hidden;
|
|
138
|
-
position: relative;
|
|
139
|
-
background: #fafafa;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.gpt-vis-wrapper-chart {
|
|
143
|
-
min-width: 300px;
|
|
144
|
-
max-width: 100%;
|
|
145
|
-
overflow: hidden;
|
|
146
|
-
position: relative;
|
|
147
|
-
padding: 16px;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.gpt-vis-wrapper-chart-container {
|
|
151
|
-
width: 100%;
|
|
152
|
-
height: 100%;
|
|
153
|
-
overflow: auto;
|
|
154
|
-
scrollbar-width: none;
|
|
155
|
-
-ms-overflow-style: none;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.gpt-vis-wrapper-chart-container::-webkit-scrollbar {
|
|
159
|
-
display: none;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.gpt-vis-wrapper-code {
|
|
163
|
-
max-height: 500px;
|
|
164
|
-
overflow: auto;
|
|
165
|
-
padding: 16px;
|
|
166
|
-
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
|
|
167
|
-
font-size: 12px;
|
|
168
|
-
line-height: 1.6;
|
|
169
|
-
color: #333;
|
|
170
|
-
background: #fafafa;
|
|
171
|
-
white-space: pre-wrap;
|
|
172
|
-
word-wrap: break-word;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.gpt-vis-wrapper-tab-hide {
|
|
176
|
-
display: none;
|
|
177
|
-
}
|
|
178
|
-
`;
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Inject styles into the document head
|
|
182
|
-
*/
|
|
183
|
-
export function injectWrapperStyles(): void {
|
|
184
|
-
const styleId = 'gpt-vis-wrapper-styles';
|
|
185
|
-
|
|
186
|
-
// Check if styles already exist
|
|
187
|
-
if (document.getElementById(styleId)) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const styleElement = document.createElement('style');
|
|
192
|
-
styleElement.id = styleId;
|
|
193
|
-
styleElement.textContent = wrapperStyles;
|
|
194
|
-
document.head.appendChild(styleElement);
|
|
195
|
-
}
|