@pushwoosh/kit-charts 0.0.10 → 0.0.11

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.
@@ -14,6 +14,8 @@ const ANCHOR = {
14
14
  center: 'middle',
15
15
  right: 'end'
16
16
  };
17
+ /** `style.textAlign` wins over the anchor the axis derives from its own geometry. */
18
+ const anchorFor = (style, fallback) => style?.textAlign && ANCHOR[style.textAlign] || fallback;
17
19
  /** What a tick draws: its own node if a formatter made one, its text otherwise. */
18
20
  const tickContent = tick => {
19
21
  if (tick.node !== undefined && tick.node !== null) {
@@ -33,7 +35,7 @@ function TickLabel({
33
35
  const text = _jsx("text", {
34
36
  x: x,
35
37
  y: y,
36
- textAnchor: anchor,
38
+ textAnchor: anchorFor(style, anchor),
37
39
  ...textProps(style),
38
40
  children: children
39
41
  });
@@ -89,7 +91,7 @@ function AxisTitle({
89
91
  return _jsx("text", {
90
92
  x: at.x,
91
93
  y: at.y,
92
- textAnchor: rotation === 0 ? anchor : 'middle',
94
+ textAnchor: rotation === 0 ? anchorFor(title.style, anchor) : 'middle',
93
95
  transform: rotation === 0 ? undefined : `rotate(${rotation} ${at.x} ${at.y})`,
94
96
  ...textProps(title.style),
95
97
  children: title.text
@@ -337,7 +337,9 @@ export function buildChartModel({
337
337
  }) => {
338
338
  points.forEach(point => {
339
339
  if (typeof point.x === 'string') {
340
- point.band = point.x;
340
+ // Highcharts reads a string in `[name, value]` as the point's name and
341
+ // places it by index; we key by category, and fall back where it misses.
342
+ point.band = !explicitCategories || categories.includes(point.x) ? point.x : categories[point.index] ?? point.x;
341
343
  return;
342
344
  }
343
345
  if (!explicitCategories) {
@@ -347,6 +349,8 @@ export function buildChartModel({
347
349
  point.band = categories[Number(point.x)] ?? categories[point.index] ?? String(point.x);
348
350
  });
349
351
  });
352
+ // A band still outside the list extends the axis: a surplus point is data, and
353
+ // dropping it would lose it without a word.
350
354
  resolved.forEach(({
351
355
  points
352
356
  }) => {
@@ -86,10 +86,8 @@ export interface AxisLabelsOptions {
86
86
  hint?: (ctx: AxisLabelContext) => string | undefined;
87
87
  allowOverlap?: boolean;
88
88
  align?: 'left' | 'center' | 'right';
89
- rotation?: number;
90
89
  x?: number;
91
90
  y?: number;
92
- padding?: number;
93
91
  style?: TextStyle;
94
92
  }
95
93
  /** `zIndex` at or above this draws over the series instead of under it. */
@@ -168,7 +166,6 @@ export interface LegendOptions<TSeriesMeta = unknown> {
168
166
  align?: 'left' | 'center' | 'right';
169
167
  verticalAlign?: 'top' | 'middle' | 'bottom';
170
168
  layout?: 'horizontal' | 'vertical';
171
- margin?: number;
172
169
  x?: number;
173
170
  y?: number;
174
171
  itemStyle?: TextStyle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/kit-charts",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Small React chart library on SVG, with a Highcharts-shaped configuration model",
5
5
  "license": "MIT",
6
6
  "repository": {