Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color provider hook to manage what colors are assigned to which node #1644

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions packages/ott-vis-panel/src/colors.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import * as d3 from "d3";

class ColorProvider {
private color: d3.ScaleOrdinal<string, string>;
Victor-M-Giraldo marked this conversation as resolved.
Show resolved Hide resolved
private assignments: Map<string, string>;
Victor-M-Giraldo marked this conversation as resolved.
Show resolved Hide resolved

constructor() {
this.color = d3.scaleOrdinal(d3.schemeCategory10);
this.assignments = new Map();
}

public assign(thing: string): string {
// TODO: implement
return "";
if (!this.assignments.has(thing)) {
this.assignments.set(thing, this.color(thing));

Check warning on line 14 in packages/ott-vis-panel/src/colors.ts

View check run for this annotation

Codecov / codecov/patch

packages/ott-vis-panel/src/colors.ts#L13-L14

Added lines #L13 - L14 were not covered by tests
}
return this.assignments.get(thing) as string;

Check warning on line 16 in packages/ott-vis-panel/src/colors.ts

View check run for this annotation

Codecov / codecov/patch

packages/ott-vis-panel/src/colors.ts#L16

Added line #L16 was not covered by tests
Victor-M-Giraldo marked this conversation as resolved.
Show resolved Hide resolved
}

public assignments(): Map<string, string> {
// TODO: implement
return new Map();
public getAssignments(): Map<string, string> {
return this.assignments;

Check warning on line 20 in packages/ott-vis-panel/src/colors.ts

View check run for this annotation

Codecov / codecov/patch

packages/ott-vis-panel/src/colors.ts#L19-L20

Added lines #L19 - L20 were not covered by tests
}
}

Expand Down
Loading