Skip to content
Snippets Groups Projects
Unverified Commit f84e0d23 authored by Jesse Devaney's avatar Jesse Devaney Committed by GitHub
Browse files

Update default `map.type` display for breakouts with un-binned coordinates (#44717)

* fix map default display type with un-binned coordinates

- default to `"map.type"` = "pin" when coordinates are not binned
- default to `"map.type"` = "grid" when coordinates are binned

* add tests

* refactor breakouts usage
parent c0f10581
No related branches found
No related tags found
No related merge requests found
......@@ -99,10 +99,23 @@ export const defaultDisplay = (query: Lib.Query): DefaultDisplay => {
return Lib.isCoordinate(column);
});
if (areBreakoutsCoordinates) {
const binningOne = Lib.binning(breakouts[0]);
const binningTwo = Lib.binning(breakouts[1]);
const areBothBinned = binningOne !== null && binningTwo !== null;
if (areBothBinned) {
return {
display: "map",
settings: {
"map.type": "grid",
},
};
}
return {
display: "map",
settings: {
"map.type": "grid",
"map.type": "pin",
},
};
}
......
......@@ -182,7 +182,32 @@ describe("defaultDisplay", () => {
expect(defaultDisplay(query)).toEqual({ display: "line" });
});
it("returns 'map' display for queries with 1 aggregation and 2 breakouts by coordinates", () => {
it("returns 'map' display with 'grid' type for queries with 1 aggregation and 2 binned breakouts by coordinates", () => {
const query = createQueryWithClauses({
aggregations: [{ operatorName: "count" }],
breakouts: [
{
columnName: "LATITUDE",
tableName: "PEOPLE",
binningStrategyName: "Auto bin",
},
{
columnName: "LONGITUDE",
tableName: "PEOPLE",
binningStrategyName: "Auto bin",
},
],
});
expect(defaultDisplay(query)).toEqual({
display: "map",
settings: {
"map.type": "grid",
},
});
});
it("returns 'map' display with 'pin' type for queries with 1 aggregation and 2 un-binned breakouts by coordinates", () => {
const query = createQueryWithClauses({
aggregations: [{ operatorName: "count" }],
breakouts: [
......@@ -194,7 +219,28 @@ describe("defaultDisplay", () => {
expect(defaultDisplay(query)).toEqual({
display: "map",
settings: {
"map.type": "grid",
"map.type": "pin",
},
});
});
it("returns 'map' display with 'pin' type for queries with 1 aggregation and 2 breakouts by coordinates - 1 binned, 1 unbinned", () => {
const query = createQueryWithClauses({
aggregations: [{ operatorName: "count" }],
breakouts: [
{
columnName: "LATITUDE",
tableName: "PEOPLE",
binningStrategyName: "Auto bin",
},
{ columnName: "LONGITUDE", tableName: "PEOPLE" },
],
});
expect(defaultDisplay(query)).toEqual({
display: "map",
settings: {
"map.type": "pin",
},
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment