Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/marks/tip.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {Data, FrameAnchor, MarkOptions, RenderableMark} from "../mark.js";
import type {TextStyles} from "./text.js";

/** Options for the tip mark. */
export interface TipOptions extends MarkOptions, TextStyles {
export interface TipOptions extends Omit<MarkOptions, "tip">, TextStyles {
/**
* The horizontal position channel specifying the tip’s anchor, typically
* bound to the *x* scale.
Expand Down
17 changes: 17 additions & 0 deletions test/options.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {it} from "vitest";
import {valueof} from "../src/options.js";
import * as Plot from "../src/index.js";

it("a function is not a valid input data", () => {
// @ts-expect-error
Expand All @@ -22,3 +23,19 @@ it("a bigint is not a valid value", () => {
// @ts-expect-error
valueof(null, 2n);
});

it("tip options do not allow nested tips", () => {
// @ts-expect-error tips cannot create another tip
Plot.dot([1, 2], {tip: {tip: {}}});
// @ts-expect-error the tip mark ignores its own tip option
Plot.tip([1, 2], {tip: true});
// @ts-expect-error the Tip constructor has the same options as the factory
new Plot.Tip([1, 2], {tip: {}});
});

it("tip options retain shared mark and text styling", () => {
Plot.dot([1, 2], {tip: {anchor: "top", fill: "white", fontSize: 14, textPadding: 4}});
Plot.dot([1, 2], {tip: true});
Plot.tip([1, 2], {anchor: "top", fill: "white", fontSize: 14, textPadding: 4});
new Plot.Tip([1, 2], {frameAnchor: "top", format: ".1f"});
});