Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maps integration #240

Merged
merged 71 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
50da8f9
feat: Add interactiveFiltersConfig to maps
bprusinowski Nov 23, 2021
3948b3e
feat: Initial addition of GeoDimension
bprusinowski Nov 23, 2021
f5ba35e
feat: Initial integration of maps with configurator: base layers
bprusinowski Nov 23, 2021
d9eac54
feat: Show areaLayer and symbolLayer in the configurator panel for maps
bprusinowski Nov 23, 2021
04855f6
refactor: Minor code cleaning
bprusinowski Nov 23, 2021
d6cae96
feat: Add geoShapes fetching to RDF and GraphQL
bprusinowski Nov 24, 2021
f1e89d8
feat; Add initial custom shapes drawing
bprusinowski Nov 24, 2021
f572ada
feat: Add geoShapes parsing to resolvers + minor improvements
bprusinowski Nov 29, 2021
d350226
fix: Map tooltip
bprusinowski Nov 29, 2021
9882cf3
feat: Add color palette selector to maps
bprusinowski Nov 30, 2021
ec636d8
chore: Clean up the code
bprusinowski Nov 30, 2021
e2f852d
feat: Add scale type selector to maps
bprusinowski Nov 30, 2021
8beedf5
feat: Add symbol layer to maps
bprusinowski Nov 30, 2021
93b9d6c
chore: Remove experimental map
bprusinowski Dec 1, 2021
943ca30
refactor: Use isSegmentInConfig method to check for segments
bprusinowski Dec 1, 2021
2414a13
chore: Revert SPARQL_ENDPOINT to a correct value
bprusinowski Dec 1, 2021
2889b61
feat: Switch to topoJSON + add mesh to the map
bprusinowski Dec 2, 2021
ad5976d
perf: Save observations in GeoJSON.Feature properties
bprusinowski Dec 2, 2021
edfc783
fix: Legend for no data points
bprusinowski Dec 2, 2021
c429a73
refactor: Move number of classes options outside of the component
bprusinowski Dec 2, 2021
5118f10
chore: Remove unused map prototype components
bprusinowski Dec 2, 2021
c5597e1
fix: Color and radius issues for undefined observations
bprusinowski Dec 2, 2021
a2597c7
feat: Use DataLoader for geoShapes fetching
bprusinowski Dec 2, 2021
29d81a7
feat: Add an ability to set symbolLayer color
bprusinowski Dec 2, 2021
4d03c9a
feat: Use batching from DataLoader to fetch geoDimensions
bprusinowski Dec 2, 2021
f239a5b
wip: Initial map legend optimizations & sizing issue fixes
bprusinowski Dec 2, 2021
dcc9eab
feat: Add GeoCoordinatesDimension
bprusinowski Jan 11, 2022
13e027f
Merge branch 'feat/fetch-dimension-values-if-no-sh-in' of github.com:…
bprusinowski Jan 11, 2022
a25f06e
feat: Change the query not to use OPTIONAL + n of outputs === n of in…
bprusinowski Jan 11, 2022
5253ad8
chore: Update yarn.lock
bprusinowski Jan 11, 2022
4e33ecb
feat: Remove OPTIONAL fields from GeoCoordinates + clean the code
bprusinowski Jan 11, 2022
068a837
Merge branch 'main' of github.com:visualize-admin/visualization-tool …
bprusinowski Jan 12, 2022
d88e62b
feat: Enable geo fetching for new dimensionValues format
bprusinowski Jan 12, 2022
5f99327
fix: Load GeoCoordinates using versioned dimension values
bprusinowski Jan 12, 2022
868b459
feat: Add getGeoDimensions functions
bprusinowski Jan 12, 2022
449b60d
feat: Populate initial map chart config symbol field with proper dims
bprusinowski Jan 12, 2022
3c4df67
feat: Update map chart options
bprusinowski Jan 12, 2022
14d2aba
feat: Add initial geoCoordinates drawing
bprusinowski Jan 12, 2022
9db11ec
fix: Flickering screen when selecting a map chart
bprusinowski Jan 13, 2022
8496dda
feat: Minor deck.gl adjustments
bprusinowski Jan 13, 2022
c502611
fix: Radius extent to start from 0
bprusinowski Jan 13, 2022
43074ac
fix: Hover on shape boundary
bprusinowski Jan 13, 2022
b50eaeb
feat: Add useTooltip
bprusinowski Jan 13, 2022
42326eb
feat: Map tooltip & legend optimizations
bprusinowski Jan 13, 2022
45dba12
fix: Initial legend labels
bprusinowski Jan 13, 2022
53bed74
fix: Hide lower circle in symbol legend on hover
bprusinowski Jan 13, 2022
b8f809b
refactor: Map legend & tooltip
bprusinowski Jan 13, 2022
64977a2
feat: Add fallback for geo labels with no locales
bprusinowski Jan 17, 2022
953cb00
feat: Small improvements to the map
bprusinowski Jan 18, 2022
1069b87
feat: Initial geo hierarchies
bprusinowski Jan 18, 2022
7725bc5
feat: Add geo hierarchies to area layer
bprusinowski Jan 18, 2022
227cae8
refactor: Simplify createHierarchy
bprusinowski Jan 18, 2022
1c06e65
Merge branch fix/data-loader-bugs
bprusinowski Jan 20, 2022
74ac892
feat: Retrieve SPARQL_GEO_ENDPOINT from env variables
bprusinowski Jan 20, 2022
03fe84f
feat: Switck back to int.lindas for preview deployments
bprusinowski Jan 20, 2022
ff6220d
fix: Hierarchy select types + small improvements
bprusinowski Jan 20, 2022
d542d98
chore: Rename chart prototype file
bprusinowski Jan 20, 2022
c761d73
refactor: Improve types
bprusinowski Jan 20, 2022
bf172b6
chore: Remove unused map config field
bprusinowski Jan 20, 2022
2aeabc4
refactor: Small optimization
bprusinowski Jan 20, 2022
e2093e7
fix: Enabled chart types
bprusinowski Jan 20, 2022
8bb49ff
feat: Decrease maxBatchSize for geoCoords due to filtering in SpQL
bprusinowski Jan 20, 2022
222f157
refactor: Map legend improvements
bprusinowski Jan 24, 2022
15dcaf4
refactor: Extract Circle from CircleLegend
bprusinowski Jan 24, 2022
b97a2a4
refactor: Map chart options to useMemo
bprusinowski Jan 24, 2022
ec093d3
refactor: Use ns.schema instead of hard-coded string in geoCoords
bprusinowski Jan 24, 2022
609c2a6
refactor: Use hierarchy levels defined in shapes instead of creating …
bprusinowski Jan 24, 2022
7e63406
fix: Allow observation to be undefined in GeoProperties
bprusinowski Jan 24, 2022
56ab798
refactor: Use proper ns.schema instead of hard-coded string in geoCoords
bprusinowski Jan 24, 2022
b3b8310
refactor: Map tooltip optimizations
bprusinowski Jan 24, 2022
c2d56d0
refactor: Split geoShapes query into 2 to prevent SPARQL failures + s…
bprusinowski Jan 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions app/charts/chart-config-ui-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ export type DimensionType =
| "TemporalDimension"
| "NominalDimension"
| "OrdinalDimension"
| "GeoDimension"
| "Measure"
| "Attribute";

