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

Maps integration #240

merged 71 commits into from
Jan 25, 2022

Conversation

bprusinowski
Copy link
Collaborator

@bprusinowski bprusinowski commented Nov 30, 2021

Draft of integrating maps to the app. You can test the feature by using a "Covid 19 Vaccinated Persons" dataset (and pass e.g. 2021-11-20 to the date filter to actually see some data :) ).

Currently all the shapes are fetched dynamically (so the static files are not used).

TODO:

  • handle GeoCoordinates dimensions
  • set GEO_SPARQL_ENDPOINT in .env file
  • separate tooltip for area layer & symbol layer when selected geo dimensions are different
  • add translations
  • centroids for weird shapes (symbolLayer based on geoShape)
  • handle aggregated rows - partially done, waiting for Zazuko to decide on the final approach
  • refactor geoShapes fetching so they are fetched once (not per every locale, as the shapes are the same)
  • fix jenks color legend bug when number of classes is bigger than number of observations\
  • index by label - add DataProvider
  • move hierarchy creation to dimension-hierarchy + add test

TBD:

  • hide shapes with no data linked to them
  • add more information to a tooltip / allow switching measures in interactive filters
  • match observations to shapes by IRI, not label
  • hierarchies for geoCoordinates

Nice to have:

  • highlight areas or symbols on hover
  • change the select element for choosing the color palette to a colorPicker
  • optimize map legend logic
  • polish the design of the chart options selector
  • add an ability to set mesh color
  • initial zoom to bounding box of visible shapes

@jstcki jstcki temporarily deployed to visualize-ad-feat-integ-2hricn November 30, 2021 13:24 Inactive
app/charts/map/map-state.tsx Outdated Show resolved Hide resolved
app/charts/map/chart-map-prototype.tsx Outdated Show resolved Hide resolved
app/configurator/configurator-state.tsx Outdated Show resolved Hide resolved
app/rdf/query-geoshapes.ts Outdated Show resolved Hide resolved
app/charts/map/map-state.tsx Outdated Show resolved Hide resolved
app/charts/map/map.tsx Outdated Show resolved Hide resolved
app/charts/map/map-legend.tsx Outdated Show resolved Hide resolved
app/charts/map/map.tsx Outdated Show resolved Hide resolved
app/charts/map/map.tsx Outdated Show resolved Hide resolved
@ptbrowne
Copy link
Collaborator

ptbrowne commented Dec 1, 2021

Apart from the small stuff I commented, the code is clear, thanks for having the smallish commits ;)

Copy link
Contributor

@jstcki jstcki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Added a few comments but overall seems to work nicely 👏

app/domain/env.ts Outdated Show resolved Hide resolved
app/domain/env.ts Outdated Show resolved Hide resolved
app/configurator/map/map-chart-options.tsx Outdated Show resolved Hide resolved
app/domain/data.ts Show resolved Hide resolved
@jstcki jstcki temporarily deployed to visualize-ad-feat-integ-hqsuze December 2, 2021 10:24 Inactive
@jstcki jstcki temporarily deployed to visualize-ad-feat-integ-hqsuze December 2, 2021 11:40 Inactive
@jstcki jstcki temporarily deployed to visualize-ad-feat-integ-hqsuze December 2, 2021 12:53 Inactive
@ptbrowne ptbrowne had a problem deploying to visualize-ad-feat-integ-qpnfjh January 20, 2022 16:33 Failure
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 20, 2022 16:46 Inactive
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 20, 2022 16:54 Inactive
Copy link
Collaborator

@ptbrowne ptbrowne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see any blocker for here. LGTM :) Great job !

A pattern I have noticed though in the code was the use of find and filter where indexing could be used and be clearer / faster.

(o) =>
o[chartConfig.fields.areaLayer.componentIri] === d.properties!.label
);
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use an index label -> observations here so that this step is O(nlogn) instead of O(n2).

observation: data?.dataCubeByIri?.observations.data.find(
(o) =>
o[chartConfig.fields.areaLayer.componentIri] === d.properties!.label
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The observtions by label index could be used here.

app/charts/map/map-legend.tsx Outdated Show resolved Hide resolved
app/charts/map/map-legend.tsx Show resolved Hide resolved
app/configurator/map/map-chart-options.tsx Show resolved Hide resolved
label: d.label,
observation: observations?.find(
(o) => o[symbolGeoDimensionIri] === d.label
),
Copy link
Collaborator

@ptbrowne ptbrowne Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A observations by label index could be useful. Since it is needed in a lot of places, I wonder if we should have a DataProvider somewhere in the tree that does the indexing so that children do not have to do this repeatedly, what do you think ? (this is not the scope of the PR).

allIris: dimensionIris,
narrowerValues,
});
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this could be moved into the dimension-hierarchy file, and a test could be good :)

app/rdf/query-geo-shapes.ts Show resolved Hide resolved
app/charts/map/map-state.tsx Outdated Show resolved Hide resolved
return data.filter((d) => hierarchyLabels.includes(getLabel(d)));
}

return data;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having a callback, I think we could directly index the shapes by level so that we can use them directly afterwards without recomputation.

const dataByLevel = useMemo(() => { groupBy(data, x=> getLevelByLabel(x.label)) }

@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 24, 2022 10:49 Inactive
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 24, 2022 11:11 Inactive
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 24, 2022 11:25 Inactive
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 24, 2022 11:59 Inactive
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 24, 2022 12:20 Inactive
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 24, 2022 14:46 Inactive
@bprusinowski bprusinowski force-pushed the feat/integrate-maps-with-configurator branch from ba1b5b6 to a9c074a Compare January 24, 2022 15:40
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 24, 2022 15:41 Inactive
@bprusinowski bprusinowski force-pushed the feat/integrate-maps-with-configurator branch from a9c074a to 56ab798 Compare January 24, 2022 15:42
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 24, 2022 15:42 Inactive
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 24, 2022 16:49 Inactive
@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-integ-qpnfjh January 24, 2022 19:21 Inactive
@bprusinowski bprusinowski marked this pull request as ready for review January 25, 2022 08:26
@bprusinowski bprusinowski merged commit 07c9659 into main Jan 25, 2022
@bprusinowski bprusinowski deleted the feat/integrate-maps-with-configurator branch January 25, 2022 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants