Skip to content

Commit

Permalink
increases default lineHeight mod to 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
davelandry committed Aug 19, 2017
1 parent dbb9cea commit 01538f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/TextBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {transition} from "d3-transition";
import {max, min, sum} from "d3-array";

import {accessor, BaseClass, constant} from "d3plus-common";
import {default as textSplit} from "./textSplit";
import {default as measure} from "./textWidth";
import {default as wrap} from "./textWrap";
import textSplit from "./textSplit";
import measure from "./textWidth";
import wrap from "./textWrap";
import {trimRight} from "./trim";

/**
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class TextBox extends BaseClass {
render(callback) {

if (this._select === void 0) this.select(select("body").append("svg").style("width", `${window.innerWidth}px`).style("height", `${window.innerHeight}px`).node());
if (this._lineHeight === void 0) this._lineHeight = (d, i) => this._fontSize(d, i) * 1.1;
if (this._lineHeight === void 0) this._lineHeight = (d, i) => this._fontSize(d, i) * 1.4;
const that = this;

const boxes = this._select.selectAll(".d3plus-textBox").data(this._data.reduce((arr, d, i) => {
Expand All @@ -74,7 +74,7 @@ export default class TextBox extends BaseClass {
const resize = this._fontResize(d, i);

let fS = resize ? this._fontMax(d, i) : this._fontSize(d, i),
lH = resize ? fS * 1.1 : this._lineHeight(d, i),
lH = resize ? fS * 1.4 : this._lineHeight(d, i),
line = 1,
lineData = [],
sizes;
Expand Down Expand Up @@ -116,7 +116,7 @@ export default class TextBox extends BaseClass {
else if (fS > fMax) fS = fMax;

if (resize) {
lH = fS * 1.1;
lH = fS * 1.4;
wrapper
.fontSize(fS)
.lineHeight(lH);
Expand All @@ -143,7 +143,7 @@ export default class TextBox extends BaseClass {

}

if (w > fMin && (h > lH || resize && h > fMin * 1.1)) {
if (w > fMin && (h > lH || resize && h > fMin * 1.4)) {

if (resize) {

Expand Down Expand Up @@ -430,7 +430,7 @@ function(d, i) {

/**
@memberof TextBox
@desc Sets the line height to the specified accessor function or static number, which is 1.1 times the [font size](#textBox.fontSize) by default.
@desc Sets the line height to the specified accessor function or static number, which is 1.4 times the [font size](#textBox.fontSize) by default.
@param {Function|Number} [*value*]
*/
lineHeight(_) {
Expand Down
8 changes: 4 additions & 4 deletions src/textWrap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {default as measure} from "./textWidth";
import {default as defaultSplit} from "./textSplit";
import {default as stringify} from "./stringify";
import measure from "./textWidth";
import defaultSplit from "./textSplit";
import stringify from "./stringify";
import {trimRight} from "./trim";

/**
Expand All @@ -26,7 +26,7 @@ export default function() {

sentence = stringify(sentence);

if (lineHeight === void 0) lineHeight = Math.ceil(fontSize * 1.1);
if (lineHeight === void 0) lineHeight = Math.ceil(fontSize * 1.4);

const words = split(sentence);

Expand Down

0 comments on commit 01538f7

Please sign in to comment.