export type EncodingField = "x" | "y" | "segment";
export type BaseEncodingField = "x" | "y" | "segment" | "settings";
export type GeoEncodingField = "areaLayer" | "symbolLayer";
export type EncodingField = BaseEncodingField | GeoEncodingField;
export type EncodingOption =
| "chartSubType"
| "sorting"
Expand Down Expand Up @@ -228,7 +231,26 @@ export const chartConfigOptionsUISpec: ChartSpecs = {
},
map: {
chartType: "map",
encodings: [],
encodings: [
{
field: "settings",
optional: true,
values: ["Attribute"], // FIXME: currently not used anywhere
filters: false,
},
{
field: "areaLayer",
optional: false,
values: ["Measure"],
filters: false,
},
{
field: "symbolLayer",
optional: true,
values: ["Measure"],
filters: false,
},
],
interactiveFilters: [],
},
};
Expand Down
54 changes: 27 additions & 27 deletions app/charts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const enabledChartTypes: ChartType[] = [
"scatterplot",
"pie",
"table",
"map",
];

/**
Expand Down Expand Up @@ -262,32 +263,26 @@ export const getInitialConfig = ({
},
},
fields: {
baseLayer: {
componentIri: dimensions[0].iri,
relief: true,
lakes: true,
},
areaLayer: {
componentIri: measures[0].iri,
show: false,
componentIri:
dimensions.find((d) => d.__typename === "GeoDimension")?.iri ||
"",
measureIri: measures[0].iri,
show: true,
label: { componentIri: dimensions[0].iri },
palette: "oranges",
nbClass: 5,
paletteType: "continuous",
},
symbolLayer: {
show: false,
componentIri: measures[0].iri,
},
// FIXME: unused fields
x: { componentIri: dimensions[0].iri },
y: {
componentIri: measures[0].iri,
},
segment: {
componentIri: dimensions[0].iri,
show: false,
},
},
settings: {
showRelief: true,
showLakes: true,
},
};

// This code *should* be unreachable! If it's not, it means we haven't checked all cases (and we should get a TS error).
Expand All @@ -307,30 +302,35 @@ export const getPossibleChartType = ({

const hasZeroQ = measures.length === 0;
const hasMultipleQ = measures.length > 1;
const hasGeo = dimensions.some((dim) => dim.__typename === "GeoDimension");
const hasTime = dimensions.some(
(dim) => dim.__typename === "TemporalDimension"
);

// const geoBased: ChartType[] = ["map"];
const geoBased: ChartType[] = ["map"];
const catBased: ChartType[] = ["bar", "column", "pie", "table"];
const multipleQ: ChartType[] = ["scatterplot"];
const timeBased: ChartType[] = ["line", "area"];

let possibles: ChartType[] = [];
if (hasZeroQ) {
possibles = ["table"];
} else if (hasMultipleQ && hasTime) {
possibles = [...multipleQ, ...timeBased, ...catBased];
} else if (hasMultipleQ && !hasTime) {
possibles = [...multipleQ, ...catBased];
} else if (!hasMultipleQ && hasTime) {
possibles = [...catBased, ...timeBased];
} else if (!hasMultipleQ && !hasTime) {
possibles = [...catBased];
} else {
// Tables should always be possible
possibles = ["table"];
possibles.push(...catBased);

if (hasMultipleQ) {
possibles.push(...multipleQ);
}

if (hasTime) {
possibles.push(...timeBased);
}

if (hasGeo) {
possibles.push(...geoBased);
}
}

return enabledChartTypes.filter((type) => possibles.includes(type));
};

Expand Down
Loading