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

Feature/statisticts table #119

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5278025
Replaced List View with Dynamic Table
CliffHack Jan 5, 2024
50136e1
Added Table View Component
CliffHack Jan 18, 2024
ff1ebf0
Groupby functions init for table views
CliffHack Jan 19, 2024
1f6ba20
Added dymic read of the MapConfig to read Tables
CliffHack Jan 22, 2024
e7230ff
Grouped by tables complete with sorting implemented
CliffHack Jan 23, 2024
df1b82f
simple point on area join
LBHSBALLEY Jan 23, 2024
96fc879
Merged Spatial Enrichment Logic
CliffHack Jan 24, 2024
574e953
Added spatial enrichments to local config
CliffHack Jan 24, 2024
b9dd0c3
load geographies before data layers
LBHSBALLEY Jan 24, 2024
f34a913
Merging new enrichment changes
CliffHack Jan 24, 2024
83cb206
Refactor
CliffHack Jan 24, 2024
b9833ab
Enrichement waits for geography layers
LBHSBALLEY Jan 25, 2024
25bf6dd
Testing replacer code for unwanted values in df
CliffHack Jan 25, 2024
b15258b
Merging new code to allow layers to fully load before enrichment
CliffHack Jan 25, 2024
73226ea
Merging new code to allow layers to fully load before enrichment 2
CliffHack Jan 25, 2024
d44559a
Branch Switch
CliffHack Jan 25, 2024
2f79e67
Moved list-view into table-view to allow the front-end initAll to wor…
CliffHack Jan 25, 2024
318fafa
list enriching layers with other layers
LBHSBALLEY Jan 26, 2024
73dc51b
List view reads from geojson not from map
LBHSBALLEY Jan 26, 2024
32c1df3
clear debugging comments
LBHSBALLEY Jan 26, 2024
e803f05
Merge branch 'feat/spatial-enrichment' into cliff-dev-table
CliffHack Jan 29, 2024
250062f
Refactered code to catch errors when data is not present for tables
CliffHack Jan 29, 2024
94f4534
Moved attribute alignment code into spatial-enrichment.js from table …
CliffHack Jan 29, 2024
6fbd060
Statistics Table-View Beta with no comments
CliffHack Jan 30, 2024
c4747e0
Statistics Table-View BETA
CliffHack Jan 30, 2024
2ef709e
enrich only once
LBHSBALLEY Feb 6, 2024
3465a3a
Bug Fix - Decoupled List View and Table-View
CliffHack Feb 7, 2024
1c86d82
enableSpiderfy option
LBHSBALLEY Feb 26, 2024
e0453b2
Add gitguardian yaml to gitignore
LBHSBALLEY Feb 27, 2024
79099dd
Adding Statistics Tables to README and Spatial Enrichment
CliffHack Feb 27, 2024
2355a6b
Merge branch 'feature/statisticts-table' of https://github.com/LBHack…
CliffHack Feb 27, 2024
8c8c220
Adding Statistics Tables to README and Spatial Enrichments 2
CliffHack Feb 28, 2024
449fb81
Update README.md
LBHSBALLEY Feb 29, 2024
3e0f673
Remove global spatialEnrichment flag
LBHSBALLEY Feb 29, 2024
0bad63d
Refactoring Statistic Tables README
CliffHack Feb 29, 2024
ce7d3a2
Refactoring Statistic Tables README table headers
CliffHack Feb 29, 2024
04f6856
Refactoring Statistic Tables README table with functions table example
CliffHack Feb 29, 2024
50a6052
Refactoring Statistic Tables README table with functions table example2
CliffHack Feb 29, 2024
5e979aa
Refactoring Statistic Tables README table with json blocks
CliffHack Feb 29, 2024
34f8e15
Refactoring Statistic Tables README table with json blocks refactor
CliffHack Feb 29, 2024
5f6c201
Refactoring Statistic Tables README table with json blocks refactor2
CliffHack Feb 29, 2024
5b95f12
Refactoring Statistic Tables README table with json blocks refactor3
CliffHack Feb 29, 2024
16f88a9
Use the tableview-container and custom header
LBHSBALLEY Feb 29, 2024
b6371d9
Refactoring Statistic Tables README table with json blocks refactor2
CliffHack Feb 29, 2024
97aa299
Merge branch 'feature/statisticts-table' of https://github.com/LBHack…
CliffHack Feb 29, 2024
6dd93c2
Refactoring Statistic Tables README table with json blocks refactor 4
CliffHack Feb 29, 2024
55ac9cc
Refactoring Statistic Tables README table with json blocks refactor 5
CliffHack Mar 1, 2024
f5a018d
Refactoring Statistic Tables README table with json blocks refactor 6
CliffHack Mar 1, 2024
c1f1b77
Refactoring Statistic Tables README
CliffHack Mar 1, 2024
d5922e7
tweak table_view to support single list
LBHSBALLEY Mar 5, 2024
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ src/js/helpers/osdata.js
src/js/helpers/addressesProxy.js
src/js/helpers/hackneyGeoserver.js
.npmrc
web.config
web.config
.pre-commit-config.yaml
168 changes: 167 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ Object properties:
| `tooltip` | Object | optional | Used to configure the tooltips for the layer. [See Tooltip Options for details](#tooltip-options) |
| `searchable` | Boolean | optional | If `true`, and if there is a `search` object defined for this map, the layer will be included in the search. The layer must have an attribute with the name specified in `searchField` in the `search` object. |
| `listView` | Object | optional | If listView is configured, and if there is a `list` defined for this map, the features of this layer will be listed in an accordion below the map. This object describe which fields are displayed in the list entry. [See ListView Options for details](#listview-options) |
|`spatialEnrichments`|Array| optional | This layer will be enriched with extra attributes using spatial joins (point on area only) as defined in the objects in this list. Where :<br>`geographyLayer` = Source of new attribute, must be the title of a layer in the Layers' Array<br>`sourceAttribute` = Attribute to be copied from enriching layer <br>`targetAttribute` = Attribute name being added as enrichment to this layer<br>|

```javascript
[
{
"geographyLayer": "enriching_layer_title",
"sourceAttribute": "enriching_layer_target_attribute",
"targetAttribute": "attribute_name_to_add_to_this_layer"
}
]
```
> Only available for enriching a points layer only


### Point Style Options

Expand All @@ -180,8 +193,9 @@ Object properties:
| `icon2` | String | optional | A second FontAwesome icon can be used when an advanced style is required (e.g: an outline and a filled colour with different colours). Both icons will be stacked using the FontAwesome data-fa transformations.|
| `markerColor` | String | optional | Colour of the marker when `markerType` is set to `"AwesomeMarker"` or `"CircleMarker"`. See variable `MARKER_COLORS` in `src/js/map/consts.js` to get the list of colours. |
| `markerIcon2` | String | optional | Colour of the second marker when there is a second icon `icon2` is required. See variable `MARKER_COLORS` in `src/js/map/consts.js` to get the list of colours. |
| `cluster` | Boolean | optional | If `true`, Leaflet will use the ClusterMarker plugin up to zoom 17. Beyond zoom 17 the individual markers will be used as defined above. We use a purple cluster style with a level of transparency depending on the size of the cluster. |
| `cluster` | Boolean | optional | If `true`, Leaflet will use the ClusterMarker plugin up to zoom 12 (default), or up to the value specified in the next option. Beyond this zoom threshold, the individual markers will be used as defined above. The clusters are styled using the markerColor option.|
| `disableClusteringAtZoom` | Number | optional | This value is the zoom level at which the clustering will be disabled. It can only be used if the cluster is `true`. If the cluster is `true` and the zoom is empty, the clustering will be disabled at the zoom level 12.|
| `enableSpiderfy` | Boolean | optional | If `true`, Leaflet will use the spiderfyOnMaxZoom option, which means that a cluster might get spiderfied (all markers individual shown) when clicked on. The spiderfy only occurs if all items within the cluster are still clustered at the maximum zoom level or at the zoom level specified by disableClusteringAtZoom option.|

### Line Polygon Options

Expand Down Expand Up @@ -225,6 +239,158 @@ Object properties:
| `title` | String | required | The name of the field to use as the title of the list entry. |
| `fields` | Array | optional | A list of field objects to show in the list entry with the following properties:<br>`label` (String): a label shown in bold before the field value<br>`name` (String): geoserver field name (matches the table column name) |

### Statistics Options

| Option | Type | Required | Description | Default |
| --- | -- | --- | ---- | -- |
| `sectionHeader` | String | optional | The name of the field to use as the title of the Tables section. | `"Tables"` |
| `accordionStatus` | String | Optional | If string "allExplanded" is entered, this will expand all Statistic Accordions on load. | `false`|
| `statisticsTables` | Array | required | A list of Statistic tables to be shown | |

### Statistics Table Options

* To avoid errors, please ommit **any** options **NOT** being used in your Tables.

<details>

> These option can be written in any order however they will be proccessed in the following order when creating a **table**:
1. `filters`
2. `dtypes`
3. `groupBy` + `aggregations` | **OR** | `functions`
4. `labels`
4. `fillNa`
5. `round`
6. `sortBy`
7. `replacers`

</details>
<br>

| Option | Type | Required | Description | Default |
| --- | -- | --- | ---- | -- |
| `tableTitle` | String | required | The name of the field to use as the **Title** of the Statistic Table. | |
| `scope` | Array | required | A list of map layers' titles from the layers for whose data should be referenced in **this** table creation. **Note** These layers must all have the same data schema for the fields beings referenced |
| `filters` | Array | optional | A list of object data filters to be applied to all the data in the **scope** for this table.| `false` |
```json
[
{
"attribute": "Name of field/column | String",
"operator": "condition to check e.g '===' | String",
"value": "value to compare with i.e. check against | String / Number"
}
]
```
>`operator` options:
>- "==="&emsp;&emsp;&emsp;&ensp;--> Equals to value and type (String/Number/Boolean),
>- ">"&emsp;&emsp;&emsp;&emsp;&emsp;--> Greater than value,
>- "<"&emsp;&emsp;&emsp;&emsp;&emsp;--> Less than value,
>- "!=="&emsp;&emsp;&emsp;&emsp;--> Not equal to value and type (String/Number/Boolean),
>- ">="&emsp;&emsp;&emsp;&emsp; --> Greater or equal to value,
>- "<="&emsp;&emsp;&emsp;&emsp; --> Less than or equal to value,
>- "contains"&emsp;&emsp;--> If attribute contains the value substring


| Option | Type | Required | Description | Default |
| --- | -- | --- | ---- | -- |
| `dtypes` | Object | required | An object with `"int32","float32"` Number data types as **keys** and array of **fields** to be cast into each corresponding data type key as **values**. Any column/field that needs an arithmetic operation performed on it will need to be of `Number` type.| `false` |
```json
{
"int32":["field_name_1"],
"float32":["field_name_2","field_name_3"]
}
```
| Option | Type | Required | Description | Default |
| --- | -- | --- | ---- | -- |
| `groupBy` | Array | optional | A list of fields/cloumns to group the data. The **order** of the fields is important to the output. | `false` |
| `aggregations` | Object | conditional | **Required** with a **groupBy** clause!<br> An Object with the field/column names as the **keys** and and Object of **"functions"** key with an arithmetic operations values array as the **values**. | |
```json
{
"field_name_1":{
"functions":["count","mean"],
},
"field_name_2":{
"functions":["count"],
}
}
```
| Option | Type | Required | Description | Default |
| --- | -- | --- | ---- | -- |
| `functions` | Object | conditional | **Cannot** be used in conjuction with **groupBy** and **aggregations**.<br>An object where the name of an operation is the **key** and an array of fields as **values**. Useful for when you need to perform the same operation on different fields and or perform different operations on different fields but displayed on the same table.|`false`|

```json
{
"sum": ["A"],
"count": ["B"]
}
```
>`functions` ***key*** options:
> - `"sum"`, `"count"`, `"median"` ,` "mean"`, `"mode"`, `"max"`,
> - `"var"` --> variance , `"std"` --> standard deviation
>
>`functions`; flag if used will always result into a table like below:
<div style="display:flex; width:100%; justify-content:center;align-items:center;">
<table>
<tr><th>A</th><th>B</th><th></th><th></th><th>column</th><th>value</th></tr>
<tr> <td>1</td><td>2</td><td></td><td>--------></td><td>A_sum</td><td>6</td></tr>
<tr> <td>5</td><td>9</td><td></td><td></td><td>B_count</td><td>2</td></tr>
</table>
</div>
<br>

| Option | Type | Required | Description | Default |
| --- | -- | --- | ---- | -- |
| `labels` | Object | conditional | An object where the the default field/column title after aggregations or applied functions is the **key**, and the renaming String as the **value**. | |
>If using `groupBy` and `aggregations`. The **field/column** `name` + `_operation` become column titles (keys). These can be replaced with user friendly String values.
```json
{
"field_name_1_count":"Number of A",
"field_name_1_mean":"Average Number of A",
"field_name_2_count":"Number of B"
}
```

>If using `functions`
```json
{ "value":" " }
```
> - The table columns default the two labels: column & value.<br> Since the first table column is always **hidden** by Default the empty string will replace the "value" column title. However this could be replaced with any `String`. The table content will need to be replaced by `replacers` <br>(**see below**).


| Option | Type | Required | Description | Default |
| --- | -- | --- | ---- | -- |
| `replacers` | Array | optional | Mostly useful when using functions. A list of operation to change/replace entries in the resultant Table. Each object entry will need an **attribute**, a **value**, and a **replacerValue**.| `false` |
```json
[
{
"attribute" : "field/column name from resulting table | String",
"value" : "target value_to_replace | String / Number",
"replacerValue": "Value to replace with | String"
}
]
```
> ***Note*** Table attribute/column names from using functions will default to column and value
<br>


| Option | Type | Required | Description | Default |
| --- | -- | --- | ---- | -- |
| `sortBy` | Object | Optional | An object of resulting Table's field/column names as keys and sort order as values. Sorting will be handled in the order of the given keys and sort direction. Defaults to **false**. | `false` |
```json
{
"column_A":"ascending",
"column_B":"descending"
}
```

>The final Table will result in data sorted by first column_A ascending, then by column_B descending.<br>
***Note*** If any columns have been **renamed/replaced**, please use the new names.
<br>

| Option | Type | Required | Description | Default |
| --- | -- | --- | ---- | -- |
| `round` | Object | optional | An object of resulting Table's field/column names as keys and the Number of decimal places to round the column data to:<br>e.g. ```{"column_A":2}``` will round column_A to **2** decimal places.|`false` |
| `fillNa` | Object | optional | An object of resulting Table's field/column names as keys and the value to fill the data with as value:<br> e.g. ```{"column_A":0}``` will fill the resulting table with 0 in column_A where the values are **NaN**.| `false` |


## Troubleshooting

Expand Down
2 changes: 1 addition & 1 deletion dist/lbh-webmap.min.css

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions dist/lbh-webmap.min.js

Large diffs are not rendered by default.

Loading