cell.d.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import type {ChannelValueSpec} from "../channel.js";
  2. import type {InsetOptions} from "../inset.js";
  3. import type {Data, MarkOptions, RenderableMark} from "../mark.js";
  4. import type {RectCornerOptions} from "./rect.js";
  5. /** Options for the cell mark. */
  6. export interface CellOptions extends MarkOptions, InsetOptions, RectCornerOptions {
  7. /**
  8. * The horizontal position of the cell; an optional ordinal channel typically
  9. * bound to the *x* scale. If not specified, the cell spans the horizontal
  10. * extent of the frame; otherwise the *x* scale must be a *band* scale.
  11. *
  12. * If *x* represents quantitative or temporal values, use a barX mark instead;
  13. * if *y* is also quantitative or temporal, use a rect mark.
  14. */
  15. x?: ChannelValueSpec;
  16. /**
  17. * The vertical position of the cell; an optional ordinal channel typically
  18. * bound to the *y* scale. If not specified, the cell spans the vertical
  19. * extent of the frame; otherwise the *y* scale must be a *band* scale.
  20. *
  21. * If *y* represents quantitative or temporal values, use a barY mark instead;
  22. * if *x* is also quantitative or temporal, use a rect mark.
  23. */
  24. y?: ChannelValueSpec;
  25. }
  26. /**
  27. * Returns a rectangular cell mark for the given *data* and *options*. Along
  28. * with **x** and/or **y**, a **fill** channel is typically specified to encode
  29. * value as color. For example, for a heatmap of the IMDb ratings of Simpons
  30. * episodes by season:
  31. *
  32. * ```js
  33. * Plot.cell(simpsons, {x: "number_in_season", y: "season", fill: "imdb_rating"})
  34. * ```
  35. *
  36. * If neither **x** nor **y** are specified, *data* is assumed to be an array of
  37. * pairs [[*x₀*, *y₀*], [*x₁*, *y₁*], [*x₂*, *y₂*], …] such that **x** = [*x₀*,
  38. * *x₁*, *x₂*, …] and **y** = [*y₀*, *y₁*, *y₂*, …].
  39. *
  40. * Both **x** and **y** should be ordinal; if only **x** is quantitative (or
  41. * temporal), use a barX mark; if only **y** is quantitative, use a barY mark;
  42. * if both are quantitative, use a rect mark.
  43. */
  44. export function cell(data?: Data, options?: CellOptions): Cell;
  45. /**
  46. * Like cell, but **x** defaults to the zero-based index [0, 1, 2, …], and if
  47. * **stroke** is not a channel, **fill** defaults to the identity function,
  48. * assuming that *data* = [*x₀*, *x₁*, *x₂*, …]. For a quick horizontal stripe
  49. * map visualizating an array of numbers:
  50. *
  51. * ```js
  52. * Plot.cellX(values)
  53. * ```
  54. */
  55. export function cellX(data?: Data, options?: CellOptions): Cell;
  56. /**
  57. * Like cell, but **y** defaults to the zero-based index [0, 1, 2, …], and if
  58. * **stroke** is not a channel, **fill** defaults to the identity function,
  59. * assuming that *data* = [*y₀*, *y₁*, *y₂*, …]. For a quick vertical stripe map
  60. * visualizating an array of numbers:
  61. *
  62. * ```js
  63. * Plot.cellY(values)
  64. * ```
  65. */
  66. export function cellY(data?: Data, options?: CellOptions): Cell;
  67. /** The cell mark. */
  68. export class Cell extends RenderableMark {}