@internetstiftelsen/charts 0.9.1 → 0.9.2

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/grid.d.ts CHANGED
@@ -3,11 +3,11 @@ import type { GridConfig, ChartTheme, D3Scale, ExportHooks, GridConfigBase } fro
3
3
  import type { ChartComponent } from './chart-interface.js';
4
4
  export declare class Grid implements ChartComponent<GridConfigBase> {
5
5
  readonly type: "grid";
6
- readonly horizontal: boolean;
7
- readonly vertical: boolean;
6
+ readonly value: boolean;
7
+ readonly category: boolean;
8
8
  readonly exportHooks?: ExportHooks<GridConfigBase>;
9
9
  constructor(config?: GridConfig);
10
10
  getExportConfig(): GridConfigBase;
11
11
  createExportComponent(override?: Partial<GridConfigBase>): ChartComponent<GridConfigBase>;
12
- render(plotGroup: Selection<SVGGElement, undefined, null, undefined>, x: D3Scale, y: D3Scale, theme: ChartTheme): void;
12
+ render(plotGroup: Selection<SVGGElement, undefined, null, undefined>, x: D3Scale, y: D3Scale, theme: ChartTheme, isHorizontalOrientation: boolean): void;
13
13
  }
package/dist/grid.js CHANGED
@@ -8,13 +8,13 @@ export class Grid {
8
8
  writable: true,
9
9
  value: 'grid'
10
10
  });
11
- Object.defineProperty(this, "horizontal", {
11
+ Object.defineProperty(this, "value", {
12
12
  enumerable: true,
13
13
  configurable: true,
14
14
  writable: true,
15
15
  value: void 0
16
16
  });
17
- Object.defineProperty(this, "vertical", {
17
+ Object.defineProperty(this, "category", {
18
18
  enumerable: true,
19
19
  configurable: true,
20
20
  writable: true,
@@ -26,14 +26,14 @@ export class Grid {
26
26
  writable: true,
27
27
  value: void 0
28
28
  });
29
- this.horizontal = config?.horizontal ?? true;
30
- this.vertical = config?.vertical ?? true;
29
+ this.value = config?.value ?? true;
30
+ this.category = config?.category ?? true;
31
31
  this.exportHooks = config?.exportHooks;
32
32
  }
33
33
  getExportConfig() {
34
34
  return {
35
- horizontal: this.horizontal,
36
- vertical: this.vertical,
35
+ value: this.value,
36
+ category: this.category,
37
37
  };
38
38
  }
39
39
  createExportComponent(override) {
@@ -43,13 +43,19 @@ export class Grid {
43
43
  exportHooks: this.exportHooks,
44
44
  });
45
45
  }
46
- render(plotGroup, x, y, theme) {
46
+ render(plotGroup, x, y, theme, isHorizontalOrientation) {
47
47
  // Get plot area dimensions from the scale ranges
48
48
  const xRange = x.range();
49
49
  const yRange = y.range();
50
50
  const plotWidth = xRange[1] - xRange[0];
51
51
  const plotHeight = yRange[0] - yRange[1];
52
- if (this.horizontal) {
52
+ const showHorizontalLines = isHorizontalOrientation
53
+ ? this.category
54
+ : this.value;
55
+ const showVerticalLines = isHorizontalOrientation
56
+ ? this.value
57
+ : this.category;
58
+ if (showHorizontalLines) {
53
59
  plotGroup
54
60
  .append('g')
55
61
  .attr('class', 'grid-lines horizontal')
@@ -65,7 +71,7 @@ export class Grid {
65
71
  .selectAll('.domain')
66
72
  .remove();
67
73
  }
68
- if (this.vertical) {
74
+ if (showVerticalLines) {
69
75
  plotGroup
70
76
  .append('g')
71
77
  .attr('class', 'grid-lines vertical')
package/dist/types.d.ts CHANGED
@@ -258,8 +258,8 @@ export type YAxisConfig = YAxisConfigBase & {
258
258
  exportHooks?: ExportHooks<YAxisConfigBase>;
259
259
  };
260
260
  export type GridConfigBase = {
261
- horizontal?: boolean;
262
- vertical?: boolean;
261
+ value?: boolean;
262
+ category?: boolean;
263
263
  };
264
264
  export type GridConfig = GridConfigBase & {
265
265
  exportHooks?: ExportHooks<GridConfigBase>;
package/dist/xy-chart.js CHANGED
@@ -149,7 +149,7 @@ export class XYChart extends BaseChart {
149
149
  this.setupScales();
150
150
  this.renderTitle(svg);
151
151
  if (this.grid && this.x && this.y) {
152
- this.grid.render(plotGroup, this.x, this.y, this.renderTheme);
152
+ this.grid.render(plotGroup, this.x, this.y, this.renderTheme, this.isHorizontalOrientation());
153
153
  }
154
154
  this.renderSeries(visibleSeries);
155
155
  if (this.x && this.y) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.1",
2
+ "version": "0.9.2",
3
3
  "name": "@internetstiftelsen/charts",
4
4
  "type": "module",
5
5
  "sideEffects": false,