From b60a66fb0446be8688d0c6f1a43a30914f5e41ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Tue, 19 Apr 2022 09:52:09 +0200 Subject: [PATCH 1/2] shorthand areaY closes #850 --- src/transforms/bin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transforms/bin.js b/src/transforms/bin.js index db0eb485ae..6691dff201 100644 --- a/src/transforms/bin.js +++ b/src/transforms/bin.js @@ -27,7 +27,7 @@ export function bin(outputs = {fill: "count"}, options = {}) { return binn(x, y, null, null, outputs, maybeInsetX(maybeInsetY(options))); } -function maybeDenseInterval(bin, k, options) { +function maybeDenseInterval(bin, k, options = {}) { return options?.interval == null ? options : bin({[k]: options?.reduce === undefined ? reduceFirst : options.reduce, filter: null}, options); } From 3eeb42b71adde1af6132ab48713df35fdc0d2b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Tue, 19 Apr 2022 09:52:19 +0200 Subject: [PATCH 2/2] all shorthand tests --- test/output/shorthandArea.svg | 74 ++++++++++ test/output/shorthandAreaY.svg | 74 ++++++++++ test/output/shorthandBarY.svg | 209 +++++++++++++++++++++++++++++ test/output/shorthandBinRectY.svg | 88 ++++++++++++ test/output/shorthandBoxX.svg | 43 ++++++ test/output/shorthandCell.svg | 77 +++++++++++ test/output/shorthandCellX.svg | 180 +++++++++++++++++++++++++ test/output/shorthandDot.svg | 122 +++++++++++++++++ test/output/shorthandDotX.svg | 75 +++++++++++ test/output/shorthandGroupBarY.svg | 62 +++++++++ test/output/shorthandLine.svg | 83 ++++++++++++ test/output/shorthandLineY.svg | 83 ++++++++++++ test/output/shorthandRectY.svg | 116 ++++++++++++++++ test/output/shorthandRuleX.svg | 75 +++++++++++ test/output/shorthandText.svg | 81 +++++++++++ test/output/shorthandTextX.svg | 34 +++++ test/output/shorthandTickX.svg | 75 +++++++++++ test/output/shorthandVector.svg | 122 +++++++++++++++++ test/output/shorthandVectorX.svg | 75 +++++++++++ test/plots/index.js | 19 +++ test/plots/shorthand-area.js | 47 +++++++ test/plots/shorthand-areaY.js | 11 ++ test/plots/shorthand-barY.js | 11 ++ test/plots/shorthand-binRectY.js | 11 ++ test/plots/shorthand-boxX.js | 11 ++ test/plots/shorthand-cell.js | 20 +++ test/plots/shorthand-cellX.js | 11 ++ test/plots/shorthand-dot.js | 47 +++++++ test/plots/shorthand-dotX.js | 11 ++ test/plots/shorthand-groupBarY.js | 6 + test/plots/shorthand-line.js | 47 +++++++ test/plots/shorthand-lineY.js | 11 ++ test/plots/shorthand-rectY.js | 11 ++ test/plots/shorthand-ruleX.js | 11 ++ test/plots/shorthand-text.js | 47 +++++++ test/plots/shorthand-textX.js | 11 ++ test/plots/shorthand-tickX.js | 11 ++ test/plots/shorthand-vector.js | 47 +++++++ test/plots/shorthand-vectorX.js | 11 ++ 39 files changed, 2160 insertions(+) create mode 100644 test/output/shorthandArea.svg create mode 100644 test/output/shorthandAreaY.svg create mode 100644 test/output/shorthandBarY.svg create mode 100644 test/output/shorthandBinRectY.svg create mode 100644 test/output/shorthandBoxX.svg create mode 100644 test/output/shorthandCell.svg create mode 100644 test/output/shorthandCellX.svg create mode 100644 test/output/shorthandDot.svg create mode 100644 test/output/shorthandDotX.svg create mode 100644 test/output/shorthandGroupBarY.svg create mode 100644 test/output/shorthandLine.svg create mode 100644 test/output/shorthandLineY.svg create mode 100644 test/output/shorthandRectY.svg create mode 100644 test/output/shorthandRuleX.svg create mode 100644 test/output/shorthandText.svg create mode 100644 test/output/shorthandTextX.svg create mode 100644 test/output/shorthandTickX.svg create mode 100644 test/output/shorthandVector.svg create mode 100644 test/output/shorthandVectorX.svg create mode 100644 test/plots/shorthand-area.js create mode 100644 test/plots/shorthand-areaY.js create mode 100644 test/plots/shorthand-barY.js create mode 100644 test/plots/shorthand-binRectY.js create mode 100644 test/plots/shorthand-boxX.js create mode 100644 test/plots/shorthand-cell.js create mode 100644 test/plots/shorthand-cellX.js create mode 100644 test/plots/shorthand-dot.js create mode 100644 test/plots/shorthand-dotX.js create mode 100644 test/plots/shorthand-groupBarY.js create mode 100644 test/plots/shorthand-line.js create mode 100644 test/plots/shorthand-lineY.js create mode 100644 test/plots/shorthand-rectY.js create mode 100644 test/plots/shorthand-ruleX.js create mode 100644 test/plots/shorthand-text.js create mode 100644 test/plots/shorthand-textX.js create mode 100644 test/plots/shorthand-tickX.js create mode 100644 test/plots/shorthand-vector.js create mode 100644 test/plots/shorthand-vectorX.js diff --git a/test/output/shorthandArea.svg b/test/output/shorthandArea.svg new file mode 100644 index 0000000000..df900b135a --- /dev/null +++ b/test/output/shorthandArea.svg @@ -0,0 +1,74 @@ + + + + + 0 + + + 20 + + + 40 + + + 60 + + + 80 + + + 100 + + + 120 + + + 140 + + + 160 + + + + + Jan 07 + + + Jan 14 + + + Jan 21 + + + Jan 28 + + + Feb 04 + + + Feb 11 + + + Feb 18 + + + Feb 25 + + + + + + \ No newline at end of file diff --git a/test/output/shorthandAreaY.svg b/test/output/shorthandAreaY.svg new file mode 100644 index 0000000000..3a9d7705d6 --- /dev/null +++ b/test/output/shorthandAreaY.svg @@ -0,0 +1,74 @@ + + + + + 0 + + + 20 + + + 40 + + + 60 + + + 80 + + + 100 + + + 120 + + + 140 + + + 160 + + + + + 0 + + + 5 + + + 10 + + + 15 + + + 20 + + + 25 + + + 30 + + + 35 + + + + + + \ No newline at end of file diff --git a/test/output/shorthandBarY.svg b/test/output/shorthandBarY.svg new file mode 100644 index 0000000000..107b61b2df --- /dev/null +++ b/test/output/shorthandBarY.svg @@ -0,0 +1,209 @@ + + + + + 0 + + + 20 + + + 40 + + + 60 + + + 80 + + + 100 + + + 120 + + + 140 + + + 160 + + + + + 0 + + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + + + 7 + + + 8 + + + 9 + + + 10 + + + 11 + + + 12 + + + 13 + + + 14 + + + 15 + + + 16 + + + 17 + + + 18 + + + 19 + + + 20 + + + 21 + + + 22 + + + 23 + + + 24 + + + 25 + + + 26 + + + 27 + + + 28 + + + 29 + + + 30 + + + 31 + + + 32 + + + 33 + + + 34 + + + 35 + + + 36 + + + 37 + + + 38 + + + 39 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandBinRectY.svg b/test/output/shorthandBinRectY.svg new file mode 100644 index 0000000000..aebb721be0 --- /dev/null +++ b/test/output/shorthandBinRectY.svg @@ -0,0 +1,88 @@ + + + + + 0 + + + 2 + + + 4 + + + 6 + + + 8 + + + 10 + + + 12 + + + 14 + + + 16 + + + 18 + + + 20 + + + 22 + + + 24 + + + 26 + ↑ Frequency + + + + 150 + + + 155 + + + 160 + + + 165 + + + 170 + + + 175 + + + 180 + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandBoxX.svg b/test/output/shorthandBoxX.svg new file mode 100644 index 0000000000..c2ac673da5 --- /dev/null +++ b/test/output/shorthandBoxX.svg @@ -0,0 +1,43 @@ + + + + + 155 + + + 160 + + + 165 + + + 170 + + + 175 + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandCell.svg b/test/output/shorthandCell.svg new file mode 100644 index 0000000000..4721f7de92 --- /dev/null +++ b/test/output/shorthandCell.svg @@ -0,0 +1,77 @@ + + + + + Ava + + + Emma + + + Jacob + + + Mason + + + Mia + + + Noah + + + Olivia + + + + + Ava + + + Emma + + + Jacob + + + Mason + + + Mia + + + Noah + + + Olivia + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandCellX.svg b/test/output/shorthandCellX.svg new file mode 100644 index 0000000000..e59faec337 --- /dev/null +++ b/test/output/shorthandCellX.svg @@ -0,0 +1,180 @@ + + + + + 0 + + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + + + 7 + + + 8 + + + 9 + + + 10 + + + 11 + + + 12 + + + 13 + + + 14 + + + 15 + + + 16 + + + 17 + + + 18 + + + 19 + + + 20 + + + 21 + + + 22 + + + 23 + + + 24 + + + 25 + + + 26 + + + 27 + + + 28 + + + 29 + + + 30 + + + 31 + + + 32 + + + 33 + + + 34 + + + 35 + + + 36 + + + 37 + + + 38 + + + 39 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandDot.svg b/test/output/shorthandDot.svg new file mode 100644 index 0000000000..540bd30a92 --- /dev/null +++ b/test/output/shorthandDot.svg @@ -0,0 +1,122 @@ + + + + + 156 + + + 158 + + + 160 + + + 162 + + + 164 + + + 166 + + + 168 + + + 170 + + + 172 + + + 174 + + + 176 + + + 178 + + + + + Jan 07 + + + Jan 14 + + + Jan 21 + + + Jan 28 + + + Feb 04 + + + Feb 11 + + + Feb 18 + + + Feb 25 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandDotX.svg b/test/output/shorthandDotX.svg new file mode 100644 index 0000000000..c0c381f7c8 --- /dev/null +++ b/test/output/shorthandDotX.svg @@ -0,0 +1,75 @@ + + + + + 155 + + + 160 + + + 165 + + + 170 + + + 175 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandGroupBarY.svg b/test/output/shorthandGroupBarY.svg new file mode 100644 index 0000000000..eb0b9d5a3b --- /dev/null +++ b/test/output/shorthandGroupBarY.svg @@ -0,0 +1,62 @@ + + + + + 0 + + + 5 + + + 10 + + + 15 + + + 20 + + + 25 + + + 30 + + + 35 + ↑ Frequency + + + + A + + + C + + + G + + + T + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandLine.svg b/test/output/shorthandLine.svg new file mode 100644 index 0000000000..e26914f283 --- /dev/null +++ b/test/output/shorthandLine.svg @@ -0,0 +1,83 @@ + + + + + 156 + + + 158 + + + 160 + + + 162 + + + 164 + + + 166 + + + 168 + + + 170 + + + 172 + + + 174 + + + 176 + + + 178 + + + + + Jan 07 + + + Jan 14 + + + Jan 21 + + + Jan 28 + + + Feb 04 + + + Feb 11 + + + Feb 18 + + + Feb 25 + + + + + + \ No newline at end of file diff --git a/test/output/shorthandLineY.svg b/test/output/shorthandLineY.svg new file mode 100644 index 0000000000..6ed32217c2 --- /dev/null +++ b/test/output/shorthandLineY.svg @@ -0,0 +1,83 @@ + + + + + 156 + + + 158 + + + 160 + + + 162 + + + 164 + + + 166 + + + 168 + + + 170 + + + 172 + + + 174 + + + 176 + + + 178 + + + + + 0 + + + 5 + + + 10 + + + 15 + + + 20 + + + 25 + + + 30 + + + 35 + + + + + + \ No newline at end of file diff --git a/test/output/shorthandRectY.svg b/test/output/shorthandRectY.svg new file mode 100644 index 0000000000..0a9be353d5 --- /dev/null +++ b/test/output/shorthandRectY.svg @@ -0,0 +1,116 @@ + + + + + 0 + + + 20 + + + 40 + + + 60 + + + 80 + + + 100 + + + 120 + + + 140 + + + 160 + + + + + 0 + + + 5 + + + 10 + + + 15 + + + 20 + + + 25 + + + 30 + + + 35 + + + 40 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandRuleX.svg b/test/output/shorthandRuleX.svg new file mode 100644 index 0000000000..5313fac52f --- /dev/null +++ b/test/output/shorthandRuleX.svg @@ -0,0 +1,75 @@ + + + + + 155 + + + 160 + + + 165 + + + 170 + + + 175 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandText.svg b/test/output/shorthandText.svg new file mode 100644 index 0000000000..297548d1fc --- /dev/null +++ b/test/output/shorthandText.svg @@ -0,0 +1,81 @@ + + + + + 156 + + + 158 + + + 160 + + + 162 + + + 164 + + + 166 + + + 168 + + + 170 + + + 172 + + + 174 + + + 176 + + + 178 + + + + + Jan 07 + + + Jan 14 + + + Jan 21 + + + Jan 28 + + + Feb 04 + + + Feb 11 + + + Feb 18 + + + Feb 25 + + + 0123456789101112131415161718192021222324252627282930313233343536373839 + \ No newline at end of file diff --git a/test/output/shorthandTextX.svg b/test/output/shorthandTextX.svg new file mode 100644 index 0000000000..1b4a802332 --- /dev/null +++ b/test/output/shorthandTextX.svg @@ -0,0 +1,34 @@ + + + + + 155 + + + 160 + + + 165 + + + 170 + + + 175 + + + 170.16172.53172.54173.44174.35174.55173.16174.59176.18177.9176.15179.37178.61177.3177.3177.25174.51172170.16165.53166.87167.17166159.1154.83163.09160.29157.07158.5161.95163.04169.79172.36172.05172.83171.8173.67176.35179.1179.26 + \ No newline at end of file diff --git a/test/output/shorthandTickX.svg b/test/output/shorthandTickX.svg new file mode 100644 index 0000000000..bad4c4b32a --- /dev/null +++ b/test/output/shorthandTickX.svg @@ -0,0 +1,75 @@ + + + + + 155 + + + 160 + + + 165 + + + 170 + + + 175 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandVector.svg b/test/output/shorthandVector.svg new file mode 100644 index 0000000000..cdda4f9eab --- /dev/null +++ b/test/output/shorthandVector.svg @@ -0,0 +1,122 @@ + + + + + 156 + + + 158 + + + 160 + + + 162 + + + 164 + + + 166 + + + 168 + + + 170 + + + 172 + + + 174 + + + 176 + + + 178 + + + + + Jan 07 + + + Jan 14 + + + Jan 21 + + + Jan 28 + + + Feb 04 + + + Feb 11 + + + Feb 18 + + + Feb 25 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/shorthandVectorX.svg b/test/output/shorthandVectorX.svg new file mode 100644 index 0000000000..dc281fd9e1 --- /dev/null +++ b/test/output/shorthandVectorX.svg @@ -0,0 +1,75 @@ + + + + + 155 + + + 160 + + + 165 + + + 170 + + + 175 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plots/index.js b/test/plots/index.js index 47d0089d9a..693cd10825 100644 --- a/test/plots/index.js +++ b/test/plots/index.js @@ -133,6 +133,25 @@ export {default as seattleTemperatureCell} from "./seattle-temperature-cell.js"; export {default as sfCovidDeaths} from "./sf-covid-deaths.js"; export {default as sfTemperatureBand} from "./sf-temperature-band.js"; export {default as sfTemperatureBandArea} from "./sf-temperature-band-area.js"; +export {default as shorthandArea} from "./shorthand-area.js"; +export {default as shorthandAreaY} from "./shorthand-areaY.js"; +export {default as shorthandBarY} from "./shorthand-barY.js"; +export {default as shorthandBinRectY} from "./shorthand-binRectY.js"; +export {default as shorthandBoxX} from "./shorthand-boxX.js"; +export {default as shorthandCell} from "./shorthand-cell.js"; +export {default as shorthandCellX} from "./shorthand-cellX.js"; +export {default as shorthandDot} from "./shorthand-dot.js"; +export {default as shorthandDotX} from "./shorthand-dotX.js"; +export {default as shorthandGroupBarY} from "./shorthand-groupBarY.js"; +export {default as shorthandLine} from "./shorthand-line.js"; +export {default as shorthandLineY} from "./shorthand-lineY.js"; +export {default as shorthandRectY} from "./shorthand-rectY.js"; +export {default as shorthandRuleX} from "./shorthand-ruleX.js"; +export {default as shorthandText} from "./shorthand-text.js"; +export {default as shorthandTextX} from "./shorthand-textX.js"; +export {default as shorthandTickX} from "./shorthand-tickX.js"; +export {default as shorthandVector} from "./shorthand-vector.js"; +export {default as shorthandVectorX} from "./shorthand-vectorX.js"; export {default as simpsonsRatings} from "./simpsons-ratings.js"; export {default as simpsonsRatingsDots} from "./simpsons-ratings-dots.js"; export {default as simpsonsViews} from "./simpsons-views.js"; diff --git a/test/plots/shorthand-area.js b/test/plots/shorthand-area.js new file mode 100644 index 0000000000..a54245eaec --- /dev/null +++ b/test/plots/shorthand-area.js @@ -0,0 +1,47 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const timeSeries = [ + [new Date("2018-01-02"), 170.160004], + [new Date("2018-01-03"), 172.529999], + [new Date("2018-01-04"), 172.539993], + [new Date("2018-01-05"), 173.440002], + [new Date("2018-01-08"), 174.350006], + [new Date("2018-01-09"), 174.550003], + [new Date("2018-01-10"), 173.160004], + [new Date("2018-01-11"), 174.589996], + [new Date("2018-01-12"), 176.179993], + [new Date("2018-01-16"), 177.899994], + [new Date("2018-01-17"), 176.149994], + [new Date("2018-01-18"), 179.369995], + [new Date("2018-01-19"), 178.610001], + [new Date("2018-01-22"), 177.300003], + [new Date("2018-01-23"), 177.300003], + [new Date("2018-01-24"), 177.250000], + [new Date("2018-01-25"), 174.509995], + [new Date("2018-01-26"), 172.000000], + [new Date("2018-01-29"), 170.160004], + [new Date("2018-01-30"), 165.529999], + [new Date("2018-01-31"), 166.869995], + [new Date("2018-02-01"), 167.169998], + [new Date("2018-02-02"), 166.000000], + [new Date("2018-02-05"), 159.100006], + [new Date("2018-02-06"), 154.830002], + [new Date("2018-02-07"), 163.089996], + [new Date("2018-02-08"), 160.289993], + [new Date("2018-02-09"), 157.070007], + [new Date("2018-02-12"), 158.500000], + [new Date("2018-02-13"), 161.949997], + [new Date("2018-02-14"), 163.039993], + [new Date("2018-02-15"), 169.789993], + [new Date("2018-02-16"), 172.360001], + [new Date("2018-02-20"), 172.050003], + [new Date("2018-02-21"), 172.830002], + [new Date("2018-02-22"), 171.800003], + [new Date("2018-02-23"), 173.669998], + [new Date("2018-02-26"), 176.350006], + [new Date("2018-02-27"), 179.100006], + [new Date("2018-02-28"), 179.259995] + ]; + return Plot.area(timeSeries).plot(); +} diff --git a/test/plots/shorthand-areaY.js b/test/plots/shorthand-areaY.js new file mode 100644 index 0000000000..b5bd7e55e8 --- /dev/null +++ b/test/plots/shorthand-areaY.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.areaY(numbers).plot(); +} diff --git a/test/plots/shorthand-barY.js b/test/plots/shorthand-barY.js new file mode 100644 index 0000000000..7edfa5e4d1 --- /dev/null +++ b/test/plots/shorthand-barY.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.barY(numbers).plot(); +} diff --git a/test/plots/shorthand-binRectY.js b/test/plots/shorthand-binRectY.js new file mode 100644 index 0000000000..5ea3e87bb8 --- /dev/null +++ b/test/plots/shorthand-binRectY.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.rectY(numbers, Plot.binX()).plot(); +} diff --git a/test/plots/shorthand-boxX.js b/test/plots/shorthand-boxX.js new file mode 100644 index 0000000000..4e7d90d3bd --- /dev/null +++ b/test/plots/shorthand-boxX.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.boxX(numbers).plot(); +} diff --git a/test/plots/shorthand-cell.js b/test/plots/shorthand-cell.js new file mode 100644 index 0000000000..a88a0d8555 --- /dev/null +++ b/test/plots/shorthand-cell.js @@ -0,0 +1,20 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const matrix = [ + ["Jacob", "Olivia"], + ["Mia", "Noah"], + ["Noah", "Ava"], + ["Ava", "Mason"], + ["Olivia", "Noah"], + ["Jacob", "Emma"], + ["Ava", "Noah"], + ["Noah", "Jacob"], + ["Olivia", "Ava"], + ["Mason", "Emma"], + ["Jacob", "Mia"], + ["Mia", "Jacob"], + ["Emma", "Jacob"] + ]; + return Plot.cell(matrix).plot(); +} diff --git a/test/plots/shorthand-cellX.js b/test/plots/shorthand-cellX.js new file mode 100644 index 0000000000..983a1cc1c2 --- /dev/null +++ b/test/plots/shorthand-cellX.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.cellX(numbers).plot(); +} diff --git a/test/plots/shorthand-dot.js b/test/plots/shorthand-dot.js new file mode 100644 index 0000000000..0dca393818 --- /dev/null +++ b/test/plots/shorthand-dot.js @@ -0,0 +1,47 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const timeSeries = [ + [new Date("2018-01-02"), 170.160004], + [new Date("2018-01-03"), 172.529999], + [new Date("2018-01-04"), 172.539993], + [new Date("2018-01-05"), 173.440002], + [new Date("2018-01-08"), 174.350006], + [new Date("2018-01-09"), 174.550003], + [new Date("2018-01-10"), 173.160004], + [new Date("2018-01-11"), 174.589996], + [new Date("2018-01-12"), 176.179993], + [new Date("2018-01-16"), 177.899994], + [new Date("2018-01-17"), 176.149994], + [new Date("2018-01-18"), 179.369995], + [new Date("2018-01-19"), 178.610001], + [new Date("2018-01-22"), 177.300003], + [new Date("2018-01-23"), 177.300003], + [new Date("2018-01-24"), 177.250000], + [new Date("2018-01-25"), 174.509995], + [new Date("2018-01-26"), 172.000000], + [new Date("2018-01-29"), 170.160004], + [new Date("2018-01-30"), 165.529999], + [new Date("2018-01-31"), 166.869995], + [new Date("2018-02-01"), 167.169998], + [new Date("2018-02-02"), 166.000000], + [new Date("2018-02-05"), 159.100006], + [new Date("2018-02-06"), 154.830002], + [new Date("2018-02-07"), 163.089996], + [new Date("2018-02-08"), 160.289993], + [new Date("2018-02-09"), 157.070007], + [new Date("2018-02-12"), 158.500000], + [new Date("2018-02-13"), 161.949997], + [new Date("2018-02-14"), 163.039993], + [new Date("2018-02-15"), 169.789993], + [new Date("2018-02-16"), 172.360001], + [new Date("2018-02-20"), 172.050003], + [new Date("2018-02-21"), 172.830002], + [new Date("2018-02-22"), 171.800003], + [new Date("2018-02-23"), 173.669998], + [new Date("2018-02-26"), 176.350006], + [new Date("2018-02-27"), 179.100006], + [new Date("2018-02-28"), 179.259995] + ]; + return Plot.dot(timeSeries).plot(); +} diff --git a/test/plots/shorthand-dotX.js b/test/plots/shorthand-dotX.js new file mode 100644 index 0000000000..427027fa9d --- /dev/null +++ b/test/plots/shorthand-dotX.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.dotX(numbers).plot(); +} diff --git a/test/plots/shorthand-groupBarY.js b/test/plots/shorthand-groupBarY.js new file mode 100644 index 0000000000..a93fe01077 --- /dev/null +++ b/test/plots/shorthand-groupBarY.js @@ -0,0 +1,6 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const gene = "AAAAGAGTGAAGATGCTGGAGACGAGTGAAGCATTCACTTTAGGGAAAGCGAGGCAAGAGCGTTTCAGAAGACGAAACCTGGTAGGTGCACTCACCACAG"; + return Plot.barY(gene, Plot.groupX()).plot(); +} diff --git a/test/plots/shorthand-line.js b/test/plots/shorthand-line.js new file mode 100644 index 0000000000..a3526b01b8 --- /dev/null +++ b/test/plots/shorthand-line.js @@ -0,0 +1,47 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const timeSeries = [ + [new Date("2018-01-02"), 170.160004], + [new Date("2018-01-03"), 172.529999], + [new Date("2018-01-04"), 172.539993], + [new Date("2018-01-05"), 173.440002], + [new Date("2018-01-08"), 174.350006], + [new Date("2018-01-09"), 174.550003], + [new Date("2018-01-10"), 173.160004], + [new Date("2018-01-11"), 174.589996], + [new Date("2018-01-12"), 176.179993], + [new Date("2018-01-16"), 177.899994], + [new Date("2018-01-17"), 176.149994], + [new Date("2018-01-18"), 179.369995], + [new Date("2018-01-19"), 178.610001], + [new Date("2018-01-22"), 177.300003], + [new Date("2018-01-23"), 177.300003], + [new Date("2018-01-24"), 177.250000], + [new Date("2018-01-25"), 174.509995], + [new Date("2018-01-26"), 172.000000], + [new Date("2018-01-29"), 170.160004], + [new Date("2018-01-30"), 165.529999], + [new Date("2018-01-31"), 166.869995], + [new Date("2018-02-01"), 167.169998], + [new Date("2018-02-02"), 166.000000], + [new Date("2018-02-05"), 159.100006], + [new Date("2018-02-06"), 154.830002], + [new Date("2018-02-07"), 163.089996], + [new Date("2018-02-08"), 160.289993], + [new Date("2018-02-09"), 157.070007], + [new Date("2018-02-12"), 158.500000], + [new Date("2018-02-13"), 161.949997], + [new Date("2018-02-14"), 163.039993], + [new Date("2018-02-15"), 169.789993], + [new Date("2018-02-16"), 172.360001], + [new Date("2018-02-20"), 172.050003], + [new Date("2018-02-21"), 172.830002], + [new Date("2018-02-22"), 171.800003], + [new Date("2018-02-23"), 173.669998], + [new Date("2018-02-26"), 176.350006], + [new Date("2018-02-27"), 179.100006], + [new Date("2018-02-28"), 179.259995] + ]; + return Plot.line(timeSeries).plot(); +} diff --git a/test/plots/shorthand-lineY.js b/test/plots/shorthand-lineY.js new file mode 100644 index 0000000000..822752439f --- /dev/null +++ b/test/plots/shorthand-lineY.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.lineY(numbers).plot(); +} diff --git a/test/plots/shorthand-rectY.js b/test/plots/shorthand-rectY.js new file mode 100644 index 0000000000..9e803d2113 --- /dev/null +++ b/test/plots/shorthand-rectY.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.rectY(numbers).plot(); +} diff --git a/test/plots/shorthand-ruleX.js b/test/plots/shorthand-ruleX.js new file mode 100644 index 0000000000..f8234f61b0 --- /dev/null +++ b/test/plots/shorthand-ruleX.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.ruleX(numbers).plot(); +} diff --git a/test/plots/shorthand-text.js b/test/plots/shorthand-text.js new file mode 100644 index 0000000000..a8971c3075 --- /dev/null +++ b/test/plots/shorthand-text.js @@ -0,0 +1,47 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const timeSeries = [ + [new Date("2018-01-02"), 170.160004], + [new Date("2018-01-03"), 172.529999], + [new Date("2018-01-04"), 172.539993], + [new Date("2018-01-05"), 173.440002], + [new Date("2018-01-08"), 174.350006], + [new Date("2018-01-09"), 174.550003], + [new Date("2018-01-10"), 173.160004], + [new Date("2018-01-11"), 174.589996], + [new Date("2018-01-12"), 176.179993], + [new Date("2018-01-16"), 177.899994], + [new Date("2018-01-17"), 176.149994], + [new Date("2018-01-18"), 179.369995], + [new Date("2018-01-19"), 178.610001], + [new Date("2018-01-22"), 177.300003], + [new Date("2018-01-23"), 177.300003], + [new Date("2018-01-24"), 177.250000], + [new Date("2018-01-25"), 174.509995], + [new Date("2018-01-26"), 172.000000], + [new Date("2018-01-29"), 170.160004], + [new Date("2018-01-30"), 165.529999], + [new Date("2018-01-31"), 166.869995], + [new Date("2018-02-01"), 167.169998], + [new Date("2018-02-02"), 166.000000], + [new Date("2018-02-05"), 159.100006], + [new Date("2018-02-06"), 154.830002], + [new Date("2018-02-07"), 163.089996], + [new Date("2018-02-08"), 160.289993], + [new Date("2018-02-09"), 157.070007], + [new Date("2018-02-12"), 158.500000], + [new Date("2018-02-13"), 161.949997], + [new Date("2018-02-14"), 163.039993], + [new Date("2018-02-15"), 169.789993], + [new Date("2018-02-16"), 172.360001], + [new Date("2018-02-20"), 172.050003], + [new Date("2018-02-21"), 172.830002], + [new Date("2018-02-22"), 171.800003], + [new Date("2018-02-23"), 173.669998], + [new Date("2018-02-26"), 176.350006], + [new Date("2018-02-27"), 179.100006], + [new Date("2018-02-28"), 179.259995] + ]; + return Plot.text(timeSeries).plot(); +} diff --git a/test/plots/shorthand-textX.js b/test/plots/shorthand-textX.js new file mode 100644 index 0000000000..055be4a586 --- /dev/null +++ b/test/plots/shorthand-textX.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.textX(numbers).plot(); +} diff --git a/test/plots/shorthand-tickX.js b/test/plots/shorthand-tickX.js new file mode 100644 index 0000000000..23a9894281 --- /dev/null +++ b/test/plots/shorthand-tickX.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.tickX(numbers).plot(); +} diff --git a/test/plots/shorthand-vector.js b/test/plots/shorthand-vector.js new file mode 100644 index 0000000000..6068db0622 --- /dev/null +++ b/test/plots/shorthand-vector.js @@ -0,0 +1,47 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const timeSeries = [ + [new Date("2018-01-02"), 170.160004], + [new Date("2018-01-03"), 172.529999], + [new Date("2018-01-04"), 172.539993], + [new Date("2018-01-05"), 173.440002], + [new Date("2018-01-08"), 174.350006], + [new Date("2018-01-09"), 174.550003], + [new Date("2018-01-10"), 173.160004], + [new Date("2018-01-11"), 174.589996], + [new Date("2018-01-12"), 176.179993], + [new Date("2018-01-16"), 177.899994], + [new Date("2018-01-17"), 176.149994], + [new Date("2018-01-18"), 179.369995], + [new Date("2018-01-19"), 178.610001], + [new Date("2018-01-22"), 177.300003], + [new Date("2018-01-23"), 177.300003], + [new Date("2018-01-24"), 177.250000], + [new Date("2018-01-25"), 174.509995], + [new Date("2018-01-26"), 172.000000], + [new Date("2018-01-29"), 170.160004], + [new Date("2018-01-30"), 165.529999], + [new Date("2018-01-31"), 166.869995], + [new Date("2018-02-01"), 167.169998], + [new Date("2018-02-02"), 166.000000], + [new Date("2018-02-05"), 159.100006], + [new Date("2018-02-06"), 154.830002], + [new Date("2018-02-07"), 163.089996], + [new Date("2018-02-08"), 160.289993], + [new Date("2018-02-09"), 157.070007], + [new Date("2018-02-12"), 158.500000], + [new Date("2018-02-13"), 161.949997], + [new Date("2018-02-14"), 163.039993], + [new Date("2018-02-15"), 169.789993], + [new Date("2018-02-16"), 172.360001], + [new Date("2018-02-20"), 172.050003], + [new Date("2018-02-21"), 172.830002], + [new Date("2018-02-22"), 171.800003], + [new Date("2018-02-23"), 173.669998], + [new Date("2018-02-26"), 176.350006], + [new Date("2018-02-27"), 179.100006], + [new Date("2018-02-28"), 179.259995] + ]; + return Plot.vector(timeSeries).plot(); +} diff --git a/test/plots/shorthand-vectorX.js b/test/plots/shorthand-vectorX.js new file mode 100644 index 0000000000..eba73a548f --- /dev/null +++ b/test/plots/shorthand-vectorX.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + const numbers = [ + 170.16, 172.53, 172.54, 173.44, 174.35, 174.55, 173.16, 174.59, 176.18, 177.90, + 176.15, 179.37, 178.61, 177.30, 177.30, 177.25, 174.51, 172.00, 170.16, 165.53, + 166.87, 167.17, 166.00, 159.10, 154.83, 163.09, 160.29, 157.07, 158.50, 161.95, + 163.04, 169.79, 172.36, 172.05, 172.83, 171.80, 173.67, 176.35, 179.10, 179.26 + ]; + return Plot.vectorX(numbers).plot(); +}