Skip to content

Commit

Permalink
Optimized getDataWithBaseline when required data is present
Browse files Browse the repository at this point in the history
If the datum already contains a baseline creating a new new object via
assign is not neccecary.
  • Loading branch information
Max Fritzsche committed Jan 7, 2019
1 parent 2054528 commit 9b9fc32
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/victory-area/src/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const getDataWithBaseline = (props, scale) => {
const minY = Math.min(...domainY) > 0 ? Math.min(...domainY) : defaultMin;

return data.map((datum) => {
if ((datum._y1 !== undefined || datum._y !== undefined) && datum._y0 !== undefined) {
return datum;
}

const _y1 = datum._y1 !== undefined ? datum._y1 : datum._y;
const _y0 = datum._y0 !== undefined ? datum._y0 : minY;
return assign({}, datum, { _y0, _y1 });
Expand Down

0 comments on commit 9b9fc32

Please sign in to comment.