@opendata-ai/openchart-vanilla 6.3.0 → 6.5.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 +53 -5
- package/dist/index.js +897 -168
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -764
- package/package.json +3 -3
- package/src/__tests__/animation.test.ts +358 -0
- package/src/__tests__/edit-events.test.ts +35 -35
- package/src/__tests__/events.test.ts +7 -7
- package/src/__tests__/export.test.ts +1 -1
- package/src/__tests__/mount.test.ts +10 -10
- package/src/__tests__/selection-events.test.ts +869 -0
- package/src/__tests__/svg-renderer.test.ts +67 -67
- package/src/__tests__/table-keyboard.test.ts +18 -18
- package/src/__tests__/table-mount.test.ts +138 -17
- package/src/__tests__/tooltip.test.ts +12 -12
- package/src/animation.ts +75 -0
- package/src/graph/__tests__/graph-mount.test.ts +16 -16
- package/src/graph-mount.ts +18 -18
- package/src/index.ts +3 -1
- package/src/mount.ts +668 -30
- package/src/renderers/table-cells.ts +11 -9
- package/src/svg-renderer.ts +164 -54
- package/src/table-keyboard.ts +5 -5
- package/src/table-mount.ts +34 -11
- package/src/table-renderer.ts +70 -39
- package/src/text-edit-overlay.ts +255 -0
- package/src/tooltip.ts +8 -8
|
@@ -142,7 +142,7 @@ describe('chart event handlers', () => {
|
|
|
142
142
|
const onAnnotationClick = vi.fn();
|
|
143
143
|
const chart = createChart(container, annotatedSpec, { onAnnotationClick });
|
|
144
144
|
|
|
145
|
-
const annotation = container.querySelector('.
|
|
145
|
+
const annotation = container.querySelector('.oc-annotation');
|
|
146
146
|
if (!annotation) {
|
|
147
147
|
// Refline at y=0 may resolve outside the chart area in test env
|
|
148
148
|
chart.destroy();
|
|
@@ -166,7 +166,7 @@ describe('chart event handlers', () => {
|
|
|
166
166
|
const onAnnotationEdit = vi.fn();
|
|
167
167
|
const chart = createChart(container, textAnnotatedSpec, { onAnnotationEdit });
|
|
168
168
|
|
|
169
|
-
const annotation = container.querySelector('.
|
|
169
|
+
const annotation = container.querySelector('.oc-annotation-text') as SVGGElement | null;
|
|
170
170
|
if (!annotation) {
|
|
171
171
|
chart.destroy();
|
|
172
172
|
return;
|
|
@@ -180,7 +180,7 @@ describe('chart event handlers', () => {
|
|
|
180
180
|
const onAnnotationEdit = vi.fn();
|
|
181
181
|
const chart = createChart(container, annotatedSpec, { onAnnotationEdit });
|
|
182
182
|
|
|
183
|
-
const annotation = container.querySelector('.
|
|
183
|
+
const annotation = container.querySelector('.oc-annotation-refline') as SVGGElement | null;
|
|
184
184
|
if (!annotation) {
|
|
185
185
|
chart.destroy();
|
|
186
186
|
return;
|
|
@@ -194,7 +194,7 @@ describe('chart event handlers', () => {
|
|
|
194
194
|
const onAnnotationEdit = vi.fn();
|
|
195
195
|
const chart = createChart(container, textAnnotatedSpec, { onAnnotationEdit });
|
|
196
196
|
|
|
197
|
-
const annotation = container.querySelector('.
|
|
197
|
+
const annotation = container.querySelector('.oc-annotation-text') as SVGGElement | null;
|
|
198
198
|
if (!annotation) {
|
|
199
199
|
chart.destroy();
|
|
200
200
|
return;
|
|
@@ -220,7 +220,7 @@ describe('chart event handlers', () => {
|
|
|
220
220
|
const onAnnotationEdit = vi.fn();
|
|
221
221
|
const chart = createChart(container, textAnnotatedSpec, { onAnnotationEdit });
|
|
222
222
|
|
|
223
|
-
const annotation = container.querySelector('.
|
|
223
|
+
const annotation = container.querySelector('.oc-annotation-text') as SVGGElement | null;
|
|
224
224
|
if (!annotation) {
|
|
225
225
|
chart.destroy();
|
|
226
226
|
return;
|
|
@@ -243,7 +243,7 @@ describe('chart event handlers', () => {
|
|
|
243
243
|
onAnnotationEdit,
|
|
244
244
|
});
|
|
245
245
|
|
|
246
|
-
const annotation = container.querySelector('.
|
|
246
|
+
const annotation = container.querySelector('.oc-annotation-text') as SVGGElement | null;
|
|
247
247
|
if (!annotation) {
|
|
248
248
|
chart.destroy();
|
|
249
249
|
return;
|
|
@@ -268,7 +268,7 @@ describe('chart event handlers', () => {
|
|
|
268
268
|
const onAnnotationEdit = vi.fn();
|
|
269
269
|
const chart = createChart(container, textAnnotatedSpec, { onAnnotationEdit });
|
|
270
270
|
|
|
271
|
-
const annotation = container.querySelector('.
|
|
271
|
+
const annotation = container.querySelector('.oc-annotation-text') as SVGGElement | null;
|
|
272
272
|
if (!annotation) {
|
|
273
273
|
chart.destroy();
|
|
274
274
|
return;
|
|
@@ -67,7 +67,7 @@ describe('exportSVG', () => {
|
|
|
67
67
|
const result = exportSVG(svg);
|
|
68
68
|
// Bar chart should have rect elements
|
|
69
69
|
expect(result).toContain('<rect');
|
|
70
|
-
expect(result).toContain('
|
|
70
|
+
expect(result).toContain('oc-mark-rect');
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it('returned string is well-formed XML (ends with closing svg tag)', () => {
|
|
@@ -23,7 +23,7 @@ describe('createChart', () => {
|
|
|
23
23
|
|
|
24
24
|
const svg = container.querySelector('svg');
|
|
25
25
|
expect(svg).not.toBeNull();
|
|
26
|
-
expect(svg?.getAttribute('class')).toBe('
|
|
26
|
+
expect(svg?.getAttribute('class')).toBe('oc-chart');
|
|
27
27
|
|
|
28
28
|
chart.destroy();
|
|
29
29
|
});
|
|
@@ -41,15 +41,15 @@ describe('createChart', () => {
|
|
|
41
41
|
it('chrome text elements are present with correct content', () => {
|
|
42
42
|
const chart = createChart(container, lineSpec);
|
|
43
43
|
|
|
44
|
-
const title = container.querySelector('.
|
|
44
|
+
const title = container.querySelector('.oc-title');
|
|
45
45
|
expect(title).not.toBeNull();
|
|
46
46
|
expect(title?.textContent).toBe('GDP Growth');
|
|
47
47
|
|
|
48
|
-
const subtitle = container.querySelector('.
|
|
48
|
+
const subtitle = container.querySelector('.oc-subtitle');
|
|
49
49
|
expect(subtitle).not.toBeNull();
|
|
50
50
|
expect(subtitle?.textContent).toBe('US vs UK over time');
|
|
51
51
|
|
|
52
|
-
const source = container.querySelector('.
|
|
52
|
+
const source = container.querySelector('.oc-source');
|
|
53
53
|
expect(source).not.toBeNull();
|
|
54
54
|
expect(source?.textContent).toBe('World Bank');
|
|
55
55
|
|
|
@@ -59,12 +59,12 @@ describe('createChart', () => {
|
|
|
59
59
|
it('update() re-renders with new data', () => {
|
|
60
60
|
const chart = createChart(container, lineSpec);
|
|
61
61
|
|
|
62
|
-
const titleBefore = container.querySelector('.
|
|
62
|
+
const titleBefore = container.querySelector('.oc-title');
|
|
63
63
|
expect(titleBefore?.textContent).toBe('GDP Growth');
|
|
64
64
|
|
|
65
65
|
chart.update(barSpec);
|
|
66
66
|
|
|
67
|
-
const titleAfter = container.querySelector('.
|
|
67
|
+
const titleAfter = container.querySelector('.oc-title');
|
|
68
68
|
expect(titleAfter?.textContent).toBe('Updated Chart');
|
|
69
69
|
|
|
70
70
|
chart.destroy();
|
|
@@ -82,7 +82,7 @@ describe('createChart', () => {
|
|
|
82
82
|
expect(svgAfter).toBeNull();
|
|
83
83
|
|
|
84
84
|
// Tooltip div should also be removed
|
|
85
|
-
const tooltip = container.querySelector('.
|
|
85
|
+
const tooltip = container.querySelector('.oc-tooltip');
|
|
86
86
|
expect(tooltip).toBeNull();
|
|
87
87
|
});
|
|
88
88
|
|
|
@@ -132,8 +132,8 @@ describe('createChart', () => {
|
|
|
132
132
|
it('renders axis elements', () => {
|
|
133
133
|
const chart = createChart(container, lineSpec);
|
|
134
134
|
|
|
135
|
-
const xAxis = container.querySelector('.
|
|
136
|
-
const yAxis = container.querySelector('.
|
|
135
|
+
const xAxis = container.querySelector('.oc-axis-x');
|
|
136
|
+
const yAxis = container.querySelector('.oc-axis-y');
|
|
137
137
|
expect(xAxis).not.toBeNull();
|
|
138
138
|
expect(yAxis).not.toBeNull();
|
|
139
139
|
|
|
@@ -143,7 +143,7 @@ describe('createChart', () => {
|
|
|
143
143
|
it('renders chrome wrapper group', () => {
|
|
144
144
|
const chart = createChart(container, lineSpec);
|
|
145
145
|
|
|
146
|
-
const chromeGroup = container.querySelector('.
|
|
146
|
+
const chromeGroup = container.querySelector('.oc-chrome');
|
|
147
147
|
expect(chromeGroup).not.toBeNull();
|
|
148
148
|
|
|
149
149
|
chart.destroy();
|