Skip to content

Commit

Permalink
Merge pull request #3721 from VisActor/feat/support-stack-inverse-in-…
Browse files Browse the repository at this point in the history
…waterfall

Feat/support stack inverse in waterfall
  • Loading branch information
xile611 authored Feb 12, 2025
2 parents 3a09d67 + d66ca30 commit f1a9aaa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "feat: support stackInverse for waterfall chart\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "[email protected]"
}
2 changes: 1 addition & 1 deletion packages/vchart/__tests__/runtime/browser/index.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
*/

// import VChart from '../../../src';
import './index.page.local';
import './index.page.local.ts';
// window['VChart'] = VChart;
3 changes: 2 additions & 1 deletion packages/vchart/src/data/transforms/waterfall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface IWaterfallOpt {
increase: string;
decrease: string;
};
stackInverse: boolean;
groupData: () => DataView;
}

Expand Down Expand Up @@ -77,7 +78,7 @@ export const waterfall = (lastData: Array<Datum>, op: IWaterfallOpt) => {
negative: temp.end
};

const indexData = dimensionData[key];
const indexData = op.stackInverse === true ? dimensionData[key].reverse() : dimensionData[key];
indexData?.forEach((d, i) => {
if (i === indexData.length - 1) {
d[STACK_FIELD_TOTAL_TOP] = true;
Expand Down
6 changes: 4 additions & 2 deletions packages/vchart/src/series/waterfall/waterfall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export class WaterfallSeries<T extends IWaterfallSeriesSpec = IWaterfallSeriesSp
valueField: this.getStackValueField(),
seriesField: this.getSeriesField(),
seriesFieldName: this._theme.seriesFieldName,
total: this._spec.total
total: this._spec.total,
stackInverse: this.getRegion().getStackInverse()
}
},
false
Expand All @@ -123,7 +124,8 @@ export class WaterfallSeries<T extends IWaterfallSeriesSpec = IWaterfallSeriesSp
startAs: STACK_FIELD_START,
endAs: STACK_FIELD_END,
total: this._spec.total,
groupData: () => this.getGroups().groupData
groupData: () => this.getGroups().groupData,
stackInverse: this.getRegion().getStackInverse()
}
},
false
Expand Down

0 comments on commit f1a9aaa

Please sign in to comment.