-
Notifications
You must be signed in to change notification settings - Fork 48
CODAP-1505: store point shape per legend category #2692
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
Merged
kswenson
merged 5 commits into
leads-point-shapes
from
CODAP-1505-per-category-point-shape
Sep 10, 2026
+825
−45
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a5db0ef
CODAP-1505: store point shape per legend category
kswenson 649b3da
CODAP-1505: address Copilot review
kswenson 256bc48
Fix category colors for values that collide with object keys
kswenson 1014d6b
CODAP-1505: address review comments
kswenson 85d56cb
CODAP-1505: say the v2 namespace constraint once
kswenson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
v3/src/components/data-display/models/display-item-description-model.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { applySnapshot, getSnapshot } from "mobx-state-tree" | ||
| import { DisplayItemDescriptionModel } from "./display-item-description-model" | ||
|
|
||
| describe("DisplayItemDescriptionModel point shape", () => { | ||
| it("defaults to circle, so existing documents render unchanged", () => { | ||
| const description = DisplayItemDescriptionModel.create() | ||
| expect(description.pointShape).toBe("circle") | ||
| expect(description.itemShape).toBe("circle") | ||
| }) | ||
|
|
||
| it("stores an assigned shape", () => { | ||
| const description = DisplayItemDescriptionModel.create() | ||
| description.setPointShape("triangle") | ||
| expect(description.pointShape).toBe("triangle") | ||
| }) | ||
|
|
||
| it("stores the default as absence, so an unused document does not gain the field", () => { | ||
| /* | ||
| * V3 saves the serialized snapshot, so a materialized default would mean that merely opening | ||
| * and saving a document that never used shapes changes it. Asserted against the JSON rather | ||
| * than the snapshot object: `maybe` leaves the key present with an undefined value in memory, | ||
| * and it is stringify dropping it that keeps the saved document unchanged. | ||
| */ | ||
| const description = DisplayItemDescriptionModel.create() | ||
| const serialized = JSON.parse(JSON.stringify(getSnapshot(description))) | ||
| expect(serialized).not.toHaveProperty("_itemShape") | ||
| expect(description.pointShape).toBe("circle") | ||
| }) | ||
|
|
||
| it("removes the stored shape when it is set back to the default", () => { | ||
| const description = DisplayItemDescriptionModel.create() | ||
| description.setPointShape("star") | ||
| expect(getSnapshot(description)._itemShape).toBe("star") | ||
|
|
||
| description.setPointShape("circle") | ||
| expect(JSON.parse(JSON.stringify(getSnapshot(description)))).not.toHaveProperty("_itemShape") | ||
| expect(description.pointShape).toBe("circle") | ||
| }) | ||
|
|
||
| it("persists the shape in the snapshot", () => { | ||
| const description = DisplayItemDescriptionModel.create() | ||
| description.setPointShape("plus") | ||
| expect(getSnapshot(description)._itemShape).toBe("plus") | ||
|
|
||
| const restored = DisplayItemDescriptionModel.create(getSnapshot(description)) | ||
| expect(restored.pointShape).toBe("plus") | ||
| }) | ||
|
|
||
| it("resolves a shape it does not recognize to the default", () => { | ||
| const description = DisplayItemDescriptionModel.create() | ||
| // simulates a document written by a build that knows a shape this one does not | ||
| applySnapshot(description, { ...getSnapshot(description), _itemShape: "hexagon" }) | ||
| expect(description.pointShape).toBe("circle") | ||
| }) | ||
|
|
||
| it("is independent of point color", () => { | ||
| // shape is a second encoding channel, so setting one must not disturb the other | ||
| const description = DisplayItemDescriptionModel.create() | ||
| const originalColor = description.pointColor | ||
| description.setPointShape("star") | ||
| expect(description.pointColor).toBe(originalColor) | ||
|
|
||
| description.setPointColor("#123456") | ||
| expect(description.pointShape).toBe("star") | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.