From 8241496abb899145685072476246a3d8295570af Mon Sep 17 00:00:00 2001 From: Toph Tucker Date: Tue, 6 Jun 2023 21:27:17 -0400 Subject: [PATCH] Auto: given bar, use cell over rect when no reducer (#1674) * given bar, use cell over rect when no reducer * lint * test output --- src/marks/auto.js | 4 +- test/output/autoBarNoReducer.svg | 736 +++++++++++++++++++++++++++++++ test/plots/autoplot.ts | 5 + 3 files changed, 744 insertions(+), 1 deletion(-) create mode 100644 test/output/autoBarNoReducer.svg diff --git a/src/marks/auto.js b/src/marks/auto.js index 0cb576a25b..b53c632ef0 100644 --- a/src/marks/auto.js +++ b/src/marks/auto.js @@ -131,7 +131,9 @@ export function autoSpec(data, options) { ? rectX : yReduce != null ? rectY - : rect; + : colorReduce != null + ? rect + : cell; colorMode = "fill"; break; default: diff --git a/test/output/autoBarNoReducer.svg b/test/output/autoBarNoReducer.svg new file mode 100644 index 0000000000..81e595ffbc --- /dev/null +++ b/test/output/autoBarNoReducer.svg @@ -0,0 +1,736 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + number_in_season + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + season + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plots/autoplot.ts b/test/plots/autoplot.ts index a5a63c169c..0b876f3326 100644 --- a/test/plots/autoplot.ts +++ b/test/plots/autoplot.ts @@ -259,3 +259,8 @@ export async function autoChannels() { const athletes = await d3.csv("data/athletes.csv", d3.autoType); return Plot.auto(athletes, {x: Plot.valueof(athletes, "height"), y: Plot.valueof(athletes, "sport")}).plot(); } + +export async function autoBarNoReducer() { + const simpsons = await d3.csv("data/simpsons.csv", d3.autoType); + return Plot.auto(simpsons, {x: "season", y: "number_in_season", color: "imdb_rating", mark: "bar"}).plot(); +}