@opendata-ai/openchart-vanilla 7.1.2 → 7.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendata-ai/openchart-vanilla",
3
- "version": "7.1.2",
3
+ "version": "7.1.3",
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": "7.1.2",
54
- "@opendata-ai/openchart-engine": "7.1.2",
53
+ "@opendata-ai/openchart-core": "7.1.3",
54
+ "@opendata-ai/openchart-engine": "7.1.3",
55
55
  "d3-force": "^3.0.0",
56
56
  "d3-quadtree": "^3.0.1"
57
57
  },
@@ -71,40 +71,20 @@ export function renderEndpointLabels(parent: SVGElement, layout: ChartLayout): v
71
71
  entryG.appendChild(leader);
72
72
  }
73
73
 
74
- // Swatch: rounded chip with a colored bar through its midline, matching
75
- // the traditional legend so a chart never shows two swatch idioms.
74
+ // Swatch: bare colored line segment matching the legend style.
76
75
  const rowY = entry.labelY + labelFontSize / 2;
77
- const chipHeight = Math.max(12, Math.round(ep.swatchSize * 0.85));
78
- const chipY = rowY - chipHeight / 2;
79
- const chip = createSVGElement('rect');
80
- chip.setAttribute('class', 'oc-endpoint-swatch-chip');
81
- setAttrs(chip, {
82
- x: chipX,
83
- y: chipY,
84
- width: chipWidth,
85
- height: chipHeight,
86
- rx: 3,
87
- ry: 3,
88
- fill: ep.swatchChipFill,
76
+ const line = createSVGElement('line');
77
+ line.setAttribute('class', 'oc-endpoint-swatch-line');
78
+ setAttrs(line, {
79
+ x1: chipX,
80
+ y1: rowY,
81
+ x2: chipX + chipWidth,
82
+ y2: rowY,
83
+ stroke: entry.color,
84
+ 'stroke-width': 2,
85
+ 'stroke-linecap': 'round',
89
86
  });
90
- entryG.appendChild(chip);
91
-
92
- const barWidth = Math.max(8, chipWidth - 8);
93
- const barHeight = 3;
94
- const barX = chipX + (chipWidth - barWidth) / 2;
95
- const barY = rowY - barHeight / 2;
96
- const bar = createSVGElement('rect');
97
- bar.setAttribute('class', 'oc-endpoint-swatch-bar');
98
- setAttrs(bar, {
99
- x: barX,
100
- y: barY,
101
- width: barWidth,
102
- height: barHeight,
103
- rx: barHeight / 2,
104
- ry: barHeight / 2,
105
- fill: entry.color,
106
- });
107
- entryG.appendChild(bar);
87
+ entryG.appendChild(line);
108
88
 
109
89
  // Label text. Multi-line via tspans when wrapped.
110
90
  const label = createSVGElement('text');
@@ -60,53 +60,47 @@ export function renderLegend(parent: SVGElement, legend: LegendLayout): void {
60
60
  }
61
61
  }
62
62
 
63
- // Swatch
64
- // The default ('square') and 'line' shapes render as a "chip": a small
65
- // rounded rectangle in a subtle elevated surface tone with a colored
66
- // rounded bar through the middle. Matches the editorial mock-2 legend
67
- // and the endpoint-labels swatch so a chart never shows two swatch styles.
68
- // 'circle' is preserved for point/scatter charts.
63
+ // Swatch: bare colored mark matching the chart type.
64
+ // Circle for point/scatter, line segment for line/area, filled rect for bar.
65
+ const midX = offsetX + legend.swatchSize / 2;
66
+ const midY = offsetY + legend.swatchSize / 2;
69
67
  if (entry.shape === 'circle') {
70
68
  const circle = createSVGElement('circle');
71
69
  setAttrs(circle, {
72
- cx: offsetX + legend.swatchSize / 2,
73
- cy: offsetY + legend.swatchSize / 2,
70
+ cx: midX,
71
+ cy: midY,
74
72
  r: legend.swatchSize / 2,
75
73
  fill: entry.color,
76
74
  });
77
75
  entryG.appendChild(circle);
78
- } else {
79
- const chipHeight = Math.max(12, Math.round(legend.swatchSize * 0.85));
80
- const chipY = offsetY + legend.swatchSize / 2 - chipHeight / 2;
81
- const chip = createSVGElement('rect');
82
- chip.setAttribute('class', 'oc-legend-swatch-chip');
83
- setAttrs(chip, {
84
- x: offsetX,
85
- y: chipY,
86
- width: legend.swatchSize,
87
- height: chipHeight,
88
- rx: 3,
89
- ry: 3,
90
- fill: legend.swatchChipFill,
76
+ } else if (entry.shape === 'line') {
77
+ const lineWidth = legend.swatchSize;
78
+ const line = createSVGElement('line');
79
+ line.setAttribute('class', 'oc-legend-swatch-line');
80
+ setAttrs(line, {
81
+ x1: offsetX,
82
+ y1: midY,
83
+ x2: offsetX + lineWidth,
84
+ y2: midY,
85
+ stroke: entry.color,
86
+ 'stroke-width': 2,
87
+ 'stroke-linecap': 'round',
91
88
  });
92
- entryG.appendChild(chip);
93
-
94
- const barWidth = Math.max(8, legend.swatchSize - 8);
95
- const barHeight = 3;
96
- const barX = offsetX + (legend.swatchSize - barWidth) / 2;
97
- const barY = offsetY + legend.swatchSize / 2 - barHeight / 2;
98
- const bar = createSVGElement('rect');
99
- bar.setAttribute('class', 'oc-legend-swatch-bar');
100
- setAttrs(bar, {
101
- x: barX,
102
- y: barY,
103
- width: barWidth,
104
- height: barHeight,
105
- rx: barHeight / 2,
106
- ry: barHeight / 2,
89
+ entryG.appendChild(line);
90
+ } else {
91
+ const rectSize = Math.round(legend.swatchSize * 0.6);
92
+ const rect = createSVGElement('rect');
93
+ rect.setAttribute('class', 'oc-legend-swatch-rect');
94
+ setAttrs(rect, {
95
+ x: offsetX + (legend.swatchSize - rectSize) / 2,
96
+ y: midY - rectSize / 2,
97
+ width: rectSize,
98
+ height: rectSize,
99
+ rx: 2,
100
+ ry: 2,
107
101
  fill: entry.color,
108
102
  });
109
- entryG.appendChild(bar);
103
+ entryG.appendChild(rect);
110
104
  }
111
105
 
112
106
  // Label