Skip to content

Commit

Permalink
Merge pull request #409 from NASA-AMMOS/jr-legend-justify
Browse files Browse the repository at this point in the history
Allow the legend tool to be right justified on the screen
  • Loading branch information
jtroberts authored Aug 8, 2023
2 parents 1984777 + ba30c8d commit 6b881cb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
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

0 comments on commit 6b881cb

Please sign in to comment.