Skip to content

Commit

Permalink
add Accessor<boolean> as an attribute type (#3482)
Browse files Browse the repository at this point in the history
  • Loading branch information
scapetta authored and themadcreator committed Feb 4, 2019
1 parent b6e36fb commit e9fb12f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/plots/plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>|Accessor<string>} attrValue
* @param {number|string|Accessor<number>|Accessor<string>|Accessor<boolean>} attrValue
* @returns {Plot} The calling Plot.
*/
public attr(attr: string, attrValue: number | string | IAccessor<number> | IAccessor<string>): this;
public attr(attr: string, attrValue: number | string | IAccessor<number> | IAccessor<string> | IAccessor<boolean>): 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.
Expand Down
4 changes: 4 additions & 0 deletions src/plots/xyPlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,13 @@ export class XYPlot<X, Y> extends Plot {
protected _getDataToDraw(): Utils.Map<Dataset, any[]> {
const dataToDraw: Utils.Map<Dataset, any[]> = 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);
};
Expand Down

1 comment on commit e9fb12f

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add Accessor as an attribute type (#3482)

Demo: quicktests | fiddle

Please sign in to comment.