-
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
polylinear (aka piecewise linear) scales with an unspecified range #530
Closed
Closed
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4110b45
polylinear (aka piecewise linear) scale should work without specifyin…
Fil cc28a5d
utc
Fil 9d1851c
braces
Fil 42679eb
fix test
Fil 9438f70
timezones… is this going to work?
Fil bffffbf
more utc
Fil 1584ae1
polylinear color schemes
Fil 85ed812
polylinear scale with a color interpolate function (color scheme)
Fil 24cf670
fix polylinear scheme
Fil 7690ea1
honor reverse: true, and accept a reversed (monotone-decreasing) domain.
Fil 0124bcf
`zero: true` was not compatible with a polylinear domain.
Fil 41f4268
simplify
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 * as Plot from "@observablehq/plot"; | ||
import * as d3 from "d3"; | ||
|
||
const times = [ | ||
new Date(2013, 3, 5), | ||
new Date(2013, 3, 11), | ||
new Date(2013, 3, 14), | ||
new Date(2013, 3, 16), | ||
new Date(2013, 3, 18), | ||
new Date(2013, 3, 21), | ||
new Date(2013, 3, 27) | ||
]; | ||
|
||
const events = [ | ||
{ date: new Date(2013, 3, 5, 13, 0), text: "Initiate" }, | ||
{ date: new Date(2013, 3, 11, 13, 0), text: "Begin" }, | ||
{ date: new Date(2013, 3, 13, 20, 0), text: "Entry" }, | ||
{ date: new Date(2013, 3, 15, 0, 0), text: "Test" }, | ||
{ date: new Date(2013, 3, 16, 0, 0), text: "Drive" }, | ||
{ date: new Date(2013, 3, 17, 8, 0), text: "Drive" }, | ||
{ date: new Date(2013, 3, 18, 15, 0), text: "Brake" }, | ||
{ date: new Date(2013, 3, 20, 10, 0), text: "Stop" }, | ||
{ date: new Date(2013, 3, 23, 14, 0), text: "Shutdown" } | ||
]; | ||
|
||
export default async function() { | ||
return Plot.plot({ | ||
grid: true, | ||
x: { | ||
domain: times, | ||
type: "linear", | ||
ticks: [...d3.timeDays(...d3.extent(times)), times[times.length-1]], | ||
tickFormat: d3.timeFormat("%d"), | ||
inset: 20, | ||
label: "date →" | ||
}, | ||
color: { scheme: "cool" }, | ||
marks: [ | ||
Plot.barX(d3.pairs(times), {x1: "0", x2: "1", fill: (_,i) => i}), | ||
Plot.dotX(events, {x: "date", fill: "white"}), | ||
Plot.textX(events, {x: "date", text: "text", dx: -5, dy: -10, fill: "white", textAnchor: "start"}) | ||
], | ||
height: 90 | ||
}); | ||
} |
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.
These are local times; could we use UTC to avoid being dependent on the local timezone? (And then use d3.utcDays instead of d3.timeDays etc. below.)
I’d also prefer if you changed your prettier settings to avoid the spaces inside the curly braces. 🙂