Skip to content

Commit

Permalink
Added SetTransform Function (#5)
Browse files Browse the repository at this point in the history
* Added SetTransform Function

* Added requested changes to PR

* Added Requested Changes to PR

* Fixed issues

---------

Co-authored-by: venkatesh-sivaraman <[email protected]>
  • Loading branch information
eli-kranjec and venkatesh-sivaraman authored Oct 2, 2024
1 parent 841ed67 commit e431dac
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 4 deletions.
27 changes: 27 additions & 0 deletions counterpoint/dist/counterpoint-vis.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,15 @@ class b {
freeze() {
return this.animation && this._cleanUpAnimation(!0), this.value = this.last(), this.valueFn = void 0, this;
}
/**
* Sets transform of an attribute to a new function, can be applied to an Attribute,
* a Mark, or a MarkRenderGroup
* @param attrToModify attribute to modify
* @param newFunc new function to set transform to
*/
setTransform(t) {
this.transform = t, this.updateTransform();
}
/**
* @returns whether or not this attribute changed value (due to animation or
* other updates) on the last call to `advance`
Expand Down Expand Up @@ -3216,6 +3225,15 @@ class ra {
count() {
return this.markSet.size;
}
/**
* Sets transform of an attribute to a new function, can be applied to an Attribute,
* a Mark, or a MarkRenderGroup
* @param attrToModify attribute to modify
* @param newFunc new function to set transform to
*/
setTransform(t, e) {
this.forEach((r) => r.setTransform(t, e));
}
/**
* @param attrNames the attributes to check for changes in (if none provided,
* checks all attributes)
Expand Down Expand Up @@ -3562,6 +3580,15 @@ class Z {
_removeEdgeFrom(t) {
return this._reverseAdjacency.delete(t), this;
}
/**
* Sets transform of an attribute to a new function, can be applied to an Attribute,
* a Mark, or a MarkRenderGroup
* @param attrToModify attribute to modify
* @param newFunc new function to set transform to
*/
setTransform(t, e) {
this.attributes[t].setTransform(e);
}
}
function ca(i) {
let t;
Expand Down
2 changes: 1 addition & 1 deletion counterpoint/dist/counterpoint-vis.umd.js

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion counterpoint/lib/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,21 @@ export class Attribute<
this.valueFn = undefined;
return this;
}

/**
* Sets transform of an attribute to a new function, can be applied to an Attribute,
* a Mark, or a MarkRenderGroup
* @param attrToModify attribute to modify
* @param newFunc new function to set transform to
*/
setTransform(
newFunc: (
raw: ValueType,
computeArg: ComputeArgumentType
) => TransformedValueType
): void {
this.transform = newFunc;
this.updateTransform();
}
/**
* @returns whether or not this attribute changed value (due to animation or
* other updates) on the last call to `advance`
Expand Down
13 changes: 12 additions & 1 deletion counterpoint/lib/mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,6 @@ export class Mark<AttributeSet extends AttributeSetBase = MarkAttributes>
this._reverseAdjacency.add(sourceMark);
return this;
}

/**
* Tells the mark that it no longer has an edge from the given mark.
* @param sourceMark the mark that has no longer has an edge to this mark
Expand All @@ -678,6 +677,18 @@ export class Mark<AttributeSet extends AttributeSetBase = MarkAttributes>
this._reverseAdjacency.delete(sourceMark);
return this;
}
/**
* Sets transform of an attribute to a new function, can be applied to an Attribute,
* a Mark, or a MarkRenderGroup
* @param attrToModify attribute to modify
* @param newFunc new function to set transform to
*/
setTransform(
attrToModify: string,
newFunc: (raw: any, computeArg: any) => any
): void {
this.attributes[attrToModify].setTransform(newFunc);
}
}

type AttributeConstructorShorthand<
Expand Down
13 changes: 12 additions & 1 deletion counterpoint/lib/rendergroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,18 @@ export class MarkRenderGroup<
count(): number {
return this.markSet.size;
}

/**
* Sets transform of an attribute to a new function, can be applied to an Attribute,
* a Mark, or a MarkRenderGroup
* @param attrToModify attribute to modify
* @param newFunc new function to set transform to
*/
setTransform(
attrToModify: string,
newFunc: (raw: any, computeArg: any) => any
): void {
this.forEach((m) => m.setTransform(attrToModify, newFunc));
}
/**
* @param attrNames the attributes to check for changes in (if none provided,
* checks all attributes)
Expand Down

0 comments on commit e431dac

Please sign in to comment.