@opendata-ai/openchart-vanilla 6.4.1 → 6.5.1

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.
@@ -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('.viz-annotation');
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('.viz-annotation-text') as SVGGElement | null;
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('.viz-annotation-refline') as SVGGElement | null;
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('.viz-annotation-text') as SVGGElement | null;
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('.viz-annotation-text') as SVGGElement | null;
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('.viz-annotation-text') as SVGGElement | null;
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('.viz-annotation-text') as SVGGElement | null;
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('viz-mark-rect');
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('viz-chart');
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('.viz-title');
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('.viz-subtitle');
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('.viz-source');
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('.viz-title');
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('.viz-title');
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('.viz-tooltip');
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('.viz-axis-x');
136
- const yAxis = container.querySelector('.viz-axis-y');
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('.viz-chrome');
146
+ const chromeGroup = container.querySelector('.oc-chrome');
147
147
  expect(chromeGroup).not.toBeNull();
148
148
 
149
149
  chart.destroy();
@@ -319,7 +319,7 @@ describe('selection events', () => {
319
319
  // 3. Selection overlay
320
320
  // =========================================================================
321
321
  describe('selection overlay', () => {
322
- it('viz-selection-overlay group appears after selection', () => {
322
+ it('oc-selection-overlay group appears after selection', () => {
323
323
  const onSelect = vi.fn();
324
324
  const chart = createChart(container, selectionSpec, { onSelect });
325
325
 
@@ -330,12 +330,12 @@ describe('selection events', () => {
330
330
  }
331
331
 
332
332
  // No overlay initially
333
- expect(container.querySelector('.viz-selection-overlay')).toBeNull();
333
+ expect(container.querySelector('.oc-selection-overlay')).toBeNull();
334
334
 
335
335
  simulateClick(titleEl);
336
336
 
337
337
  // Overlay should now exist
338
- expect(container.querySelector('.viz-selection-overlay')).not.toBeNull();
338
+ expect(container.querySelector('.oc-selection-overlay')).not.toBeNull();
339
339
 
340
340
  chart.destroy();
341
341
  });
@@ -353,13 +353,13 @@ describe('selection events', () => {
353
353
 
354
354
  // Select
355
355
  simulateClick(titleEl);
356
- expect(container.querySelector('.viz-selection-overlay')).not.toBeNull();
356
+ expect(container.querySelector('.oc-selection-overlay')).not.toBeNull();
357
357
 
358
358
  // Deselect by clicking empty area
359
359
  const svg = getSvg(container);
360
360
  svg.dispatchEvent(new MouseEvent('click', { bubbles: false }));
361
361
 
362
- expect(container.querySelector('.viz-selection-overlay')).toBeNull();
362
+ expect(container.querySelector('.oc-selection-overlay')).toBeNull();
363
363
 
364
364
  chart.destroy();
365
365
  });
@@ -538,13 +538,13 @@ describe('selection events', () => {
538
538
  }
539
539
 
540
540
  simulateClick(titleEl);
541
- expect(container.querySelector('.viz-selection-overlay')).not.toBeNull();
541
+ expect(container.querySelector('.oc-selection-overlay')).not.toBeNull();
542
542
 
543
543
  // Update with same spec (should re-render but preserve selection)
544
544
  chart.update(selectionSpec);
545
545
 
546
546
  // Selection overlay should still be present
547
- expect(container.querySelector('.viz-selection-overlay')).not.toBeNull();
547
+ expect(container.querySelector('.oc-selection-overlay')).not.toBeNull();
548
548
  expect(chart.getSelectedElement()?.type).toBe('chrome');
549
549
 
550
550
  chart.destroy();
@@ -573,7 +573,7 @@ describe('selection events', () => {
573
573
 
574
574
  // Selection should be cleared because source no longer exists
575
575
  expect(chart.getSelectedElement()).toBeNull();
576
- expect(container.querySelector('.viz-selection-overlay')).toBeNull();
576
+ expect(container.querySelector('.oc-selection-overlay')).toBeNull();
577
577
 
578
578
  chart.destroy();
579
579
  });
@@ -614,7 +614,7 @@ describe('selection events', () => {
614
614
  // 7. Hover feedback
615
615
  // =========================================================================
616
616
  describe('hover feedback', () => {
617
- it('mouse enter on editable element adds viz-editable-hover class', () => {
617
+ it('mouse enter on editable element adds oc-editable-hover class', () => {
618
618
  const onSelect = vi.fn();
619
619
  const chart = createChart(container, selectionSpec, { onSelect });
620
620
 
@@ -627,12 +627,12 @@ describe('selection events', () => {
627
627
  // Trigger mouseenter (uses capture so dispatch on the target itself)
628
628
  titleEl.dispatchEvent(new MouseEvent('mouseenter', { bubbles: true }));
629
629
 
630
- expect(titleEl.classList.contains('viz-editable-hover')).toBe(true);
630
+ expect(titleEl.classList.contains('oc-editable-hover')).toBe(true);
631
631
 
632
632
  chart.destroy();
633
633
  });
634
634
 
635
- it('mouse leave removes viz-editable-hover class', () => {
635
+ it('mouse leave removes oc-editable-hover class', () => {
636
636
  const onSelect = vi.fn();
637
637
  const chart = createChart(container, selectionSpec, { onSelect });
638
638
 
@@ -644,11 +644,11 @@ describe('selection events', () => {
644
644
 
645
645
  // Add hover class first
646
646
  titleEl.dispatchEvent(new MouseEvent('mouseenter', { bubbles: true }));
647
- expect(titleEl.classList.contains('viz-editable-hover')).toBe(true);
647
+ expect(titleEl.classList.contains('oc-editable-hover')).toBe(true);
648
648
 
649
649
  // Remove hover class
650
650
  titleEl.dispatchEvent(new MouseEvent('mouseleave', { bubbles: true }));
651
- expect(titleEl.classList.contains('viz-editable-hover')).toBe(false);
651
+ expect(titleEl.classList.contains('oc-editable-hover')).toBe(false);
652
652
 
653
653
  chart.destroy();
654
654
  });
@@ -834,7 +834,7 @@ describe('selection events', () => {
834
834
  });
835
835
 
836
836
  // The overlay should be rendered
837
- expect(container.querySelector('.viz-selection-overlay')).not.toBeNull();
837
+ expect(container.querySelector('.oc-selection-overlay')).not.toBeNull();
838
838
  expect(chart.getSelectedElement()?.type).toBe('chrome');
839
839
 
840
840
  chart.destroy();