Skip to content

Commit

Permalink
Merge branch 'main' into fil/waffle-tips-stroke
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Nov 22, 2024
2 parents 1533c86 + 5fb8616 commit f3ab10e
Show file tree
Hide file tree
Showing 23 changed files with 1,381 additions and 139 deletions.
2 changes: 1 addition & 1 deletion docs/features/intervals.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The *interval*.**offset** method takes a *value* and returns the corresponding v

```js
Plot.utcInterval("day").offset(new Date("2013-04-12T12:34:56Z"), 1) // 2013-04-13T12:34:56Z
Plot.utcInterval("day").offset(new Date("2013-04-12T12:34:56Z"), -2) // 2013-03-22T12:34:56Z
Plot.utcInterval("day").offset(new Date("2013-04-12T12:34:56Z"), -2) // 2013-04-10T12:34:56Z
```

The *interval*.**range** method returns an array of values representing every interval boundary greater than or equal to *start* (inclusive) and less than *stop* (exclusive). The first value in the returned array is the least boundary greater than or equal to *start*; subsequent values are offset by intervals and floored.
Expand Down
2 changes: 1 addition & 1 deletion docs/features/marks.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Plot.plot({
```
:::

Marks may also be a function which returns an SVG element, if you wish to insert arbitrary content. (Here we use [Hypertext Literal](https://github.com/observablehq/htl) to generate an SVG gradient.)
Marks may also be a function which returns an [SVG element](https://developer.mozilla.org/en-US/docs/Web/SVG/Element), if you wish to insert arbitrary content. (Here we use [Hypertext Literal](https://github.com/observablehq/htl) to generate an SVG gradient.)

:::plot defer https://observablehq.com/@observablehq/plot-gradient-bars
```js
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
"docs:build": "node --experimental-network-imports node_modules/vitepress/dist/node/cli.js build docs",
"docs:preview": "vitepress preview docs"
},
"_moduleAliases": {
"@observablehq/plot": "./src/index.js"
},
"sideEffects": [
"./src/index.js"
],
Expand All @@ -67,7 +64,6 @@
"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",
Expand Down
15 changes: 10 additions & 5 deletions src/facet.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@ export function facetGroups(data, {fx, fy}) {
}

export function facetTranslator(fx, fy, {marginTop, marginLeft}) {
return fx && fy
? ({x, y}) => `translate(${fx(x) - marginLeft},${fy(y) - marginTop})`
: fx
? ({x}) => `translate(${fx(x) - marginLeft},0)`
: ({y}) => `translate(0,${fy(y) - marginTop})`;
const x = fx ? ({x}) => fx(x) - marginLeft : () => 0;
const y = fy ? ({y}) => fy(y) - marginTop : () => 0;
return function (d) {
if (this.tagName === "svg") {
this.setAttribute("x", x(d));
this.setAttribute("y", y(d));
} else {
this.setAttribute("transform", `translate(${x(d)},${y(d)})`);
}
};
}

// Returns an index that for each facet lists all the elements present in other
Expand Down
3 changes: 2 additions & 1 deletion src/mark.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {Channel, ChannelDomainSort, ChannelValue, ChannelValues, ChannelValueSpec} from "./channel.js";
import type {Context} from "./context.js";
import type {Dimensions} from "./dimensions.js";
import type {PointerOptions} from "./interactions/pointer.js";
import type {TipOptions} from "./marks/tip.js";
import type {plot} from "./plot.js";
import type {ScaleFunctions} from "./scales.js";
Expand Down Expand Up @@ -288,7 +289,7 @@ export interface MarkOptions {
title?: ChannelValue;

/** Whether to generate a tooltip for this mark, and any tip options. */
tip?: boolean | TipPointer | (TipOptions & {pointer?: TipPointer});
tip?: boolean | TipPointer | (TipOptions & PointerOptions & {pointer?: TipPointer});

/**
* How to clip the mark; one of:
Expand Down
4 changes: 2 additions & 2 deletions src/marks/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,10 @@ export function inferTickFormat(scale, data, ticks, tickFormat, anchor) {
? inferTimeFormat(scale.type, data, anchor) ?? formatDefault
: scale.tickFormat
? scale.tickFormat(typeof ticks === "number" ? ticks : null, tickFormat)
: typeof tickFormat === "string" && scale.domain().length > 0
? (isTemporal(scale.domain()) ? utcFormat : format)(tickFormat)
: tickFormat === undefined
? formatDefault
: typeof tickFormat === "string"
? (isTemporal(scale.domain()) ? utcFormat : format)(tickFormat)
: constant(tickFormat);
}

Expand Down
Loading

0 comments on commit f3ab10e

Please sign in to comment.