@multiplatform.one/components 9.5.0 → 9.7.0
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/cjs/charts/LineChart.cjs +137 -81
- package/dist/cjs/charts/LineChart.native.js +209 -93
- package/dist/cjs/charts/LineChart.native.js.map +1 -1
- package/dist/cjs/charts/SeriesLegend.cjs +85 -0
- package/dist/cjs/charts/SeriesLegend.native.js +93 -0
- package/dist/cjs/charts/SeriesLegend.native.js.map +1 -0
- package/dist/cjs/charts/series.cjs +47 -3
- package/dist/cjs/charts/series.native.js +49 -5
- package/dist/cjs/charts/series.native.js.map +1 -1
- package/dist/esm/charts/LineChart.mjs +138 -82
- package/dist/esm/charts/LineChart.mjs.map +1 -1
- package/dist/esm/charts/LineChart.native.js +210 -94
- package/dist/esm/charts/LineChart.native.js.map +1 -1
- package/dist/esm/charts/SeriesLegend.mjs +60 -0
- package/dist/esm/charts/SeriesLegend.mjs.map +1 -0
- package/dist/esm/charts/SeriesLegend.native.js +65 -0
- package/dist/esm/charts/SeriesLegend.native.js.map +1 -0
- package/dist/esm/charts/series.mjs +43 -3
- package/dist/esm/charts/series.mjs.map +1 -1
- package/dist/esm/charts/series.native.js +45 -5
- package/dist/esm/charts/series.native.js.map +1 -1
- package/dist/jsx/charts/LineChart.mjs +138 -82
- package/dist/jsx/charts/LineChart.mjs.map +1 -1
- package/dist/jsx/charts/LineChart.native.js +209 -93
- package/dist/jsx/charts/LineChart.native.js.map +1 -1
- package/dist/jsx/charts/SeriesLegend.mjs +60 -0
- package/dist/jsx/charts/SeriesLegend.mjs.map +1 -0
- package/dist/jsx/charts/SeriesLegend.native.js +93 -0
- package/dist/jsx/charts/SeriesLegend.native.js.map +1 -0
- package/dist/jsx/charts/series.mjs +43 -3
- package/dist/jsx/charts/series.mjs.map +1 -1
- package/dist/jsx/charts/series.native.js +49 -5
- package/dist/jsx/charts/series.native.js.map +1 -1
- package/package.json +7 -7
- package/src/charts/Charts.stories.tsx +25 -0
- package/src/charts/LineChart.tsx +185 -105
- package/src/charts/SeriesLegend.native.spec.tsx +99 -0
- package/src/charts/SeriesLegend.tsx +68 -0
- package/src/charts/multiSeriesLine.spec.tsx +111 -0
- package/src/charts/series.tsx +73 -11
- package/types/charts/LineChart.d.ts +21 -5
- package/types/charts/LineChart.d.ts.map +1 -1
- package/types/charts/SeriesLegend.d.ts +21 -0
- package/types/charts/SeriesLegend.d.ts.map +1 -0
- package/types/charts/series.d.ts +18 -1
- package/types/charts/series.d.ts.map +1 -1
|
@@ -29,6 +29,8 @@ __export(LineChart_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(LineChart_exports);
|
|
31
31
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_tamagui = require("tamagui");
|
|
32
34
|
var import_i18n = require("../shared/i18n.native.js");
|
|
33
35
|
var import_Axis = require("./Axis.native.js");
|
|
34
36
|
var import_ChartDataView = require("./ChartDataView.native.js");
|
|
@@ -37,10 +39,13 @@ var import_accessibility = require("./accessibility.native.js");
|
|
|
37
39
|
var import_composeChart = require("./composeChart.native.js");
|
|
38
40
|
var import_math = require("./math.native.js");
|
|
39
41
|
var import_series = require("./series.native.js");
|
|
42
|
+
var import_SeriesLegend = require("./SeriesLegend.native.js");
|
|
43
|
+
var import_svg = require("./svg.native.js");
|
|
40
44
|
var import_useChartTheme = require("./useChartTheme.native.js");
|
|
41
45
|
function LineChart(param) {
|
|
42
46
|
var {
|
|
43
47
|
data,
|
|
48
|
+
series,
|
|
44
49
|
height = 200,
|
|
45
50
|
width,
|
|
46
51
|
color,
|
|
@@ -62,6 +67,8 @@ function LineChart(param) {
|
|
|
62
67
|
onDatumHoverOut,
|
|
63
68
|
...stackProps
|
|
64
69
|
} = param;
|
|
70
|
+
var _ref;
|
|
71
|
+
var _all_;
|
|
65
72
|
var {
|
|
66
73
|
t
|
|
67
74
|
} = (0, import_i18n.useTranslation)();
|
|
@@ -69,111 +76,220 @@ function LineChart(param) {
|
|
|
69
76
|
palette,
|
|
70
77
|
labelFontSize
|
|
71
78
|
} = (0, import_useChartTheme.useChartTheme)();
|
|
72
|
-
var
|
|
79
|
+
var [hidden, setHidden] = (0, import_react.useState)(function () {
|
|
80
|
+
return /* @__PURE__ */new Set();
|
|
81
|
+
});
|
|
82
|
+
var all = series !== null && series !== void 0 ? series : [{
|
|
83
|
+
id: "series",
|
|
84
|
+
label: title !== null && title !== void 0 ? title : "",
|
|
85
|
+
data: data !== null && data !== void 0 ? data : []
|
|
86
|
+
}];
|
|
87
|
+
var multi = all.length > 1;
|
|
88
|
+
var strokes = all.map(function (entry2, index) {
|
|
89
|
+
var _entry_color, _ref2;
|
|
90
|
+
return multi ? (_entry_color = entry2.color) !== null && _entry_color !== void 0 ? _entry_color : palette.categorical[index % palette.categorical.length] : (_ref2 = color !== null && color !== void 0 ? color : entry2.color) !== null && _ref2 !== void 0 ? _ref2 : palette.single;
|
|
91
|
+
});
|
|
92
|
+
var encodings = all.map(function (_, index) {
|
|
93
|
+
return multi ? (0, import_series.seriesEncoding)(index) : {
|
|
94
|
+
marker: "circle",
|
|
95
|
+
dash: void 0
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
var flat = multi ? all.flatMap(function (entry2) {
|
|
99
|
+
return entry2.data.map(function (datum2) {
|
|
100
|
+
return {
|
|
101
|
+
...datum2,
|
|
102
|
+
label: `${entry2.label} ${datum2.label}`
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
}) : (_ref = (_all_ = all[0]) === null || _all_ === void 0 ? void 0 : _all_.data) !== null && _ref !== void 0 ? _ref : [];
|
|
73
106
|
var format = valueFormatter !== null && valueFormatter !== void 0 ? valueFormatter : import_math.formatChartValue;
|
|
74
|
-
var
|
|
75
|
-
|
|
107
|
+
var kind = typeLabel !== null && typeLabel !== void 0 ? typeLabel : showArea ? t("Area chart") : t("Line chart");
|
|
108
|
+
var ariaLabel = label !== null && label !== void 0 ? label : multi ? `${title ? `${kind}, ${title}` : kind}: ${all.length} series. ${all.map(function (entry2) {
|
|
109
|
+
return (0, import_accessibility.describeChart)({
|
|
110
|
+
typeLabel: entry2.label,
|
|
111
|
+
data: entry2.data,
|
|
112
|
+
formatValue: valueFormatter
|
|
113
|
+
});
|
|
114
|
+
}).join(" ")}` : (0, import_accessibility.describeChart)({
|
|
115
|
+
typeLabel: kind,
|
|
76
116
|
title,
|
|
77
|
-
data,
|
|
117
|
+
data: flat,
|
|
78
118
|
formatValue: valueFormatter
|
|
79
119
|
});
|
|
80
120
|
var interactive = Boolean(onDatumPress || onDatumHoverIn || onDatumHoverOut);
|
|
121
|
+
var toggle = function toggle2(id) {
|
|
122
|
+
return setHidden(function (current) {
|
|
123
|
+
var next = new Set(current);
|
|
124
|
+
if (next.has(id)) next.delete(id);else next.add(id);
|
|
125
|
+
return next;
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
var categories = [];
|
|
129
|
+
var _iteratorNormalCompletion = true,
|
|
130
|
+
_didIteratorError = false,
|
|
131
|
+
_iteratorError = void 0,
|
|
132
|
+
_iteratorNormalCompletion1 = true,
|
|
133
|
+
_didIteratorError1 = false,
|
|
134
|
+
_iteratorError1 = void 0;
|
|
135
|
+
try {
|
|
136
|
+
for (var _iterator = all[Symbol.iterator](), _step; !(_iteratorNormalCompletion1 = (_step = _iterator.next()).done); _iteratorNormalCompletion1 = true) {
|
|
137
|
+
var entry = _step.value;
|
|
138
|
+
try {
|
|
139
|
+
for (var _iterator1 = entry.data[Symbol.iterator](), _step1; !(_iteratorNormalCompletion = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion = true) {
|
|
140
|
+
var datum = _step1.value;
|
|
141
|
+
if (!categories.includes(datum.label)) categories.push(datum.label);
|
|
142
|
+
}
|
|
143
|
+
} catch (err) {
|
|
144
|
+
_didIteratorError = true;
|
|
145
|
+
_iteratorError = err;
|
|
146
|
+
} finally {
|
|
147
|
+
try {
|
|
148
|
+
if (!_iteratorNormalCompletion && _iterator1.return != null) {
|
|
149
|
+
_iterator1.return();
|
|
150
|
+
}
|
|
151
|
+
} finally {
|
|
152
|
+
if (_didIteratorError) {
|
|
153
|
+
throw _iteratorError;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} catch (err) {
|
|
159
|
+
_didIteratorError1 = true;
|
|
160
|
+
_iteratorError1 = err;
|
|
161
|
+
} finally {
|
|
162
|
+
try {
|
|
163
|
+
if (!_iteratorNormalCompletion1 && _iterator.return != null) {
|
|
164
|
+
_iterator.return();
|
|
165
|
+
}
|
|
166
|
+
} finally {
|
|
167
|
+
if (_didIteratorError1) {
|
|
168
|
+
throw _iteratorError1;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
var chart = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ChartSurface.ChartSurface, {
|
|
173
|
+
label: ariaLabel,
|
|
174
|
+
proof: {
|
|
175
|
+
kind: showArea ? "area" : "line",
|
|
176
|
+
separated: false,
|
|
177
|
+
datumText: false,
|
|
178
|
+
datumValues: (0, import_accessibility.chartDatumText)(flat, valueFormatter),
|
|
179
|
+
datumCount: flat.length
|
|
180
|
+
},
|
|
181
|
+
height,
|
|
182
|
+
width,
|
|
183
|
+
...(multi ? {} : stackProps),
|
|
184
|
+
children: function children(size) {
|
|
185
|
+
var domain = (0, import_math.valueDomain)(flat.map(function (datum2) {
|
|
186
|
+
return datum2.value;
|
|
187
|
+
}));
|
|
188
|
+
var marginScale = (0, import_math.createLinearScale)({
|
|
189
|
+
domain,
|
|
190
|
+
range: [0, 1]
|
|
191
|
+
});
|
|
192
|
+
var tickValues = (0, import_math.getLinearTicks)(marginScale, yTicks);
|
|
193
|
+
var plot = (0, import_composeChart.computeCartesianPlot)(size, {
|
|
194
|
+
showXAxis,
|
|
195
|
+
showYAxis,
|
|
196
|
+
yTickLabels: tickValues.map(function (value) {
|
|
197
|
+
return format(value);
|
|
198
|
+
}),
|
|
199
|
+
fontSize: labelFontSize
|
|
200
|
+
});
|
|
201
|
+
if (plot.width <= 0 || plot.height <= 0 || categories.length === 0) return null;
|
|
202
|
+
var xScale = (0, import_math.createPointScale)({
|
|
203
|
+
domain: categories,
|
|
204
|
+
range: [plot.x, plot.x + plot.width],
|
|
205
|
+
padding: 0.5
|
|
206
|
+
});
|
|
207
|
+
var yScale = (0, import_math.createLinearScale)({
|
|
208
|
+
domain,
|
|
209
|
+
range: [plot.y + plot.height, plot.y]
|
|
210
|
+
});
|
|
211
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
212
|
+
children: [showYAxis || showGrid ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Axis.YAxis, {
|
|
213
|
+
plot,
|
|
214
|
+
scale: yScale,
|
|
215
|
+
ticks: yTicks,
|
|
216
|
+
tickFormat: function tickFormat(value) {
|
|
217
|
+
return format(value);
|
|
218
|
+
},
|
|
219
|
+
showLabels: showYAxis,
|
|
220
|
+
showGrid
|
|
221
|
+
}) : null, all.map(function (entry2, index) {
|
|
222
|
+
var _encodings_index, _encodings_index1;
|
|
223
|
+
if (hidden.has(entry2.id)) return null;
|
|
224
|
+
var points = entry2.data.map(function (datum2) {
|
|
225
|
+
var _xScale;
|
|
226
|
+
return {
|
|
227
|
+
x: (_xScale = xScale(datum2.label)) !== null && _xScale !== void 0 ? _xScale : plot.x,
|
|
228
|
+
y: yScale(datum2.value)
|
|
229
|
+
};
|
|
230
|
+
});
|
|
231
|
+
var stroke = strokes[index];
|
|
232
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_svg.G, {
|
|
233
|
+
children: [showArea ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_series.AreaSeries, {
|
|
234
|
+
points,
|
|
235
|
+
baseline: plot.y + plot.height,
|
|
236
|
+
color: stroke,
|
|
237
|
+
opacity: areaOpacity,
|
|
238
|
+
curve
|
|
239
|
+
}) : null, /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_series.LineSeries, {
|
|
240
|
+
seriesId: entry2.id,
|
|
241
|
+
data: entry2.data,
|
|
242
|
+
points,
|
|
243
|
+
color: stroke,
|
|
244
|
+
strokeWidth,
|
|
245
|
+
curve,
|
|
246
|
+
showPoints,
|
|
247
|
+
marker: (_encodings_index = encodings[index]) === null || _encodings_index === void 0 ? void 0 : _encodings_index.marker,
|
|
248
|
+
dash: (_encodings_index1 = encodings[index]) === null || _encodings_index1 === void 0 ? void 0 : _encodings_index1.dash,
|
|
249
|
+
bounds: size,
|
|
250
|
+
onDatumPress,
|
|
251
|
+
onDatumHoverIn,
|
|
252
|
+
onDatumHoverOut,
|
|
253
|
+
datumLabel: interactive ? function (datum2) {
|
|
254
|
+
return (0, import_accessibility.describeDatum)({
|
|
255
|
+
datum: datum2,
|
|
256
|
+
formatValue: valueFormatter
|
|
257
|
+
});
|
|
258
|
+
} : void 0
|
|
259
|
+
})]
|
|
260
|
+
}, entry2.id);
|
|
261
|
+
}), showXAxis ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Axis.XAxis, {
|
|
262
|
+
plot,
|
|
263
|
+
scale: xScale,
|
|
264
|
+
tickValues: (0, import_composeChart.thinCategories)(categories, plot.width, labelFontSize)
|
|
265
|
+
}) : null]
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
});
|
|
81
269
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ChartDataView.ChartDataFrame, {
|
|
82
|
-
data,
|
|
270
|
+
data: flat,
|
|
83
271
|
title,
|
|
84
272
|
valueFormatter,
|
|
85
273
|
width,
|
|
86
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.
|
|
87
|
-
|
|
88
|
-
proof: {
|
|
89
|
-
kind: showArea ? "area" : "line",
|
|
90
|
-
separated: false,
|
|
91
|
-
datumText: false,
|
|
92
|
-
datumValues: (0, import_accessibility.chartDatumText)(data, valueFormatter),
|
|
93
|
-
datumCount: data.length
|
|
94
|
-
},
|
|
95
|
-
height,
|
|
96
|
-
width,
|
|
274
|
+
children: multi ? /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.YStack, {
|
|
275
|
+
gap: "$2",
|
|
97
276
|
...stackProps,
|
|
98
|
-
children:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var marginScale = (0, import_math.createLinearScale)({
|
|
103
|
-
domain,
|
|
104
|
-
range: [0, 1]
|
|
105
|
-
});
|
|
106
|
-
var tickValues = (0, import_math.getLinearTicks)(marginScale, yTicks);
|
|
107
|
-
var plot = (0, import_composeChart.computeCartesianPlot)(size, {
|
|
108
|
-
showXAxis,
|
|
109
|
-
showYAxis,
|
|
110
|
-
yTickLabels: tickValues.map(function (value) {
|
|
111
|
-
return format(value);
|
|
112
|
-
}),
|
|
113
|
-
fontSize: labelFontSize
|
|
114
|
-
});
|
|
115
|
-
if (plot.width <= 0 || plot.height <= 0 || data.length === 0) return null;
|
|
116
|
-
var xScale = (0, import_math.createPointScale)({
|
|
117
|
-
domain: data.map(function (datum) {
|
|
118
|
-
return datum.label;
|
|
119
|
-
}),
|
|
120
|
-
range: [plot.x, plot.x + plot.width],
|
|
121
|
-
padding: 0.5
|
|
122
|
-
});
|
|
123
|
-
var yScale = (0, import_math.createLinearScale)({
|
|
124
|
-
domain,
|
|
125
|
-
range: [plot.y + plot.height, plot.y]
|
|
126
|
-
});
|
|
127
|
-
var points = data.map(function (datum) {
|
|
128
|
-
var _xScale;
|
|
277
|
+
children: [chart, /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_SeriesLegend.SeriesLegend, {
|
|
278
|
+
entries: all.map(function (entry2, index) {
|
|
279
|
+
var _ref2;
|
|
280
|
+
var _encodings_index, _encodings_index1;
|
|
129
281
|
return {
|
|
130
|
-
|
|
131
|
-
|
|
282
|
+
id: entry2.id,
|
|
283
|
+
label: entry2.label,
|
|
284
|
+
color: strokes[index],
|
|
285
|
+
marker: (_ref2 = (_encodings_index = encodings[index]) === null || _encodings_index === void 0 ? void 0 : _encodings_index.marker) !== null && _ref2 !== void 0 ? _ref2 : "circle",
|
|
286
|
+
dash: (_encodings_index1 = encodings[index]) === null || _encodings_index1 === void 0 ? void 0 : _encodings_index1.dash,
|
|
287
|
+
shown: !hidden.has(entry2.id)
|
|
132
288
|
};
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
scale: yScale,
|
|
138
|
-
ticks: yTicks,
|
|
139
|
-
tickFormat: function tickFormat(value) {
|
|
140
|
-
return format(value);
|
|
141
|
-
},
|
|
142
|
-
showLabels: showYAxis,
|
|
143
|
-
showGrid
|
|
144
|
-
}) : null, showArea ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_series.AreaSeries, {
|
|
145
|
-
points,
|
|
146
|
-
baseline: plot.y + plot.height,
|
|
147
|
-
color: stroke,
|
|
148
|
-
opacity: areaOpacity,
|
|
149
|
-
curve
|
|
150
|
-
}) : null, /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_series.LineSeries, {
|
|
151
|
-
data,
|
|
152
|
-
points,
|
|
153
|
-
color: stroke,
|
|
154
|
-
strokeWidth,
|
|
155
|
-
curve,
|
|
156
|
-
showPoints,
|
|
157
|
-
bounds: size,
|
|
158
|
-
onDatumPress,
|
|
159
|
-
onDatumHoverIn,
|
|
160
|
-
onDatumHoverOut,
|
|
161
|
-
datumLabel: interactive ? function (datum) {
|
|
162
|
-
return (0, import_accessibility.describeDatum)({
|
|
163
|
-
datum,
|
|
164
|
-
formatValue: valueFormatter
|
|
165
|
-
});
|
|
166
|
-
} : void 0
|
|
167
|
-
}), showXAxis ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Axis.XAxis, {
|
|
168
|
-
plot,
|
|
169
|
-
scale: xScale,
|
|
170
|
-
tickValues: (0, import_composeChart.thinCategories)(data.map(function (datum) {
|
|
171
|
-
return datum.label;
|
|
172
|
-
}), plot.width, labelFontSize)
|
|
173
|
-
}) : null]
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
})
|
|
289
|
+
}),
|
|
290
|
+
onToggle: toggle
|
|
291
|
+
})]
|
|
292
|
+
}) : chart
|
|
177
293
|
});
|
|
178
294
|
}
|
|
179
295
|
function AreaChart(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","LineChart_exports","AreaChart","LineChart","module","exports","import_jsx_runtime","require","import_i18n","import_Axis","import_ChartDataView","import_ChartSurface","import_accessibility","import_composeChart","import_math","import_series","import_useChartTheme","param","data","height","width","color","showArea","areaOpacity","curve","showPoints","strokeWidth","showXAxis","showYAxis","showGrid","yTicks","valueFormatter","title","label","typeLabel","onDatumPress","onDatumHoverIn","onDatumHoverOut","stackProps","t","useTranslation","palette","labelFontSize","useChartTheme","
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","LineChart_exports","AreaChart","LineChart","module","exports","import_jsx_runtime","require","import_react","import_tamagui","import_i18n","import_Axis","import_ChartDataView","import_ChartSurface","import_accessibility","import_composeChart","import_math","import_series","import_SeriesLegend","import_svg","import_useChartTheme","param","data","series","height","width","color","showArea","areaOpacity","curve","showPoints","strokeWidth","showXAxis","showYAxis","showGrid","yTicks","valueFormatter","title","label","typeLabel","onDatumPress","onDatumHoverIn","onDatumHoverOut","stackProps","_ref","_all_","t","useTranslation","palette","labelFontSize","useChartTheme","hidden","setHidden","useState","Set","id","multi","length","strokes","map","entry2","index","_entry_color","_ref2","categorical","single","encodings","_","seriesEncoding","marker","dash","flat","flatMap","datum2","format","formatChartValue","kind","ariaLabel","describeChart","formatValue","join","interactive","Boolean","toggle","toggle2","current","next","has","delete","add","categories","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1","_iterator","Symbol","iterator","_step","done","entry","_iterator1","_step1","datum","includes","push","err","return","chart","jsx","ChartSurface","proof","separated","datumText","datumValues","chartDatumText","datumCount","children","size","domain","valueDomain","marginScale","createLinearScale","range","tickValues","getLinearTicks","plot","computeCartesianPlot","yTickLabels","fontSize","xScale","createPointScale","x","padding","yScale","y","jsxs","Fragment","YAxis","scale","ticks","tickFormat","showLabels"],"sources":["../../../src/charts/LineChart.tsx"],"sourcesContent":[null],"mappings":"AAAA,YAAS;;AACT,IAAAA,SAAS,GAAAC,MAAA,CAAgCC,cAAA;AAEzC,IAAAC,gBAAS,GAAAF,MAAA,CAAAG,wBAAsB;AAC/B,IAAAC,iBAAgB,GAAAJ,MAAa,CAAAK,mBAAA;AAC7B,IAAAC,YAAS,GAAAN,MAAA,CAAAO,SAAsB,CAAAC,cAAA;AAC/B,IAAAC,QAAS,GAAAA,CAAAC,MAAA,EAAAC,GAAA,KAAoB;EAC7B,SAASC,IAAA,IAAAD,GAAA,EACTZ,SAAS,CAAAW,MAAA,EAAAE,IAAA;IAAAC,GAAsB,EAAAF,GAAA,CAAAC,IAAA;IAAAE,UAAsB;EAAA;AACrD;AAAA,IACEC,WAAA,GAAAA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAAAC,IAAA;EACA,IAAAF,IAAA,WAAAA,IAAA,wBAAAA,IAAA;IACA,SAAAG,GAAA,IAAAhB,iBAAA,CAAAa,IAAA,GACA,KAAAX,YAAA,CAAAe,IAAA,CAAAL,EAAA,EAAAI,GAAA,KAAAA,GAAA,KAAAF,MAAA,EACAnB,SAAA,CAAAiB,EAAA,EAAAI,GAAA;MAAAP,GAAA,E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AN,IAAA,CAAAvG,KAAA;QACF8G,OAAA;MAGF;MAIS,IAAAC,MAAA,OAAAxH,WAAA,CAAA4G,iBAAA;QACDH,MAAA;QAACI,KAAA,GAAAG,IAAA,CAAAS,CAAA,GAAAT,IAAA,CAAAxG,MAAA,EACCwG,IAAA,CAAAS,CAAA;MACY;MACG,OACb,eAAe,CAAK,GAAAnI,kBAAA,CAAAoI,IAAA,EAAApI,kBAAA,CAAAqI,QAAA;QAAApB,QACpB,EAAQ,CACRtF,SAAM,IAAAC,QAAe,GAAG,mBAAA5B,kBAAA,CAAAyG,GAAA,EAAApG,WAAA,CAAAiI,KAAA;UACxBZ,IAAA;UACAa,KAAA,EAAAL,MAAA;UACFM,KAAA,EAAU3G,MAAA;UAAA4G,UAAA,WAAAA,WAAA/I,KAAA;YACZ,OAAA0E,MAAA,CAAA1E,KAAA;UAGF;UAIRgJ,UAAA,EAAA/G,SAAA;UAKgBC;QACP,WACT/C,GAAA,CAAAwE,GAAA,WAAAC,MAAA,EAAAC,KAAA","ignoreList":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MIN_PRESS_TARGET, useResolvedKnobs } from "@multiplatform.one/theme";
|
|
2
|
+
import { Text, XStack, isWeb } from "tamagui";
|
|
3
|
+
import { markerPath } from "./series.mjs";
|
|
4
|
+
import { Line, Path, Svg, chartWebProps } from "./svg.mjs";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
function SeriesLegend({
|
|
7
|
+
entries,
|
|
8
|
+
onToggle
|
|
9
|
+
}) {
|
|
10
|
+
const {
|
|
11
|
+
knobProps
|
|
12
|
+
} = useResolvedKnobs();
|
|
13
|
+
return /* @__PURE__ */jsx(XStack, {
|
|
14
|
+
flexWrap: "wrap",
|
|
15
|
+
columnGap: "$3",
|
|
16
|
+
...chartWebProps({
|
|
17
|
+
"data-line-legend": ""
|
|
18
|
+
}),
|
|
19
|
+
children: entries.map(entry => /* @__PURE__ */jsxs(XStack, {
|
|
20
|
+
role: "checkbox",
|
|
21
|
+
"aria-checked": entry.shown,
|
|
22
|
+
"aria-label": entry.label,
|
|
23
|
+
...(isWeb ? {} : {
|
|
24
|
+
accessibilityState: {
|
|
25
|
+
checked: entry.shown
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
onPress: () => onToggle(entry.id),
|
|
29
|
+
minHeight: MIN_PRESS_TARGET,
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
gap: "$2",
|
|
32
|
+
cursor: "pointer",
|
|
33
|
+
opacity: entry.shown ? 1 : 0.45,
|
|
34
|
+
children: [/* @__PURE__ */jsxs(Svg, {
|
|
35
|
+
width: 22,
|
|
36
|
+
height: 12,
|
|
37
|
+
children: [/* @__PURE__ */jsx(Line, {
|
|
38
|
+
x1: 1,
|
|
39
|
+
y1: 6,
|
|
40
|
+
x2: 21,
|
|
41
|
+
y2: 6,
|
|
42
|
+
stroke: entry.color,
|
|
43
|
+
strokeWidth: 2,
|
|
44
|
+
strokeDasharray: entry.dash
|
|
45
|
+
}), /* @__PURE__ */jsx(Path, {
|
|
46
|
+
d: markerPath(entry.marker, 11, 6, 3),
|
|
47
|
+
fill: entry.color
|
|
48
|
+
})]
|
|
49
|
+
}), /* @__PURE__ */jsx(Text, {
|
|
50
|
+
...knobProps.body,
|
|
51
|
+
fontSize: "$2",
|
|
52
|
+
color: knobProps.textAccentColor,
|
|
53
|
+
textDecorationLine: entry.shown ? "none" : "line-through",
|
|
54
|
+
children: entry.label
|
|
55
|
+
})]
|
|
56
|
+
}, entry.id))
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export { SeriesLegend };
|
|
60
|
+
//# sourceMappingURL=SeriesLegend.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MIN_PRESS_TARGET","useResolvedKnobs","Text","XStack","isWeb","markerPath","Line","Path","Svg","chartWebProps","jsx","jsxs","SeriesLegend","entries","onToggle","knobProps","flexWrap","columnGap","children","map","entry","role","shown","label","accessibilityState","checked","onPress","id","minHeight","alignItems","gap","cursor","opacity","width","height","x1","y1","x2","y2","stroke","color","strokeWidth","strokeDasharray","dash","d","marker","fill","body","fontSize","textAccentColor","textDecorationLine"],"sources":["../../../src/charts/SeriesLegend.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,gBAAA,EAAkBC,gBAAA,QAAwB;AACnD,SAASC,IAAA,EAAMC,MAAA,EAAQC,KAAA,QAAa;AACpC,SAASC,UAAA,QAAoC;AAC7C,SAASC,IAAA,EAAMC,IAAA,EAAMC,GAAA,EAAKC,aAAA,QAAqB;AAwCrC,SACEC,GAAA,EADFC,IAAA;AAlBH,SAASC,aAAa;EAAEC,OAAA;EAASC;AAAS,GAAsB;EACrE,MAAM;IAAEC;EAAU,IAAId,gBAAA,CAAiB;EACvC,OACE,eAAAS,GAAA,CAACP,MAAA;IAAOa,QAAA,EAAS;IAAOC,SAAA,EAAU;IAAM,GAAGR,aAAA,CAAc;MAAE,oBAAoB;IAAG,CAAC;IAChFS,QAAA,EAAAL,OAAA,CAAQM,GAAA,CAAKC,KAAA,IACZ,eAAAT,IAAA,CAACR,MAAA;MAECkB,IAAA,EAAK;MACL,gBAAcD,KAAA,CAAME,KAAA;MACpB,cAAYF,KAAA,CAAMG,KAAA;MACjB,IAAInB,KAAA,GAAQ,CAAC,IAAI;QAAEoB,kBAAA,EAAoB;UAAEC,OAAA,EAASL,KAAA,CAAME;QAAM;MAAE;MACjEI,OAAA,EAASA,CAAA,KAAMZ,QAAA,CAASM,KAAA,CAAMO,EAAE;MAChCC,SAAA,EAAW5B,gBAAA;MACX6B,UAAA,EAAW;MACXC,GAAA,EAAI;MACJC,MAAA,EAAO;MACPC,OAAA,EAASZ,KAAA,CAAME,KAAA,GAAQ,IAAI;MAE3BJ,QAAA,kBAAAP,IAAA,CAACH,GAAA;QAAIyB,KAAA,EAAO;QAAIC,MAAA,EAAQ;QACtBhB,QAAA,kBAAAR,GAAA,CAACJ,IAAA;UACC6B,EAAA,EAAI;UACJC,EAAA,EAAI;UACJC,EAAA,EAAI;UACJC,EAAA,EAAI;UACJC,MAAA,EAAQnB,KAAA,CAAMoB,KAAA;UACdC,WAAA,EAAa;UACbC,eAAA,EAAiBtB,KAAA,CAAMuB;QAAA,CACzB,GACA,eAAAjC,GAAA,CAACH,IAAA;UAAKqC,CAAA,EAAGvC,UAAA,CAAWe,KAAA,CAAMyB,MAAA,EAAQ,IAAI,GAAG,CAAC;UAAGC,IAAA,EAAM1B,KAAA,CAAMoB;QAAA,CAAO;MAAA,CAClE,GACA,eAAA9B,GAAA,CAACR,IAAA;QACE,GAAGa,SAAA,CAAUgC,IAAA;QACdC,QAAA,EAAS;QACTR,KAAA,EAAOzB,SAAA,CAAUkC,eAAA;QACjBC,kBAAA,EAAoB9B,KAAA,CAAME,KAAA,GAAQ,SAAS;QAE1CJ,QAAA,EAAAE,KAAA,CAAMG;MAAA,CACT;IAAA,GA/BKH,KAAA,CAAMO,EAgCb,CACD;EAAA,CACH;AAEJ","ignoreList":[]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var SeriesLegend_exports = {};
|
|
26
|
+
__export(SeriesLegend_exports, {
|
|
27
|
+
SeriesLegend: () => SeriesLegend
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(SeriesLegend_exports);
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var import_theme = require("@multiplatform.one/theme");
|
|
32
|
+
var import_tamagui = require("tamagui");
|
|
33
|
+
var import_series = require("./series.native.js");
|
|
34
|
+
var import_svg = require("./svg.native.js");
|
|
35
|
+
function SeriesLegend(param) {
|
|
36
|
+
var {
|
|
37
|
+
entries,
|
|
38
|
+
onToggle
|
|
39
|
+
} = param;
|
|
40
|
+
var {
|
|
41
|
+
knobProps
|
|
42
|
+
} = (0, import_theme.useResolvedKnobs)();
|
|
43
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.XStack, {
|
|
44
|
+
flexWrap: "wrap",
|
|
45
|
+
columnGap: "$3",
|
|
46
|
+
...(0, import_svg.chartWebProps)({
|
|
47
|
+
"data-line-legend": ""
|
|
48
|
+
}),
|
|
49
|
+
children: entries.map(function (entry) {
|
|
50
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
|
|
51
|
+
role: "checkbox",
|
|
52
|
+
"aria-checked": entry.shown,
|
|
53
|
+
"aria-label": entry.label,
|
|
54
|
+
...(import_tamagui.isWeb ? {} : {
|
|
55
|
+
accessibilityState: {
|
|
56
|
+
checked: entry.shown
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
onPress: function onPress() {
|
|
60
|
+
return onToggle(entry.id);
|
|
61
|
+
},
|
|
62
|
+
minHeight: import_theme.MIN_PRESS_TARGET,
|
|
63
|
+
alignItems: "center",
|
|
64
|
+
gap: "$2",
|
|
65
|
+
cursor: "pointer",
|
|
66
|
+
opacity: entry.shown ? 1 : 0.45,
|
|
67
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_svg.Svg, {
|
|
68
|
+
width: 22,
|
|
69
|
+
height: 12,
|
|
70
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_svg.Line, {
|
|
71
|
+
x1: 1,
|
|
72
|
+
y1: 6,
|
|
73
|
+
x2: 21,
|
|
74
|
+
y2: 6,
|
|
75
|
+
stroke: entry.color,
|
|
76
|
+
strokeWidth: 2,
|
|
77
|
+
strokeDasharray: entry.dash
|
|
78
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_svg.Path, {
|
|
79
|
+
d: (0, import_series.markerPath)(entry.marker, 11, 6, 3),
|
|
80
|
+
fill: entry.color
|
|
81
|
+
})]
|
|
82
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Text, {
|
|
83
|
+
...knobProps.body,
|
|
84
|
+
fontSize: "$2",
|
|
85
|
+
color: knobProps.textAccentColor,
|
|
86
|
+
textDecorationLine: entry.shown ? "none" : "line-through",
|
|
87
|
+
children: entry.label
|
|
88
|
+
})]
|
|
89
|
+
}, entry.id);
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=SeriesLegend.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","SeriesLegend_exports","SeriesLegend","module","exports","import_jsx_runtime","require","import_theme","import_tamagui","import_series","import_svg","param","entries","onToggle","knobProps","useResolvedKnobs","jsx","XStack","flexWrap","columnGap","chartWebProps","children","map","entry","jsxs","role","shown","label","isWeb","accessibilityState","checked","onPress","id","minHeight","MIN_PRESS_TARGET"],"sources":["../../../src/charts/SeriesLegend.tsx"],"sourcesContent":[null],"mappings":"AAAA,YAAS;;AACT,IAAAA,SAAS,GAAMC,MAAA,CAAQC,cAAa;AACpC,IAAAC,gBAAS,GAAAF,MAAoC,CAAAG,wBAAA;AAC7C,IAAAC,iBAAqB,GAAAJ,MAAK,CAAAK,mBAAqB;AAwCrC,IAAAC,YAAA,GAAAN,MAAA,CAAAO,SAAA,CAAAC,cAAA;AAlBH,IAAAC,QAAS,GAAAA,CAAAC,MAAa,EAAEC,GAAA;EAC7B,SAAQC,IAAA,IAAAD,GAAU,EAClBZ,SACE,CAAAW,MAAA,EAAAE,IAAA;IAACC,GAAA,EAAAF,GAAA,CAAOC,IAAA;IAAAE,UAAS,EAAO;EAAA;AAEpB;AAAC,IAAAC,WAAA,GAAAA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAAAC,IAAA;EAAA,IAECF,IAAA,IAAK,OAAAA,IAAA,wBAAAA,IAAA;IAAA,KACL,IAAAG,GAAA,IAAAhB,iBAAoB,CAAAa,IAAA,GACpB,KAAAX,YAAY,CAAAe,IAAM,CAAAL,EAAA,EAAAI,GAAA,KAAAA,GAAA,KAAAF,MAAA,EACjBnB,SAAY,CAACiB,EAAA,EAAII,GAAE;MAAAP,GAAA,EAAAA,CAAA,KAAAI,IAAoB,CAAAG,GAAE;MAAAN,UAAe,IAAAK,IAAQ,GAAAjB,gBAAA,CAAAe,IAAA,EAAAG,GAAA,MAAAD,IAAA,CAAAL;IAAA;EAAA;EACjC,OAChCE,EAAA;AAAW;AACA,IAAAM,YACP,GAAAC,GAAA,IAAAR,WAAA,CAAAhB,SAAA;EAAAyB,KAAA;AAAA,IAAAD,GAAA;AAAA,IAAAE,oBACG;AAAAhB,QACP,CAAAgB,oBAAuB;EAAIC,YAE3B,EAAAA,CAAA,KAAAA;AAAA;AACEC,MAAA,CAAAC,OAAA,GAAAN,YAAA,CAAAG,oBAAA;AAAA,IAAAI,kBAAC,GAAAC,OAAA;AAAA,IAAAC,YAAA,GAAAD,OAAA;AAAA,IAAAE,cACK,GAAAF,OAAA;AAAA,IAAAG,aACJ,GAAIH,OAAA;AAAA,IAAAI,UACJ,GAAAJ,OAAI;AAAA,SAAAJ,YACAA,CAAAS,KAAA;EAAA;IAAAC,OACJ;IAAAC;EAAQ,IAAMF,KAAA;EAAA;IAAAG;EACd,QAAAP,YAAa,CAAAQ,gBAAA;EAAA,sBACb,IAAAV,kBAAuB,CAAAW,GAAA,EAAAR,cAAA,CAAAS,MAAA;IAAAC,QAAA;IAAAC,SACzB;IAAA,OACAT,UAAA,CAAAU,aAAC;MAA+D,kBAClE;IAAA;IACAC,QAAC,EAAAT,OAAA,CAAAU,GAAA,WAAAC,KAAA;MAAA,0BAAAlB,kBAAA,CAAAmB,IAAA,EAAAhB,cAAA,CAAAS,MAAA;QAAAQ,IACE,YAAG;QAAU,cACL,EAAAF,KAAA,CAAAG,KAAA;QAAA,YACF,EAAAH,KAAA,CAAAI,KAAU;QAAA,IAAAnB,cACjB,CAAAoB,KAAA,GAAoB,KAAM;UAAiBC,kBAEpC;YAAAC,OAAA,EAAAP,KAAA,CAAAG;UACT;QAAA;QAAAK,OAAA,WAAAA,QAAA;UA/BW,OAAAlB,QAAA,CAAAU,KAAA,CAAAS,EAAA;QAkCjB;QAEJC,SAAA,EAAA1B,YAAA,CAAA2B,gBAAA","ignoreList":[]}
|
|
@@ -75,6 +75,34 @@ function BarSeries({
|
|
|
75
75
|
})
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
+
const markerShapes = ["circle", "square", "triangle", "diamond", "triangleDown", "cross"];
|
|
79
|
+
const seriesDashes = ["6 4", "2 3", "8 3 2 3", "4 2"];
|
|
80
|
+
function seriesEncoding(index) {
|
|
81
|
+
return {
|
|
82
|
+
marker: markerShapes[index % markerShapes.length],
|
|
83
|
+
dash: index >= 4 ? seriesDashes[(index - 4) % seriesDashes.length] : void 0
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function markerPath(shape, x, y, r) {
|
|
87
|
+
const s = r * 1.15;
|
|
88
|
+
switch (shape) {
|
|
89
|
+
case "square":
|
|
90
|
+
return `M${x - s},${y - s}H${x + s}V${y + s}H${x - s}Z`;
|
|
91
|
+
case "triangle":
|
|
92
|
+
return `M${x},${y - s * 1.2}L${x + s * 1.15},${y + s * 0.8}H${x - s * 1.15}Z`;
|
|
93
|
+
case "triangleDown":
|
|
94
|
+
return `M${x},${y + s * 1.2}L${x + s * 1.15},${y - s * 0.8}H${x - s * 1.15}Z`;
|
|
95
|
+
case "diamond":
|
|
96
|
+
return `M${x},${y - s * 1.35}L${x + s * 1.35},${y}L${x},${y + s * 1.35}L${x - s * 1.35},${y}Z`;
|
|
97
|
+
case "cross":
|
|
98
|
+
{
|
|
99
|
+
const t = s * 0.45;
|
|
100
|
+
return `M${x - t},${y - s * 1.2}H${x + t}V${y - t}H${x + s * 1.2}V${y + t}H${x + t}V${y + s * 1.2}H${x - t}V${y + t}H${x - s * 1.2}V${y - t}H${x - t}Z`;
|
|
101
|
+
}
|
|
102
|
+
default:
|
|
103
|
+
return `M${x - r},${y}a${r},${r} 0 1,0 ${r * 2},0a${r},${r} 0 1,0 ${-r * 2},0`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
78
106
|
function clampTargetCenter(value, radius, extent) {
|
|
79
107
|
if (extent === void 0 || extent < radius * 2) return value;
|
|
80
108
|
return Math.min(Math.max(value, radius), extent - radius);
|
|
@@ -88,11 +116,18 @@ function LineSeries({
|
|
|
88
116
|
showPoints = true,
|
|
89
117
|
pointRadius = 3,
|
|
90
118
|
bounds,
|
|
119
|
+
marker = "circle",
|
|
120
|
+
dash,
|
|
121
|
+
seriesId = "series",
|
|
91
122
|
...callbacks
|
|
92
123
|
}) {
|
|
93
124
|
const interactive = hasTargets(callbacks);
|
|
94
125
|
const targetRadius = MIN_PRESS_TARGET / 2;
|
|
95
126
|
return /* @__PURE__ */jsxs(G, {
|
|
127
|
+
...chartWebProps({
|
|
128
|
+
"data-line-series": seriesId,
|
|
129
|
+
"data-marker": marker
|
|
130
|
+
}),
|
|
96
131
|
children: [/* @__PURE__ */jsx(Path, {
|
|
97
132
|
...chartMarkProps("series line"),
|
|
98
133
|
d: linePath(points, {
|
|
@@ -100,13 +135,18 @@ function LineSeries({
|
|
|
100
135
|
}),
|
|
101
136
|
fill: "none",
|
|
102
137
|
stroke: color,
|
|
103
|
-
strokeWidth
|
|
104
|
-
|
|
138
|
+
strokeWidth,
|
|
139
|
+
strokeDasharray: dash
|
|
140
|
+
}), showPoints ? points.map((point, index) => marker === "circle" ? /* @__PURE__ */jsx(Circle, {
|
|
105
141
|
...chartMarkProps(data[index]?.label ?? `point ${index + 1}`),
|
|
106
142
|
cx: point.x,
|
|
107
143
|
cy: point.y,
|
|
108
144
|
r: pointRadius,
|
|
109
145
|
fill: color
|
|
146
|
+
}, `point-${index}`) : /* @__PURE__ */jsx(Path, {
|
|
147
|
+
...chartMarkProps(data[index]?.label ?? `point ${index + 1}`),
|
|
148
|
+
d: markerPath(marker, point.x, point.y, pointRadius),
|
|
149
|
+
fill: color
|
|
110
150
|
}, `point-${index}`)) : null, interactive ? points.map((point, index) => /* @__PURE__ */jsx(Circle, {
|
|
111
151
|
cx: clampTargetCenter(point.x, targetRadius, bounds?.width),
|
|
112
152
|
cy: clampTargetCenter(point.y, targetRadius, bounds?.height),
|
|
@@ -199,5 +239,5 @@ function PieSeries({
|
|
|
199
239
|
})
|
|
200
240
|
});
|
|
201
241
|
}
|
|
202
|
-
export { AreaSeries, BarSeries, LineSeries, PieSeries };
|
|
242
|
+
export { AreaSeries, BarSeries, LineSeries, PieSeries, markerPath, markerShapes, seriesDashes, seriesEncoding };
|
|
203
243
|
//# sourceMappingURL=series.mjs.map
|