@pushwoosh/kit-charts 0.0.2 → 0.0.4

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.
@@ -35,7 +35,7 @@ export interface TooltipNeighbour {
35
35
  y: number | null;
36
36
  index: number;
37
37
  }
38
- export interface TooltipPoint<TSeriesMeta = unknown> {
38
+ export interface TooltipPoint<TSeriesMeta = unknown, TPointMeta = unknown> {
39
39
  seriesIndex: number;
40
40
  seriesName: string;
41
41
  color: string;
@@ -44,16 +44,18 @@ export interface TooltipPoint<TSeriesMeta = unknown> {
44
44
  value: number | null;
45
45
  index: number;
46
46
  meta: TSeriesMeta | undefined;
47
+ /** The hovered point's own `meta` — what `onPointClick` reports, at hover time. */
48
+ pointMeta: TPointMeta | undefined;
47
49
  prev: TooltipNeighbour | undefined;
48
50
  next: TooltipNeighbour | undefined;
49
51
  }
50
- export interface TooltipContext<TChartMeta = unknown, TSeriesMeta = unknown> {
52
+ export interface TooltipContext<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown> {
51
53
  x: number | string;
52
- points: readonly TooltipPoint<TSeriesMeta>[];
54
+ points: readonly TooltipPoint<TSeriesMeta, TPointMeta>[];
53
55
  chart: {
54
56
  title: string | undefined;
55
57
  meta: TChartMeta | undefined;
56
58
  };
57
59
  }
58
- export type TooltipFormatter<TChartMeta = unknown, TSeriesMeta = unknown> = (ctx: TooltipContext<TChartMeta, TSeriesMeta>) => ReactNode;
59
- export type TooltipCellFormatter<TSeriesMeta = unknown> = (point: TooltipPoint<TSeriesMeta>) => ReactNode;
60
+ export type TooltipFormatter<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown> = (ctx: TooltipContext<TChartMeta, TSeriesMeta, TPointMeta>) => ReactNode;
61
+ export type TooltipCellFormatter<TSeriesMeta = unknown, TPointMeta = unknown> = (point: TooltipPoint<TSeriesMeta, TPointMeta>) => ReactNode;
@@ -175,36 +175,36 @@ export interface LegendOptions<TSeriesMeta = unknown> {
175
175
  symbolPadding?: number;
176
176
  labelFormatter?: LegendLabelFormatter<TSeriesMeta>;
177
177
  }
178
- export interface TooltipTableColumn<TChartMeta = unknown, TSeriesMeta = unknown> {
178
+ export interface TooltipTableColumn<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown> {
179
179
  /**
180
180
  * A function is resolved per hover, and one that returns `null` drops the whole
181
181
  * column: that is how a "vs the previous point" column names the date it
182
182
  * compares against and disappears on the first point, where there is none.
183
183
  */
184
- title?: string | TooltipFormatter<TChartMeta, TSeriesMeta>;
184
+ title?: string | TooltipFormatter<TChartMeta, TSeriesMeta, TPointMeta>;
185
185
  align?: 'left' | 'right';
186
- cell: TooltipCellFormatter<TSeriesMeta>;
186
+ cell: TooltipCellFormatter<TSeriesMeta, TPointMeta>;
187
187
  }
188
188
  /**
189
189
  * Lays the tooltip out as a table: a header line, a heading row, and one row per
190
190
  * series with its swatch. Use it when a point carries more than one figure —
191
191
  * a count and its share of the whole — and a single line would run them together.
192
192
  */
193
- export interface TooltipTableOptions<TChartMeta = unknown, TSeriesMeta = unknown> {
193
+ export interface TooltipTableOptions<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown> {
194
194
  /** The line above the table. Defaults to the formatted x. */
195
- header?: TooltipFormatter<TChartMeta, TSeriesMeta>;
195
+ header?: TooltipFormatter<TChartMeta, TSeriesMeta, TPointMeta>;
196
196
  /** Heading over the series-name column. */
197
197
  seriesTitle?: string;
198
- columns: readonly TooltipTableColumn<TChartMeta, TSeriesMeta>[];
198
+ columns: readonly TooltipTableColumn<TChartMeta, TSeriesMeta, TPointMeta>[];
199
199
  }
200
- export interface TooltipOptions<TChartMeta = unknown, TSeriesMeta = unknown> {
200
+ export interface TooltipOptions<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown> {
201
201
  enabled?: boolean;
202
202
  shared?: boolean;
203
- table?: TooltipTableOptions<TChartMeta, TSeriesMeta>;
203
+ table?: TooltipTableOptions<TChartMeta, TSeriesMeta, TPointMeta>;
204
204
  /** `callout` anchors a beaked bubble to the point; `box` floats near the cursor. */
205
205
  shape?: 'callout' | 'box';
206
206
  followPointer?: boolean;
207
- formatter?: TooltipFormatter<TChartMeta, TSeriesMeta>;
207
+ formatter?: TooltipFormatter<TChartMeta, TSeriesMeta, TPointMeta>;
208
208
  dateFormat?: string;
209
209
  valuePrefix?: string;
210
210
  valueSuffix?: string;
@@ -298,6 +298,8 @@ export interface SeriesOptionsBase<TSeriesMeta = unknown, TPointMeta = unknown>
298
298
  */
299
299
  borderPosition?: 'all' | 'top';
300
300
  fillOpacity?: number;
301
+ /** The body's own colour, where the fill is not a wash of the series colour. */
302
+ fillColor?: string;
301
303
  pointPadding?: number;
302
304
  groupPadding?: number;
303
305
  minPointLength?: number;
@@ -321,7 +323,7 @@ export interface ChartOptions<TChartMeta = unknown, TSeriesMeta = unknown, TPoin
321
323
  yAxis?: AxisOptions | readonly AxisOptions[];
322
324
  colorAxis?: ColorAxisOptions;
323
325
  legend?: LegendOptions<TSeriesMeta>;
324
- tooltip?: TooltipOptions<TChartMeta, TSeriesMeta>;
326
+ tooltip?: TooltipOptions<TChartMeta, TSeriesMeta, TPointMeta>;
325
327
  plotOptions?: PlotOptions<TSeriesMeta, TPointMeta>;
326
328
  series?: readonly SeriesOptionsBase<TSeriesMeta, TPointMeta>[];
327
329
  colors?: readonly string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/kit-charts",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Small React chart library on SVG, with a Highcharts-shaped configuration model",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "@pushwoosh/kit-constants": "^1.8.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@pushwoosh/frontend-builder-engine": "^3.0.0",
41
+ "@pushwoosh/frontend-builder-engine": "^3.1.0",
42
42
  "@testing-library/jest-dom": "^6.9.1",
43
43
  "@testing-library/react": "^16.3.0",
44
44
  "@types/jest": "^30.0.0",
@@ -1,3 +1,3 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import { type ChartProps } from '../core/Chart/Chart';
3
- export declare function AreaChart<TChartMeta = unknown, TSeriesMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta>): ReactElement;
3
+ export declare function AreaChart<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta, TPointMeta>): ReactElement;
@@ -1,3 +1,3 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import { type ChartProps } from '../core/Chart/Chart';
3
- export declare function ColumnChart<TChartMeta = unknown, TSeriesMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta>): ReactElement;
3
+ export declare function ColumnChart<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta, TPointMeta>): ReactElement;
@@ -1,3 +1,3 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import { type ChartProps } from '../core/Chart/Chart';
3
- export declare function LineChart<TChartMeta = unknown, TSeriesMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta>): ReactElement;
3
+ export declare function LineChart<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta, TPointMeta>): ReactElement;
@@ -1,3 +1,3 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import { type ChartProps } from '../core/Chart/Chart';
3
- export declare function PieChart<TChartMeta = unknown, TSeriesMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta>): ReactElement;
3
+ export declare function PieChart<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta, TPointMeta>): ReactElement;
@@ -1,7 +1,7 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import { type ChartProps } from '../core/Chart/Chart';
3
3
  import { type Stacking } from '../core/types/options';
