From e9fb12f751e4958367041a129937a6b17922de2e Mon Sep 17 00:00:00 2001 From: SteveCapetta <44687431+SteveCapetta@users.noreply.github.com> Date: Mon, 4 Feb 2019 13:10:19 -0500 Subject: [PATCH] add Accessor as an attribute type (#3482) --- src/plots/plot.ts | 4 ++-- src/plots/xyPlot.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plots/plot.ts b/src/plots/plot.ts index 312c38bc95..f3d5fa0c22 100644 --- a/src/plots/plot.ts +++ b/src/plots/plot.ts @@ -333,10 +333,10 @@ export class Plot extends Component { * Sets a particular attribute to a constant value or the result of an Accessor. * * @param {string} attr - * @param {number|string|Accessor|Accessor} attrValue + * @param {number|string|Accessor|Accessor|Accessor} attrValue * @returns {Plot} The calling Plot. */ - public attr(attr: string, attrValue: number | string | IAccessor | IAccessor): this; + public attr(attr: string, attrValue: number | string | IAccessor | IAccessor | IAccessor): this; /** * Sets a particular attribute to a scaled constant value or scaled result of an Accessor. * The provided Scale will account for the attribute values when autoDomain()-ing. diff --git a/src/plots/xyPlot.ts b/src/plots/xyPlot.ts index bcfec58a74..754e68d207 100644 --- a/src/plots/xyPlot.ts +++ b/src/plots/xyPlot.ts @@ -360,9 +360,13 @@ export class XYPlot extends Plot { protected _getDataToDraw(): Utils.Map { const dataToDraw: Utils.Map = super._getDataToDraw(); + const definedAttr = this.attr("defined"); const definedFunction = (d: any, i: number, dataset: Dataset) => { const positionX = Plot._scaledAccessor(this.x())(d, i, dataset); const positionY = Plot._scaledAccessor(this.y())(d, i, dataset); + if (definedAttr && definedAttr.accessor(d, i, dataset) === false) { + return false; + } return Utils.Math.isValidNumber(positionX) && Utils.Math.isValidNumber(positionY); };