juxscript 1.0.6 → 1.0.8

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.
@@ -669,7 +669,7 @@ export class BarChart {
669
669
  const barGap = barHeight * 0.2;
670
670
  const actualBarHeight = barHeight - barGap;
671
671
 
672
- // X-axis (now the value axis)
672
+ // X-axis (now the value axis) - use yAxisLabel since values are horizontal
673
673
  if (showScaleX) {
674
674
  const xAxis = document.createElementNS('http://www.w3.org/2000/svg', 'line');
675
675
  const axisX = isReverse ? width - padding.right : padding.left;
@@ -681,8 +681,8 @@ export class BarChart {
681
681
  xAxis.setAttribute('stroke-width', '2');
682
682
  svg.appendChild(xAxis);
683
683
 
684
- // X-axis label (now the value label)
685
- if (xAxisLabel && showTicksX) {
684
+ // X-axis label (use yAxisLabel for values in horizontal mode)
685
+ if (yAxisLabel && showTicksX) {
686
686
  const label = document.createElementNS('http://www.w3.org/2000/svg', 'text');
687
687
  label.setAttribute('x', (padding.left + chartWidth / 2).toString());
688
688
  label.setAttribute('y', (height - 15).toString());
@@ -691,7 +691,7 @@ export class BarChart {
691
691
  label.setAttribute('font-size', '12');
692
692
  label.setAttribute('font-weight', '500');
693
693
  label.setAttribute('font-family', 'inherit');
694
- label.textContent = xAxisLabel;
694
+ label.textContent = yAxisLabel;
695
695
  svg.appendChild(label);
696
696
  }
697
697
 
@@ -715,7 +715,7 @@ export class BarChart {
715
715
  gridLine.setAttribute('stroke-dasharray', '4,4');
716
716
  svg.appendChild(gridLine);
717
717
 
718
- // Tick label
718
+ // Tick label (use scaleYUnit since values are on x-axis now)
719
719
  const tickLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text');
720
720
  tickLabel.setAttribute('x', x.toString());
721
721
  tickLabel.setAttribute('y', (height - padding.bottom + 20).toString());
@@ -729,7 +729,7 @@ export class BarChart {
729
729
  }
730
730
  }
731
731
 
732
- // Y-axis (now the category axis)
732
+ // Y-axis (now the category axis) - use xAxisLabel since categories are vertical
733
733
  if (showScaleY) {
734
734
  const yAxis = document.createElementNS('http://www.w3.org/2000/svg', 'line');
735
735
  yAxis.setAttribute('x1', padding.left.toString());
@@ -740,8 +740,8 @@ export class BarChart {
740
740
  yAxis.setAttribute('stroke-width', '2');
741
741
  svg.appendChild(yAxis);
742
742
 
743
- // Y-axis label (now the category label)
744
- if (yAxisLabel && showTicksY) {
743
+ // Y-axis label (use xAxisLabel for categories in horizontal mode)
744
+ if (xAxisLabel && showTicksY) {
745
745
  const label = document.createElementNS('http://www.w3.org/2000/svg', 'text');
746
746
  label.setAttribute('x', '20');
747
747
  label.setAttribute('y', (padding.top + chartHeight / 2).toString());
@@ -751,7 +751,7 @@ export class BarChart {
751
751
  label.setAttribute('font-size', '12');
752
752
  label.setAttribute('font-weight', '500');
753
753
  label.setAttribute('font-family', 'inherit');
754
- label.textContent = yAxisLabel;
754
+ label.textContent = xAxisLabel;
755
755
  svg.appendChild(label);
756
756
  }
757
757
  }
@@ -1000,7 +1000,7 @@ export class BarChart {
1000
1000
  }
1001
1001
 
1002
1002
  private _createDataTable(): HTMLElement {
1003
- const { data, xAxisLabel, yAxisLabel } = this.state;
1003
+ const { data, xAxisLabel, yAxisLabel, chartOrientation } = this.state;
1004
1004
 
1005
1005
  const table = document.createElement('table');
1006
1006
  table.className = 'jux-barchart-table';
@@ -1008,10 +1008,10 @@ export class BarChart {
1008
1008
  const thead = document.createElement('thead');
1009
1009
  const headerRow = document.createElement('tr');
1010
1010
 
1011
- const columnHeaders = [
1012
- xAxisLabel || 'Label',
1013
- yAxisLabel || 'Value'
1014
- ];
1011
+ // Swap headers based on orientation
1012
+ const columnHeaders = chartOrientation === 'horizontal'
1013
+ ? [yAxisLabel || 'Label', xAxisLabel || 'Value']
1014
+ : [xAxisLabel || 'Label', yAxisLabel || 'Value'];
1015
1015
 
1016
1016
  columnHeaders.forEach(text => {
1017
1017
  const th = document.createElement('th');
@@ -1178,11 +1178,13 @@ ${variablesCSS}
1178
1178
  padding: 0.5rem;
1179
1179
  border-bottom: 2px solid #e5e7eb;
1180
1180
  font-weight: 600;
1181
+ text-align: center;
1181
1182
  }
1182
1183
 
1183
1184
  .jux-barchart-table tbody td {
1184
1185
  padding: 0.5rem;
1185
1186
  border-bottom: 1px solid #f3f4f6;
1187
+ text-align: center;
1186
1188
  }
1187
1189
 
1188
1190
  .jux-barchart-svg {