4
- export interface StackedColumnChartProps<TChartMeta = unknown, TSeriesMeta = unknown> extends ChartProps<TChartMeta, TSeriesMeta> {
4
+ export interface StackedColumnChartProps<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown> extends ChartProps<TChartMeta, TSeriesMeta, TPointMeta> {
5
5
  stacking?: Stacking;
6
6
  }
7
- export declare function StackedColumnChart<TChartMeta = unknown, TSeriesMeta = unknown>(props: StackedColumnChartProps<TChartMeta, TSeriesMeta>): ReactElement;
7
+ export declare function StackedColumnChart<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown>(props: StackedColumnChartProps<TChartMeta, TSeriesMeta, TPointMeta>): ReactElement;
@@ -13,7 +13,6 @@ export const area = {
13
13
  },
14
14
  extendDomain: (series, acc) => includeZero(series, acc),
15
15
  render: ctx => {
16
- var _ctx$hovered, _ctx$series$marker;
17
16
  const slots = projectSeries(ctx);
18
17
  const projected = drawable(slots);
19
18
  if (!projected.length) {
@@ -21,14 +20,14 @@ export const area = {
21
20
  }
22
21
  const color = ctx.color;
23
22
  const lineWidth = ctx.series.lineWidth ?? 2;
24
- const hoveredIndex = (_ctx$hovered = ctx.hovered) === null || _ctx$hovered === void 0 ? void 0 : _ctx$hovered.pointIndex;
23
+ const hoveredIndex = ctx.hovered?.pointIndex;
25
24
  const hovered = hoveredIndex === undefined ? undefined : projected.find(({
26
25
  point
27
26
  }) => point.index === hoveredIndex);
28
27
  return _jsxs("g", {
29
28
  children: [_jsx("path", {
30
29
  d: toAreaPath(slots),
31
- fill: color,
30
+ fill: ctx.series.fillColor ?? color,
32
31
  fillOpacity: ctx.series.fillOpacity ?? DEFAULT_FILL_OPACITY,
33
32
  stroke: "none"
34
33
  }), lineWidth ? _jsx("path", {
@@ -45,7 +44,7 @@ export const area = {
45
44
  }), hovered ? _jsx("circle", {
46
45
  cx: hovered.px,
47
46
  cy: hovered.py,
48
- r: ((_ctx$series$marker = ctx.series.marker) === null || _ctx$series$marker === void 0 || (_ctx$series$marker = _ctx$series$marker.states) === null || _ctx$series$marker === void 0 || (_ctx$series$marker = _ctx$series$marker.hover) === null || _ctx$series$marker === void 0 ? void 0 : _ctx$series$marker.radius) ?? 4,
47
+ r: ctx.series.marker?.states?.hover?.radius ?? 4,
49
48
  fill: color,
50
49
  stroke: "#FFFFFF",
51
50
  strokeWidth: 2
@@ -42,12 +42,11 @@ function toBars(ctx) {
42
42
  });
43
43
  }
44
44
  const fillOf = (ctx, bar, hovered) => {
45
- var _ctx$series$states;
46
45
  const base = bar.point.color ?? ctx.color;
47
46
  if (!hovered) {
48
47
  return base;
49
48
  }
50
- return brighten(base, ((_ctx$series$states = ctx.series.states) === null || _ctx$series$states === void 0 || (_ctx$series$states = _ctx$series$states.hover) === null || _ctx$series$states === void 0 ? void 0 : _ctx$series$states.brightness) ?? DEFAULT_HOVER_BRIGHTNESS);
49
+ return brighten(base, ctx.series.states?.hover?.brightness ?? DEFAULT_HOVER_BRIGHTNESS);
51
50
  };
52
51
  /**
53
52
  * A translucent body under a solid rule is the funnel look: the series keeps its
@@ -55,12 +54,11 @@ const fillOf = (ctx, bar, hovered) => {
55
54
  * bar is washed out. Hovering deepens it.
56
55
  */
57
56
  const opacityOf = (ctx, hovered) => {
58
- var _ctx$series$states2;
59
57
  const base = ctx.series.fillOpacity;
60
58
  if (!hovered) {
61
59
  return base;
62
60
  }
63
- return ((_ctx$series$states2 = ctx.series.states) === null || _ctx$series$states2 === void 0 || (_ctx$series$states2 = _ctx$series$states2.hover) === null || _ctx$series$states2 === void 0 ? void 0 : _ctx$series$states2.fillOpacity) ?? base;
61
+ return ctx.series.states?.hover?.fillOpacity ?? base;
64
62
  };
65
63
  export const column = {
66
64
  type: 'column',
@@ -71,12 +69,11 @@ export const column = {
71
69
  exit: 'collapse',
72
70
  extendDomain: (series, acc) => includeZero(series, acc),
73
71
  render: ctx => {
74
- var _ctx$hovered;
75
72
  const bars = toBars(ctx);
76
73
  if (!bars.length) {
77
74
  return null;
78
75
  }
79
- const hoveredIndex = (_ctx$hovered = ctx.hovered) === null || _ctx$hovered === void 0 ? void 0 : _ctx$hovered.pointIndex;
76
+ const hoveredIndex = ctx.hovered?.pointIndex;
80
77
  const radius = ctx.series.borderRadius;
81
78
  const borderWidth = ctx.series.borderWidth ?? 0;
82
79
  const capped = borderWidth > 0 && ctx.series.borderPosition === 'top';
@@ -120,7 +117,6 @@ export const column = {
120
117
  });
121
118
  },
122
119
  hitTest: (ctx, pointer) => {
123
- var _ctx$slot;
124
120
  const bars = toBars(ctx);
125
121
  if (!bars.length) {
126
122
  return null;
@@ -130,7 +126,7 @@ export const column = {
130
126
  if (pointer.y < top || pointer.y > bottom) {
131
127
  return null;
132
128
  }
133
- const step = ((_ctx$slot = ctx.slot) === null || _ctx$slot === void 0 ? void 0 : _ctx$slot.step) ?? ctx.plot.width / 2;
129
+ const step = ctx.slot?.step ?? ctx.plot.width / 2;
134
130
  let candidate;
135
131
  let candidateGap = Infinity;
136
132
  bars.forEach(bar => {
@@ -74,18 +74,16 @@ function toCells(ctx) {
74
74
  }, []);
75
75
  }
76
76
  const fillOf = (ctx, cell, hovered) => {
77
- var _ctx$scales$color, _ctx$series$states;
78
- const scaled = cell.point.value === null ? undefined : (_ctx$scales$color = ctx.scales.color) === null || _ctx$scales$color === void 0 ? void 0 : _ctx$scales$color.map(cell.point.value);
77
+ const scaled = cell.point.value === null ? undefined : ctx.scales.color?.map(cell.point.value);
79
78
  const base = cell.point.color ?? scaled ?? ctx.color;
80
79
  if (!hovered) {
81
80
  return base;
82
81
  }
83
- return brighten(base, ((_ctx$series$states = ctx.series.states) === null || _ctx$series$states === void 0 || (_ctx$series$states = _ctx$series$states.hover) === null || _ctx$series$states === void 0 ? void 0 : _ctx$series$states.brightness) ?? DEFAULT_HOVER_BRIGHTNESS);
82
+ return brighten(base, ctx.series.states?.hover?.brightness ?? DEFAULT_HOVER_BRIGHTNESS);
84
83
  };
85
84
  const labelX = (ctx, cell) => {
86
- var _ctx$series$dataLabel, _ctx$series$dataLabel2;
87
- const padding = ((_ctx$series$dataLabel = ctx.series.dataLabels) === null || _ctx$series$dataLabel === void 0 ? void 0 : _ctx$series$dataLabel.padding) ?? VALUE_LABEL_GAP;
88
- const align = (_ctx$series$dataLabel2 = ctx.series.dataLabels) === null || _ctx$series$dataLabel2 === void 0 ? void 0 : _ctx$series$dataLabel2.align;
85
+ const padding = ctx.series.dataLabels?.padding ?? VALUE_LABEL_GAP;
86
+ const align = ctx.series.dataLabels?.align;
89
87
  if (align === 'left') {
90
88
  return cell.x + padding;
91
89
  }
@@ -117,12 +115,11 @@ export const heatmap = {
117
115
  };
118
116
  },
119
117
  render: ctx => {
120
- var _ctx$hovered;
121
118
  const cells = toCells(ctx);
122
119
  if (!cells.length) {
123
120
  return null;
124
121
  }
125
- const hoveredIndex = (_ctx$hovered = ctx.hovered) === null || _ctx$hovered === void 0 ? void 0 : _ctx$hovered.pointIndex;
122
+ const hoveredIndex = ctx.hovered?.pointIndex;
126
123
  const borderWidth = ctx.series.borderWidth ?? 0;
127
124
  const radius = ctx.series.borderRadius;
128
125
  return _jsxs("g", {
@@ -11,14 +11,13 @@ export const line = {
11
11
  },
12
12
  extendDomain: (_series, acc) => acc,
13
13
  render: ctx => {
14
- var _ctx$hovered, _ctx$series$marker;
15
14
  const slots = projectSeries(ctx);
16
15
  const projected = drawable(slots);
17
16
  if (!projected.length) {
18
17
  return null;
19
18
  }
20
19
  const color = ctx.color;
21
- const hoveredIndex = (_ctx$hovered = ctx.hovered) === null || _ctx$hovered === void 0 ? void 0 : _ctx$hovered.pointIndex;
20
+ const hoveredIndex = ctx.hovered?.pointIndex;
22
21
  const hovered = hoveredIndex === undefined ? undefined : projected.find(({
23
22
  point
24
23
  }) => point.index === hoveredIndex);
@@ -37,7 +36,7 @@ export const line = {
37
36
  }), hovered ? _jsx("circle", {
38
37
  cx: hovered.px,
39
38
  cy: hovered.py,
40
- r: ((_ctx$series$marker = ctx.series.marker) === null || _ctx$series$marker === void 0 || (_ctx$series$marker = _ctx$series$marker.states) === null || _ctx$series$marker === void 0 || (_ctx$series$marker = _ctx$series$marker.hover) === null || _ctx$series$marker === void 0 ? void 0 : _ctx$series$marker.radius) ?? 4,
39
+ r: ctx.series.marker?.states?.hover?.radius ?? 4,
41
40
  fill: color,
42
41
  stroke: "#FFFFFF",
43
42
  strokeWidth: 2
package/series/pie/pie.js CHANGED
@@ -95,11 +95,10 @@ function Labels({
95
95
  geometry
96
96
  }) {
97
97
  const labels = ctx.series.dataLabels;
98
- if (!(labels !== null && labels !== void 0 && labels.enabled)) {
98
+ if (!labels?.enabled) {
99
99
  return null;
100
100
  }
101
101
  return slices.filter(slice => !slice.hidden).map(slice => {
102
- var _labels$style, _labels$style2, _labels$style3, _labels$style4;
103
102
  const mid = (slice.from + slice.to) / 2;
104
103
  const at = polar(geometry.cx, geometry.cy, geometry.outer + LABEL_OFFSET, mid);
105
104
  const text = labels.formatter ? labels.formatter({
@@ -116,10 +115,10 @@ function Labels({
116
115
  y: at.y,
117
116
  textAnchor: Math.cos(mid) < 0 ? 'end' : 'start',
118
117
  dominantBaseline: "middle",
119
- fill: labels.color ?? ((_labels$style = labels.style) === null || _labels$style === void 0 ? void 0 : _labels$style.color),
120
- fontFamily: (_labels$style2 = labels.style) === null || _labels$style2 === void 0 ? void 0 : _labels$style2.fontFamily,
121
- fontSize: ((_labels$style3 = labels.style) === null || _labels$style3 === void 0 ? void 0 : _labels$style3.fontSize) ?? '11px',
122
- fontWeight: (_labels$style4 = labels.style) === null || _labels$style4 === void 0 ? void 0 : _labels$style4.fontWeight,
118
+ fill: labels.color ?? labels.style?.color,
119
+ fontFamily: labels.style?.fontFamily,
120
+ fontSize: labels.style?.fontSize ?? '11px',
121
+ fontWeight: labels.style?.fontWeight,
123
122
  children: text
124
123
  }, `label-${slice.point.index}`);
125
124
  });
@@ -134,7 +133,6 @@ function Labels({
134
133
  function Slices({
135
134
  ctx
136
135
  }) {
137
- var _ctx$hovered;
138
136
  const slices = toSlices(ctx);
139
137
  const alive = ctx.points.some(point => !ctx.hiddenPoints.has(point.index));
140
138
  const targets = [...slices.flatMap(slice => [slice.from, slice.to]), ctx.hidden || !alive ? 0 : 1];
@@ -144,7 +142,7 @@ function Slices({
144
142
  }
145
143
  const radiusScale = tweened[tweened.length - 1] ?? 1;
146
144
  const geometry = geometryOf(ctx, radiusScale);
147
- const hovered = (_ctx$hovered = ctx.hovered) === null || _ctx$hovered === void 0 ? void 0 : _ctx$hovered.pointIndex;
145
+ const hovered = ctx.hovered?.pointIndex;
148
146
  const drawn = slices.map((slice, index) => ({
149
147
  ...slice,
150
148
  from: tweened[index * 2] ?? slice.from,
@@ -13,11 +13,11 @@ export const labelAnchor = align => {
13
13
  return 'middle';
14
14
  };
15
15
  const textProps = style => ({
16
- fontFamily: style === null || style === void 0 ? void 0 : style.fontFamily,
17
- fontSize: style === null || style === void 0 ? void 0 : style.fontSize,
18
- fontWeight: style === null || style === void 0 ? void 0 : style.fontWeight,
19
- fontStyle: style === null || style === void 0 ? void 0 : style.fontStyle,
20
- paintOrder: (style === null || style === void 0 ? void 0 : style.textOutline) === 'none' ? undefined : 'stroke'
16
+ fontFamily: style?.fontFamily,
17
+ fontSize: style?.fontSize,
18
+ fontWeight: style?.fontWeight,
19
+ fontStyle: style?.fontStyle,
20
+ paintOrder: style?.textOutline === 'none' ? undefined : 'stroke'
21
21
  });
22
22
  /** No formatter and no format string: the chart's own number rule prints it. */
23
23
  const defaultLabel = (ctx, format, y) => {
@@ -44,7 +44,7 @@ export function DataLabels({
44
44
  positionOf
45
45
  }) {
46
46
  const options = ctx.series.dataLabels;
47
- if (!(options !== null && options !== void 0 && options.enabled)) {
47
+ if (!options?.enabled) {
48
48
  return null;
49
49
  }
50
50
  const turbo = ctx.series.turboThreshold;
@@ -110,12 +110,12 @@ export function DataLabels({
110
110
  x: at.x,
111
111
  y: y,
112
112
  textAnchor: anchor,
113
- fill: options.color ?? (style === null || style === void 0 ? void 0 : style.color) ?? DEFAULT_TEXT_COLOR,
113
+ fill: options.color ?? style?.color ?? DEFAULT_TEXT_COLOR,
114
114
  ...textProps(style),
115
115
  children: lines && lines.length > 1 ? lines.map((text, index) => _jsx("tspan", {
116
116
  x: at.x,
117
117
  dy: index === 0 ? 0 : textHeight(secondary ?? style),
118
- fill: index === 0 ? undefined : secondary === null || secondary === void 0 ? void 0 : secondary.color,
118
+ fill: index === 0 ? undefined : secondary?.color,
119
119
  ...(index === 0 ? {} : textProps(secondary)),
120
120
  children: text
121
121
  }, `line-${index}`)) : content
@@ -1,16 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- const markerRadius = marker => (marker === null || marker === void 0 ? void 0 : marker.radius) ?? (marker !== null && marker !== void 0 && marker.width ? marker.width / 2 : 3);
2
+ const markerRadius = marker => marker?.radius ?? (marker?.width ? marker.width / 2 : 3);
3
3
  export function Markers({
4
4
  marker,
5
5
  projected,
6
6
  color
7
7
  }) {
8
- if ((marker === null || marker === void 0 ? void 0 : marker.enabled) === false || (marker === null || marker === void 0 ? void 0 : marker.symbol) === 'none') {
8
+ if (marker?.enabled === false || marker?.symbol === 'none') {
9
9
  return null;
10
10
  }
11
11
  const radius = markerRadius(marker);
12
- const fill = (marker === null || marker === void 0 ? void 0 : marker.fillColor) ?? color;
13
- const square = (marker === null || marker === void 0 ? void 0 : marker.symbol) === 'square';
12
+ const fill = marker?.fillColor ?? color;
13
+ const square = marker?.symbol === 'square';
14
14
  return projected.map(({
15
15
  point,
16
16
  px,
@@ -21,14 +21,14 @@ export function Markers({
21
21
  width: radius * 2,
22
22
  height: radius * 2,
23
23
  fill: fill,
24
- stroke: marker === null || marker === void 0 ? void 0 : marker.lineColor,
25
- strokeWidth: marker === null || marker === void 0 ? void 0 : marker.lineWidth
24
+ stroke: marker?.lineColor,
25
+ strokeWidth: marker?.lineWidth
26
26
  }, `m-${point.index}`) : _jsx("circle", {
27
27
  cx: px,
28
28
  cy: py,
29
29
  r: radius,
30
30
  fill: fill,
31
- stroke: marker === null || marker === void 0 ? void 0 : marker.lineColor,
32
- strokeWidth: marker === null || marker === void 0 ? void 0 : marker.lineWidth
31
+ stroke: marker?.lineColor,
32
+ strokeWidth: marker?.lineWidth
33
33
  }, `m-${point.index}`));
34
34
  }