Skip to content

Commit

Permalink
fix(barbackground): datakey is undefined when set custom datakey
Browse files Browse the repository at this point in the history
  • Loading branch information
skie1997 committed Jul 5, 2024
1 parent 019fb4b commit efb0679
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "fix(barbackground): datakey is undefined when set custom datakey",
"type": "none"
}
],
"packageName": "@visactor/vchart"
}
5 changes: 4 additions & 1 deletion packages/vchart/src/series/bar/bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { IMark, IMarkProgressiveConfig } from '../../mark/interface';
import { MarkTypeEnum } from '../../mark/interface/type';
import {
AttributeLevel,
DEFAULT_DATA_KEY,
STACK_FIELD_END,
STACK_FIELD_END_PERCENT,
STACK_FIELD_START,
Expand Down Expand Up @@ -171,11 +172,13 @@ export class BarSeries<T extends IBarSeriesSpec = IBarSeriesSpec> extends Cartes
continue;
}
const newDataCollect: Datum[] = [];
const dataKey = (this._spec.dataKey as string) ?? DEFAULT_DATA_KEY;
for (let j = 0; j < values.length; j++) {
for (let k = 0; k < dataCollect.length; k++) {
newDataCollect.push({
...dataCollect[k],
[field]: values[j]
[field]: values[j],
[dataKey]: values[j]
});
}
}
Expand Down

0 comments on commit efb0679

Please sign in to comment.