Skip to content

d3 7.9.0 #2020

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
merged 5 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,23 @@
"@types/d3": "^7.4.0",
"@types/mocha": "^10.0.1",
"@types/node": "^20.5.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"c8": "^8.0.1",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"c8": "^9.1.0",
"canvas": "^2.0.0",
"d3-geo-projection": "^4.0.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^9.1.0",
"htl": "^0.3.0",
"js-beautify": "1",
"jsdom": "^23.0.1",
"jsdom": "^24.0.0",
"markdown-it-container": "^4.0.0",
"mocha": "^10.0.0",
"module-alias": "^2.0.0",
"prettier": "~3.0.0",
"rollup": "^4.9.1",
"topojson-client": "^3.1.0",
"ts-morph": "^21.0.1",
"ts-morph": "^22.0.0",
"tsx": "^4.7.0",
"typescript": "^5.0.2",
"vite": "^5.0.10",
Expand All @@ -88,7 +88,7 @@
]
},
"dependencies": {
"d3": "^7.8.0",
"d3": "^7.9.0",
"interval-tree-1d": "^1.0.0",
"isoformat": "^0.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/context.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {creator, select} from "d3";
import {maybeClip} from "./style.js";
import {maybeClip} from "./options.js";

export function createContext(options = {}) {
const {document = typeof window !== "undefined" ? window.document : undefined, clip} = options;
Expand Down
4 changes: 2 additions & 2 deletions src/mark.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {channelDomain, createChannels, valueObject} from "./channel.js";
import {defined} from "./defined.js";
import {maybeFacetAnchor} from "./facet.js";
import {maybeNamed, maybeValue} from "./options.js";
import {maybeClip, maybeNamed, maybeValue} from "./options.js";
import {arrayify, isDomainSort, isObject, isOptions, keyword, range, singleton} from "./options.js";
import {project} from "./projection.js";
import {maybeClip, styles} from "./style.js";
import {styles} from "./style.js";
import {basic, initializer} from "./transforms/basic.js";

export class Mark {
Expand Down
21 changes: 10 additions & 11 deletions src/options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {descending, quantile, range as rangei} from "d3";
import {quantile, range as rangei} from "d3";
import {parse as isoParse} from "isoformat";
import {defined} from "./defined.js";
import {maybeTimeInterval, maybeUtcInterval} from "./time.js";
Expand Down Expand Up @@ -510,16 +510,6 @@ export function maybeFrameAnchor(value = "middle") {
return maybeAnchor(value, "frameAnchor");
}

// Like a sort comparator, returns a positive value if the given array of values
// is in ascending order, a negative value if the values are in descending
// order. Assumes monotonicity; only tests the first and last values.
export function orderof(values) {
if (values == null) return;
const first = values[0];
const last = values[values.length - 1];
return descending(first, last);
}

// Unlike {...defaults, ...options}, this ensures that any undefined (but
// present) properties in options inherit the given default value.
export function inherit(options = {}, ...rest) {
Expand Down Expand Up @@ -557,3 +547,12 @@ export function named(things) {
export function maybeNamed(things) {
return isIterable(things) ? named(things) : things;
}

// TODO Accept other types of clips (paths, urls, x, y, other marks…)?
// https://github.com/observablehq/plot/issues/181
export function maybeClip(clip) {
if (clip === true) clip = "frame";
else if (clip === false) clip = null;
else if (clip != null) clip = keyword(clip, "clip", ["frame", "sphere"]);
return clip;
}
11 changes: 11 additions & 0 deletions src/order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {descending} from "d3";

// Like a sort comparator, returns a positive value if the given array of values
// is in ascending order, a negative value if the values are in descending
// order. Assumes monotonicity; only tests the first and last values.
export function orderof(values) {
if (values == null) return;
const first = values[0];
const last = values[values.length - 1];
return descending(first, last);
}
2 changes: 1 addition & 1 deletion src/scales.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
isNumericString,
isScaleOptions,
map,
orderof,
slice,
coerceNumbers,
coerceDates
} from "./options.js";
import {orderof} from "./order.js";
import {registry, color, position, radius, opacity, symbol, length} from "./scales/index.js";
import {
createScaleLinear,
Expand Down
3 changes: 2 additions & 1 deletion src/scales/quantitative.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
ticks
} from "d3";
import {finite, negative, positive} from "../defined.js";
import {arrayify, constant, maybeNiceInterval, maybeRangeInterval, orderof, slice} from "../options.js";
import {arrayify, constant, maybeNiceInterval, maybeRangeInterval, slice} from "../options.js";
import {orderof} from "../order.js";
import {color, length, opacity, radius, registry, hasNumericRange} from "./index.js";
import {ordinalRange, quantitativeScheme} from "./schemes.js";

Expand Down
15 changes: 1 addition & 14 deletions src/scales/schemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
schemeGnBu,
schemeGreens,
schemeGreys,
schemeObservable10,
schemeOranges,
schemeOrRd,
schemePaired,
Expand Down Expand Up @@ -77,20 +78,6 @@ import {
schemeYlOrRd
} from "d3";

// TODO https://github.com/d3/d3-scale-chromatic/pull/51
const schemeObservable10 = [
"#4269d0",
"#efb118",
"#ff725c",
"#6cc5b0",
"#3ca951",
"#ff8ab7",
"#a463f2",
"#97bbf5",
"#9c6b4e",
"#9498a0"
];

const categoricalSchemes = new Map([
["accent", schemeAccent],
["category10", schemeCategory10],
Expand Down
11 changes: 1 addition & 10 deletions src/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {create} from "./context.js";
import {defined, nonempty} from "./defined.js";
import {formatDefault} from "./format.js";
import {isNone, isNoneish, isRound, maybeColorChannel, maybeNumberChannel} from "./options.js";
import {keyof, keyword, number, string} from "./options.js";
import {keyof, number, string} from "./options.js";
import {warn} from "./warnings.js";

export const offset = (typeof window !== "undefined" ? window.devicePixelRatio > 1 : typeof it === "undefined") ? 0 : 0.5; // prettier-ignore
Expand Down Expand Up @@ -297,15 +297,6 @@ export function* groupIndex(I, position, mark, channels) {
}
}

// TODO Accept other types of clips (paths, urls, x, y, other marks…)?
// https://github.com/observablehq/plot/issues/181
export function maybeClip(clip) {
if (clip === true) clip = "frame";
else if (clip === false) clip = null;
else if (clip != null) clip = keyword(clip, "clip", ["frame", "sphere"]);
return clip;
}

// Note: may mutate selection.node!
function applyClip(selection, mark, dimensions, context) {
let clipUrl;
Expand Down
2 changes: 1 addition & 1 deletion src/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {utcSecond, utcMinute, utcHour, unixDay, utcWeek, utcMonth, utcYear} from
import {utcMonday, utcTuesday, utcWednesday, utcThursday, utcFriday, utcSaturday, utcSunday} from "d3";
import {timeSecond, timeMinute, timeHour, timeDay, timeWeek, timeMonth, timeYear} from "d3";
import {timeMonday, timeTuesday, timeWednesday, timeThursday, timeFriday, timeSaturday, timeSunday} from "d3";
import {orderof} from "./options.js";
import {orderof} from "./order.js";

const durationSecond = 1000;
const durationMinute = durationSecond * 60;
Expand Down
2 changes: 1 addition & 1 deletion test/output/projectionBleedEdges.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/output/projectionClipAngle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions test/output/projectionClipAngleFrame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions test/output/projectionHeightOrthographic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/output/usStateCapitalsVoronoi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading