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 all commits
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
16 changes: 11 additions & 5 deletions packages/ott-vis-panel/src/colors.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import * as d3 from "d3";

class ColorProvider {
private color = d3.scaleOrdinal(d3.schemeCategory10);
private assignments: Map<string, string> = 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 9 in packages/ott-vis-panel/src/colors.ts

View check run for this annotation

Codecov / codecov/patch

packages/ott-vis-panel/src/colors.ts#L8-L9

Added lines #L8 - L9 were not covered by tests
}
return this.assignments.get(thing)!;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L11 was not covered by tests
}

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L14 - L15 were not covered by tests
}
}

Expand Down
Loading