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

(WIP) feat: Added Australia to Choropleth visualisation #4374

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./client/app/visualizations/choropleth/maps/australia.postcodes.geo.json filter=lfs diff=lfs merge=lfs -text
Copy link
Member

Choose a reason for hiding this comment

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

What's this about?

Not sure if related, but this PR is missing the actual map JSON files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I tried to upload it, but its hitting the limits of github file sizes.
I will down-sample the map and create another PR for this.

Copy link
Member

Choose a reason for hiding this comment

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

@kravets-levko is working on a way to load custom maps without adding them to the repo (#4599), so maybe just wait for it and load the map from an external source?

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ function TemplateFormatHint({ mapType }) { // eslint-disable-line react/prop-typ
<div><code>{'{{ @@iso_3166_2 }}'}</code> five-letter ISO subdivision code (JP-xx);</div>
</React.Fragment>
)}
{mapType === 'postcode_australia' && (
<React.Fragment>
<div><code>{'{{ @@name }}'}</code> Postcode or Suburb name in English;</div>
<div><code>{'{{ @@postcode }}'}</code> four digit post code (xxxx);</div>
</React.Fragment>
)}
</React.Fragment>
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
name_local: 'Name (local)',
iso_3166_2: 'ISO-3166-2',
};
case 'postcode_australia':
return {
name: 'Name',
postcode: 'Postcode',
};
default:
return {};
}
Expand Down Expand Up @@ -49,6 +54,7 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
>
<Select.Option key="countries" data-test="Choropleth.Editor.MapType.Countries">Countries</Select.Option>
<Select.Option key="subdiv_japan" data-test="Choropleth.Editor.MapType.Japan">Japan/Prefectures</Select.Option>
<Select.Option key="postcode_australia" data-test="Choropleth.Editor.MapType.Australia">Australia/Postcodes</Select.Option>
</Select>
</div>

Expand Down
5 changes: 4 additions & 1 deletion client/app/visualizations/choropleth/Editor/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ export function inferCountryCodeType(mapType, data, countryCodeField) {
},
subdiv_japan: {
name: /^[a-z]+$/i,
name_local: /^[\u3400-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]+$/i,
iso_3166_2: /^JP-[0-9]{2}$/i,
},
postcode_australia: {
name: /^[a-z]+$/i,
postcode: /^[0-9]{4}$/i,
},
};

const regex = regexMap[mapType];
Expand Down
2 changes: 2 additions & 0 deletions client/app/visualizations/choropleth/Renderer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import './renderer.less';

import countriesDataUrl from '../maps/countries.geo.json';
import subdivJapanDataUrl from '../maps/japan.prefectures.geo.json';
import postcodesAustraliaDataUrl from '../maps/australia.postcodes.geo.json';

function getDataUrl(type) {
switch (type) {
case 'countries': return countriesDataUrl;
case 'subdiv_japan': return subdivJapanDataUrl;
case 'postcode_australia': return postcodesAustraliaDataUrl;
default: return null;
}
}
Expand Down