layerchart 2.0.0-next.47 → 2.0.0-next.48
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.
|
@@ -152,7 +152,8 @@ export class ChartState {
|
|
|
152
152
|
return explicit;
|
|
153
153
|
// Generate implicit series from registered marks.
|
|
154
154
|
// Use the value axis accessor (y for horizontal charts, x for vertical).
|
|
155
|
-
const valueAxis = this.
|
|
155
|
+
const valueAxis = this.valueAxis;
|
|
156
|
+
const chartValueProp = valueAxis === 'y' ? this.props.y : this.props.x;
|
|
156
157
|
const implicitSeries = [];
|
|
157
158
|
for (const { info } of this._markInfos) {
|
|
158
159
|
const valueAccessor = valueAxis === 'y' ? info.y : info.x;
|
|
@@ -160,6 +161,11 @@ export class ChartState {
|
|
|
160
161
|
(typeof valueAccessor === 'string' ? valueAccessor : undefined);
|
|
161
162
|
if (!key)
|
|
162
163
|
continue;
|
|
164
|
+
// Skip if the mark just reuses the chart's own axis accessor and has no
|
|
165
|
+
// separate data — it's not defining a new series, just using the chart's axis.
|
|
166
|
+
// Marks with their own data arrays are kept (multi-dataset scenario).
|
|
167
|
+
if (key === chartValueProp && !info.data)
|
|
168
|
+
continue;
|
|
163
169
|
if (implicitSeries.some((s) => s.key === key))
|
|
164
170
|
continue;
|
|
165
171
|
implicitSeries.push({
|
|
@@ -195,7 +195,6 @@ describe('ChartState mark registration', () => {
|
|
|
195
195
|
const { state, cleanup } = createChartState({
|
|
196
196
|
data: [{ date: '2024-01', value: 10 }],
|
|
197
197
|
x: 'date',
|
|
198
|
-
y: 'value',
|
|
199
198
|
});
|
|
200
199
|
try {
|
|
201
200
|
expect(state.seriesState.isDefaultSeries).toBe(true);
|
|
@@ -215,6 +214,22 @@ describe('ChartState mark registration', () => {
|
|
|
215
214
|
cleanup();
|
|
216
215
|
}
|
|
217
216
|
});
|
|
217
|
+
it('should not create implicit series when mark accessor matches chart accessor', () => {
|
|
218
|
+
const { state, cleanup } = createChartState({
|
|
219
|
+
data: [{ date: '2024-01', value: 10 }],
|
|
220
|
+
x: 'date',
|
|
221
|
+
y: 'value',
|
|
222
|
+
});
|
|
223
|
+
try {
|
|
224
|
+
// Mark with same y as chart — not a new series, just using chart's axis
|
|
225
|
+
state.registerMark({ y: 'value', color: 'red' });
|
|
226
|
+
flushSync();
|
|
227
|
+
expect(state.seriesState.isDefaultSeries).toBe(true);
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
cleanup();
|
|
231
|
+
}
|
|
232
|
+
});
|
|
218
233
|
it('should generate implicit series from marks with string y accessors', () => {
|
|
219
234
|
const data = [
|
|
220
235
|
{ date: '2024-01', apples: 10, bananas: 15 },
|
package/package.json
CHANGED