Socket
Socket
Sign inDemoInstall

@fishawack/lab-d3

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fishawack/lab-d3 - npm Package Compare versions

Comparing version 2.7.2 to 2.8.0

3

CHANGELOG.md
## Changelog
### 2.8.0 (2021-03-09)
* [Feature] Can now have line breaks in text by adding <br> tags
### 2.7.2 (2021-03-03)

@@ -4,0 +7,0 @@ * [Feature] Band and Point scales can now have their axis tick values hard coded

7

package.json
{
"name": "@fishawack/lab-d3",
"version": "2.7.2",
"version": "2.8.0",
"description": "Abstract layer built on top of d3",

@@ -13,4 +13,5 @@ "scripts": {

"test": "npm test --prefix node_modules/@fishawack/core/",
"prepublishOnly": "rimraf src && mkdir src && npm test",
"pretest": "rimraf src && mkdir src && babel _Build/js/ --out-dir src/ --ignore \"_Build/js/script.js\",\"_Build/js/archive/**/*.js\",\"_Build/js/generated/**/*.js\",\"_Build/js/libs/archive/**/*.js\",\"_Build/js/libs/*.js\""
"pretest": "rimraf src && mkdir src && babel _Build/js/ --out-dir src/ --ignore \"_Build/js/script.js\",\"_Build/js/archive/**/*.js\",\"_Build/js/generated/**/*.js\",\"_Build/js/libs/archive/**/*.js\",\"_Build/js/libs/*.js\"",
"preversion": "lab-env test",
"postversion": "git push && git push --tags && npm publish"
},

@@ -17,0 +18,0 @@ "license": "BSD-3-Clause",

@@ -134,26 +134,39 @@ "use strict";

text.each(function () {
var text = d3.select(this),
words = text.text().split(/\s+/).reverse(),
word = words.pop(),
line = [],
lineNumber = 0,
lineHeight = 1.1,
// ems
x = text.attr("x") || 0,
y = text.attr("y") || 0,
dy = parseFloat(text.attr("dy")) || 0,
tspan = text.text(null).append("tspan").attr("x", x).attr("y", y).attr("dy", dy + "em");
var text = d3.select(this);
var breaks = text.text().split(/<br>/).reverse();
var breakage = breaks.pop();
var line = [];
var lineNumber = 0;
var lineHeight = 1.1; // ems
while (word) {
line.push(word);
tspan.text(line.join(" "));
var x = text.attr("x") || 0;
var y = text.attr("y") || 0;
var dy = parseFloat(text.attr("dy")) || 0;
var tspan = text.text(null).append("tspan").attr("x", x).attr("y", y).attr("dy", dy + "em");
if (tspan.node().getComputedTextLength() > width && line.length > 1) {
line.pop();
while (breakage != null) {
var words = breakage.split(/\s+/).reverse();
var word = words.pop();
while (word != null) {
line.push(word || " "); // Insert hidden &ensp; char when empty so height calculations are still accurate
tspan.text(line.join(" "));
line = [word];
if (tspan.node().getComputedTextLength() > width && line.length > 1) {
line.pop();
tspan.text(line.join(" "));
line = [word];
tspan = text.append("tspan").attr("x", x).attr("y", y).attr("dy", ++lineNumber * lineHeight + dy + "em").text(word);
}
word = words.pop();
}
breakage = breaks.pop();
if (breakage != null) {
tspan = text.append("tspan").attr("x", x).attr("y", y).attr("dy", ++lineNumber * lineHeight + dy + "em").text(word);
line = [];
}
word = words.pop();
}

@@ -160,0 +173,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc