Attribute
Defining Attributes for shapes.
cm.rgb(r[, g[, b]])
Returns a string representing the RGB color according to the [CSS Object Model specification](CSS Object Model specification).
cm.rgb(234, 260, 180); // 'rgb(234, 260, 180)'
If only on argument is specified, sets all channels to the same value.
cm.rgb(100); // 'rgb(100, 100, 100)'
cm.hsl(h[, s[, l]])
Returns a string representing the HSL color according to the [CSS Object Model specification](CSS Object Model specification).
cm.hsl(234, 50, 50); // 'hsl(234, 50%, 50%)'
cm.constant(value)
Defines a attribute with the specified constant value, which is useful for defining some non-data-driven options for composite shape.
app.data(["A", "B", "C"]).append(bar, {
x: (d) => d,
y: (_, i) => i,
axis: cm.constant(false),
colors: cm.constant(["yellow", "red"]),
});
function bar(
flow,
{
x, // ["A", "B", "C"]
y, // [0, 1, 2]
axis, // false
colors, // ["yellow", "red"]
},
) {
// ...
}