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

Allow the legend tool to be right justified on the screen #409

Merged
merged 2 commits into from
Aug 8, 2023
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
8 changes: 6 additions & 2 deletions docs/pages/Tools/Legend/Legend.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ parent: Tools

A layer can be configured with a legend by pointing its Legend field to a .csv file or by including a JSON `legend` array into the layer's Raw Variables. The Legend Tool renders symbologies and gradient scales for any properly configured on layer.

On the Configure page, under Tools, you can specify if the expanded legend should automatically be displayed on start:
On the Configure page, under Tools, you can specify additional options:

* displayOnStart: Whether the expanded legend should automatically be displayed on start (`true`/`false`)
* justification: The legend will display on the right side of the screen if set to `right`, otherwise default to the left side

```javascript
{
"displayOnStart": true
"displayOnStart": true,
"justification": "right"
}
```

Expand Down
11 changes: 11 additions & 0 deletions src/essence/Tools/Legend/LegendTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@ var LegendTool = {
targetId: null,
made: false,
displayOnStart: false,
justification: 'left',
initialize: function () {
//Get tool variables
this.displayOnStart = L_.getToolVars('legend')['displayOnStart']
this.justification = L_.getToolVars('legend')['justification']
if (this.justification == 'right') {
var toolController = d3.select('#toolcontroller_sepdiv')
var toolContent = d3.select('#toolContentSeparated_Legend')
toolController.style('top', '110px')
toolController.style('left', null)
toolController.style('right', '5px')
toolContent.style('left', null)
toolContent.style('right', '0px')
}
},
make: function (targetId) {
this.targetId = targetId
Expand Down
8 changes: 7 additions & 1 deletion src/essence/Tools/Legend/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"defaultIcon": "map-legend",
"description": "Show a chart mapping colors and symbols to meaning.",
"descriptionFull": "",
"descriptionFull": {
"title": "Show a chart legend that maps colors and symbols to meaning.",
"example": {
"displayOnStart": true,
"justification": "right"
}
},
"hasVars": true,
"name": "Legend",
"toolbarPriority": 2,
Expand Down