Skip to content

API Index ​

Every function and method of Charming, by module.

Core ​

Flow ​

  • cm.flow - Returns a new root flow, whose only row is 0.
  • flow.renderer - Sets or returns the renderer of the root.
  • flow.data - Returns a new flow whose rows are the values of data.
  • flow.datum - Equivalent to flow.data([datum]).
  • flow.append - Appends a shape for each row of this flow and returns a new flow, under that shape, to nest more shapes in.
  • flow.add - Like flow.append, but returns this flow, so that siblings share its rows and channels, such as the marks of a chart.
  • flow.transform - Records transform with params and returns a new flow.
  • flow.branch - Builds a pipeline for each of branches and joins them, such as layers sharing the scales of cm.plane.
  • flow.call - Calls callback with this flow and params, and returns this flow, to reuse a piece of a flow in a chain.
  • flow.pipe - Like flow.call, but returns what callback returns, such as the flow it built, so the chain continues from it.
  • flow.render - Runs the steps of the root and draws the tree with the renderer.
  • flow.clear - Drops what the root has built, so the next render draws only what's built after it.
  • flow.finished - Returns a promise that resolves when the transition of the last render ends.

Transforms ​

  • cm.bind - Binds channels to the rows of each group.
  • cm.scale - Maps bound channels with scales.
  • cm.fit - Maps the positions to the size of the renderer.

Shapes ​

  • cm.circle - Draws circles.
  • cm.rect - Draws rectangles.
  • cm.link - Draws straight lines from (x, y) to (x1, y1).
  • cm.line - Draws one line through the points (x, y) of the rows of each group.
  • cm.triangle - Draws triangles through (x, y), (x1, y1) and (x2, y2).
  • cm.polygon - Draws polygons.
  • cm.path - Draws paths.
  • cm.point - Draws dots, 1 pixel in radius.
  • cm.text - Draws texts.
  • cm.g - Groups the shapes appended to it, translated and rotated.
  • cm.clear - Fills the whole renderer with fill, such as the background of a frame.

Transitions ​

  • cm.keyframe - A shape whose rows are moments, played one after another rather than drawn at once.

Signals ​

Extensions ​

  • cm.primitive - Returns a shape drawn by the renderer itself.
  • cm.shape - Returns a shape made of other shapes.
  • cm.mark - Returns a mark, a shape that receives its options as they are rather than per row, such as a whole chart.

Vis ​

Encode ​

  • cm.encode - Binds channels to the rows, like cm.bind, and records how each is scaled.

Data Transforms ​

  • cm.groupX - Groups the rows by x and turns each group into one row.
  • cm.groupY - Like cm.groupX, but groups by y, with outputs {x: "count"} by default.
  • cm.group - Like cm.groupX, but groups by x and y, with outputs {fill: "count"} by default, such as the cells of a heatmap.
  • cm.binX - Bins the rows on x.
  • cm.binY - Like cm.binX, but bins on y, with outputs {x: "count"} by default.
  • cm.bin - Like cm.binX, but bins on x and y, with outputs {fill: "count"} by default, such as the cells of a binned heatmap.
  • cm.stackY - Stacks y per x, from y1 to y, such as stacked columns or areas.
  • cm.stackX - Like cm.stackY, but stacks x per y, from x1 to x, such as stacked bars or a pie in cm.polar.
  • cm.stackEnter - Stacks the entrances of the rows along time, like G2's stackEnter.
  • cm.stackExit - Like cm.stackEnter, but for exits, with exitDuration.
  • cm.spreadX - Places each category of x in a band, from x to x1, like a d3 band scale, such as the columns of a bar chart.
  • cm.spreadY - Like cm.spreadX, for the categories of y, such as the bars of a horizontal bar chart.
  • cm.unitY - Turns the rows into one row per unit, such as the squares of a waffle.
  • cm.unitX - Like cm.unitY, along x, grouped by y.
  • cm.fold - Folds fields of each row into rows of their own, like Vega-Lite's fold.
  • cm.pack - Packs the rows of each group into a grid of square cells, like G2's pack.

Coordinates ​

  • cm.plane - Maps x and x1 to the frame from left to right, and y and y1 from bottom to top, like Observable Plot.
  • cm.polar - Maps x to angles and y to radii, like d3.arc.

Marks ​

  • cm.lineY - Draws one line per series along x, such as a time series.
  • cm.lineX - Like cm.lineY, along y at x, such as a vertical line.
  • cm.lineRadial - The line of cm.polar: x is the angle and y the radius.
  • cm.areaY - Draws one area per series along x, from y1 to y, such as the layers of a stacked area chart after cm.stackY.
  • cm.areaX - Like cm.areaY, along y from x1 to x, such as the halves of a population pyramid.
  • cm.areaRadial - The area of cm.polar: x is the angle, y the outer radius and y1 the inner radius.
  • cm.arc - Draws the wedges of cm.polar with d3.arc, such as the slices of a pie or the petals of a rose.
  • cm.label - Draws a text in or around the box of each row, like G2's labels.
  • cm.annotate - Turns a shape into an annotation, drawn in data units, such as a rule at a value.

Guides ​

  • cm.axisX - Draws the axis of x: tick marks, tick labels and title.
  • cm.axisY - Like cm.axisX, for y: on the left by default, or "right".
  • cm.axis - Draws both axes.
  • cm.legend - Draws the legends of the colors, radii and opacities of the chart.
  • cm.tip - Draws a box describing each row, pointing at it, like Plot's tip.

Interaction ​

  • cm.selection - Returns a new, empty selection: the rows chosen by its sources, one clause per source.
  • selection.test - Returns whether the selection chooses a row.
  • selection.match - Returns a channel: selected for the rows chosen, else other.
  • selection.set - Sets or removes the clause of a source.
  • cm.nearestX - Selects the row nearest the pointer along x, like Plot's pointerX.
  • cm.nearestY - Like cm.nearestX, along y then x.
  • cm.nearest - Like cm.nearestX, by distance in both directions.
  • cm.toggle - Selects the rows clicked, adding more with shift.
  • cm.brushX - Selects by dragging along x.
  • cm.brushY - Like cm.brushX, along y; its by is "x".
  • cm.brush - Like cm.brushX, along x and y, with select "rows" by default.

Modifiers ​

  • cm.inset - Shrinks the box of a mark by k on each side, like Plot's inset.
  • cm.insetX - Like cm.inset, on the left and right only, such as the bars of a histogram.
  • cm.insetY - Like cm.inset, on the top and bottom only, such as the bars of a horizontal histogram.

Renderers ​

SVG ​

  • cm.svg - Returns a renderer that draws into an SVG element.
  • renderer.node - Returns the element drawn into, to add to the page.

Canvas ​

  • cm.canvas - Returns a renderer that draws into a canvas element.

Terminal ​

  • cm.terminal - Returns a renderer that draws a terminal.