@flourish/legend
Advanced tools
Comparing version 2.2.0 to 3.0.0
{ | ||
"name": "@flourish/legend", | ||
"version": "2.2.0", | ||
"version": "3.0.0", | ||
"description": "Flourish module for making legend", | ||
@@ -5,0 +5,0 @@ "main": "legend.js", |
@@ -153,3 +153,7 @@ # Flourish legend component | ||
`legend.autoTitle(string)` | ||
Sets the automatic title for the legend. This could be a column name for example. | ||
## Multiple legend instances | ||
@@ -156,0 +160,0 @@ |
@@ -0,1 +1,4 @@ | ||
# 3.0.0 | ||
* Add `autoTitle` method | ||
# 2.2.0 | ||
@@ -2,0 +5,0 @@ * Add `markerValue` method to continuous color legend |
@@ -30,9 +30,20 @@ function appendTo(container) { | ||
function autoTitle() { | ||
var auto_title = ""; | ||
return function (value) { | ||
if (value === undefined) return auto_title; | ||
auto_title = value; | ||
return this; | ||
}; | ||
} | ||
function _updateTitle() { | ||
var _this = this; | ||
var title = _this._state.title_mode == "auto" ? this.autoTitle() : _this._state.title; | ||
this._container.select(".fl-legend-title") | ||
.text(this._state.title) | ||
.text(title) | ||
.style("display", function() { | ||
if (!_this._state.title.trim()) return "none"; | ||
if (!title.trim()) return "none"; | ||
else if (_this._state.orientation === undefined) return "inline-block"; | ||
@@ -51,2 +62,2 @@ else return _this._state.orientation == "horizontal" ? "inline-block" : "block"; | ||
export { appendTo, format, getContainer, visible, _updateTitle }; | ||
export { appendTo, format, getContainer, visible, autoTitle, _updateTitle }; |
import { select } from "d3-selection"; | ||
import { scaleLinear } from "d3-scale"; | ||
import { appendTo, format, getContainer, visible, _updateTitle } from "../common"; | ||
import { appendTo, format, getContainer, visible, autoTitle, _updateTitle } from "../common"; | ||
import { remToPx } from "../utils"; | ||
@@ -10,2 +10,3 @@ | ||
title_mode: "auto", | ||
title: "", | ||
@@ -54,2 +55,3 @@ title_weight: "bold", | ||
ContinuousColorLegend.prototype.visible = visible; | ||
ContinuousColorLegend.prototype.autoTitle = autoTitle(); | ||
ContinuousColorLegend.prototype._updateTitle = _updateTitle; | ||
@@ -56,0 +58,0 @@ |
import { select } from "d3-selection"; | ||
import { appendTo, format, getContainer, visible, _updateTitle } from "../common"; | ||
import { appendTo, format, getContainer, visible, autoTitle, _updateTitle } from "../common"; | ||
import { remToPx, roundDown } from "../utils"; | ||
@@ -9,2 +9,3 @@ | ||
title_mode: "auto", | ||
title: "", | ||
@@ -61,2 +62,3 @@ title_weight: "bold", | ||
ContinuousSizeLegend.prototype.format = format; | ||
ContinuousSizeLegend.prototype.autoTitle = autoTitle(); | ||
ContinuousSizeLegend.prototype._updateTitle = _updateTitle; | ||
@@ -63,0 +65,0 @@ ContinuousSizeLegend.prototype.getContainer = getContainer; |
import { select, event as d3_event } from "d3-selection"; | ||
import { appendTo, format, getContainer, visible, _updateTitle } from "../common"; | ||
import { appendTo, format, getContainer, visible, autoTitle, _updateTitle } from "../common"; | ||
@@ -8,2 +8,3 @@ var legend_count = 0; | ||
title_mode: "auto", | ||
title: "", | ||
@@ -48,2 +49,3 @@ title_weight: "bold", | ||
DiscreteColorLegend.prototype.visible = visible; | ||
DiscreteColorLegend.prototype.autoTitle = autoTitle(); | ||
DiscreteColorLegend.prototype._updateTitle = _updateTitle; | ||
@@ -50,0 +52,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
163492
4157
212
0