Split label view data#1313
Conversation
✅ Deploy Preview for afmg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Refactors label handling to move state and burg label information into a data layer (pack.labels) while keeping rendering in SVG renderers, aiming to make labels more data-driven and reusable across the app.
Changes:
- Added a
Labelsmodule to generate/store/update state and burg label data inpack.labels - Extracted state-label raycast logic into a reusable
src/utils/label-raycast.tsutility - Updated state/burg label renderers and map generation to use/populate the new label data
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/label-raycast.ts | New shared raycast + scoring utilities for state label path selection |
| src/types/PackedGraph.ts | Extends PackedGraph with labels: LabelData[] |
| src/renderers/draw-state-labels.ts | Renders state labels from Labels data and updates label data (text/font size) during fitting |
| src/renderers/draw-burg-labels.ts | Renders burg labels from Labels data and syncs offsets back to label data |
| src/modules/labels.ts | New global Labels module for label CRUD + generation from states/burgs |
| src/modules/index.ts | Ensures Labels module is loaded/registered |
| public/main.js | Calls Labels.generate() during map generation |
|
@SheepFromHeaven do you intend on migrating any of the editor in the near future? Since I would need to edit the burgs-editor.js for feature completeness. I hope I can safe both of us some merge conflicts |
|
No worries. I will then leave it out for now. There is still enough other things. Incl. Fixing bugs 😂 |
…version to 1.113.0
…l rendering logic
…in editLabel function
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Update: Mostly done. Custom Labels Migration from Older Maps still need to be tested.
|
|
This should now be test ready. The migration of labels might not fully keep the format since it approximates the textPath. TextPaths that are changed later should apply correctly. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 22 comments.
Comments suppressed due to low confidence (1)
src/renderers/draw-state-labels.ts:152
- State label rendering ignores persisted label properties:
startOffsetis hard-coded to50%(andletterSpacingisn’t applied), even though these values are stored/edited viaLabels.update(...). This makes label editor changes non-persistent across redraws. UselabelData.startOffset/labelData.letterSpacing(with defaults) when setting textPath attributes.
const textElement = textGroup
.append("text")
.attr("text-rendering", "optimizeSpeed")
.attr("id", `stateLabel${labelData.i}`)
.attr(
"transform",
`translate(${labelData.dx || 0}, ${labelData.dy || 0})`,
)
.append("textPath")
.attr("startOffset", "50%")
.attr("font-size", `${ratio}%`)
.node() as SVGTextPathElement;
| // Update label data with font size | ||
| Labels.update(labelData.i, { fontSize: ratio }); | ||
|
|
There was a problem hiding this comment.
I don't know if these update calls are needed. I have to check that
There was a problem hiding this comment.
This is currently needed as the editor will use these values.
|
I will go and fix these issues. I have added better burg labels too, I will push that change first, then cleanup |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…s are now cleaned up
…location of burg to label
|
This should now be everything that I had on my list.
Is there anything that I missed from a feature standpoint? I can migrate the label-editor to simple typescript if that is wished for. |
|
I will check, but probably not today... |
Description
This PR aims to split the view and data of the state and burg labels. What will be missing are the province labels. The goal is to get labels working as data as much as possible for states and burgs.
Type of change
Versioning