Skip to content
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
3 changes: 3 additions & 0 deletions src/context.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export interface Context {
*/
document: Document;

/** The Plot’s (typically generated) class name, for custom styles. */
className: string;

/** The current projection, if any. */
projection?: GeoStreamWrapper;
}
4 changes: 2 additions & 2 deletions src/context.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {creator, select} from "d3";
import {createProjection} from "./projection.js";

export function createContext(options = {}, dimensions) {
export function createContext(options = {}, dimensions, className) {
const {document = typeof window !== "undefined" ? window.document : undefined} = options;
return {document, projection: createProjection(options, dimensions)};
return {document, className, projection: createProjection(options, dimensions)};
}

export function create(name, {document}) {
Expand Down
4 changes: 2 additions & 2 deletions src/legends.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export function exposeLegends(scales, context, defaults = {}) {
};
}

function legendOptions(context, {label, ticks, tickFormat} = {}, options) {
return inherit(options, context, {label, ticks, tickFormat});
function legendOptions({className, ...context}, {label, ticks, tickFormat} = {}, options) {
return inherit(options, {className: `${className}-legend`, ...context}, {label, ticks, tickFormat});
}

function legendColor(color, {legend = true, ...options}) {
Expand Down
2 changes: 1 addition & 1 deletion src/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function plot(options = {}) {
const {fx, fy} = scales;
const subdimensions = fx || fy ? innerDimensions(scaleDescriptors, dimensions) : dimensions;
const superdimensions = fx || fy ? actualDimensions(scales, dimensions) : dimensions;
const context = createContext(options, subdimensions, scaleDescriptors);
const context = createContext(options, subdimensions, className);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

className replaces the spurious argument scaleDescriptors in the call to createContext—this was introduced by #1197, and was ignored in the function's signature.


// Reinitialize; for deriving channels dependent on other channels.
const newByScale = new Set();
Expand Down