@flourish/legend
Advanced tools
Comparing version 6.3.0 to 6.4.0
{ | ||
"name": "@flourish/legend", | ||
"version": "6.3.0", | ||
"version": "6.4.0", | ||
"description": "Flourish module for making legend", | ||
@@ -11,3 +11,3 @@ "main": "legend.js", | ||
"prepare": "npm run build && npm run minify", | ||
"minify": "uglifyjs -m -o legend.min.js legend.js", | ||
"minify": "terser -m -o legend.min.js legend.js", | ||
"precommit": "lint-staged" | ||
@@ -32,3 +32,3 @@ }, | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"uglify-js": "^3.4.9" | ||
"terser": "^5.7.1" | ||
}, | ||
@@ -35,0 +35,0 @@ "repository": { |
@@ -0,1 +1,6 @@ | ||
# 6.4.0 | ||
* Ensure continuous legend has access to font propertie | ||
* Support custom end labels with binned legends | ||
* Reinstate greater default legend items padding | ||
# 6.3.0 | ||
@@ -2,0 +7,0 @@ * Add spike symbol to continuous size legend |
@@ -47,4 +47,11 @@ import { select } from "d3-selection"; | ||
var font = { | ||
family: font_family, | ||
weight: font_weight, | ||
size: font_size, | ||
color: font_color | ||
}; | ||
this._legends.forEach(function(legend) { | ||
if (legend && typeof legend.update == "function") legend.update(); | ||
if (legend && typeof legend.update == "function") legend.update(font); | ||
}); | ||
@@ -51,0 +58,0 @@ |
@@ -5,3 +5,2 @@ import { select } from "d3-selection"; | ||
import { remToPx } from "../utils"; | ||
import { font_color, font_family, font_size, font_weight } from "../container"; | ||
@@ -87,3 +86,3 @@ var legend_count = 0; | ||
ContinuousColorLegend.prototype.update = function() { | ||
ContinuousColorLegend.prototype.update = function(font) { | ||
var should_display = this._state.show_legend && this._visible && this._legend_domain.length > 0; | ||
@@ -96,3 +95,3 @@ | ||
this._updateTitle(); | ||
this._updateLegend(); | ||
this._updateLegend(font); | ||
@@ -102,3 +101,3 @@ return this; | ||
ContinuousColorLegend.prototype._updateLegend = function() { | ||
ContinuousColorLegend.prototype._updateLegend = function(font) { | ||
var domain = this._legend_domain; | ||
@@ -118,3 +117,3 @@ reading_direction = document.body.getAttribute("dir"); | ||
this._container.style("display", "inline-flex") | ||
.style("align-items", "center"); | ||
.style("align-items", this._scale_type == "continuous" ? "center" : "flex-start"); | ||
@@ -180,6 +179,6 @@ this._container.select(".color-range-container") | ||
this._updateLegendLabels(); | ||
this._updateLegendLabels(font); | ||
}; | ||
ContinuousColorLegend.prototype._updateLegendLabels = function () { | ||
ContinuousColorLegend.prototype._updateLegendLabels = function (font = {}) { | ||
var label_canvas = this._container.select(".color-range-labels"); | ||
@@ -192,3 +191,3 @@ var format = this._formatFunction; | ||
.select(".min.label") | ||
.style("display", this._scale_type == "continuous" ? "inline-flex" : "none") | ||
.style("display", "inline-flex") | ||
.style("align-items", "center") | ||
@@ -202,2 +201,3 @@ .style("vertical-align", "middle") | ||
min_label_container.select(".number") | ||
.style("display", this._scale_type == "continuous" ? null : "none") | ||
.text(function () { | ||
@@ -217,3 +217,3 @@ return format ? format(domain.min) : domain.min; | ||
.select(".max.label") | ||
.style("display", this._scale_type == "continuous" ? "inline-flex" : "none") | ||
.style("display", "inline-flex") | ||
.style("align-items", "center") | ||
@@ -227,2 +227,3 @@ .style("vertical-align", "middle") | ||
max_label_container.select(".number") | ||
.style("display", this._scale_type == "continuous" ? null : "none") | ||
.text(function () { | ||
@@ -240,3 +241,2 @@ return format ? format(domain.max) : domain.max; | ||
var labels = []; | ||
@@ -252,3 +252,3 @@ var label_padding_start = 0; | ||
ctx.textBaseline = "top"; | ||
ctx.font = font_weight + " " + remToPx(font_size) + "px " + font_family; | ||
ctx.font = font.weight + " " + remToPx(font.size) + "px " + font.family; | ||
@@ -297,3 +297,3 @@ var prepLabel = (function () { | ||
var label_canvas_width = remToPx(s.color_band_width) + label_padding_start + label_padding_end; | ||
var label_h = Math.ceil(remToPx(font_size) * 0.95); | ||
var label_h = Math.ceil(remToPx(font.size) * 0.95); | ||
var pixel_ratio = window.devicePixelRatio || 1; | ||
@@ -313,4 +313,4 @@ | ||
ctx.textBaseline = "top"; | ||
ctx.font = font_weight + " " + remToPx(font_size) + "px " + font_family; | ||
ctx.fillStyle = font_color; | ||
ctx.font = font.weight + " " + remToPx(font.size) + "px " + font.family; | ||
ctx.fillStyle = font.color; | ||
@@ -317,0 +317,0 @@ prepped_labels.forEach(function(label) { |
@@ -17,3 +17,3 @@ import { select, event as d3_event } from "d3-selection"; | ||
swatch_radius: 3, | ||
legend_items_padding: 0.2, | ||
legend_items_padding: 0.5, | ||
@@ -20,0 +20,0 @@ icon_height: 1, |
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
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
201440
5040