-
Notifications
You must be signed in to change notification settings - Fork 187
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
document layouts (as "scale-aware transforms") #819
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7a47351
mark initializers
mbostock bdab310
scale hex radius so that when hexagons touch, circles also touch with…
Fil 5c073b1
simpler hexagon
mbostock 4a1e110
hexgrid
mbostock 0239f16
fix for unscaled channels
mbostock d238637
reorder
mbostock 0817303
hexbin
mbostock 1852e30
fix #806; handle missing hint
mbostock bca32ba
infer channel scales
mbostock 18d5ec1
document layouts (as "scale-aware transforms")
Fil 0d770be
document binWidth
Fil f6421fd
document the initialize option after 42ac4f08093c5819e9fa2dcecf3e09e1…
Fil 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 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 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 |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
}, | ||
"dependencies": { | ||
"d3": "^7.3.0", | ||
"d3-hexbin": "^0.2.2", | ||
"isoformat": "0.2" | ||
}, | ||
"engines": { | ||
|
This file contains 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 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 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 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,45 @@ | ||
import {create} from "d3"; | ||
import {Mark} from "../plot.js"; | ||
import {number} from "../options.js"; | ||
import {applyDirectStyles, applyIndirectStyles, applyTransform, offset} from "../style.js"; | ||
import {sqrt4_3} from "../symbols.js"; | ||
|
||
const defaults = { | ||
ariaLabel: "hexgrid", | ||
fill: "none", | ||
stroke: "currentColor", | ||
strokeOpacity: 0.1 | ||
}; | ||
|
||
export function hexgrid(options) { | ||
return new Hexgrid(options); | ||
} | ||
|
||
export class Hexgrid extends Mark { | ||
constructor({radius = 10, clip = true, ...options} = {}) { | ||
super(undefined, undefined, {clip, ...options}, defaults); | ||
this.radius = number(radius); | ||
} | ||
render(index, scales, channels, dimensions) { | ||
const {dx, dy, radius: rx} = this; | ||
const {marginTop, marginRight, marginBottom, marginLeft, width, height} = dimensions; | ||
const x0 = marginLeft, x1 = width - marginRight, y0 = marginTop, y1 = height - marginBottom; | ||
const ry = rx * sqrt4_3, hy = ry / 2, wx = rx * 2, wy = ry * 1.5; | ||
const path = `m0,${-ry}l${rx},${hy}v${ry}l${-rx},${hy}`; | ||
const i0 = Math.floor(x0 / wx), i1 = Math.ceil(x1 / wx); | ||
const j0 = Math.floor((y0 + hy) / wy), j1 = Math.ceil((y1 - hy) / wy) + 1; | ||
const m = []; | ||
for (let j = j0; j < j1; ++j) { | ||
for (let i = i0; i < i1; ++i) { | ||
m.push(`M${i * wx + (j & 1) * rx},${j * wy}${path}`); | ||
} | ||
} | ||
return create("svg:g") | ||
.call(applyIndirectStyles, this, dimensions) | ||
.call(g => g.append("path") | ||
.call(applyDirectStyles, this) | ||
.call(applyTransform, null, null, offset + dx, offset + dy) | ||
.attr("d", m.join(""))) | ||
.node(); | ||
} | ||
} |
This file contains 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fil hi, well, i really wants this functionary. which topic branch is the most updated one (ideally based on plot v0.4.3)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specifically, i want these

Plot.link
s to be stacked (currently overlapping):work-arounds like
opacity
and dashed lines aren't satisfactory... xDand it seems i can specify the stacking direction with
anchor
withtop
&bottom
? perfect. :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryoqun the current branch is https://github.com/observablehq/plot/tree/mbostock/reinitialize; please feel free to test it and give us feedback. (But note that it's highly probable that more changes will occur before this ships.)