-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
groups respect the domain option fixes #255
- Loading branch information
Showing
2 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as Plot from "@observablehq/plot"; | ||
import tape from "tape-await"; | ||
|
||
tape("groupX respects the domain option (#255)", test => { | ||
const data = ["A", "A", "C"]; | ||
const options = {x: d => d, domain: ["C", "B", "A"]}; | ||
const mark = Plot.dot(data, Plot.groupX(options)); | ||
const A = mark.initialize(); | ||
test.deepEqual(A.index, [0, 1, 2]); | ||
test.deepEqual(A.channels.find(d => d[0] === "x")[1].value, ["C", "B", "A"]); | ||
test.deepEqual(A.channels.find(d => d[0] === "y")[1].value, [1, 0, 2]); | ||
}); | ||
|
||
tape("groupY respects the domain option (#255)", test => { | ||
const data = ["A", "A", "C"]; | ||
const options = {x: d => d, domain: ["C", "B", "A"]}; | ||
const mark = Plot.dot(data, Plot.groupY(options)); | ||
const A = mark.initialize(); | ||
test.deepEqual(A.index, [0, 1, 2]); | ||
test.deepEqual(A.channels.find(d => d[0] === "y")[1].value, ["C", "B", "A"]); | ||
test.deepEqual(A.channels.find(d => d[0] === "x")[1].value, [1, 0, 2]); | ||
}); | ||
|
||
tape("group respects the domain option (#255)", test => { | ||
const data = ["A", "A", "C", "A", "C"]; | ||
const options = {x: d => d, y: d => d, domain: ["C", "B", "A"]}; | ||
const mark = Plot.dot(data, Plot.group(options)); | ||
const A = mark.initialize(); | ||
test.deepEqual(A.index, [0, 1, 2, 3, 4, 5, 6, 7, 8]); | ||
test.deepEqual(A.channels.find(d => d[0] === "fill")[1].value, [ | ||
//C, B, A | ||
2, 0, 0, // C | ||
0, 0, 0, // B | ||
0, 0, 3 // A | ||
]); | ||
}); |