Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and the versioning aim to respect [Semantic Versioning](http://semver.org/spec/v

Here is a template for new release sections

## [Unreleased]
### Added
- title and unit for choropleths in legend

## [0.8.0] - 2023-05-02
### Added
- default choropleth config
Expand Down
9 changes: 8 additions & 1 deletion django_mapengine/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class Choropleth:
"""Choropleth class used to set up choropleths in project settings"""

name: str
title: str
unit: str
layers: List[str]
use_feature_state: bool = True

Expand All @@ -116,7 +118,12 @@ def as_dict(self) -> dict:
dict
holding choropleth values needed in map setups
"""
return {"layers": self.layers, "useFeatureState": self.use_feature_state}
return {
"title": self.title,
"unit": self.unit,
"layers": self.layers,
"useFeatureState": self.use_feature_state,
}


@dataclass
Expand Down
5 changes: 3 additions & 2 deletions django_mapengine/static/django_mapengine/js/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const createLegend = (title, unit, colors, valueRanges, nextColumnStartIndex = 3


function loadLegend(msg, choroplethName){
const unit = "unit"; //need value!
const title = map_store.cold.choropleths[choroplethName]["title"];
const unit = map_store.cold.choropleths[choroplethName]["unit"];
const paintPropertiesPerLayer = map_store.cold.storedChoroplethPaintProperties[choroplethName];

/* Find active layer */
Expand Down Expand Up @@ -75,6 +76,6 @@ function loadLegend(msg, choroplethName){
}
}
const entriesPerColumn = Math.floor(values.length / 2);
legendElement.innerHTML = createLegend(choroplethName, unit, colors, values, entriesPerColumn);
legendElement.innerHTML = createLegend(title, unit, colors, values, entriesPerColumn);
return logMessage(msg);
}
2 changes: 2 additions & 0 deletions tests/django_test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

INSTALLED_APPS = ["django_mapengine", "tests.test_app.apps.TestConf"]

ROOT_URLCONF = "django_mapengine.urls"

MAP_ENGINE_CENTER_AT_STARTUP = [1, 2]
MAP_ENGINE_ZOOM_AT_STARTUP = 8

Expand Down