victory-core
Advanced tools
Comparing version 34.3.12 to 35.0.0
@@ -101,4 +101,6 @@ import * as React from "react"; | ||
export type VictoryNumberCallback = (args: CallbackArgs) => number; | ||
export type VictoryPaddingCallback = (args: CallbackArgs) => number | BlockProps; | ||
export type StringOrNumberOrCallback = string | number | VictoryStringOrNumberCallback; | ||
export type NumberOrCallback = number | VictoryNumberCallback; | ||
export type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback; | ||
@@ -397,2 +399,29 @@ export type SliceNumberOrCallback<T, P = null> = number | ((props: Omit<T, P>) => number); | ||
} & ThemeBaseProps; | ||
polarAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
}; | ||
} & ThemeBaseProps; | ||
polarDependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
}; | ||
} & ThemeBaseProps; | ||
polarIndependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
}; | ||
} & ThemeBaseProps; | ||
scatter?: { | ||
@@ -410,2 +439,3 @@ style?: { | ||
pointerLength?: number; | ||
flyoutPadding?: number; | ||
}; | ||
@@ -412,0 +442,0 @@ voronoi?: { |
@@ -67,2 +67,13 @@ import _isEmpty from "lodash/isEmpty"; | ||
var getSingleValue = function (prop) { | ||
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
return Array.isArray(prop) ? prop[index] || prop[0] : prop; | ||
}; | ||
var useMultiLineBackgrounds = function (props) { | ||
var backgroundStyle = props.backgroundStyle, | ||
backgroundPadding = props.backgroundPadding; | ||
return Array.isArray(backgroundStyle) && !_isEmpty(backgroundStyle) || Array.isArray(backgroundPadding) && !_isEmpty(backgroundPadding); | ||
}; | ||
var getStyles = function (style, props) { | ||
@@ -79,11 +90,33 @@ var getSingleStyle = function (s) { | ||
return getSingleStyle(s); | ||
}) : [getSingleStyle(style)]; | ||
}) : getSingleStyle(style); | ||
}; | ||
var getHeight = function (props, type) { | ||
return Helpers.evaluateProp(props[type], props); | ||
var getBackgroundStyles = function (style, props) { | ||
if (!style) { | ||
return undefined; | ||
} | ||
return Array.isArray(style) && !_isEmpty(style) ? style.map(function (s) { | ||
return Helpers.evaluateStyle(s, props); | ||
}) : Helpers.evaluateStyle(style); | ||
}; | ||
var getBackgroundPadding = function (props) { | ||
if (props.backgroundPadding && Array.isArray(props.backgroundPadding)) { | ||
return props.backgroundPadding.map(function (backgroundPadding) { | ||
var padding = Helpers.evaluateProp(backgroundPadding, props); | ||
return Helpers.getPadding({ | ||
padding: padding | ||
}); | ||
}); | ||
} else { | ||
var padding = Helpers.evaluateProp(props.backgroundPadding, props); | ||
return Helpers.getPadding({ | ||
padding: padding | ||
}); | ||
} | ||
}; | ||
var getLineHeight = function (props) { | ||
var lineHeight = getHeight(props, "lineHeight"); | ||
var lineHeight = Helpers.evaluateProp(props.lineHeight, props); | ||
@@ -93,3 +126,3 @@ if (Array.isArray(lineHeight)) { | ||
} else { | ||
return [lineHeight]; | ||
return lineHeight; | ||
} | ||
@@ -118,21 +151,28 @@ }; | ||
var getDy = function (props, lineHeight) { | ||
var style = Array.isArray(props.style) ? props.style[0] : props.style; | ||
lineHeight = lineHeight[0]; | ||
var fontSize = style.fontSize; | ||
var getDy = function (props, verticalAnchor, lineHeight) { | ||
var dy = props.dy ? Helpers.evaluateProp(props.dy, props) : 0; | ||
var length = props.inline ? 1 : props.text.length; | ||
var capHeight = getHeight(props, "capHeight"); | ||
var verticalAnchor = style.verticalAnchor || props.verticalAnchor; | ||
var capHeight = Helpers.evaluateProp(props.capHeight, props); | ||
var anchor = verticalAnchor ? Helpers.evaluateProp(verticalAnchor, props) : "middle"; | ||
switch (anchor) { | ||
case "end": | ||
return dy + (capHeight / 2 + (0.5 - length) * lineHeight) * fontSize; | ||
var fontSizes = _toConsumableArray(Array(length).keys()).map(function (i) { | ||
return getSingleValue(props.style, i).fontSize; | ||
}); | ||
case "middle": | ||
return dy + (capHeight / 2 + (0.5 - length / 2) * lineHeight) * fontSize; | ||
var lineHeights = _toConsumableArray(Array(length).keys()).map(function (i) { | ||
return getSingleValue(lineHeight, i); | ||
}); | ||
default: | ||
return dy + (capHeight / 2 + lineHeight / 2) * fontSize; | ||
if (anchor === "start") { | ||
return dy + (capHeight / 2 + lineHeights[0] / 2) * fontSizes[0]; | ||
} else if (props.inline) { | ||
return anchor === "end" ? dy + (capHeight / 2 - lineHeights[0] / 2) * fontSizes[0] : dy + capHeight / 2 * fontSizes[0]; | ||
} else if (length === 1) { | ||
return anchor === "end" ? dy + (capHeight / 2 + (0.5 - length) * lineHeights[0]) * fontSizes[0] : dy + (capHeight / 2 + (0.5 - length / 2) * lineHeights[0]) * fontSizes[0]; | ||
} else { | ||
var allHeights = _toConsumableArray(Array(length).keys()).reduce(function (memo, i) { | ||
return memo + (capHeight / 2 - lineHeights[i]) * fontSizes[i]; | ||
}, 0); | ||
return anchor === "end" ? dy + allHeights : dy + allHeights / 2 + capHeight / 2 * lineHeights[length - 1] * fontSizes[length - 1]; | ||
} | ||
@@ -144,4 +184,4 @@ }; | ||
y = props.y, | ||
polar = props.polar, | ||
style = props.style; | ||
polar = props.polar; | ||
var style = getSingleValue(props.style); | ||
var defaultAngle = polar ? LabelHelpers.getPolarAngle(props) : 0; | ||
@@ -161,3 +201,4 @@ var baseAngle = style.angle === undefined ? props.angle : style.angle; | ||
textAnchor = calculatedProps.textAnchor, | ||
x = calculatedProps.x; | ||
x = calculatedProps.x, | ||
dx = calculatedProps.dx; | ||
@@ -169,5 +210,2 @@ if (direction === "rtl") { | ||
switch (textAnchor) { | ||
case "start": | ||
return x; | ||
case "middle": | ||
@@ -180,12 +218,13 @@ return Math.round(x - labelSizeWidth / 2); | ||
default: | ||
return x; | ||
// start | ||
return x + (dx || 0); | ||
} | ||
}; | ||
var getYCoordinate = function (calculatedProps, props, textHeight) { | ||
var getYCoordinate = function (calculatedProps, textHeight) { | ||
var verticalAnchor = calculatedProps.verticalAnchor, | ||
y = calculatedProps.y; | ||
var dy = props.dy, | ||
inline = props.inline; | ||
var offset = y + (dy || 0); | ||
y = calculatedProps.y, | ||
_calculatedProps$orig = calculatedProps.originalDy, | ||
originalDy = _calculatedProps$orig === void 0 ? 0 : _calculatedProps$orig; | ||
var offset = y + originalDy; | ||
@@ -196,42 +235,22 @@ switch (verticalAnchor) { | ||
case "middle": | ||
return Math.floor(offset - textHeight / 2); | ||
case "end": | ||
return inline ? Math.floor(offset) : Math.ceil(offset - textHeight); | ||
return Math.ceil(offset - textHeight); | ||
default: | ||
return inline ? Math.floor(offset) : Math.floor(offset - textHeight / 2); | ||
// middle | ||
return Math.floor(offset - textHeight / 2); | ||
} | ||
}; | ||
var getBackgroundPadding = function (props) { | ||
if (props.backgroundPadding && Array.isArray(props.backgroundPadding)) { | ||
return props.backgroundPadding.map(function (backgroundPadding) { | ||
return Helpers.getPadding({ | ||
backgroundPadding: backgroundPadding | ||
}, "backgroundPadding"); | ||
}); | ||
} else { | ||
return Helpers.getPadding(props, "backgroundPadding"); | ||
} | ||
}; | ||
var getBackgroundPaddingProp = function (i, backgroundPadding) { | ||
if (Array.isArray(backgroundPadding)) { | ||
return backgroundPadding[i] || backgroundPadding[0]; | ||
} else { | ||
return backgroundPadding; | ||
} | ||
}; | ||
var getFullBackground = function (props, calculatedProps, tspanValues) { | ||
var backgroundComponent = props.backgroundComponent, | ||
backgroundStyle = props.backgroundStyle, | ||
inline = props.inline; | ||
var dx = calculatedProps.dx, | ||
var getFullBackground = function (calculatedProps, tspanValues) { | ||
var _calculatedProps$dx = calculatedProps.dx, | ||
dx = _calculatedProps$dx === void 0 ? 0 : _calculatedProps$dx, | ||
transform = calculatedProps.transform, | ||
backgroundComponent = calculatedProps.backgroundComponent, | ||
backgroundStyle = calculatedProps.backgroundStyle, | ||
inline = calculatedProps.inline, | ||
backgroundPadding = calculatedProps.backgroundPadding, | ||
transform = calculatedProps.transform; | ||
capHeight = calculatedProps.capHeight; | ||
var textSizes = tspanValues.map(function (tspan) { | ||
return TextSize.approximateTextSize(tspan.text, tspan.style); | ||
return tspan.textSize; | ||
}); | ||
@@ -241,11 +260,13 @@ var height = inline ? Math.max.apply(Math, _toConsumableArray(textSizes.map(function (size) { | ||
}))) : textSizes.reduce(function (memo, size, i) { | ||
return memo + size.height * tspanValues[i].lineHeight; | ||
var capHeightAdjustment = i ? capHeight / 2 : 0; | ||
return memo + size.height * (tspanValues[i].lineHeight - capHeightAdjustment); | ||
}, 0); | ||
var width = inline ? textSizes.reduce(function (memo, size) { | ||
return memo + size.width; | ||
}, 0) + (dx || 0) : Math.max.apply(Math, _toConsumableArray(textSizes.map(function (size) { | ||
var width = inline ? textSizes.reduce(function (memo, size, index) { | ||
var offset = index ? dx : 0; | ||
return memo + size.width + offset; | ||
}, 0) : Math.max.apply(Math, _toConsumableArray(textSizes.map(function (size) { | ||
return size.width; | ||
}))) + (dx || 0); | ||
}))); | ||
var xCoordinate = getXCoordinate(calculatedProps, width); | ||
var yCoordinate = getYCoordinate(calculatedProps, props, height); | ||
var yCoordinate = getYCoordinate(calculatedProps, height); | ||
var backgroundProps = { | ||
@@ -257,3 +278,3 @@ key: "background", | ||
width: width + backgroundPadding.left + backgroundPadding.right, | ||
x: xCoordinate, | ||
x: inline ? xCoordinate - backgroundPadding.left : xCoordinate + dx - backgroundPadding.left, | ||
y: yCoordinate | ||
@@ -264,20 +285,58 @@ }; | ||
var getChildBackgrounds = function (props, calculatedProps, tspanValues) { | ||
var backgroundStyle = props.backgroundStyle, | ||
backgroundComponent = props.backgroundComponent, | ||
inline = props.inline, | ||
y = props.y; | ||
var getInlineXOffset = function (calculatedProps, textElements, index) { | ||
var textAnchor = calculatedProps.textAnchor; | ||
var widths = textElements.map(function (t) { | ||
return t.widthWithPadding; | ||
}); | ||
var totalWidth = widths.reduce(function (memo, width) { | ||
return memo + width; | ||
}, 0); | ||
var centerOffset = -totalWidth / 2; | ||
switch (textAnchor) { | ||
case "start": | ||
return widths.reduce(function (memo, width, i) { | ||
memo = i < index ? memo + width : memo; | ||
return memo; | ||
}, 0); | ||
case "end": | ||
return widths.reduce(function (memo, width, i) { | ||
memo = i > index ? memo - width : memo; | ||
return memo; | ||
}, 0); | ||
default: | ||
// middle | ||
return widths.reduce(function (memo, width, i) { | ||
var offsetWidth = i < index ? width : 0; | ||
memo = i === index ? memo + width / 2 : memo + offsetWidth; | ||
return memo; | ||
}, centerOffset); | ||
} | ||
}; | ||
var getChildBackgrounds = function (calculatedProps, tspanValues) { | ||
var dy = calculatedProps.dy, | ||
dx = calculatedProps.dx, | ||
transform = calculatedProps.transform, | ||
backgroundStyle = calculatedProps.backgroundStyle, | ||
backgroundPadding = calculatedProps.backgroundPadding, | ||
transform = calculatedProps.transform; | ||
backgroundComponent = calculatedProps.backgroundComponent, | ||
inline = calculatedProps.inline, | ||
y = calculatedProps.y; | ||
var textElements = tspanValues.map(function (current, i) { | ||
var previous = tspanValues[i - 1] || tspanValues[0]; | ||
var labelSize = TextSize.approximateTextSize(current.text, current.style); | ||
var previous = getSingleValue(tspanValues, i - 1); | ||
var labelSize = current.textSize; | ||
var totalLineHeight = current.fontSize * current.lineHeight; | ||
var textHeight = Math.ceil(totalLineHeight); | ||
var prevPaddingProp = getBackgroundPaddingProp(i - 1, backgroundPadding); | ||
var childDy = i && !inline ? previous.fontSize * previous.lineHeight + prevPaddingProp.top + prevPaddingProp.bottom : dy - totalLineHeight * 0.5 - (current.fontSize - current.capHeight); | ||
var padding = getSingleValue(backgroundPadding, i); | ||
var prevPadding = getSingleValue(backgroundPadding, i - 1); | ||
var xOffset = inline ? dx || 0 : 0; | ||
var childDy = i && !inline ? previous.fontSize * previous.lineHeight + prevPadding.top + prevPadding.bottom : dy - totalLineHeight * 0.5 - (current.fontSize - current.capHeight); | ||
return { | ||
textHeight: textHeight, | ||
labelSize: labelSize, | ||
heightWithPadding: textHeight + padding.top + padding.bottom, | ||
widthWithPadding: labelSize.width + padding.left + padding.right + xOffset, | ||
y: y, | ||
@@ -293,11 +352,14 @@ fontSize: current.fontSize, | ||
}, y); | ||
var padding = getBackgroundPaddingProp(i, backgroundPadding); | ||
var padding = getSingleValue(backgroundPadding, i); | ||
var height = textElement.heightWithPadding; | ||
var xCoord = inline ? getInlineXOffset(calculatedProps, textElements, i) + xCoordinate - padding.left : xCoordinate; | ||
var yCoord = inline ? getYCoordinate(calculatedProps, height) - padding.top : yCoordinate; | ||
var backgroundProps = { | ||
key: "tspan-background-".concat(i), | ||
height: textElement.textHeight + padding.top + padding.bottom, | ||
style: backgroundStyle[i] || backgroundStyle[0], | ||
width: textElement.labelSize.width + padding.left + padding.right, | ||
height: height, | ||
style: getSingleValue(backgroundStyle, i), | ||
width: textElement.widthWithPadding, | ||
transform: transform, | ||
x: xCoordinate, | ||
y: yCoordinate | ||
x: xCoord - padding.left, | ||
y: yCoord | ||
}; | ||
@@ -308,18 +370,23 @@ return React.cloneElement(backgroundComponent, _defaults({}, backgroundComponent.props, backgroundProps)); | ||
var getBackgroundElement = function (props, calculatedProps, tspanValues) { | ||
return Array.isArray(props.backgroundStyle) ? getChildBackgrounds(props, calculatedProps, tspanValues) : getFullBackground(props, calculatedProps, tspanValues); | ||
var getBackgroundElement = function (calculatedProps, tspanValues) { | ||
return useMultiLineBackgrounds(calculatedProps) ? getChildBackgrounds(calculatedProps, tspanValues) : getFullBackground(calculatedProps, tspanValues); | ||
}; | ||
var calculateSpanDy = function (current, previous) { | ||
return -0.5 * previous.fontSize - 0.5 * (previous.fontSize * previous.lineHeight) + previous.fontSize * previous.lineHeight + 0.5 * current.fontSize + 0.5 * current.fontSize * current.lineHeight - (current.fontSize - current.capHeight) * 0.5 + (previous.fontSize - previous.capHeight) * 0.5; | ||
var calculateSpanDy = function (tspanValues, i, calculatedProps) { | ||
var current = getSingleValue(tspanValues, i); | ||
var previous = getSingleValue(tspanValues, i - 1); | ||
var previousHeight = previous.fontSize * previous.lineHeight; | ||
var currentHeight = current.fontSize * current.lineHeight; | ||
var previousCaps = previous.fontSize - previous.capHeight; | ||
var currentCaps = current.fontSize - current.capHeight; | ||
var textHeight = previousHeight - previous.fontSize / 2 + current.fontSize / 2 - previousHeight / 2 + currentHeight / 2 - currentCaps / 2 + previousCaps / 2; | ||
return useMultiLineBackgrounds(calculatedProps) ? textHeight + current.backgroundPadding.top + previous.backgroundPadding.bottom : textHeight; | ||
}; | ||
var getTSpanDy = function (tspanValues, props, i) { | ||
var inline = props.inline, | ||
backgroundStyle = props.backgroundStyle; | ||
var current = tspanValues[i]; | ||
var previous = tspanValues[i - 1] || tspanValues[0]; | ||
var getTSpanDy = function (tspanValues, calculatedProps, i) { | ||
var inline = calculatedProps.inline; | ||
var current = getSingleValue(tspanValues, i); | ||
if (i && !inline) { | ||
return backgroundStyle && Array.isArray(backgroundStyle) && backgroundStyle.length > 1 ? calculateSpanDy(current, previous) + current.backgroundPadding.top + previous.backgroundPadding.bottom : calculateSpanDy(current, previous); | ||
return calculateSpanDy(tspanValues, i, calculatedProps); | ||
} else if (inline) { | ||
@@ -342,4 +409,15 @@ return i === 0 ? current.backgroundPadding.top : undefined; | ||
})); | ||
var backgroundStyle = getBackgroundStyles(props.backgroundStyle, _assign({}, props, { | ||
text: text, | ||
style: style | ||
})); | ||
var backgroundPadding = getBackgroundPadding(_assign({}, props, { | ||
text: text, | ||
style: style, | ||
backgroundStyle: backgroundStyle | ||
})); | ||
var id = Helpers.evaluateProp(props.id, props); | ||
return _assign({}, props, { | ||
backgroundStyle: backgroundStyle, | ||
backgroundPadding: backgroundPadding, | ||
style: style, | ||
@@ -352,13 +430,13 @@ text: text, | ||
var getCalculatedProps = function (props) { | ||
var style = getSingleValue(props.style); | ||
var lineHeight = getLineHeight(props); | ||
var direction = props.direction ? Helpers.evaluateProp(props.direction, props) : "inherit"; | ||
var textAnchor = props.textAnchor ? Helpers.evaluateProp(props.textAnchor, props) : "start"; | ||
var verticalAnchor = props.verticalAnchor ? Helpers.evaluateProp(props.verticalAnchor, props) : "middle"; | ||
var textAnchor = props.textAnchor ? Helpers.evaluateProp(props.textAnchor, props) : style.textAnchor || "start"; | ||
var verticalAnchor = props.verticalAnchor ? Helpers.evaluateProp(props.verticalAnchor, props) : style.verticalAnchor || "middle"; | ||
var dx = props.dx ? Helpers.evaluateProp(props.dx, props) : 0; | ||
var dy = getDy(props, lineHeight); | ||
var dy = getDy(props, verticalAnchor, lineHeight); | ||
var transform = getTransform(props); | ||
var x = props.x !== undefined ? props.x : getPosition(props, "x"); | ||
var y = props.y !== undefined ? props.y : getPosition(props, "y"); | ||
var backgroundPadding = getBackgroundPadding(props); | ||
return { | ||
return _assign({}, props, { | ||
lineHeight: lineHeight, | ||
@@ -370,17 +448,17 @@ direction: direction, | ||
dy: dy, | ||
backgroundPadding: backgroundPadding, | ||
originalDy: props.dy, | ||
transform: transform, | ||
x: x, | ||
y: y | ||
}; | ||
}); | ||
}; | ||
var renderLabel = function (props, calculatedProps, tspanValues) { | ||
var inline = props.inline, | ||
className = props.className, | ||
title = props.title, | ||
events = props.events, | ||
direction = props.direction, | ||
text = props.text; | ||
var textAnchor = calculatedProps.textAnchor, | ||
var renderLabel = function (calculatedProps, tspanValues) { | ||
var inline = calculatedProps.inline, | ||
className = calculatedProps.className, | ||
title = calculatedProps.title, | ||
events = calculatedProps.events, | ||
direction = calculatedProps.direction, | ||
text = calculatedProps.text, | ||
textAnchor = calculatedProps.textAnchor, | ||
dx = calculatedProps.dx, | ||
@@ -390,3 +468,8 @@ dy = calculatedProps.dy, | ||
x = calculatedProps.x, | ||
y = calculatedProps.y; | ||
y = calculatedProps.y, | ||
desc = calculatedProps.desc, | ||
tabIndex = calculatedProps.tabIndex, | ||
id = calculatedProps.id, | ||
tspanComponent = calculatedProps.tspanComponent, | ||
textComponent = calculatedProps.textComponent; | ||
@@ -403,5 +486,5 @@ var textProps = _objectSpread({ | ||
title: title, | ||
desc: Helpers.evaluateProp(props.desc, props), | ||
tabIndex: Helpers.evaluateProp(props.tabIndex, props), | ||
id: props.id | ||
desc: Helpers.evaluateProp(desc, calculatedProps), | ||
tabIndex: Helpers.evaluateProp(tabIndex, calculatedProps), | ||
id: id | ||
}); | ||
@@ -412,6 +495,6 @@ | ||
var tspanProps = { | ||
key: "".concat(props.id, "-key-").concat(i), | ||
x: !inline ? props.x : undefined, | ||
dx: dx + tspanValues[i].backgroundPadding.left, | ||
dy: getTSpanDy(tspanValues, props, i), | ||
key: "".concat(id, "-key-").concat(i), | ||
x: !inline ? x : undefined, | ||
dx: inline ? dx + tspanValues[i].backgroundPadding.left : dx, | ||
dy: getTSpanDy(tspanValues, calculatedProps, i), | ||
textAnchor: currentStyle.textAnchor || textAnchor, | ||
@@ -421,5 +504,5 @@ style: currentStyle, | ||
}; | ||
return React.cloneElement(props.tspanComponent, tspanProps); | ||
return React.cloneElement(tspanComponent, tspanProps); | ||
}); | ||
return React.cloneElement(props.textComponent, textProps, tspans); | ||
return React.cloneElement(textComponent, textProps, tspans); | ||
}; | ||
@@ -435,12 +518,11 @@ | ||
var calculatedProps = getCalculatedProps(props); | ||
var _props = props, | ||
text = _props.text, | ||
style = _props.style, | ||
capHeight = _props.capHeight; | ||
var backgroundPadding = calculatedProps.backgroundPadding, | ||
var text = calculatedProps.text, | ||
style = calculatedProps.style, | ||
capHeight = calculatedProps.capHeight, | ||
backgroundPadding = calculatedProps.backgroundPadding, | ||
lineHeight = calculatedProps.lineHeight; | ||
var tspanValues = text.map(function (line, i) { | ||
var currentStyle = style[i] || style[0]; | ||
var currentStyle = getSingleValue(style, i); | ||
var capHeightPx = TextSize.convertLengthToPixels("".concat(capHeight, "em"), currentStyle.fontSize); | ||
var currentLineHeight = lineHeight[i] || lineHeight[0]; | ||
var currentLineHeight = getSingleValue(lineHeight, i); | ||
return { | ||
@@ -451,10 +533,11 @@ style: currentStyle, | ||
text: line, | ||
textSize: TextSize.approximateTextSize(line, currentStyle), | ||
lineHeight: currentLineHeight, | ||
backgroundPadding: getBackgroundPaddingProp(i, backgroundPadding) | ||
backgroundPadding: getSingleValue(backgroundPadding, i) | ||
}; | ||
}); | ||
var label = renderLabel(props, calculatedProps, tspanValues); | ||
var label = renderLabel(calculatedProps, tspanValues); | ||
if (props.backgroundStyle) { | ||
var backgroundElement = getBackgroundElement(props, calculatedProps, tspanValues); | ||
var backgroundElement = getBackgroundElement(calculatedProps, tspanValues); | ||
var children = [backgroundElement, label]; | ||
@@ -461,0 +544,0 @@ var backgroundWithLabel = React.cloneElement(props.groupComponent, {}, children); |
@@ -11,3 +11,3 @@ import _assign from "lodash/assign"; | ||
var sansSerif = "'Gill Sans', 'Gill Sans MT', 'Seravek', 'Trebuchet MS', sans-serif"; | ||
var sansSerif = "'Gill Sans', 'Seravek', 'Trebuchet MS', sans-serif"; | ||
var letterSpacing = "normal"; | ||
@@ -96,3 +96,5 @@ var fontSize = 14; // * | ||
}, | ||
maxLabels: baseLabelStyles, | ||
maxLabels: _assign({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
median: { | ||
@@ -103,3 +105,5 @@ padding: 8, | ||
}, | ||
medianLabels: baseLabelStyles, | ||
medianLabels: _assign({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
min: { | ||
@@ -110,3 +114,5 @@ padding: 8, | ||
}, | ||
minLabels: baseLabelStyles, | ||
minLabels: _assign({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
q1: { | ||
@@ -116,3 +122,5 @@ padding: 8, | ||
}, | ||
q1Labels: baseLabelStyles, | ||
q1Labels: _assign({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
q3: { | ||
@@ -122,3 +130,5 @@ padding: 8, | ||
}, | ||
q3Labels: baseLabelStyles | ||
q3Labels: _assign({}, baseLabelStyles, { | ||
padding: 3 | ||
}) | ||
}, | ||
@@ -133,3 +143,5 @@ boxWidth: 20 | ||
}, | ||
labels: baseLabelStyles | ||
labels: _assign({}, baseLabelStyles, { | ||
padding: 5 | ||
}) | ||
}, | ||
@@ -222,3 +234,3 @@ candleColors: { | ||
style: _assign({}, baseLabelStyles, { | ||
padding: 5, | ||
padding: 0, | ||
pointerEvents: "none" | ||
@@ -232,2 +244,3 @@ }), | ||
}, | ||
flyoutPadding: 5, | ||
cornerRadius: 5, | ||
@@ -234,0 +247,0 @@ pointerLength: 10 |
@@ -19,3 +19,3 @@ import _assign from "lodash/assign"; | ||
var sansSerif = "'Roboto', 'Helvetica Neue', Helvetica, sans-serif"; | ||
var sansSerif = "'Helvetica Neue', 'Helvetica', sans-serif"; | ||
var letterSpacing = "normal"; | ||
@@ -98,2 +98,11 @@ var fontSize = 12; // * | ||
}, baseProps), | ||
polarDependentAxis: _assign({ | ||
style: { | ||
ticks: { | ||
fill: "transparent", | ||
size: 1, | ||
stroke: "transparent" | ||
} | ||
} | ||
}), | ||
bar: _assign({ | ||
@@ -116,3 +125,5 @@ style: { | ||
}, | ||
maxLabels: baseLabelStyles, | ||
maxLabels: _assign({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
median: { | ||
@@ -123,3 +134,5 @@ padding: padding, | ||
}, | ||
medianLabels: baseLabelStyles, | ||
medianLabels: _assign({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
min: { | ||
@@ -130,3 +143,5 @@ padding: padding, | ||
}, | ||
minLabels: baseLabelStyles, | ||
minLabels: _assign({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
q1: { | ||
@@ -136,3 +151,5 @@ padding: padding, | ||
}, | ||
q1Labels: baseLabelStyles, | ||
q1Labels: _assign({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
q3: { | ||
@@ -142,3 +159,5 @@ padding: padding, | ||
}, | ||
q3Labels: baseLabelStyles | ||
q3Labels: _assign({}, baseLabelStyles, { | ||
padding: 3 | ||
}) | ||
}, | ||
@@ -152,3 +171,5 @@ boxWidth: 20 | ||
}, | ||
labels: baseLabelStyles | ||
labels: _assign({}, baseLabelStyles, { | ||
padding: 5 | ||
}) | ||
}, | ||
@@ -241,3 +262,3 @@ candleColors: { | ||
style: _assign({}, baseLabelStyles, { | ||
padding: 5, | ||
padding: 0, | ||
pointerEvents: "none" | ||
@@ -251,2 +272,3 @@ }), | ||
}, | ||
flyoutPadding: 5, | ||
cornerRadius: 5, | ||
@@ -253,0 +275,0 @@ pointerLength: 10 |
@@ -122,2 +122,26 @@ import _assign from "lodash/assign"; | ||
function isTooltip(component) { | ||
var labelRole = component && component.type && component.type.role; | ||
return labelRole === "tooltip"; | ||
} | ||
function getDefaultStyles(props, role) { | ||
var _props$theme = props.theme, | ||
theme = _props$theme === void 0 ? {} : _props$theme, | ||
labelComponent = props.labelComponent; | ||
var defaultStyles = theme[role] && theme[role].style || {}; | ||
if (!isTooltip(labelComponent)) { | ||
return defaultStyles; | ||
} | ||
var tooltipStyle = theme.tooltip && theme.tooltip.style || {}; | ||
var labelStyle = _defaults({}, tooltipStyle, defaultStyles.labels); | ||
return _defaults({}, { | ||
labels: labelStyle | ||
}, defaultStyles); | ||
} | ||
function getStyles(style, defaultStyles) { | ||
@@ -346,2 +370,3 @@ var width = "100%"; | ||
getPadding: getPadding, | ||
getDefaultStyles: getDefaultStyles, | ||
getStyles: getStyles, | ||
@@ -359,3 +384,4 @@ evaluateProp: evaluateProp, | ||
reduceChildren: reduceChildren, | ||
isHorizontal: isHorizontal | ||
isHorizontal: isHorizontal, | ||
isTooltip: isTooltip | ||
}; |
@@ -0,6 +1,9 @@ | ||
import _defaults from "lodash/defaults"; | ||
/* eslint-disable func-style */ | ||
/* eslint-disable no-use-before-define */ | ||
import Helpers from "./helpers"; // Private Functions | ||
import Helpers from "./helpers"; | ||
// Private Functions | ||
function getVerticalAnchor(props, datum) { | ||
@@ -161,5 +164,5 @@ datum = datum || {}; | ||
var degrees = baseAngle !== undefined ? baseAngle : getDegrees(props, datum); | ||
var degrees = baseAngle !== undefined ? baseAngle % 360 : getDegrees(props, datum); | ||
var sign = degrees > 90 && degrees < 180 || degrees > 270 ? 1 : -1; | ||
var angle; | ||
var angle = 0; | ||
@@ -182,3 +185,3 @@ if (degrees === 0 || degrees === 180) { | ||
return Helpers.radiansToDegrees(props.scale.x(x)); | ||
return Helpers.radiansToDegrees(props.scale.x(x)) % 360; | ||
} | ||
@@ -193,3 +196,5 @@ | ||
width = props.width, | ||
height = props.height; | ||
height = props.height, | ||
theme = props.theme, | ||
labelComponent = props.labelComponent; | ||
var datum = data[index]; | ||
@@ -211,3 +216,3 @@ var degrees = getDegrees(props, datum); | ||
return { | ||
var labelProps = { | ||
angle: angle, | ||
@@ -232,2 +237,9 @@ data: data, | ||
}; | ||
if (!Helpers.isTooltip(labelComponent)) { | ||
return labelProps; | ||
} | ||
var tooltipTheme = theme && theme.tooltip || {}; | ||
return _defaults({}, labelProps, Helpers.omit(tooltipTheme, ["style"])); | ||
} | ||
@@ -234,0 +246,0 @@ |
@@ -12,26 +12,101 @@ import _defaults from "lodash/defaults"; | ||
var fontDictionary = { | ||
"American Typewriter": 2.09, | ||
Baskerville: 2.51, | ||
Georgia: 2.27, | ||
"Hoefler Text": 2.39, | ||
Palatino: 2.26, | ||
"Times New Roman": 2.48, | ||
Arial: 2.26, | ||
"Gill Sans": 2.47, | ||
"Gill Sans 300": 2.58, | ||
"Helvetica Neue": 2.24, | ||
"Lucida Grande": 2.05, | ||
Tahoma: 2.25, | ||
"Trebuchet MS": 2.2, | ||
Verdana: 1.96, | ||
"Courier New": 1.67, | ||
cursive: 1.84, | ||
fantasy: 2.09, | ||
monospace: 1.81, | ||
serif: 2.04, | ||
"sans-serif": 1.89 | ||
}; //https://developer.mozilla.org/en/docs/Web/CSS/length | ||
// Absolute sizes in pixels for obsolete measurement units. | ||
// Based on measuring specific character widths | ||
// as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf | ||
//prettier-ignore | ||
var fonts = { | ||
"American Typewriter": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.4203125, 0.3296875, 0.6, 0.6375, 0.8015625, 0.8203125, 0.1875, 0.45625, 0.45625, 0.6375, 0.5, 0.2734375, 0.309375, 0.2734375, 0.4390625, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.2734375, 0.2734375, 0.5, 0.5, 0.5, 0.6, 0.6921875, 0.7640625, 0.6921875, 0.6375, 0.728125, 0.6734375, 0.6203125, 0.7109375, 0.784375, 0.3828125, 0.6421875, 0.7859375, 0.6375, 0.9484375, 0.7640625, 0.65625, 0.6375, 0.65625, 0.7296875, 0.6203125, 0.6375, 0.7109375, 0.740625, 0.940625, 0.784375, 0.7578125, 0.6203125, 0.4375, 0.5, 0.4375, 0.5, 0.5, 0.4921875, 0.5734375, 0.5890625, 0.5109375, 0.6, 0.528125, 0.43125, 0.5578125, 0.6375, 0.3109375, 0.40625, 0.6234375, 0.309375, 0.928125, 0.6375, 0.546875, 0.6, 0.58125, 0.4921875, 0.4921875, 0.4, 0.6203125, 0.625, 0.825, 0.6375, 0.640625, 0.528125, 0.5, 0.5, 0.5, 0.6671875], | ||
avg: 0.5793421052631578 | ||
}, | ||
Arial: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.278125, 0.278125, 0.35625, 0.55625, 0.55625, 0.890625, 0.6671875, 0.1921875, 0.334375, 0.334375, 0.390625, 0.584375, 0.278125, 0.334375, 0.278125, 0.278125, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.278125, 0.278125, 0.584375, 0.584375, 0.584375, 0.55625, 1.015625, 0.6703125, 0.6671875, 0.7234375, 0.7234375, 0.6671875, 0.6109375, 0.778125, 0.7234375, 0.278125, 0.5, 0.6671875, 0.55625, 0.834375, 0.7234375, 0.778125, 0.6671875, 0.778125, 0.7234375, 0.6671875, 0.6109375, 0.7234375, 0.6671875, 0.9453125, 0.6671875, 0.6671875, 0.6109375, 0.278125, 0.278125, 0.278125, 0.4703125, 0.584375, 0.334375, 0.55625, 0.55625, 0.5, 0.55625, 0.55625, 0.3125, 0.55625, 0.55625, 0.2234375, 0.2703125, 0.5, 0.2234375, 0.834375, 0.55625, 0.55625, 0.55625, 0.55625, 0.346875, 0.5, 0.278125, 0.55625, 0.5, 0.7234375, 0.5, 0.5, 0.5, 0.334375, 0.2609375, 0.334375, 0.584375], | ||
avg: 0.528733552631579 | ||
}, | ||
"Arial Black": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.33125, 0.334375, 0.5, 0.6609375, 0.6671875, 1, 0.890625, 0.278125, 0.390625, 0.390625, 0.55625, 0.6609375, 0.334375, 0.334375, 0.334375, 0.28125, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.334375, 0.334375, 0.6609375, 0.6609375, 0.6609375, 0.6109375, 0.7453125, 0.78125, 0.778125, 0.778125, 0.778125, 0.7234375, 0.6671875, 0.834375, 0.834375, 0.390625, 0.6671875, 0.834375, 0.6671875, 0.9453125, 0.834375, 0.834375, 0.7234375, 0.834375, 0.78125, 0.7234375, 0.7234375, 0.834375, 0.7796875, 1.003125, 0.78125, 0.78125, 0.7234375, 0.390625, 0.28125, 0.390625, 0.6609375, 0.5125, 0.334375, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.41875, 0.6671875, 0.6671875, 0.334375, 0.384375, 0.6671875, 0.334375, 1, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.4703125, 0.6109375, 0.4453125, 0.6671875, 0.6140625, 0.946875, 0.6671875, 0.615625, 0.55625, 0.390625, 0.278125, 0.390625, 0.6609375], | ||
avg: 0.6213157894736842 | ||
}, | ||
Baskerville: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.25, 0.40625, 0.6671875, 0.490625, 0.875, 0.7015625, 0.178125, 0.2453125, 0.246875, 0.4171875, 0.6671875, 0.25, 0.3125, 0.25, 0.521875, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.25, 0.25, 0.6671875, 0.6671875, 0.6671875, 0.396875, 0.9171875, 0.684375, 0.615625, 0.71875, 0.7609375, 0.625, 0.553125, 0.771875, 0.803125, 0.3546875, 0.515625, 0.78125, 0.6046875, 0.928125, 0.75, 0.8234375, 0.5625, 0.96875, 0.7296875, 0.5421875, 0.6984375, 0.771875, 0.7296875, 0.9484375, 0.771875, 0.678125, 0.6359375, 0.3640625, 0.521875, 0.3640625, 0.46875, 0.5125, 0.334375, 0.46875, 0.521875, 0.428125, 0.521875, 0.4375, 0.3890625, 0.4765625, 0.53125, 0.25, 0.359375, 0.4640625, 0.240625, 0.803125, 0.53125, 0.5, 0.521875, 0.521875, 0.365625, 0.334375, 0.2921875, 0.521875, 0.4640625, 0.678125, 0.4796875, 0.465625, 0.428125, 0.4796875, 0.5109375, 0.4796875, 0.6671875], | ||
avg: 0.5323519736842108 | ||
}, | ||
Courier: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5984375, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6078125, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.61875, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.615625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6140625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625], | ||
avg: 0.6020559210526316 | ||
}, | ||
"Courier New": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5984375, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625], | ||
avg: 0.6015296052631579 | ||
}, | ||
cursive: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1921875, 0.24375, 0.40625, 0.5671875, 0.3984375, 0.721875, 0.909375, 0.2328125, 0.434375, 0.365625, 0.4734375, 0.5578125, 0.19375, 0.3484375, 0.19375, 0.7734375, 0.503125, 0.4171875, 0.5453125, 0.45, 0.6046875, 0.4703125, 0.5984375, 0.55625, 0.503125, 0.5546875, 0.20625, 0.2, 0.5625, 0.5546875, 0.546875, 0.403125, 0.70625, 0.734375, 0.7078125, 0.64375, 0.85, 0.753125, 0.75, 0.6484375, 1.0765625, 0.44375, 0.5359375, 0.8359375, 0.653125, 1.0109375, 1.1515625, 0.6796875, 0.6984375, 1.0625, 0.8234375, 0.5125, 0.9234375, 0.8546875, 0.70625, 0.9109375, 0.7421875, 0.715625, 0.6015625, 0.4640625, 0.3359375, 0.4109375, 0.5421875, 0.5421875, 0.4328125, 0.5125, 0.5, 0.3859375, 0.7375, 0.359375, 0.75625, 0.540625, 0.5328125, 0.3203125, 0.5296875, 0.5015625, 0.484375, 0.7890625, 0.5640625, 0.4203125, 0.703125, 0.471875, 0.4734375, 0.35, 0.4125, 0.5640625, 0.471875, 0.6484375, 0.5296875, 0.575, 0.4140625, 0.415625, 0.20625, 0.3796875, 0.5421875], | ||
avg: 0.5604440789473684 | ||
}, | ||
fantasy: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.215625, 0.2625, 0.3265625, 0.6109375, 0.534375, 0.7625, 0.7828125, 0.2, 0.4359375, 0.4359375, 0.3765625, 0.5109375, 0.2796875, 0.4609375, 0.2796875, 0.5296875, 0.6640625, 0.253125, 0.521875, 0.4765625, 0.6640625, 0.490625, 0.528125, 0.5546875, 0.496875, 0.5421875, 0.2796875, 0.2796875, 0.5625, 0.4609375, 0.5625, 0.4828125, 0.609375, 0.740625, 0.7234375, 0.740625, 0.8265625, 0.7234375, 0.6171875, 0.7359375, 0.765625, 0.240625, 0.5453125, 0.715625, 0.6078125, 0.8640625, 0.653125, 0.9125, 0.6484375, 0.946875, 0.6921875, 0.653125, 0.6953125, 0.8015625, 0.58125, 0.784375, 0.671875, 0.6265625, 0.690625, 0.4359375, 0.5296875, 0.4359375, 0.53125, 0.5, 0.2875, 0.5375, 0.603125, 0.4984375, 0.60625, 0.53125, 0.434375, 0.6421875, 0.56875, 0.209375, 0.4671875, 0.5484375, 0.2203125, 0.709375, 0.55, 0.5984375, 0.6140625, 0.5765625, 0.40625, 0.4734375, 0.3734375, 0.559375, 0.4421875, 0.6421875, 0.4890625, 0.578125, 0.4484375, 0.2546875, 0.2203125, 0.2546875, 0.55], | ||
avg: 0.536496710526316 | ||
}, | ||
Geneva: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.3328125, 0.3046875, 0.5, 0.6671875, 0.6671875, 0.90625, 0.728125, 0.3046875, 0.446875, 0.446875, 0.5078125, 0.6671875, 0.3046875, 0.3796875, 0.3046875, 0.5390625, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.3046875, 0.3046875, 0.6671875, 0.6671875, 0.6671875, 0.56875, 0.871875, 0.728125, 0.6375, 0.6515625, 0.7015625, 0.5765625, 0.5546875, 0.675, 0.690625, 0.2421875, 0.4921875, 0.6640625, 0.584375, 0.7890625, 0.709375, 0.7359375, 0.584375, 0.78125, 0.60625, 0.60625, 0.640625, 0.6671875, 0.728125, 0.946875, 0.6109375, 0.6109375, 0.5765625, 0.446875, 0.5390625, 0.446875, 0.6671875, 0.6671875, 0.5921875, 0.5546875, 0.6109375, 0.546875, 0.603125, 0.5765625, 0.390625, 0.6109375, 0.584375, 0.2359375, 0.334375, 0.5390625, 0.2359375, 0.8953125, 0.584375, 0.60625, 0.603125, 0.603125, 0.3875, 0.509375, 0.44375, 0.584375, 0.565625, 0.78125, 0.53125, 0.571875, 0.5546875, 0.4515625, 0.246875, 0.4515625, 0.6671875], | ||
avg: 0.5762664473684211 | ||
}, | ||
Georgia: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2421875, 0.33125, 0.4125, 0.64375, 0.6109375, 0.81875, 0.7109375, 0.215625, 0.375, 0.375, 0.4734375, 0.64375, 0.2703125, 0.375, 0.2703125, 0.46875, 0.6140625, 0.4296875, 0.559375, 0.553125, 0.565625, 0.5296875, 0.5671875, 0.503125, 0.596875, 0.5671875, 0.3125, 0.3125, 0.64375, 0.64375, 0.64375, 0.4796875, 0.9296875, 0.715625, 0.6546875, 0.6421875, 0.75, 0.6546875, 0.6, 0.7265625, 0.815625, 0.390625, 0.51875, 0.7203125, 0.6046875, 0.928125, 0.7671875, 0.7453125, 0.6109375, 0.7453125, 0.7234375, 0.5625, 0.61875, 0.7578125, 0.70625, 0.99375, 0.7125, 0.6640625, 0.6015625, 0.375, 0.46875, 0.375, 0.64375, 0.65, 0.5, 0.5046875, 0.56875, 0.4546875, 0.575, 0.484375, 0.39375, 0.509375, 0.5828125, 0.29375, 0.3671875, 0.546875, 0.2875, 0.88125, 0.5921875, 0.5390625, 0.571875, 0.5640625, 0.4109375, 0.4328125, 0.3453125, 0.5765625, 0.5203125, 0.75625, 0.50625, 0.5171875, 0.4453125, 0.43125, 0.375, 0.43125, 0.64375], | ||
avg: 0.5551809210526316 | ||
}, | ||
"Gill Sans": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2765625, 0.271875, 0.3546875, 0.584375, 0.5421875, 0.6765625, 0.625, 0.1890625, 0.3234375, 0.3234375, 0.4171875, 0.584375, 0.2203125, 0.3234375, 0.2203125, 0.28125, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.2203125, 0.2296875, 0.584375, 0.584375, 0.584375, 0.334375, 1.0109375, 0.6671875, 0.5640625, 0.709375, 0.75, 0.5, 0.4703125, 0.740625, 0.7296875, 0.25, 0.3125, 0.65625, 0.490625, 0.78125, 0.78125, 0.8234375, 0.5109375, 0.8234375, 0.6046875, 0.459375, 0.6046875, 0.709375, 0.6046875, 1.0421875, 0.709375, 0.6046875, 0.646875, 0.334375, 0.28125, 0.334375, 0.4703125, 0.5828125, 0.334375, 0.428125, 0.5, 0.4390625, 0.5109375, 0.4796875, 0.296875, 0.428125, 0.5, 0.2203125, 0.2265625, 0.5, 0.2203125, 0.771875, 0.5, 0.553125, 0.5, 0.5, 0.3984375, 0.3859375, 0.334375, 0.5, 0.4390625, 0.7203125, 0.5, 0.4390625, 0.4171875, 0.334375, 0.2609375, 0.334375, 0.584375], | ||
avg: 0.4933717105263159 | ||
}, | ||
Helvetica: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2796875, 0.2765625, 0.3546875, 0.5546875, 0.5546875, 0.8890625, 0.665625, 0.190625, 0.3328125, 0.3328125, 0.3890625, 0.5828125, 0.2765625, 0.3328125, 0.2765625, 0.3015625, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.2765625, 0.2765625, 0.584375, 0.5828125, 0.584375, 0.5546875, 1.0140625, 0.665625, 0.665625, 0.721875, 0.721875, 0.665625, 0.609375, 0.7765625, 0.721875, 0.2765625, 0.5, 0.665625, 0.5546875, 0.8328125, 0.721875, 0.7765625, 0.665625, 0.7765625, 0.721875, 0.665625, 0.609375, 0.721875, 0.665625, 0.94375, 0.665625, 0.665625, 0.609375, 0.2765625, 0.3546875, 0.2765625, 0.4765625, 0.5546875, 0.3328125, 0.5546875, 0.5546875, 0.5, 0.5546875, 0.5546875, 0.2765625, 0.5546875, 0.5546875, 0.221875, 0.240625, 0.5, 0.221875, 0.8328125, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.3328125, 0.5, 0.2765625, 0.5546875, 0.5, 0.721875, 0.5, 0.5, 0.5, 0.3546875, 0.259375, 0.353125, 0.5890625], | ||
avg: 0.5279276315789471 | ||
}, | ||
"Helvetica Neue": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.278125, 0.259375, 0.4265625, 0.55625, 0.55625, 1, 0.6453125, 0.278125, 0.2703125, 0.26875, 0.353125, 0.6, 0.278125, 0.3890625, 0.278125, 0.36875, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.278125, 0.278125, 0.6, 0.6, 0.6, 0.55625, 0.8, 0.6625, 0.6859375, 0.7234375, 0.7046875, 0.6125, 0.575, 0.759375, 0.7234375, 0.259375, 0.5203125, 0.6703125, 0.55625, 0.871875, 0.7234375, 0.7609375, 0.6484375, 0.7609375, 0.6859375, 0.6484375, 0.575, 0.7234375, 0.6140625, 0.9265625, 0.6125, 0.6484375, 0.6125, 0.259375, 0.36875, 0.259375, 0.6, 0.5, 0.25625, 0.5375, 0.59375, 0.5375, 0.59375, 0.5375, 0.2984375, 0.575, 0.55625, 0.2234375, 0.2375, 0.5203125, 0.2234375, 0.853125, 0.55625, 0.575, 0.59375, 0.59375, 0.334375, 0.5, 0.315625, 0.55625, 0.5, 0.759375, 0.51875, 0.5, 0.48125, 0.334375, 0.2234375, 0.334375, 0.6], | ||
avg: 0.5279440789473684 | ||
}, | ||
"Hoefler Text": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2359375, 0.2234375, 0.3921875, 0.7125, 0.49375, 0.8859375, 0.771875, 0.2125, 0.3078125, 0.309375, 0.375, 0.4234375, 0.234375, 0.3125, 0.234375, 0.3, 0.5828125, 0.365625, 0.434375, 0.3921875, 0.5234375, 0.3984375, 0.5125, 0.4328125, 0.46875, 0.5125, 0.234375, 0.234375, 0.515625, 0.4234375, 0.515625, 0.340625, 0.7609375, 0.7359375, 0.6359375, 0.721875, 0.8125, 0.6375, 0.5875, 0.8078125, 0.853125, 0.4296875, 0.503125, 0.78125, 0.609375, 0.9609375, 0.8515625, 0.8140625, 0.6125, 0.8140625, 0.71875, 0.49375, 0.7125, 0.76875, 0.771875, 1.125, 0.7765625, 0.7734375, 0.65625, 0.321875, 0.3078125, 0.321875, 0.3546875, 0.5, 0.3375, 0.446875, 0.5359375, 0.45, 0.5296875, 0.4546875, 0.425, 0.4921875, 0.54375, 0.2671875, 0.240625, 0.5390625, 0.25, 0.815625, 0.5375, 0.5234375, 0.5390625, 0.5421875, 0.365625, 0.36875, 0.35625, 0.5171875, 0.5015625, 0.75, 0.5, 0.509375, 0.44375, 0.2421875, 0.14375, 0.2421875, 0.35], | ||
avg: 0.5116447368421051 | ||
}, | ||
monospace: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5984375, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6078125, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.61875, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.615625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6140625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625], | ||
avg: 0.6020559210526316 | ||
}, | ||
Palatino: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.278125, 0.371875, 0.60625, 0.5, 0.840625, 0.778125, 0.209375, 0.334375, 0.334375, 0.390625, 0.60625, 0.2578125, 0.334375, 0.25, 0.60625, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.25, 0.25, 0.60625, 0.60625, 0.60625, 0.4453125, 0.7484375, 0.778125, 0.6109375, 0.709375, 0.775, 0.6109375, 0.55625, 0.7640625, 0.8328125, 0.3375, 0.346875, 0.7265625, 0.6109375, 0.946875, 0.83125, 0.7875, 0.6046875, 0.7875, 0.66875, 0.525, 0.6140625, 0.778125, 0.7234375, 1, 0.6671875, 0.6671875, 0.6671875, 0.334375, 0.60625, 0.334375, 0.60625, 0.5, 0.334375, 0.5, 0.565625, 0.4453125, 0.6109375, 0.4796875, 0.340625, 0.55625, 0.5828125, 0.2921875, 0.2671875, 0.5640625, 0.2921875, 0.8828125, 0.5828125, 0.546875, 0.6015625, 0.5609375, 0.3953125, 0.425, 0.3265625, 0.603125, 0.565625, 0.834375, 0.5171875, 0.55625, 0.5, 0.334375, 0.60625, 0.334375, 0.60625], | ||
avg: 0.5408552631578947 | ||
}, | ||
"sans-serif": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.278125, 0.278125, 0.35625, 0.55625, 0.55625, 0.890625, 0.6671875, 0.1921875, 0.334375, 0.334375, 0.390625, 0.584375, 0.278125, 0.334375, 0.278125, 0.303125, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.278125, 0.278125, 0.5859375, 0.584375, 0.5859375, 0.55625, 1.015625, 0.6671875, 0.6671875, 0.7234375, 0.7234375, 0.6671875, 0.6109375, 0.778125, 0.7234375, 0.278125, 0.5, 0.6671875, 0.55625, 0.834375, 0.7234375, 0.778125, 0.6671875, 0.778125, 0.7234375, 0.6671875, 0.6109375, 0.7234375, 0.6671875, 0.9453125, 0.6671875, 0.6671875, 0.6109375, 0.278125, 0.35625, 0.278125, 0.478125, 0.55625, 0.334375, 0.55625, 0.55625, 0.5, 0.55625, 0.55625, 0.278125, 0.55625, 0.55625, 0.2234375, 0.2421875, 0.5, 0.2234375, 0.834375, 0.55625, 0.55625, 0.55625, 0.55625, 0.334375, 0.5, 0.278125, 0.55625, 0.5, 0.7234375, 0.5, 0.5, 0.5, 0.35625, 0.2609375, 0.3546875, 0.590625], | ||
avg: 0.5293256578947368 | ||
}, | ||
Seravek: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.215625, 0.296875, 0.4171875, 0.6734375, 0.4953125, 0.9125, 0.740625, 0.2421875, 0.3375, 0.3375, 0.409375, 0.60625, 0.2609375, 0.35625, 0.25625, 0.41875, 0.5921875, 0.3515625, 0.475, 0.4875, 0.5375, 0.509375, 0.5484375, 0.4546875, 0.5421875, 0.5484375, 0.25625, 0.2546875, 0.5875, 0.6171875, 0.5875, 0.4578125, 0.8140625, 0.6765625, 0.5703125, 0.6109375, 0.684375, 0.5109375, 0.4953125, 0.678125, 0.6859375, 0.2625, 0.2625, 0.5859375, 0.4734375, 0.846875, 0.709375, 0.740625, 0.509375, 0.740625, 0.584375, 0.5015625, 0.528125, 0.675, 0.5953125, 0.9453125, 0.596875, 0.540625, 0.540625, 0.359375, 0.4203125, 0.359375, 0.5109375, 0.421875, 0.4046875, 0.5015625, 0.5421875, 0.446875, 0.5453125, 0.484375, 0.38125, 0.5140625, 0.5546875, 0.240625, 0.2640625, 0.490625, 0.2765625, 0.8625, 0.5546875, 0.546875, 0.5453125, 0.5453125, 0.3625, 0.41875, 0.3890625, 0.5453125, 0.4703125, 0.7546875, 0.4921875, 0.4609375, 0.453125, 0.4015625, 0.2640625, 0.4015625, 0.58125], | ||
avg: 0.5044078947368421 | ||
}, | ||
serif: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2484375, 0.334375, 0.409375, 0.5, 0.5, 0.834375, 0.778125, 0.18125, 0.334375, 0.334375, 0.5, 0.5640625, 0.25, 0.334375, 0.25, 0.278125, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.278125, 0.278125, 0.5640625, 0.5640625, 0.5640625, 0.4453125, 0.921875, 0.7234375, 0.6671875, 0.6671875, 0.7234375, 0.6109375, 0.55625, 0.7234375, 0.7234375, 0.334375, 0.390625, 0.7234375, 0.6109375, 0.890625, 0.7234375, 0.7234375, 0.55625, 0.7234375, 0.6671875, 0.55625, 0.6109375, 0.7234375, 0.7234375, 0.9453125, 0.7234375, 0.7234375, 0.6109375, 0.334375, 0.340625, 0.334375, 0.4703125, 0.5, 0.3453125, 0.4453125, 0.5, 0.4453125, 0.5, 0.4453125, 0.3828125, 0.5, 0.5, 0.278125, 0.3359375, 0.5, 0.278125, 0.778125, 0.5, 0.5, 0.5, 0.5, 0.3375, 0.390625, 0.2796875, 0.5, 0.5, 0.7234375, 0.5, 0.5, 0.4453125, 0.48125, 0.2015625, 0.48125, 0.5421875], | ||
avg: 0.5126315789473684 | ||
}, | ||
Tahoma: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.3109375, 0.3328125, 0.4015625, 0.728125, 0.546875, 0.9765625, 0.70625, 0.2109375, 0.3828125, 0.3828125, 0.546875, 0.728125, 0.303125, 0.3640625, 0.303125, 0.3953125, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.3546875, 0.3546875, 0.728125, 0.728125, 0.728125, 0.475, 0.909375, 0.6109375, 0.590625, 0.6015625, 0.6796875, 0.5625, 0.521875, 0.66875, 0.6765625, 0.3734375, 0.4171875, 0.6046875, 0.4984375, 0.771875, 0.66875, 0.7078125, 0.5515625, 0.7078125, 0.6375, 0.5578125, 0.5875, 0.65625, 0.60625, 0.903125, 0.58125, 0.5890625, 0.559375, 0.3828125, 0.39375, 0.3828125, 0.728125, 0.5625, 0.546875, 0.525, 0.553125, 0.4625, 0.553125, 0.5265625, 0.3546875, 0.553125, 0.5578125, 0.2296875, 0.328125, 0.51875, 0.2296875, 0.840625, 0.5578125, 0.54375, 0.553125, 0.553125, 0.3609375, 0.446875, 0.3359375, 0.5578125, 0.4984375, 0.7421875, 0.4953125, 0.4984375, 0.4453125, 0.48125, 0.3828125, 0.48125, 0.728125], | ||
avg: 0.5384374999999998 | ||
}, | ||
"Times New Roman": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2484375, 0.334375, 0.409375, 0.5, 0.5, 0.834375, 0.778125, 0.18125, 0.334375, 0.334375, 0.5, 0.5640625, 0.25, 0.334375, 0.25, 0.28125, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.278125, 0.278125, 0.5640625, 0.5640625, 0.5640625, 0.4453125, 0.921875, 0.7234375, 0.6671875, 0.6671875, 0.7234375, 0.6109375, 0.55625, 0.7234375, 0.7234375, 0.334375, 0.390625, 0.73125, 0.6109375, 0.890625, 0.7375, 0.7234375, 0.55625, 0.7234375, 0.6765625, 0.55625, 0.6109375, 0.7234375, 0.7234375, 0.9453125, 0.7234375, 0.7234375, 0.6109375, 0.334375, 0.28125, 0.334375, 0.4703125, 0.51875, 0.334375, 0.4453125, 0.503125, 0.4453125, 0.503125, 0.4453125, 0.4359375, 0.5, 0.5, 0.278125, 0.35625, 0.50625, 0.278125, 0.778125, 0.5, 0.5, 0.5046875, 0.5, 0.340625, 0.390625, 0.2796875, 0.5, 0.5, 0.7234375, 0.5, 0.5, 0.4453125, 0.48125, 0.2015625, 0.48125, 0.5421875], | ||
avg: 0.5134375 | ||
}, | ||
"Trebuchet MS": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.3015625, 0.3671875, 0.325, 0.53125, 0.525, 0.6015625, 0.70625, 0.1609375, 0.3671875, 0.3671875, 0.3671875, 0.525, 0.3671875, 0.3671875, 0.3671875, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.3671875, 0.3671875, 0.525, 0.525, 0.525, 0.3671875, 0.771875, 0.590625, 0.5671875, 0.5984375, 0.6140625, 0.5359375, 0.525, 0.6765625, 0.6546875, 0.2796875, 0.4765625, 0.5765625, 0.5078125, 0.7109375, 0.6390625, 0.675, 0.5578125, 0.7421875, 0.5828125, 0.48125, 0.58125, 0.6484375, 0.5875, 0.853125, 0.5578125, 0.5703125, 0.5515625, 0.3671875, 0.3578125, 0.3671875, 0.525, 0.53125, 0.525, 0.5265625, 0.5578125, 0.4953125, 0.5578125, 0.546875, 0.375, 0.503125, 0.546875, 0.2859375, 0.3671875, 0.5046875, 0.2953125, 0.83125, 0.546875, 0.5375, 0.5578125, 0.5578125, 0.3890625, 0.40625, 0.396875, 0.546875, 0.490625, 0.7453125, 0.5015625, 0.49375, 0.475, 0.3671875, 0.525, 0.3671875, 0.525], | ||
avg: 0.5085197368421052 | ||
}, | ||
Verdana: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.35, 0.39375, 0.459375, 0.81875, 0.6359375, 1.0765625, 0.759375, 0.26875, 0.4546875, 0.4546875, 0.6359375, 0.81875, 0.3640625, 0.4546875, 0.3640625, 0.4703125, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.4546875, 0.4546875, 0.81875, 0.81875, 0.81875, 0.546875, 1, 0.684375, 0.6859375, 0.6984375, 0.771875, 0.6328125, 0.575, 0.7765625, 0.7515625, 0.421875, 0.4546875, 0.69375, 0.5578125, 0.84375, 0.7484375, 0.7875, 0.603125, 0.7875, 0.7, 0.684375, 0.6171875, 0.7328125, 0.684375, 0.9890625, 0.6859375, 0.615625, 0.6859375, 0.4546875, 0.46875, 0.4546875, 0.81875, 0.6421875, 0.6359375, 0.6015625, 0.6234375, 0.521875, 0.6234375, 0.596875, 0.384375, 0.6234375, 0.6328125, 0.275, 0.3765625, 0.5921875, 0.275, 0.9734375, 0.6328125, 0.6078125, 0.6234375, 0.6234375, 0.43125, 0.521875, 0.3953125, 0.6328125, 0.5921875, 0.81875, 0.5921875, 0.5921875, 0.5265625, 0.6359375, 0.4546875, 0.6359375, 0.81875], | ||
avg: 0.6171875000000003 | ||
} //https://developer.mozilla.org/en/docs/Web/CSS/length | ||
// Absolute sizes in pixels for obsolete measurement units. | ||
}; | ||
var absoluteMeasurementUnitsToPixels = { | ||
@@ -50,11 +125,5 @@ mm: 3.8, | ||
var coefficients = { | ||
averageFontConstant: 2.1675, | ||
// Average pixels per glyph in existing font. | ||
widthOverlapCoef: 1.25, | ||
// Coefficient for width value to prevent overlap. | ||
heightOverlapCoef: 1.05, | ||
// Coefficient for height value to prevent overlap. | ||
lineCapitalCoef: 1.15, | ||
// Coefficient for height value. Reserve space for capital chars. | ||
lineSpaceHeightCoef: 0.2 // Coefficient for height value. Reserve space between lines. | ||
lineCapitalCoef: 1.15 // Coefficient for height value. Reserve space for capital chars. | ||
@@ -74,5 +143,10 @@ }; | ||
var _getFontCharacterConstant = function (fontFamily) { | ||
var firstFont = fontFamily.split(",")[0].replace(/'|"/g, ""); | ||
return fontDictionary[firstFont] || coefficients.averageFontConstant; | ||
var _getFontData = function (fontFamily) { | ||
var possibleFonts = fontFamily.split(",").map(function (f) { | ||
return f.replace(/'|"/g, ""); | ||
}); | ||
var fontMatch = possibleFonts.find(function (f) { | ||
return fonts[f]; | ||
}) || "Helvetica"; | ||
return fonts[fontMatch]; | ||
}; | ||
@@ -98,7 +172,9 @@ | ||
var convertLengthToPixels = function (length, fontSize) { | ||
var attribute = length.match(/[a-zA-Z%]+/)[0]; | ||
var attribute = length.match(/[a-zA-Z%]+/) && length.match(/[a-zA-Z%]+/)[0]; | ||
var value = length.match(/[0-9.,]+/); | ||
var result; | ||
if (absoluteMeasurementUnitsToPixels.hasOwnProperty(attribute)) { | ||
if (!attribute) { | ||
result = value || 0; | ||
} else if (absoluteMeasurementUnitsToPixels.hasOwnProperty(attribute)) { | ||
result = value * absoluteMeasurementUnitsToPixels[attribute]; | ||
@@ -120,4 +196,4 @@ } else if (relativeMeasurementUnitsCoef.hasOwnProperty(attribute)) { | ||
return _assign({}, style, { | ||
characterConstant: style.characterConstant || _getFontCharacterConstant(style.fontFamily), | ||
letterSpacing: convertLengthToPixels(style.letterSpacing, style.fontSize), | ||
fontFamily: style.fontFamily, | ||
letterSpacing: typeof style.letterSpacing === "number" ? style.letterSpacing : convertLengthToPixels(String(style.letterSpacing), style.fontSize), | ||
fontSize: typeof style.fontSize === "number" ? style.fontSize : convertLengthToPixels(String(style.fontSize)) | ||
@@ -137,6 +213,13 @@ }); | ||
fontSize = _prepareParams2.fontSize, | ||
characterConstant = _prepareParams2.characterConstant, | ||
letterSpacing = _prepareParams2.letterSpacing; | ||
letterSpacing = _prepareParams2.letterSpacing, | ||
fontFamily = _prepareParams2.fontFamily; | ||
return len * fontSize / characterConstant + letterSpacing * Math.max(len - 1, 0); | ||
var fontData = _getFontData(fontFamily); | ||
var width = line.toString().split("").map(function (c) { | ||
return c.charCodeAt(0) < fontData.widths.length ? fontData.widths[c.charCodeAt(0)] : fontData.avg; | ||
}).reduce(function (cur, acc) { | ||
return acc + cur; | ||
}) * fontSize; | ||
return width + letterSpacing * Math.max(len - 1, 0); | ||
}); | ||
@@ -157,4 +240,3 @@ | ||
var height = containsCaps ? lineStyle.fontSize * coefficients.lineCapitalCoef : lineStyle.fontSize; | ||
var emptySpace = index === 0 ? 0 : lineStyle.fontSize * coefficients.lineSpaceHeightCoef; | ||
return total + lineStyle.lineHeight * (height + emptySpace); | ||
return total + lineStyle.lineHeight * height; | ||
}, 0); | ||
@@ -170,3 +252,2 @@ }; | ||
* @param {string} style.letterSpacing Text letterSpacing(space between letters). | ||
* @param {number} style.characterConstant Average pixels per glyph. | ||
* @param {number} style.lineHeight Line height coefficient. | ||
@@ -187,3 +268,3 @@ * @returns {number} Approximate text label height. | ||
return { | ||
width: widthWithRotate * coefficients.widthOverlapCoef, | ||
width: widthWithRotate, | ||
height: heightWithRotate * coefficients.heightOverlapCoef | ||
@@ -190,0 +271,0 @@ }; |
@@ -101,4 +101,6 @@ import * as React from "react"; | ||
export type VictoryNumberCallback = (args: CallbackArgs) => number; | ||
export type VictoryPaddingCallback = (args: CallbackArgs) => number | BlockProps; | ||
export type StringOrNumberOrCallback = string | number | VictoryStringOrNumberCallback; | ||
export type NumberOrCallback = number | VictoryNumberCallback; | ||
export type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback; | ||
@@ -397,2 +399,29 @@ export type SliceNumberOrCallback<T, P = null> = number | ((props: Omit<T, P>) => number); | ||
} & ThemeBaseProps; | ||
polarAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
}; | ||
} & ThemeBaseProps; | ||
polarDependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
}; | ||
} & ThemeBaseProps; | ||
polarIndependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
}; | ||
} & ThemeBaseProps; | ||
scatter?: { | ||
@@ -410,2 +439,3 @@ style?: { | ||
pointerLength?: number; | ||
flyoutPadding?: number; | ||
}; | ||
@@ -412,0 +442,0 @@ voronoi?: { |
@@ -91,2 +91,13 @@ "use strict"; | ||
var getSingleValue = function (prop) { | ||
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
return Array.isArray(prop) ? prop[index] || prop[0] : prop; | ||
}; | ||
var useMultiLineBackgrounds = function (props) { | ||
var backgroundStyle = props.backgroundStyle, | ||
backgroundPadding = props.backgroundPadding; | ||
return Array.isArray(backgroundStyle) && !(0, _isEmpty2.default)(backgroundStyle) || Array.isArray(backgroundPadding) && !(0, _isEmpty2.default)(backgroundPadding); | ||
}; | ||
var getStyles = function (style, props) { | ||
@@ -105,11 +116,35 @@ var getSingleStyle = function (s) { | ||
return getSingleStyle(s); | ||
}) : [getSingleStyle(style)]; | ||
}) : getSingleStyle(style); | ||
}; | ||
var getHeight = function (props, type) { | ||
return _helpers.default.evaluateProp(props[type], props); | ||
var getBackgroundStyles = function (style, props) { | ||
if (!style) { | ||
return undefined; | ||
} | ||
return Array.isArray(style) && !(0, _isEmpty2.default)(style) ? style.map(function (s) { | ||
return _helpers.default.evaluateStyle(s, props); | ||
}) : _helpers.default.evaluateStyle(style); | ||
}; | ||
var getBackgroundPadding = function (props) { | ||
if (props.backgroundPadding && Array.isArray(props.backgroundPadding)) { | ||
return props.backgroundPadding.map(function (backgroundPadding) { | ||
var padding = _helpers.default.evaluateProp(backgroundPadding, props); | ||
return _helpers.default.getPadding({ | ||
padding: padding | ||
}); | ||
}); | ||
} else { | ||
var padding = _helpers.default.evaluateProp(props.backgroundPadding, props); | ||
return _helpers.default.getPadding({ | ||
padding: padding | ||
}); | ||
} | ||
}; | ||
var getLineHeight = function (props) { | ||
var lineHeight = getHeight(props, "lineHeight"); | ||
var lineHeight = _helpers.default.evaluateProp(props.lineHeight, props); | ||
@@ -119,3 +154,3 @@ if (Array.isArray(lineHeight)) { | ||
} else { | ||
return [lineHeight]; | ||
return lineHeight; | ||
} | ||
@@ -144,21 +179,30 @@ }; | ||
var getDy = function (props, lineHeight) { | ||
var style = Array.isArray(props.style) ? props.style[0] : props.style; | ||
lineHeight = lineHeight[0]; | ||
var fontSize = style.fontSize; | ||
var getDy = function (props, verticalAnchor, lineHeight) { | ||
var dy = props.dy ? _helpers.default.evaluateProp(props.dy, props) : 0; | ||
var length = props.inline ? 1 : props.text.length; | ||
var capHeight = getHeight(props, "capHeight"); | ||
var verticalAnchor = style.verticalAnchor || props.verticalAnchor; | ||
var capHeight = _helpers.default.evaluateProp(props.capHeight, props); | ||
var anchor = verticalAnchor ? _helpers.default.evaluateProp(verticalAnchor, props) : "middle"; | ||
switch (anchor) { | ||
case "end": | ||
return dy + (capHeight / 2 + (0.5 - length) * lineHeight) * fontSize; | ||
var fontSizes = _toConsumableArray(Array(length).keys()).map(function (i) { | ||
return getSingleValue(props.style, i).fontSize; | ||
}); | ||
case "middle": | ||
return dy + (capHeight / 2 + (0.5 - length / 2) * lineHeight) * fontSize; | ||
var lineHeights = _toConsumableArray(Array(length).keys()).map(function (i) { | ||
return getSingleValue(lineHeight, i); | ||
}); | ||
default: | ||
return dy + (capHeight / 2 + lineHeight / 2) * fontSize; | ||
if (anchor === "start") { | ||
return dy + (capHeight / 2 + lineHeights[0] / 2) * fontSizes[0]; | ||
} else if (props.inline) { | ||
return anchor === "end" ? dy + (capHeight / 2 - lineHeights[0] / 2) * fontSizes[0] : dy + capHeight / 2 * fontSizes[0]; | ||
} else if (length === 1) { | ||
return anchor === "end" ? dy + (capHeight / 2 + (0.5 - length) * lineHeights[0]) * fontSizes[0] : dy + (capHeight / 2 + (0.5 - length / 2) * lineHeights[0]) * fontSizes[0]; | ||
} else { | ||
var allHeights = _toConsumableArray(Array(length).keys()).reduce(function (memo, i) { | ||
return memo + (capHeight / 2 - lineHeights[i]) * fontSizes[i]; | ||
}, 0); | ||
return anchor === "end" ? dy + allHeights : dy + allHeights / 2 + capHeight / 2 * lineHeights[length - 1] * fontSizes[length - 1]; | ||
} | ||
@@ -170,4 +214,4 @@ }; | ||
y = props.y, | ||
polar = props.polar, | ||
style = props.style; | ||
polar = props.polar; | ||
var style = getSingleValue(props.style); | ||
var defaultAngle = polar ? _labelHelpers.default.getPolarAngle(props) : 0; | ||
@@ -189,3 +233,4 @@ var baseAngle = style.angle === undefined ? props.angle : style.angle; | ||
textAnchor = calculatedProps.textAnchor, | ||
x = calculatedProps.x; | ||
x = calculatedProps.x, | ||
dx = calculatedProps.dx; | ||
@@ -197,5 +242,2 @@ if (direction === "rtl") { | ||
switch (textAnchor) { | ||
case "start": | ||
return x; | ||
case "middle": | ||
@@ -208,12 +250,13 @@ return Math.round(x - labelSizeWidth / 2); | ||
default: | ||
return x; | ||
// start | ||
return x + (dx || 0); | ||
} | ||
}; | ||
var getYCoordinate = function (calculatedProps, props, textHeight) { | ||
var getYCoordinate = function (calculatedProps, textHeight) { | ||
var verticalAnchor = calculatedProps.verticalAnchor, | ||
y = calculatedProps.y; | ||
var dy = props.dy, | ||
inline = props.inline; | ||
var offset = y + (dy || 0); | ||
y = calculatedProps.y, | ||
_calculatedProps$orig = calculatedProps.originalDy, | ||
originalDy = _calculatedProps$orig === void 0 ? 0 : _calculatedProps$orig; | ||
var offset = y + originalDy; | ||
@@ -224,42 +267,22 @@ switch (verticalAnchor) { | ||
case "middle": | ||
return Math.floor(offset - textHeight / 2); | ||
case "end": | ||
return inline ? Math.floor(offset) : Math.ceil(offset - textHeight); | ||
return Math.ceil(offset - textHeight); | ||
default: | ||
return inline ? Math.floor(offset) : Math.floor(offset - textHeight / 2); | ||
// middle | ||
return Math.floor(offset - textHeight / 2); | ||
} | ||
}; | ||
var getBackgroundPadding = function (props) { | ||
if (props.backgroundPadding && Array.isArray(props.backgroundPadding)) { | ||
return props.backgroundPadding.map(function (backgroundPadding) { | ||
return _helpers.default.getPadding({ | ||
backgroundPadding: backgroundPadding | ||
}, "backgroundPadding"); | ||
}); | ||
} else { | ||
return _helpers.default.getPadding(props, "backgroundPadding"); | ||
} | ||
}; | ||
var getBackgroundPaddingProp = function (i, backgroundPadding) { | ||
if (Array.isArray(backgroundPadding)) { | ||
return backgroundPadding[i] || backgroundPadding[0]; | ||
} else { | ||
return backgroundPadding; | ||
} | ||
}; | ||
var getFullBackground = function (props, calculatedProps, tspanValues) { | ||
var backgroundComponent = props.backgroundComponent, | ||
backgroundStyle = props.backgroundStyle, | ||
inline = props.inline; | ||
var dx = calculatedProps.dx, | ||
var getFullBackground = function (calculatedProps, tspanValues) { | ||
var _calculatedProps$dx = calculatedProps.dx, | ||
dx = _calculatedProps$dx === void 0 ? 0 : _calculatedProps$dx, | ||
transform = calculatedProps.transform, | ||
backgroundComponent = calculatedProps.backgroundComponent, | ||
backgroundStyle = calculatedProps.backgroundStyle, | ||
inline = calculatedProps.inline, | ||
backgroundPadding = calculatedProps.backgroundPadding, | ||
transform = calculatedProps.transform; | ||
capHeight = calculatedProps.capHeight; | ||
var textSizes = tspanValues.map(function (tspan) { | ||
return _textsize.default.approximateTextSize(tspan.text, tspan.style); | ||
return tspan.textSize; | ||
}); | ||
@@ -269,11 +292,13 @@ var height = inline ? Math.max.apply(Math, _toConsumableArray(textSizes.map(function (size) { | ||
}))) : textSizes.reduce(function (memo, size, i) { | ||
return memo + size.height * tspanValues[i].lineHeight; | ||
var capHeightAdjustment = i ? capHeight / 2 : 0; | ||
return memo + size.height * (tspanValues[i].lineHeight - capHeightAdjustment); | ||
}, 0); | ||
var width = inline ? textSizes.reduce(function (memo, size) { | ||
return memo + size.width; | ||
}, 0) + (dx || 0) : Math.max.apply(Math, _toConsumableArray(textSizes.map(function (size) { | ||
var width = inline ? textSizes.reduce(function (memo, size, index) { | ||
var offset = index ? dx : 0; | ||
return memo + size.width + offset; | ||
}, 0) : Math.max.apply(Math, _toConsumableArray(textSizes.map(function (size) { | ||
return size.width; | ||
}))) + (dx || 0); | ||
}))); | ||
var xCoordinate = getXCoordinate(calculatedProps, width); | ||
var yCoordinate = getYCoordinate(calculatedProps, props, height); | ||
var yCoordinate = getYCoordinate(calculatedProps, height); | ||
var backgroundProps = { | ||
@@ -285,3 +310,3 @@ key: "background", | ||
width: width + backgroundPadding.left + backgroundPadding.right, | ||
x: xCoordinate, | ||
x: inline ? xCoordinate - backgroundPadding.left : xCoordinate + dx - backgroundPadding.left, | ||
y: yCoordinate | ||
@@ -292,22 +317,58 @@ }; | ||
var getChildBackgrounds = function (props, calculatedProps, tspanValues) { | ||
var backgroundStyle = props.backgroundStyle, | ||
backgroundComponent = props.backgroundComponent, | ||
inline = props.inline, | ||
y = props.y; | ||
var getInlineXOffset = function (calculatedProps, textElements, index) { | ||
var textAnchor = calculatedProps.textAnchor; | ||
var widths = textElements.map(function (t) { | ||
return t.widthWithPadding; | ||
}); | ||
var totalWidth = widths.reduce(function (memo, width) { | ||
return memo + width; | ||
}, 0); | ||
var centerOffset = -totalWidth / 2; | ||
switch (textAnchor) { | ||
case "start": | ||
return widths.reduce(function (memo, width, i) { | ||
memo = i < index ? memo + width : memo; | ||
return memo; | ||
}, 0); | ||
case "end": | ||
return widths.reduce(function (memo, width, i) { | ||
memo = i > index ? memo - width : memo; | ||
return memo; | ||
}, 0); | ||
default: | ||
// middle | ||
return widths.reduce(function (memo, width, i) { | ||
var offsetWidth = i < index ? width : 0; | ||
memo = i === index ? memo + width / 2 : memo + offsetWidth; | ||
return memo; | ||
}, centerOffset); | ||
} | ||
}; | ||
var getChildBackgrounds = function (calculatedProps, tspanValues) { | ||
var dy = calculatedProps.dy, | ||
dx = calculatedProps.dx, | ||
transform = calculatedProps.transform, | ||
backgroundStyle = calculatedProps.backgroundStyle, | ||
backgroundPadding = calculatedProps.backgroundPadding, | ||
transform = calculatedProps.transform; | ||
backgroundComponent = calculatedProps.backgroundComponent, | ||
inline = calculatedProps.inline, | ||
y = calculatedProps.y; | ||
var textElements = tspanValues.map(function (current, i) { | ||
var previous = tspanValues[i - 1] || tspanValues[0]; | ||
var labelSize = _textsize.default.approximateTextSize(current.text, current.style); | ||
var previous = getSingleValue(tspanValues, i - 1); | ||
var labelSize = current.textSize; | ||
var totalLineHeight = current.fontSize * current.lineHeight; | ||
var textHeight = Math.ceil(totalLineHeight); | ||
var prevPaddingProp = getBackgroundPaddingProp(i - 1, backgroundPadding); | ||
var childDy = i && !inline ? previous.fontSize * previous.lineHeight + prevPaddingProp.top + prevPaddingProp.bottom : dy - totalLineHeight * 0.5 - (current.fontSize - current.capHeight); | ||
var padding = getSingleValue(backgroundPadding, i); | ||
var prevPadding = getSingleValue(backgroundPadding, i - 1); | ||
var xOffset = inline ? dx || 0 : 0; | ||
var childDy = i && !inline ? previous.fontSize * previous.lineHeight + prevPadding.top + prevPadding.bottom : dy - totalLineHeight * 0.5 - (current.fontSize - current.capHeight); | ||
return { | ||
textHeight: textHeight, | ||
labelSize: labelSize, | ||
heightWithPadding: textHeight + padding.top + padding.bottom, | ||
widthWithPadding: labelSize.width + padding.left + padding.right + xOffset, | ||
y: y, | ||
@@ -323,11 +384,14 @@ fontSize: current.fontSize, | ||
}, y); | ||
var padding = getBackgroundPaddingProp(i, backgroundPadding); | ||
var padding = getSingleValue(backgroundPadding, i); | ||
var height = textElement.heightWithPadding; | ||
var xCoord = inline ? getInlineXOffset(calculatedProps, textElements, i) + xCoordinate - padding.left : xCoordinate; | ||
var yCoord = inline ? getYCoordinate(calculatedProps, height) - padding.top : yCoordinate; | ||
var backgroundProps = { | ||
key: "tspan-background-".concat(i), | ||
height: textElement.textHeight + padding.top + padding.bottom, | ||
style: backgroundStyle[i] || backgroundStyle[0], | ||
width: textElement.labelSize.width + padding.left + padding.right, | ||
height: height, | ||
style: getSingleValue(backgroundStyle, i), | ||
width: textElement.widthWithPadding, | ||
transform: transform, | ||
x: xCoordinate, | ||
y: yCoordinate | ||
x: xCoord - padding.left, | ||
y: yCoord | ||
}; | ||
@@ -338,18 +402,23 @@ return _react.default.cloneElement(backgroundComponent, (0, _defaults2.default)({}, backgroundComponent.props, backgroundProps)); | ||
var getBackgroundElement = function (props, calculatedProps, tspanValues) { | ||
return Array.isArray(props.backgroundStyle) ? getChildBackgrounds(props, calculatedProps, tspanValues) : getFullBackground(props, calculatedProps, tspanValues); | ||
var getBackgroundElement = function (calculatedProps, tspanValues) { | ||
return useMultiLineBackgrounds(calculatedProps) ? getChildBackgrounds(calculatedProps, tspanValues) : getFullBackground(calculatedProps, tspanValues); | ||
}; | ||
var calculateSpanDy = function (current, previous) { | ||
return -0.5 * previous.fontSize - 0.5 * (previous.fontSize * previous.lineHeight) + previous.fontSize * previous.lineHeight + 0.5 * current.fontSize + 0.5 * current.fontSize * current.lineHeight - (current.fontSize - current.capHeight) * 0.5 + (previous.fontSize - previous.capHeight) * 0.5; | ||
var calculateSpanDy = function (tspanValues, i, calculatedProps) { | ||
var current = getSingleValue(tspanValues, i); | ||
var previous = getSingleValue(tspanValues, i - 1); | ||
var previousHeight = previous.fontSize * previous.lineHeight; | ||
var currentHeight = current.fontSize * current.lineHeight; | ||
var previousCaps = previous.fontSize - previous.capHeight; | ||
var currentCaps = current.fontSize - current.capHeight; | ||
var textHeight = previousHeight - previous.fontSize / 2 + current.fontSize / 2 - previousHeight / 2 + currentHeight / 2 - currentCaps / 2 + previousCaps / 2; | ||
return useMultiLineBackgrounds(calculatedProps) ? textHeight + current.backgroundPadding.top + previous.backgroundPadding.bottom : textHeight; | ||
}; | ||
var getTSpanDy = function (tspanValues, props, i) { | ||
var inline = props.inline, | ||
backgroundStyle = props.backgroundStyle; | ||
var current = tspanValues[i]; | ||
var previous = tspanValues[i - 1] || tspanValues[0]; | ||
var getTSpanDy = function (tspanValues, calculatedProps, i) { | ||
var inline = calculatedProps.inline; | ||
var current = getSingleValue(tspanValues, i); | ||
if (i && !inline) { | ||
return backgroundStyle && Array.isArray(backgroundStyle) && backgroundStyle.length > 1 ? calculateSpanDy(current, previous) + current.backgroundPadding.top + previous.backgroundPadding.bottom : calculateSpanDy(current, previous); | ||
return calculateSpanDy(tspanValues, i, calculatedProps); | ||
} else if (inline) { | ||
@@ -372,2 +441,11 @@ return i === 0 ? current.backgroundPadding.top : undefined; | ||
})); | ||
var backgroundStyle = getBackgroundStyles(props.backgroundStyle, (0, _assign2.default)({}, props, { | ||
text: text, | ||
style: style | ||
})); | ||
var backgroundPadding = getBackgroundPadding((0, _assign2.default)({}, props, { | ||
text: text, | ||
style: style, | ||
backgroundStyle: backgroundStyle | ||
})); | ||
@@ -377,2 +455,4 @@ var id = _helpers.default.evaluateProp(props.id, props); | ||
return (0, _assign2.default)({}, props, { | ||
backgroundStyle: backgroundStyle, | ||
backgroundPadding: backgroundPadding, | ||
style: style, | ||
@@ -385,13 +465,13 @@ text: text, | ||
var getCalculatedProps = function (props) { | ||
var style = getSingleValue(props.style); | ||
var lineHeight = getLineHeight(props); | ||
var direction = props.direction ? _helpers.default.evaluateProp(props.direction, props) : "inherit"; | ||
var textAnchor = props.textAnchor ? _helpers.default.evaluateProp(props.textAnchor, props) : "start"; | ||
var verticalAnchor = props.verticalAnchor ? _helpers.default.evaluateProp(props.verticalAnchor, props) : "middle"; | ||
var textAnchor = props.textAnchor ? _helpers.default.evaluateProp(props.textAnchor, props) : style.textAnchor || "start"; | ||
var verticalAnchor = props.verticalAnchor ? _helpers.default.evaluateProp(props.verticalAnchor, props) : style.verticalAnchor || "middle"; | ||
var dx = props.dx ? _helpers.default.evaluateProp(props.dx, props) : 0; | ||
var dy = getDy(props, lineHeight); | ||
var dy = getDy(props, verticalAnchor, lineHeight); | ||
var transform = getTransform(props); | ||
var x = props.x !== undefined ? props.x : getPosition(props, "x"); | ||
var y = props.y !== undefined ? props.y : getPosition(props, "y"); | ||
var backgroundPadding = getBackgroundPadding(props); | ||
return { | ||
return (0, _assign2.default)({}, props, { | ||
lineHeight: lineHeight, | ||
@@ -403,17 +483,17 @@ direction: direction, | ||
dy: dy, | ||
backgroundPadding: backgroundPadding, | ||
originalDy: props.dy, | ||
transform: transform, | ||
x: x, | ||
y: y | ||
}; | ||
}); | ||
}; | ||
var renderLabel = function (props, calculatedProps, tspanValues) { | ||
var inline = props.inline, | ||
className = props.className, | ||
title = props.title, | ||
events = props.events, | ||
direction = props.direction, | ||
text = props.text; | ||
var textAnchor = calculatedProps.textAnchor, | ||
var renderLabel = function (calculatedProps, tspanValues) { | ||
var inline = calculatedProps.inline, | ||
className = calculatedProps.className, | ||
title = calculatedProps.title, | ||
events = calculatedProps.events, | ||
direction = calculatedProps.direction, | ||
text = calculatedProps.text, | ||
textAnchor = calculatedProps.textAnchor, | ||
dx = calculatedProps.dx, | ||
@@ -423,3 +503,8 @@ dy = calculatedProps.dy, | ||
x = calculatedProps.x, | ||
y = calculatedProps.y; | ||
y = calculatedProps.y, | ||
desc = calculatedProps.desc, | ||
tabIndex = calculatedProps.tabIndex, | ||
id = calculatedProps.id, | ||
tspanComponent = calculatedProps.tspanComponent, | ||
textComponent = calculatedProps.textComponent; | ||
@@ -436,5 +521,5 @@ var textProps = _objectSpread({ | ||
title: title, | ||
desc: _helpers.default.evaluateProp(props.desc, props), | ||
tabIndex: _helpers.default.evaluateProp(props.tabIndex, props), | ||
id: props.id | ||
desc: _helpers.default.evaluateProp(desc, calculatedProps), | ||
tabIndex: _helpers.default.evaluateProp(tabIndex, calculatedProps), | ||
id: id | ||
}); | ||
@@ -445,6 +530,6 @@ | ||
var tspanProps = { | ||
key: "".concat(props.id, "-key-").concat(i), | ||
x: !inline ? props.x : undefined, | ||
dx: dx + tspanValues[i].backgroundPadding.left, | ||
dy: getTSpanDy(tspanValues, props, i), | ||
key: "".concat(id, "-key-").concat(i), | ||
x: !inline ? x : undefined, | ||
dx: inline ? dx + tspanValues[i].backgroundPadding.left : dx, | ||
dy: getTSpanDy(tspanValues, calculatedProps, i), | ||
textAnchor: currentStyle.textAnchor || textAnchor, | ||
@@ -454,5 +539,5 @@ style: currentStyle, | ||
}; | ||
return _react.default.cloneElement(props.tspanComponent, tspanProps); | ||
return _react.default.cloneElement(tspanComponent, tspanProps); | ||
}); | ||
return _react.default.cloneElement(props.textComponent, textProps, tspans); | ||
return _react.default.cloneElement(textComponent, textProps, tspans); | ||
}; | ||
@@ -468,14 +553,13 @@ | ||
var calculatedProps = getCalculatedProps(props); | ||
var _props = props, | ||
text = _props.text, | ||
style = _props.style, | ||
capHeight = _props.capHeight; | ||
var backgroundPadding = calculatedProps.backgroundPadding, | ||
var text = calculatedProps.text, | ||
style = calculatedProps.style, | ||
capHeight = calculatedProps.capHeight, | ||
backgroundPadding = calculatedProps.backgroundPadding, | ||
lineHeight = calculatedProps.lineHeight; | ||
var tspanValues = text.map(function (line, i) { | ||
var currentStyle = style[i] || style[0]; | ||
var currentStyle = getSingleValue(style, i); | ||
var capHeightPx = _textsize.default.convertLengthToPixels("".concat(capHeight, "em"), currentStyle.fontSize); | ||
var currentLineHeight = lineHeight[i] || lineHeight[0]; | ||
var currentLineHeight = getSingleValue(lineHeight, i); | ||
return { | ||
@@ -486,10 +570,11 @@ style: currentStyle, | ||
text: line, | ||
textSize: _textsize.default.approximateTextSize(line, currentStyle), | ||
lineHeight: currentLineHeight, | ||
backgroundPadding: getBackgroundPaddingProp(i, backgroundPadding) | ||
backgroundPadding: getSingleValue(backgroundPadding, i) | ||
}; | ||
}); | ||
var label = renderLabel(props, calculatedProps, tspanValues); | ||
var label = renderLabel(calculatedProps, tspanValues); | ||
if (props.backgroundStyle) { | ||
var backgroundElement = getBackgroundElement(props, calculatedProps, tspanValues); | ||
var backgroundElement = getBackgroundElement(calculatedProps, tspanValues); | ||
var children = [backgroundElement, label]; | ||
@@ -496,0 +581,0 @@ |
@@ -21,3 +21,3 @@ "use strict"; | ||
var sansSerif = "'Gill Sans', 'Gill Sans MT', 'Seravek', 'Trebuchet MS', sans-serif"; | ||
var sansSerif = "'Gill Sans', 'Seravek', 'Trebuchet MS', sans-serif"; | ||
var letterSpacing = "normal"; | ||
@@ -104,3 +104,5 @@ var fontSize = 14; // * | ||
}, | ||
maxLabels: baseLabelStyles, | ||
maxLabels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
median: { | ||
@@ -111,3 +113,5 @@ padding: 8, | ||
}, | ||
medianLabels: baseLabelStyles, | ||
medianLabels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
min: { | ||
@@ -118,3 +122,5 @@ padding: 8, | ||
}, | ||
minLabels: baseLabelStyles, | ||
minLabels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
q1: { | ||
@@ -124,3 +130,5 @@ padding: 8, | ||
}, | ||
q1Labels: baseLabelStyles, | ||
q1Labels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
q3: { | ||
@@ -130,3 +138,5 @@ padding: 8, | ||
}, | ||
q3Labels: baseLabelStyles | ||
q3Labels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 3 | ||
}) | ||
}, | ||
@@ -141,3 +151,5 @@ boxWidth: 20 | ||
}, | ||
labels: baseLabelStyles | ||
labels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 5 | ||
}) | ||
}, | ||
@@ -230,3 +242,3 @@ candleColors: { | ||
style: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 5, | ||
padding: 0, | ||
pointerEvents: "none" | ||
@@ -240,2 +252,3 @@ }), | ||
}, | ||
flyoutPadding: 5, | ||
cornerRadius: 5, | ||
@@ -242,0 +255,0 @@ pointerLength: 10 |
@@ -29,3 +29,3 @@ "use strict"; | ||
var sansSerif = "'Roboto', 'Helvetica Neue', Helvetica, sans-serif"; | ||
var sansSerif = "'Helvetica Neue', 'Helvetica', sans-serif"; | ||
var letterSpacing = "normal"; | ||
@@ -106,2 +106,11 @@ var fontSize = 12; // * | ||
}, baseProps), | ||
polarDependentAxis: (0, _assign2.default)({ | ||
style: { | ||
ticks: { | ||
fill: "transparent", | ||
size: 1, | ||
stroke: "transparent" | ||
} | ||
} | ||
}), | ||
bar: (0, _assign2.default)({ | ||
@@ -124,3 +133,5 @@ style: { | ||
}, | ||
maxLabels: baseLabelStyles, | ||
maxLabels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
median: { | ||
@@ -131,3 +142,5 @@ padding: padding, | ||
}, | ||
medianLabels: baseLabelStyles, | ||
medianLabels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
min: { | ||
@@ -138,3 +151,5 @@ padding: padding, | ||
}, | ||
minLabels: baseLabelStyles, | ||
minLabels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
q1: { | ||
@@ -144,3 +159,5 @@ padding: padding, | ||
}, | ||
q1Labels: baseLabelStyles, | ||
q1Labels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 3 | ||
}), | ||
q3: { | ||
@@ -150,3 +167,5 @@ padding: padding, | ||
}, | ||
q3Labels: baseLabelStyles | ||
q3Labels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 3 | ||
}) | ||
}, | ||
@@ -160,3 +179,5 @@ boxWidth: 20 | ||
}, | ||
labels: baseLabelStyles | ||
labels: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 5 | ||
}) | ||
}, | ||
@@ -249,3 +270,3 @@ candleColors: { | ||
style: (0, _assign2.default)({}, baseLabelStyles, { | ||
padding: 5, | ||
padding: 0, | ||
pointerEvents: "none" | ||
@@ -259,2 +280,3 @@ }), | ||
}, | ||
flyoutPadding: 5, | ||
cornerRadius: 5, | ||
@@ -261,0 +283,0 @@ pointerLength: 10 |
@@ -135,2 +135,24 @@ "use strict"; | ||
function isTooltip(component) { | ||
var labelRole = component && component.type && component.type.role; | ||
return labelRole === "tooltip"; | ||
} | ||
function getDefaultStyles(props, role) { | ||
var _props$theme = props.theme, | ||
theme = _props$theme === void 0 ? {} : _props$theme, | ||
labelComponent = props.labelComponent; | ||
var defaultStyles = theme[role] && theme[role].style || {}; | ||
if (!isTooltip(labelComponent)) { | ||
return defaultStyles; | ||
} | ||
var tooltipStyle = theme.tooltip && theme.tooltip.style || {}; | ||
var labelStyle = (0, _defaults2.default)({}, tooltipStyle, defaultStyles.labels); | ||
return (0, _defaults2.default)({}, { | ||
labels: labelStyle | ||
}, defaultStyles); | ||
} | ||
function getStyles(style, defaultStyles) { | ||
@@ -357,2 +379,3 @@ var width = "100%"; | ||
getPadding: getPadding, | ||
getDefaultStyles: getDefaultStyles, | ||
getStyles: getStyles, | ||
@@ -370,4 +393,5 @@ evaluateProp: evaluateProp, | ||
reduceChildren: reduceChildren, | ||
isHorizontal: isHorizontal | ||
isHorizontal: isHorizontal, | ||
isTooltip: isTooltip | ||
}; | ||
exports.default = _default; |
@@ -8,2 +8,4 @@ "use strict"; | ||
var _defaults2 = _interopRequireDefault(require("lodash/defaults")); | ||
var _helpers = _interopRequireDefault(require("./helpers")); | ||
@@ -174,5 +176,5 @@ | ||
var degrees = baseAngle !== undefined ? baseAngle : getDegrees(props, datum); | ||
var degrees = baseAngle !== undefined ? baseAngle % 360 : getDegrees(props, datum); | ||
var sign = degrees > 90 && degrees < 180 || degrees > 270 ? 1 : -1; | ||
var angle; | ||
var angle = 0; | ||
@@ -195,3 +197,3 @@ if (degrees === 0 || degrees === 180) { | ||
return _helpers.default.radiansToDegrees(props.scale.x(x)); | ||
return _helpers.default.radiansToDegrees(props.scale.x(x)) % 360; | ||
} | ||
@@ -206,3 +208,5 @@ | ||
width = props.width, | ||
height = props.height; | ||
height = props.height, | ||
theme = props.theme, | ||
labelComponent = props.labelComponent; | ||
var datum = data[index]; | ||
@@ -224,3 +228,3 @@ var degrees = getDegrees(props, datum); | ||
return { | ||
var labelProps = { | ||
angle: angle, | ||
@@ -245,2 +249,9 @@ data: data, | ||
}; | ||
if (!_helpers.default.isTooltip(labelComponent)) { | ||
return labelProps; | ||
} | ||
var tooltipTheme = theme && theme.tooltip || {}; | ||
return (0, _defaults2.default)({}, labelProps, _helpers.default.omit(tooltipTheme, ["style"])); | ||
} | ||
@@ -247,0 +258,0 @@ |
@@ -22,26 +22,101 @@ "use strict"; | ||
var fontDictionary = { | ||
"American Typewriter": 2.09, | ||
Baskerville: 2.51, | ||
Georgia: 2.27, | ||
"Hoefler Text": 2.39, | ||
Palatino: 2.26, | ||
"Times New Roman": 2.48, | ||
Arial: 2.26, | ||
"Gill Sans": 2.47, | ||
"Gill Sans 300": 2.58, | ||
"Helvetica Neue": 2.24, | ||
"Lucida Grande": 2.05, | ||
Tahoma: 2.25, | ||
"Trebuchet MS": 2.2, | ||
Verdana: 1.96, | ||
"Courier New": 1.67, | ||
cursive: 1.84, | ||
fantasy: 2.09, | ||
monospace: 1.81, | ||
serif: 2.04, | ||
"sans-serif": 1.89 | ||
}; //https://developer.mozilla.org/en/docs/Web/CSS/length | ||
// Absolute sizes in pixels for obsolete measurement units. | ||
// Based on measuring specific character widths | ||
// as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf | ||
//prettier-ignore | ||
var fonts = { | ||
"American Typewriter": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.4203125, 0.3296875, 0.6, 0.6375, 0.8015625, 0.8203125, 0.1875, 0.45625, 0.45625, 0.6375, 0.5, 0.2734375, 0.309375, 0.2734375, 0.4390625, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.2734375, 0.2734375, 0.5, 0.5, 0.5, 0.6, 0.6921875, 0.7640625, 0.6921875, 0.6375, 0.728125, 0.6734375, 0.6203125, 0.7109375, 0.784375, 0.3828125, 0.6421875, 0.7859375, 0.6375, 0.9484375, 0.7640625, 0.65625, 0.6375, 0.65625, 0.7296875, 0.6203125, 0.6375, 0.7109375, 0.740625, 0.940625, 0.784375, 0.7578125, 0.6203125, 0.4375, 0.5, 0.4375, 0.5, 0.5, 0.4921875, 0.5734375, 0.5890625, 0.5109375, 0.6, 0.528125, 0.43125, 0.5578125, 0.6375, 0.3109375, 0.40625, 0.6234375, 0.309375, 0.928125, 0.6375, 0.546875, 0.6, 0.58125, 0.4921875, 0.4921875, 0.4, 0.6203125, 0.625, 0.825, 0.6375, 0.640625, 0.528125, 0.5, 0.5, 0.5, 0.6671875], | ||
avg: 0.5793421052631578 | ||
}, | ||
Arial: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.278125, 0.278125, 0.35625, 0.55625, 0.55625, 0.890625, 0.6671875, 0.1921875, 0.334375, 0.334375, 0.390625, 0.584375, 0.278125, 0.334375, 0.278125, 0.278125, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.278125, 0.278125, 0.584375, 0.584375, 0.584375, 0.55625, 1.015625, 0.6703125, 0.6671875, 0.7234375, 0.7234375, 0.6671875, 0.6109375, 0.778125, 0.7234375, 0.278125, 0.5, 0.6671875, 0.55625, 0.834375, 0.7234375, 0.778125, 0.6671875, 0.778125, 0.7234375, 0.6671875, 0.6109375, 0.7234375, 0.6671875, 0.9453125, 0.6671875, 0.6671875, 0.6109375, 0.278125, 0.278125, 0.278125, 0.4703125, 0.584375, 0.334375, 0.55625, 0.55625, 0.5, 0.55625, 0.55625, 0.3125, 0.55625, 0.55625, 0.2234375, 0.2703125, 0.5, 0.2234375, 0.834375, 0.55625, 0.55625, 0.55625, 0.55625, 0.346875, 0.5, 0.278125, 0.55625, 0.5, 0.7234375, 0.5, 0.5, 0.5, 0.334375, 0.2609375, 0.334375, 0.584375], | ||
avg: 0.528733552631579 | ||
}, | ||
"Arial Black": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.33125, 0.334375, 0.5, 0.6609375, 0.6671875, 1, 0.890625, 0.278125, 0.390625, 0.390625, 0.55625, 0.6609375, 0.334375, 0.334375, 0.334375, 0.28125, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.334375, 0.334375, 0.6609375, 0.6609375, 0.6609375, 0.6109375, 0.7453125, 0.78125, 0.778125, 0.778125, 0.778125, 0.7234375, 0.6671875, 0.834375, 0.834375, 0.390625, 0.6671875, 0.834375, 0.6671875, 0.9453125, 0.834375, 0.834375, 0.7234375, 0.834375, 0.78125, 0.7234375, 0.7234375, 0.834375, 0.7796875, 1.003125, 0.78125, 0.78125, 0.7234375, 0.390625, 0.28125, 0.390625, 0.6609375, 0.5125, 0.334375, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.41875, 0.6671875, 0.6671875, 0.334375, 0.384375, 0.6671875, 0.334375, 1, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.4703125, 0.6109375, 0.4453125, 0.6671875, 0.6140625, 0.946875, 0.6671875, 0.615625, 0.55625, 0.390625, 0.278125, 0.390625, 0.6609375], | ||
avg: 0.6213157894736842 | ||
}, | ||
Baskerville: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.25, 0.40625, 0.6671875, 0.490625, 0.875, 0.7015625, 0.178125, 0.2453125, 0.246875, 0.4171875, 0.6671875, 0.25, 0.3125, 0.25, 0.521875, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.25, 0.25, 0.6671875, 0.6671875, 0.6671875, 0.396875, 0.9171875, 0.684375, 0.615625, 0.71875, 0.7609375, 0.625, 0.553125, 0.771875, 0.803125, 0.3546875, 0.515625, 0.78125, 0.6046875, 0.928125, 0.75, 0.8234375, 0.5625, 0.96875, 0.7296875, 0.5421875, 0.6984375, 0.771875, 0.7296875, 0.9484375, 0.771875, 0.678125, 0.6359375, 0.3640625, 0.521875, 0.3640625, 0.46875, 0.5125, 0.334375, 0.46875, 0.521875, 0.428125, 0.521875, 0.4375, 0.3890625, 0.4765625, 0.53125, 0.25, 0.359375, 0.4640625, 0.240625, 0.803125, 0.53125, 0.5, 0.521875, 0.521875, 0.365625, 0.334375, 0.2921875, 0.521875, 0.4640625, 0.678125, 0.4796875, 0.465625, 0.428125, 0.4796875, 0.5109375, 0.4796875, 0.6671875], | ||
avg: 0.5323519736842108 | ||
}, | ||
Courier: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5984375, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6078125, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.61875, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.615625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6140625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625], | ||
avg: 0.6020559210526316 | ||
}, | ||
"Courier New": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5984375, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625], | ||
avg: 0.6015296052631579 | ||
}, | ||
cursive: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1921875, 0.24375, 0.40625, 0.5671875, 0.3984375, 0.721875, 0.909375, 0.2328125, 0.434375, 0.365625, 0.4734375, 0.5578125, 0.19375, 0.3484375, 0.19375, 0.7734375, 0.503125, 0.4171875, 0.5453125, 0.45, 0.6046875, 0.4703125, 0.5984375, 0.55625, 0.503125, 0.5546875, 0.20625, 0.2, 0.5625, 0.5546875, 0.546875, 0.403125, 0.70625, 0.734375, 0.7078125, 0.64375, 0.85, 0.753125, 0.75, 0.6484375, 1.0765625, 0.44375, 0.5359375, 0.8359375, 0.653125, 1.0109375, 1.1515625, 0.6796875, 0.6984375, 1.0625, 0.8234375, 0.5125, 0.9234375, 0.8546875, 0.70625, 0.9109375, 0.7421875, 0.715625, 0.6015625, 0.4640625, 0.3359375, 0.4109375, 0.5421875, 0.5421875, 0.4328125, 0.5125, 0.5, 0.3859375, 0.7375, 0.359375, 0.75625, 0.540625, 0.5328125, 0.3203125, 0.5296875, 0.5015625, 0.484375, 0.7890625, 0.5640625, 0.4203125, 0.703125, 0.471875, 0.4734375, 0.35, 0.4125, 0.5640625, 0.471875, 0.6484375, 0.5296875, 0.575, 0.4140625, 0.415625, 0.20625, 0.3796875, 0.5421875], | ||
avg: 0.5604440789473684 | ||
}, | ||
fantasy: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.215625, 0.2625, 0.3265625, 0.6109375, 0.534375, 0.7625, 0.7828125, 0.2, 0.4359375, 0.4359375, 0.3765625, 0.5109375, 0.2796875, 0.4609375, 0.2796875, 0.5296875, 0.6640625, 0.253125, 0.521875, 0.4765625, 0.6640625, 0.490625, 0.528125, 0.5546875, 0.496875, 0.5421875, 0.2796875, 0.2796875, 0.5625, 0.4609375, 0.5625, 0.4828125, 0.609375, 0.740625, 0.7234375, 0.740625, 0.8265625, 0.7234375, 0.6171875, 0.7359375, 0.765625, 0.240625, 0.5453125, 0.715625, 0.6078125, 0.8640625, 0.653125, 0.9125, 0.6484375, 0.946875, 0.6921875, 0.653125, 0.6953125, 0.8015625, 0.58125, 0.784375, 0.671875, 0.6265625, 0.690625, 0.4359375, 0.5296875, 0.4359375, 0.53125, 0.5, 0.2875, 0.5375, 0.603125, 0.4984375, 0.60625, 0.53125, 0.434375, 0.6421875, 0.56875, 0.209375, 0.4671875, 0.5484375, 0.2203125, 0.709375, 0.55, 0.5984375, 0.6140625, 0.5765625, 0.40625, 0.4734375, 0.3734375, 0.559375, 0.4421875, 0.6421875, 0.4890625, 0.578125, 0.4484375, 0.2546875, 0.2203125, 0.2546875, 0.55], | ||
avg: 0.536496710526316 | ||
}, | ||
Geneva: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.3328125, 0.3046875, 0.5, 0.6671875, 0.6671875, 0.90625, 0.728125, 0.3046875, 0.446875, 0.446875, 0.5078125, 0.6671875, 0.3046875, 0.3796875, 0.3046875, 0.5390625, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.6671875, 0.3046875, 0.3046875, 0.6671875, 0.6671875, 0.6671875, 0.56875, 0.871875, 0.728125, 0.6375, 0.6515625, 0.7015625, 0.5765625, 0.5546875, 0.675, 0.690625, 0.2421875, 0.4921875, 0.6640625, 0.584375, 0.7890625, 0.709375, 0.7359375, 0.584375, 0.78125, 0.60625, 0.60625, 0.640625, 0.6671875, 0.728125, 0.946875, 0.6109375, 0.6109375, 0.5765625, 0.446875, 0.5390625, 0.446875, 0.6671875, 0.6671875, 0.5921875, 0.5546875, 0.6109375, 0.546875, 0.603125, 0.5765625, 0.390625, 0.6109375, 0.584375, 0.2359375, 0.334375, 0.5390625, 0.2359375, 0.8953125, 0.584375, 0.60625, 0.603125, 0.603125, 0.3875, 0.509375, 0.44375, 0.584375, 0.565625, 0.78125, 0.53125, 0.571875, 0.5546875, 0.4515625, 0.246875, 0.4515625, 0.6671875], | ||
avg: 0.5762664473684211 | ||
}, | ||
Georgia: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2421875, 0.33125, 0.4125, 0.64375, 0.6109375, 0.81875, 0.7109375, 0.215625, 0.375, 0.375, 0.4734375, 0.64375, 0.2703125, 0.375, 0.2703125, 0.46875, 0.6140625, 0.4296875, 0.559375, 0.553125, 0.565625, 0.5296875, 0.5671875, 0.503125, 0.596875, 0.5671875, 0.3125, 0.3125, 0.64375, 0.64375, 0.64375, 0.4796875, 0.9296875, 0.715625, 0.6546875, 0.6421875, 0.75, 0.6546875, 0.6, 0.7265625, 0.815625, 0.390625, 0.51875, 0.7203125, 0.6046875, 0.928125, 0.7671875, 0.7453125, 0.6109375, 0.7453125, 0.7234375, 0.5625, 0.61875, 0.7578125, 0.70625, 0.99375, 0.7125, 0.6640625, 0.6015625, 0.375, 0.46875, 0.375, 0.64375, 0.65, 0.5, 0.5046875, 0.56875, 0.4546875, 0.575, 0.484375, 0.39375, 0.509375, 0.5828125, 0.29375, 0.3671875, 0.546875, 0.2875, 0.88125, 0.5921875, 0.5390625, 0.571875, 0.5640625, 0.4109375, 0.4328125, 0.3453125, 0.5765625, 0.5203125, 0.75625, 0.50625, 0.5171875, 0.4453125, 0.43125, 0.375, 0.43125, 0.64375], | ||
avg: 0.5551809210526316 | ||
}, | ||
"Gill Sans": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2765625, 0.271875, 0.3546875, 0.584375, 0.5421875, 0.6765625, 0.625, 0.1890625, 0.3234375, 0.3234375, 0.4171875, 0.584375, 0.2203125, 0.3234375, 0.2203125, 0.28125, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.2203125, 0.2296875, 0.584375, 0.584375, 0.584375, 0.334375, 1.0109375, 0.6671875, 0.5640625, 0.709375, 0.75, 0.5, 0.4703125, 0.740625, 0.7296875, 0.25, 0.3125, 0.65625, 0.490625, 0.78125, 0.78125, 0.8234375, 0.5109375, 0.8234375, 0.6046875, 0.459375, 0.6046875, 0.709375, 0.6046875, 1.0421875, 0.709375, 0.6046875, 0.646875, 0.334375, 0.28125, 0.334375, 0.4703125, 0.5828125, 0.334375, 0.428125, 0.5, 0.4390625, 0.5109375, 0.4796875, 0.296875, 0.428125, 0.5, 0.2203125, 0.2265625, 0.5, 0.2203125, 0.771875, 0.5, 0.553125, 0.5, 0.5, 0.3984375, 0.3859375, 0.334375, 0.5, 0.4390625, 0.7203125, 0.5, 0.4390625, 0.4171875, 0.334375, 0.2609375, 0.334375, 0.584375], | ||
avg: 0.4933717105263159 | ||
}, | ||
Helvetica: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2796875, 0.2765625, 0.3546875, 0.5546875, 0.5546875, 0.8890625, 0.665625, 0.190625, 0.3328125, 0.3328125, 0.3890625, 0.5828125, 0.2765625, 0.3328125, 0.2765625, 0.3015625, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.2765625, 0.2765625, 0.584375, 0.5828125, 0.584375, 0.5546875, 1.0140625, 0.665625, 0.665625, 0.721875, 0.721875, 0.665625, 0.609375, 0.7765625, 0.721875, 0.2765625, 0.5, 0.665625, 0.5546875, 0.8328125, 0.721875, 0.7765625, 0.665625, 0.7765625, 0.721875, 0.665625, 0.609375, 0.721875, 0.665625, 0.94375, 0.665625, 0.665625, 0.609375, 0.2765625, 0.3546875, 0.2765625, 0.4765625, 0.5546875, 0.3328125, 0.5546875, 0.5546875, 0.5, 0.5546875, 0.5546875, 0.2765625, 0.5546875, 0.5546875, 0.221875, 0.240625, 0.5, 0.221875, 0.8328125, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.3328125, 0.5, 0.2765625, 0.5546875, 0.5, 0.721875, 0.5, 0.5, 0.5, 0.3546875, 0.259375, 0.353125, 0.5890625], | ||
avg: 0.5279276315789471 | ||
}, | ||
"Helvetica Neue": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.278125, 0.259375, 0.4265625, 0.55625, 0.55625, 1, 0.6453125, 0.278125, 0.2703125, 0.26875, 0.353125, 0.6, 0.278125, 0.3890625, 0.278125, 0.36875, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.278125, 0.278125, 0.6, 0.6, 0.6, 0.55625, 0.8, 0.6625, 0.6859375, 0.7234375, 0.7046875, 0.6125, 0.575, 0.759375, 0.7234375, 0.259375, 0.5203125, 0.6703125, 0.55625, 0.871875, 0.7234375, 0.7609375, 0.6484375, 0.7609375, 0.6859375, 0.6484375, 0.575, 0.7234375, 0.6140625, 0.9265625, 0.6125, 0.6484375, 0.6125, 0.259375, 0.36875, 0.259375, 0.6, 0.5, 0.25625, 0.5375, 0.59375, 0.5375, 0.59375, 0.5375, 0.2984375, 0.575, 0.55625, 0.2234375, 0.2375, 0.5203125, 0.2234375, 0.853125, 0.55625, 0.575, 0.59375, 0.59375, 0.334375, 0.5, 0.315625, 0.55625, 0.5, 0.759375, 0.51875, 0.5, 0.48125, 0.334375, 0.2234375, 0.334375, 0.6], | ||
avg: 0.5279440789473684 | ||
}, | ||
"Hoefler Text": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2359375, 0.2234375, 0.3921875, 0.7125, 0.49375, 0.8859375, 0.771875, 0.2125, 0.3078125, 0.309375, 0.375, 0.4234375, 0.234375, 0.3125, 0.234375, 0.3, 0.5828125, 0.365625, 0.434375, 0.3921875, 0.5234375, 0.3984375, 0.5125, 0.4328125, 0.46875, 0.5125, 0.234375, 0.234375, 0.515625, 0.4234375, 0.515625, 0.340625, 0.7609375, 0.7359375, 0.6359375, 0.721875, 0.8125, 0.6375, 0.5875, 0.8078125, 0.853125, 0.4296875, 0.503125, 0.78125, 0.609375, 0.9609375, 0.8515625, 0.8140625, 0.6125, 0.8140625, 0.71875, 0.49375, 0.7125, 0.76875, 0.771875, 1.125, 0.7765625, 0.7734375, 0.65625, 0.321875, 0.3078125, 0.321875, 0.3546875, 0.5, 0.3375, 0.446875, 0.5359375, 0.45, 0.5296875, 0.4546875, 0.425, 0.4921875, 0.54375, 0.2671875, 0.240625, 0.5390625, 0.25, 0.815625, 0.5375, 0.5234375, 0.5390625, 0.5421875, 0.365625, 0.36875, 0.35625, 0.5171875, 0.5015625, 0.75, 0.5, 0.509375, 0.44375, 0.2421875, 0.14375, 0.2421875, 0.35], | ||
avg: 0.5116447368421051 | ||
}, | ||
monospace: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5984375, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6078125, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.61875, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.615625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6140625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625, 0.6015625], | ||
avg: 0.6020559210526316 | ||
}, | ||
Palatino: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.278125, 0.371875, 0.60625, 0.5, 0.840625, 0.778125, 0.209375, 0.334375, 0.334375, 0.390625, 0.60625, 0.2578125, 0.334375, 0.25, 0.60625, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.25, 0.25, 0.60625, 0.60625, 0.60625, 0.4453125, 0.7484375, 0.778125, 0.6109375, 0.709375, 0.775, 0.6109375, 0.55625, 0.7640625, 0.8328125, 0.3375, 0.346875, 0.7265625, 0.6109375, 0.946875, 0.83125, 0.7875, 0.6046875, 0.7875, 0.66875, 0.525, 0.6140625, 0.778125, 0.7234375, 1, 0.6671875, 0.6671875, 0.6671875, 0.334375, 0.60625, 0.334375, 0.60625, 0.5, 0.334375, 0.5, 0.565625, 0.4453125, 0.6109375, 0.4796875, 0.340625, 0.55625, 0.5828125, 0.2921875, 0.2671875, 0.5640625, 0.2921875, 0.8828125, 0.5828125, 0.546875, 0.6015625, 0.5609375, 0.3953125, 0.425, 0.3265625, 0.603125, 0.565625, 0.834375, 0.5171875, 0.55625, 0.5, 0.334375, 0.60625, 0.334375, 0.60625], | ||
avg: 0.5408552631578947 | ||
}, | ||
"sans-serif": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.278125, 0.278125, 0.35625, 0.55625, 0.55625, 0.890625, 0.6671875, 0.1921875, 0.334375, 0.334375, 0.390625, 0.584375, 0.278125, 0.334375, 0.278125, 0.303125, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.55625, 0.278125, 0.278125, 0.5859375, 0.584375, 0.5859375, 0.55625, 1.015625, 0.6671875, 0.6671875, 0.7234375, 0.7234375, 0.6671875, 0.6109375, 0.778125, 0.7234375, 0.278125, 0.5, 0.6671875, 0.55625, 0.834375, 0.7234375, 0.778125, 0.6671875, 0.778125, 0.7234375, 0.6671875, 0.6109375, 0.7234375, 0.6671875, 0.9453125, 0.6671875, 0.6671875, 0.6109375, 0.278125, 0.35625, 0.278125, 0.478125, 0.55625, 0.334375, 0.55625, 0.55625, 0.5, 0.55625, 0.55625, 0.278125, 0.55625, 0.55625, 0.2234375, 0.2421875, 0.5, 0.2234375, 0.834375, 0.55625, 0.55625, 0.55625, 0.55625, 0.334375, 0.5, 0.278125, 0.55625, 0.5, 0.7234375, 0.5, 0.5, 0.5, 0.35625, 0.2609375, 0.3546875, 0.590625], | ||
avg: 0.5293256578947368 | ||
}, | ||
Seravek: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.215625, 0.296875, 0.4171875, 0.6734375, 0.4953125, 0.9125, 0.740625, 0.2421875, 0.3375, 0.3375, 0.409375, 0.60625, 0.2609375, 0.35625, 0.25625, 0.41875, 0.5921875, 0.3515625, 0.475, 0.4875, 0.5375, 0.509375, 0.5484375, 0.4546875, 0.5421875, 0.5484375, 0.25625, 0.2546875, 0.5875, 0.6171875, 0.5875, 0.4578125, 0.8140625, 0.6765625, 0.5703125, 0.6109375, 0.684375, 0.5109375, 0.4953125, 0.678125, 0.6859375, 0.2625, 0.2625, 0.5859375, 0.4734375, 0.846875, 0.709375, 0.740625, 0.509375, 0.740625, 0.584375, 0.5015625, 0.528125, 0.675, 0.5953125, 0.9453125, 0.596875, 0.540625, 0.540625, 0.359375, 0.4203125, 0.359375, 0.5109375, 0.421875, 0.4046875, 0.5015625, 0.5421875, 0.446875, 0.5453125, 0.484375, 0.38125, 0.5140625, 0.5546875, 0.240625, 0.2640625, 0.490625, 0.2765625, 0.8625, 0.5546875, 0.546875, 0.5453125, 0.5453125, 0.3625, 0.41875, 0.3890625, 0.5453125, 0.4703125, 0.7546875, 0.4921875, 0.4609375, 0.453125, 0.4015625, 0.2640625, 0.4015625, 0.58125], | ||
avg: 0.5044078947368421 | ||
}, | ||
serif: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2484375, 0.334375, 0.409375, 0.5, 0.5, 0.834375, 0.778125, 0.18125, 0.334375, 0.334375, 0.5, 0.5640625, 0.25, 0.334375, 0.25, 0.278125, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.278125, 0.278125, 0.5640625, 0.5640625, 0.5640625, 0.4453125, 0.921875, 0.7234375, 0.6671875, 0.6671875, 0.7234375, 0.6109375, 0.55625, 0.7234375, 0.7234375, 0.334375, 0.390625, 0.7234375, 0.6109375, 0.890625, 0.7234375, 0.7234375, 0.55625, 0.7234375, 0.6671875, 0.55625, 0.6109375, 0.7234375, 0.7234375, 0.9453125, 0.7234375, 0.7234375, 0.6109375, 0.334375, 0.340625, 0.334375, 0.4703125, 0.5, 0.3453125, 0.4453125, 0.5, 0.4453125, 0.5, 0.4453125, 0.3828125, 0.5, 0.5, 0.278125, 0.3359375, 0.5, 0.278125, 0.778125, 0.5, 0.5, 0.5, 0.5, 0.3375, 0.390625, 0.2796875, 0.5, 0.5, 0.7234375, 0.5, 0.5, 0.4453125, 0.48125, 0.2015625, 0.48125, 0.5421875], | ||
avg: 0.5126315789473684 | ||
}, | ||
Tahoma: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.3109375, 0.3328125, 0.4015625, 0.728125, 0.546875, 0.9765625, 0.70625, 0.2109375, 0.3828125, 0.3828125, 0.546875, 0.728125, 0.303125, 0.3640625, 0.303125, 0.3953125, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.3546875, 0.3546875, 0.728125, 0.728125, 0.728125, 0.475, 0.909375, 0.6109375, 0.590625, 0.6015625, 0.6796875, 0.5625, 0.521875, 0.66875, 0.6765625, 0.3734375, 0.4171875, 0.6046875, 0.4984375, 0.771875, 0.66875, 0.7078125, 0.5515625, 0.7078125, 0.6375, 0.5578125, 0.5875, 0.65625, 0.60625, 0.903125, 0.58125, 0.5890625, 0.559375, 0.3828125, 0.39375, 0.3828125, 0.728125, 0.5625, 0.546875, 0.525, 0.553125, 0.4625, 0.553125, 0.5265625, 0.3546875, 0.553125, 0.5578125, 0.2296875, 0.328125, 0.51875, 0.2296875, 0.840625, 0.5578125, 0.54375, 0.553125, 0.553125, 0.3609375, 0.446875, 0.3359375, 0.5578125, 0.4984375, 0.7421875, 0.4953125, 0.4984375, 0.4453125, 0.48125, 0.3828125, 0.48125, 0.728125], | ||
avg: 0.5384374999999998 | ||
}, | ||
"Times New Roman": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2484375, 0.334375, 0.409375, 0.5, 0.5, 0.834375, 0.778125, 0.18125, 0.334375, 0.334375, 0.5, 0.5640625, 0.25, 0.334375, 0.25, 0.28125, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.278125, 0.278125, 0.5640625, 0.5640625, 0.5640625, 0.4453125, 0.921875, 0.7234375, 0.6671875, 0.6671875, 0.7234375, 0.6109375, 0.55625, 0.7234375, 0.7234375, 0.334375, 0.390625, 0.73125, 0.6109375, 0.890625, 0.7375, 0.7234375, 0.55625, 0.7234375, 0.6765625, 0.55625, 0.6109375, 0.7234375, 0.7234375, 0.9453125, 0.7234375, 0.7234375, 0.6109375, 0.334375, 0.28125, 0.334375, 0.4703125, 0.51875, 0.334375, 0.4453125, 0.503125, 0.4453125, 0.503125, 0.4453125, 0.4359375, 0.5, 0.5, 0.278125, 0.35625, 0.50625, 0.278125, 0.778125, 0.5, 0.5, 0.5046875, 0.5, 0.340625, 0.390625, 0.2796875, 0.5, 0.5, 0.7234375, 0.5, 0.5, 0.4453125, 0.48125, 0.2015625, 0.48125, 0.5421875], | ||
avg: 0.5134375 | ||
}, | ||
"Trebuchet MS": { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.3015625, 0.3671875, 0.325, 0.53125, 0.525, 0.6015625, 0.70625, 0.1609375, 0.3671875, 0.3671875, 0.3671875, 0.525, 0.3671875, 0.3671875, 0.3671875, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.3671875, 0.3671875, 0.525, 0.525, 0.525, 0.3671875, 0.771875, 0.590625, 0.5671875, 0.5984375, 0.6140625, 0.5359375, 0.525, 0.6765625, 0.6546875, 0.2796875, 0.4765625, 0.5765625, 0.5078125, 0.7109375, 0.6390625, 0.675, 0.5578125, 0.7421875, 0.5828125, 0.48125, 0.58125, 0.6484375, 0.5875, 0.853125, 0.5578125, 0.5703125, 0.5515625, 0.3671875, 0.3578125, 0.3671875, 0.525, 0.53125, 0.525, 0.5265625, 0.5578125, 0.4953125, 0.5578125, 0.546875, 0.375, 0.503125, 0.546875, 0.2859375, 0.3671875, 0.5046875, 0.2953125, 0.83125, 0.546875, 0.5375, 0.5578125, 0.5578125, 0.3890625, 0.40625, 0.396875, 0.546875, 0.490625, 0.7453125, 0.5015625, 0.49375, 0.475, 0.3671875, 0.525, 0.3671875, 0.525], | ||
avg: 0.5085197368421052 | ||
}, | ||
Verdana: { | ||
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.35, 0.39375, 0.459375, 0.81875, 0.6359375, 1.0765625, 0.759375, 0.26875, 0.4546875, 0.4546875, 0.6359375, 0.81875, 0.3640625, 0.4546875, 0.3640625, 0.4703125, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.4546875, 0.4546875, 0.81875, 0.81875, 0.81875, 0.546875, 1, 0.684375, 0.6859375, 0.6984375, 0.771875, 0.6328125, 0.575, 0.7765625, 0.7515625, 0.421875, 0.4546875, 0.69375, 0.5578125, 0.84375, 0.7484375, 0.7875, 0.603125, 0.7875, 0.7, 0.684375, 0.6171875, 0.7328125, 0.684375, 0.9890625, 0.6859375, 0.615625, 0.6859375, 0.4546875, 0.46875, 0.4546875, 0.81875, 0.6421875, 0.6359375, 0.6015625, 0.6234375, 0.521875, 0.6234375, 0.596875, 0.384375, 0.6234375, 0.6328125, 0.275, 0.3765625, 0.5921875, 0.275, 0.9734375, 0.6328125, 0.6078125, 0.6234375, 0.6234375, 0.43125, 0.521875, 0.3953125, 0.6328125, 0.5921875, 0.81875, 0.5921875, 0.5921875, 0.5265625, 0.6359375, 0.4546875, 0.6359375, 0.81875], | ||
avg: 0.6171875000000003 | ||
} //https://developer.mozilla.org/en/docs/Web/CSS/length | ||
// Absolute sizes in pixels for obsolete measurement units. | ||
}; | ||
var absoluteMeasurementUnitsToPixels = { | ||
@@ -60,11 +135,5 @@ mm: 3.8, | ||
var coefficients = { | ||
averageFontConstant: 2.1675, | ||
// Average pixels per glyph in existing font. | ||
widthOverlapCoef: 1.25, | ||
// Coefficient for width value to prevent overlap. | ||
heightOverlapCoef: 1.05, | ||
// Coefficient for height value to prevent overlap. | ||
lineCapitalCoef: 1.15, | ||
// Coefficient for height value. Reserve space for capital chars. | ||
lineSpaceHeightCoef: 0.2 // Coefficient for height value. Reserve space between lines. | ||
lineCapitalCoef: 1.15 // Coefficient for height value. Reserve space for capital chars. | ||
@@ -84,5 +153,10 @@ }; | ||
var _getFontCharacterConstant = function (fontFamily) { | ||
var firstFont = fontFamily.split(",")[0].replace(/'|"/g, ""); | ||
return fontDictionary[firstFont] || coefficients.averageFontConstant; | ||
var _getFontData = function (fontFamily) { | ||
var possibleFonts = fontFamily.split(",").map(function (f) { | ||
return f.replace(/'|"/g, ""); | ||
}); | ||
var fontMatch = possibleFonts.find(function (f) { | ||
return fonts[f]; | ||
}) || "Helvetica"; | ||
return fonts[fontMatch]; | ||
}; | ||
@@ -108,7 +182,9 @@ | ||
var convertLengthToPixels = function (length, fontSize) { | ||
var attribute = length.match(/[a-zA-Z%]+/)[0]; | ||
var attribute = length.match(/[a-zA-Z%]+/) && length.match(/[a-zA-Z%]+/)[0]; | ||
var value = length.match(/[0-9.,]+/); | ||
var result; | ||
if (absoluteMeasurementUnitsToPixels.hasOwnProperty(attribute)) { | ||
if (!attribute) { | ||
result = value || 0; | ||
} else if (absoluteMeasurementUnitsToPixels.hasOwnProperty(attribute)) { | ||
result = value * absoluteMeasurementUnitsToPixels[attribute]; | ||
@@ -128,4 +204,4 @@ } else if (relativeMeasurementUnitsCoef.hasOwnProperty(attribute)) { | ||
return (0, _assign2.default)({}, style, { | ||
characterConstant: style.characterConstant || _getFontCharacterConstant(style.fontFamily), | ||
letterSpacing: convertLengthToPixels(style.letterSpacing, style.fontSize), | ||
fontFamily: style.fontFamily, | ||
letterSpacing: typeof style.letterSpacing === "number" ? style.letterSpacing : convertLengthToPixels(String(style.letterSpacing), style.fontSize), | ||
fontSize: typeof style.fontSize === "number" ? style.fontSize : convertLengthToPixels(String(style.fontSize)) | ||
@@ -145,6 +221,13 @@ }); | ||
fontSize = _prepareParams2.fontSize, | ||
characterConstant = _prepareParams2.characterConstant, | ||
letterSpacing = _prepareParams2.letterSpacing; | ||
letterSpacing = _prepareParams2.letterSpacing, | ||
fontFamily = _prepareParams2.fontFamily; | ||
return len * fontSize / characterConstant + letterSpacing * Math.max(len - 1, 0); | ||
var fontData = _getFontData(fontFamily); | ||
var width = line.toString().split("").map(function (c) { | ||
return c.charCodeAt(0) < fontData.widths.length ? fontData.widths[c.charCodeAt(0)] : fontData.avg; | ||
}).reduce(function (cur, acc) { | ||
return acc + cur; | ||
}) * fontSize; | ||
return width + letterSpacing * Math.max(len - 1, 0); | ||
}); | ||
@@ -165,4 +248,3 @@ | ||
var height = containsCaps ? lineStyle.fontSize * coefficients.lineCapitalCoef : lineStyle.fontSize; | ||
var emptySpace = index === 0 ? 0 : lineStyle.fontSize * coefficients.lineSpaceHeightCoef; | ||
return total + lineStyle.lineHeight * (height + emptySpace); | ||
return total + lineStyle.lineHeight * height; | ||
}, 0); | ||
@@ -178,3 +260,2 @@ }; | ||
* @param {string} style.letterSpacing Text letterSpacing(space between letters). | ||
* @param {number} style.characterConstant Average pixels per glyph. | ||
* @param {number} style.lineHeight Line height coefficient. | ||
@@ -195,3 +276,3 @@ * @returns {number} Approximate text label height. | ||
return { | ||
width: widthWithRotate * coefficients.widthOverlapCoef, | ||
width: widthWithRotate, | ||
height: heightWithRotate * coefficients.heightOverlapCoef | ||
@@ -198,0 +279,0 @@ }; |
{ | ||
"name": "victory-core", | ||
"version": "34.3.12", | ||
"version": "35.0.0", | ||
"description": "Victory Core", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -101,4 +101,6 @@ import * as React from "react"; | ||
export type VictoryNumberCallback = (args: CallbackArgs) => number; | ||
export type VictoryPaddingCallback = (args: CallbackArgs) => number | BlockProps; | ||
export type StringOrNumberOrCallback = string | number | VictoryStringOrNumberCallback; | ||
export type NumberOrCallback = number | VictoryNumberCallback; | ||
export type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback; | ||
@@ -397,2 +399,29 @@ export type SliceNumberOrCallback<T, P = null> = number | ((props: Omit<T, P>) => number); | ||
} & ThemeBaseProps; | ||
polarAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
}; | ||
} & ThemeBaseProps; | ||
polarDependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
}; | ||
} & ThemeBaseProps; | ||
polarIndependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
}; | ||
} & ThemeBaseProps; | ||
scatter?: { | ||
@@ -410,2 +439,3 @@ style?: { | ||
pointerLength?: number; | ||
flyoutPadding?: number; | ||
}; | ||
@@ -412,0 +442,0 @@ voronoi?: { |
@@ -49,2 +49,14 @@ /*eslint no-magic-numbers: ["error", { "ignore": [-0.5, 0.5, 0, 1, 2] }]*/ | ||
const getSingleValue = (prop, index = 0) => { | ||
return Array.isArray(prop) ? prop[index] || prop[0] : prop; | ||
}; | ||
const useMultiLineBackgrounds = (props) => { | ||
const { backgroundStyle, backgroundPadding } = props; | ||
return ( | ||
(Array.isArray(backgroundStyle) && !isEmpty(backgroundStyle)) || | ||
(Array.isArray(backgroundPadding) && !isEmpty(backgroundPadding)) | ||
); | ||
}; | ||
const getStyles = (style, props) => { | ||
@@ -59,15 +71,32 @@ const getSingleStyle = (s) => { | ||
? style.map((s) => getSingleStyle(s)) | ||
: [getSingleStyle(style)]; | ||
: getSingleStyle(style); | ||
}; | ||
const getHeight = (props, type) => { | ||
return Helpers.evaluateProp(props[type], props); | ||
const getBackgroundStyles = (style, props) => { | ||
if (!style) { | ||
return undefined; | ||
} | ||
return Array.isArray(style) && !isEmpty(style) | ||
? style.map((s) => Helpers.evaluateStyle(s, props)) | ||
: Helpers.evaluateStyle(style); | ||
}; | ||
const getBackgroundPadding = (props) => { | ||
if (props.backgroundPadding && Array.isArray(props.backgroundPadding)) { | ||
return props.backgroundPadding.map((backgroundPadding) => { | ||
const padding = Helpers.evaluateProp(backgroundPadding, props); | ||
return Helpers.getPadding({ padding }); | ||
}); | ||
} else { | ||
const padding = Helpers.evaluateProp(props.backgroundPadding, props); | ||
return Helpers.getPadding({ padding }); | ||
} | ||
}; | ||
const getLineHeight = (props) => { | ||
const lineHeight = getHeight(props, "lineHeight"); | ||
const lineHeight = Helpers.evaluateProp(props.lineHeight, props); | ||
if (Array.isArray(lineHeight)) { | ||
return isEmpty(lineHeight) ? [1] : lineHeight; | ||
} else { | ||
return [lineHeight]; | ||
return lineHeight; | ||
} | ||
@@ -90,18 +119,27 @@ }; | ||
const getDy = (props, lineHeight) => { | ||
const style = Array.isArray(props.style) ? props.style[0] : props.style; | ||
lineHeight = lineHeight[0]; | ||
const fontSize = style.fontSize; | ||
const getDy = (props, verticalAnchor, lineHeight) => { | ||
const dy = props.dy ? Helpers.evaluateProp(props.dy, props) : 0; | ||
const length = props.inline ? 1 : props.text.length; | ||
const capHeight = getHeight(props, "capHeight"); | ||
const verticalAnchor = style.verticalAnchor || props.verticalAnchor; | ||
const capHeight = Helpers.evaluateProp(props.capHeight, props); | ||
const anchor = verticalAnchor ? Helpers.evaluateProp(verticalAnchor, props) : "middle"; | ||
switch (anchor) { | ||
case "end": | ||
return dy + (capHeight / 2 + (0.5 - length) * lineHeight) * fontSize; | ||
case "middle": | ||
return dy + (capHeight / 2 + (0.5 - length / 2) * lineHeight) * fontSize; | ||
default: | ||
return dy + (capHeight / 2 + lineHeight / 2) * fontSize; | ||
const fontSizes = [...Array(length).keys()].map((i) => getSingleValue(props.style, i).fontSize); | ||
const lineHeights = [...Array(length).keys()].map((i) => getSingleValue(lineHeight, i)); | ||
if (anchor === "start") { | ||
return dy + (capHeight / 2 + lineHeights[0] / 2) * fontSizes[0]; | ||
} else if (props.inline) { | ||
return anchor === "end" | ||
? dy + (capHeight / 2 - lineHeights[0] / 2) * fontSizes[0] | ||
: dy + (capHeight / 2) * fontSizes[0]; | ||
} else if (length === 1) { | ||
return anchor === "end" | ||
? dy + (capHeight / 2 + (0.5 - length) * lineHeights[0]) * fontSizes[0] | ||
: dy + (capHeight / 2 + (0.5 - length / 2) * lineHeights[0]) * fontSizes[0]; | ||
} else { | ||
const allHeights = [...Array(length).keys()].reduce((memo, i) => { | ||
return memo + (capHeight / 2 - lineHeights[i]) * fontSizes[i]; | ||
}, 0); | ||
return anchor === "end" | ||
? dy + allHeights | ||
: dy + allHeights / 2 + (capHeight / 2) * lineHeights[length - 1] * fontSizes[length - 1]; | ||
} | ||
@@ -111,3 +149,4 @@ }; | ||
const getTransform = (props) => { | ||
const { x, y, polar, style } = props; | ||
const { x, y, polar } = props; | ||
const style = getSingleValue(props.style); | ||
const defaultAngle = polar ? LabelHelpers.getPolarAngle(props) : 0; | ||
@@ -123,4 +162,3 @@ const baseAngle = style.angle === undefined ? props.angle : style.angle; | ||
const getXCoordinate = (calculatedProps, labelSizeWidth) => { | ||
const { direction, textAnchor, x } = calculatedProps; | ||
const { direction, textAnchor, x, dx } = calculatedProps; | ||
if (direction === "rtl") { | ||
@@ -131,4 +169,2 @@ return x - labelSizeWidth; | ||
switch (textAnchor) { | ||
case "start": | ||
return x; | ||
case "middle": | ||
@@ -139,10 +175,10 @@ return Math.round(x - labelSizeWidth / 2); | ||
default: | ||
return x; | ||
// start | ||
return x + (dx || 0); | ||
} | ||
}; | ||
const getYCoordinate = (calculatedProps, props, textHeight) => { | ||
const { verticalAnchor, y } = calculatedProps; | ||
const { dy, inline } = props; | ||
const offset = y + (dy || 0); | ||
const getYCoordinate = (calculatedProps, textHeight) => { | ||
const { verticalAnchor, y, originalDy = 0 } = calculatedProps; | ||
const offset = y + originalDy; | ||
@@ -152,34 +188,22 @@ switch (verticalAnchor) { | ||
return Math.floor(offset); | ||
case "middle": | ||
return Math.floor(offset - textHeight / 2); | ||
case "end": | ||
return inline ? Math.floor(offset) : Math.ceil(offset - textHeight); | ||
return Math.ceil(offset - textHeight); | ||
default: | ||
return inline ? Math.floor(offset) : Math.floor(offset - textHeight / 2); | ||
// middle | ||
return Math.floor(offset - textHeight / 2); | ||
} | ||
}; | ||
const getBackgroundPadding = (props) => { | ||
if (props.backgroundPadding && Array.isArray(props.backgroundPadding)) { | ||
return props.backgroundPadding.map((backgroundPadding) => | ||
Helpers.getPadding({ backgroundPadding }, "backgroundPadding") | ||
); | ||
} else { | ||
return Helpers.getPadding(props, "backgroundPadding"); | ||
} | ||
}; | ||
const getBackgroundPaddingProp = (i, backgroundPadding) => { | ||
if (Array.isArray(backgroundPadding)) { | ||
return backgroundPadding[i] || backgroundPadding[0]; | ||
} else { | ||
return backgroundPadding; | ||
} | ||
}; | ||
const getFullBackground = (props, calculatedProps, tspanValues) => { | ||
const { backgroundComponent, backgroundStyle, inline } = props; | ||
const { dx, backgroundPadding, transform } = calculatedProps; | ||
const getFullBackground = (calculatedProps, tspanValues) => { | ||
const { | ||
dx = 0, | ||
transform, | ||
backgroundComponent, | ||
backgroundStyle, | ||
inline, | ||
backgroundPadding, | ||
capHeight | ||
} = calculatedProps; | ||
const textSizes = tspanValues.map((tspan) => { | ||
return TextSize.approximateTextSize(tspan.text, tspan.style); | ||
return tspan.textSize; | ||
}); | ||
@@ -189,10 +213,16 @@ | ||
? Math.max(...textSizes.map((size) => size.height)) | ||
: textSizes.reduce((memo, size, i) => memo + size.height * tspanValues[i].lineHeight, 0); | ||
: textSizes.reduce((memo, size, i) => { | ||
const capHeightAdjustment = i ? capHeight / 2 : 0; | ||
return memo + size.height * (tspanValues[i].lineHeight - capHeightAdjustment); | ||
}, 0); | ||
const width = inline | ||
? textSizes.reduce((memo, size) => memo + size.width, 0) + (dx || 0) | ||
: Math.max(...textSizes.map((size) => size.width)) + (dx || 0); | ||
? textSizes.reduce((memo, size, index) => { | ||
const offset = index ? dx : 0; | ||
return memo + size.width + offset; | ||
}, 0) | ||
: Math.max(...textSizes.map((size) => size.width)); | ||
const xCoordinate = getXCoordinate(calculatedProps, width); | ||
const yCoordinate = getYCoordinate(calculatedProps, props, height); | ||
const yCoordinate = getYCoordinate(calculatedProps, height); | ||
@@ -205,3 +235,3 @@ const backgroundProps = { | ||
width: width + backgroundPadding.left + backgroundPadding.right, | ||
x: xCoordinate, | ||
x: inline ? xCoordinate - backgroundPadding.left : xCoordinate + dx - backgroundPadding.left, | ||
y: yCoordinate | ||
@@ -216,16 +246,52 @@ }; | ||
const getChildBackgrounds = (props, calculatedProps, tspanValues) => { | ||
const { backgroundStyle, backgroundComponent, inline, y } = props; | ||
const { dy, backgroundPadding, transform } = calculatedProps; | ||
const getInlineXOffset = (calculatedProps, textElements, index) => { | ||
const { textAnchor } = calculatedProps; | ||
const widths = textElements.map((t) => t.widthWithPadding); | ||
const totalWidth = widths.reduce((memo, width) => memo + width, 0); | ||
const centerOffset = -totalWidth / 2; | ||
switch (textAnchor) { | ||
case "start": | ||
return widths.reduce((memo, width, i) => { | ||
memo = i < index ? memo + width : memo; | ||
return memo; | ||
}, 0); | ||
case "end": | ||
return widths.reduce((memo, width, i) => { | ||
memo = i > index ? memo - width : memo; | ||
return memo; | ||
}, 0); | ||
default: | ||
// middle | ||
return widths.reduce((memo, width, i) => { | ||
const offsetWidth = i < index ? width : 0; | ||
memo = i === index ? memo + width / 2 : memo + offsetWidth; | ||
return memo; | ||
}, centerOffset); | ||
} | ||
}; | ||
const getChildBackgrounds = (calculatedProps, tspanValues) => { | ||
const { | ||
dy, | ||
dx, | ||
transform, | ||
backgroundStyle, | ||
backgroundPadding, | ||
backgroundComponent, | ||
inline, | ||
y | ||
} = calculatedProps; | ||
const textElements = tspanValues.map((current, i) => { | ||
const previous = tspanValues[i - 1] || tspanValues[0]; | ||
const labelSize = TextSize.approximateTextSize(current.text, current.style); | ||
const previous = getSingleValue(tspanValues, i - 1); | ||
const labelSize = current.textSize; | ||
const totalLineHeight = current.fontSize * current.lineHeight; | ||
const textHeight = Math.ceil(totalLineHeight); | ||
const prevPaddingProp = getBackgroundPaddingProp(i - 1, backgroundPadding); | ||
const padding = getSingleValue(backgroundPadding, i); | ||
const prevPadding = getSingleValue(backgroundPadding, i - 1); | ||
const xOffset = inline ? dx || 0 : 0; | ||
const childDy = | ||
i && !inline | ||
? previous.fontSize * previous.lineHeight + prevPaddingProp.top + prevPaddingProp.bottom | ||
? previous.fontSize * previous.lineHeight + prevPadding.top + prevPadding.bottom | ||
: dy - totalLineHeight * 0.5 - (current.fontSize - current.capHeight); | ||
@@ -236,2 +302,4 @@ | ||
labelSize, | ||
heightWithPadding: textHeight + padding.top + padding.bottom, | ||
widthWithPadding: labelSize.width + padding.left + padding.right + xOffset, | ||
y, | ||
@@ -248,12 +316,16 @@ fontSize: current.fontSize, | ||
}, y); | ||
const padding = getBackgroundPaddingProp(i, backgroundPadding); | ||
const padding = getSingleValue(backgroundPadding, i); | ||
const height = textElement.heightWithPadding; | ||
const xCoord = inline | ||
? getInlineXOffset(calculatedProps, textElements, i) + xCoordinate - padding.left | ||
: xCoordinate; | ||
const yCoord = inline ? getYCoordinate(calculatedProps, height) - padding.top : yCoordinate; | ||
const backgroundProps = { | ||
key: `tspan-background-${i}`, | ||
height: textElement.textHeight + padding.top + padding.bottom, | ||
style: backgroundStyle[i] || backgroundStyle[0], | ||
width: textElement.labelSize.width + padding.left + padding.right, | ||
height, | ||
style: getSingleValue(backgroundStyle, i), | ||
width: textElement.widthWithPadding, | ||
transform, | ||
x: xCoordinate, | ||
y: yCoordinate | ||
x: xCoord - padding.left, | ||
y: yCoord | ||
}; | ||
@@ -268,31 +340,36 @@ | ||
const getBackgroundElement = (props, calculatedProps, tspanValues) => { | ||
return Array.isArray(props.backgroundStyle) | ||
? getChildBackgrounds(props, calculatedProps, tspanValues) | ||
: getFullBackground(props, calculatedProps, tspanValues); | ||
const getBackgroundElement = (calculatedProps, tspanValues) => { | ||
return useMultiLineBackgrounds(calculatedProps) | ||
? getChildBackgrounds(calculatedProps, tspanValues) | ||
: getFullBackground(calculatedProps, tspanValues); | ||
}; | ||
const calculateSpanDy = (current, previous) => { | ||
return ( | ||
-0.5 * previous.fontSize - | ||
0.5 * (previous.fontSize * previous.lineHeight) + | ||
previous.fontSize * previous.lineHeight + | ||
0.5 * current.fontSize + | ||
0.5 * current.fontSize * current.lineHeight - | ||
(current.fontSize - current.capHeight) * 0.5 + | ||
(previous.fontSize - previous.capHeight) * 0.5 | ||
); | ||
const calculateSpanDy = (tspanValues, i, calculatedProps) => { | ||
const current = getSingleValue(tspanValues, i); | ||
const previous = getSingleValue(tspanValues, i - 1); | ||
const previousHeight = previous.fontSize * previous.lineHeight; | ||
const currentHeight = current.fontSize * current.lineHeight; | ||
const previousCaps = previous.fontSize - previous.capHeight; | ||
const currentCaps = current.fontSize - current.capHeight; | ||
const textHeight = | ||
previousHeight - | ||
previous.fontSize / 2 + | ||
current.fontSize / 2 - | ||
previousHeight / 2 + | ||
currentHeight / 2 - | ||
currentCaps / 2 + | ||
previousCaps / 2; | ||
return useMultiLineBackgrounds(calculatedProps) | ||
? textHeight + current.backgroundPadding.top + previous.backgroundPadding.bottom | ||
: textHeight; | ||
}; | ||
const getTSpanDy = (tspanValues, props, i) => { | ||
const { inline, backgroundStyle } = props; | ||
const current = tspanValues[i]; | ||
const previous = tspanValues[i - 1] || tspanValues[0]; | ||
const getTSpanDy = (tspanValues, calculatedProps, i) => { | ||
const { inline } = calculatedProps; | ||
const current = getSingleValue(tspanValues, i); | ||
if (i && !inline) { | ||
return backgroundStyle && Array.isArray(backgroundStyle) && backgroundStyle.length > 1 | ||
? calculateSpanDy(current, previous) + | ||
current.backgroundPadding.top + | ||
previous.backgroundPadding.bottom | ||
: calculateSpanDy(current, previous); | ||
return calculateSpanDy(tspanValues, i, calculatedProps); | ||
} else if (inline) { | ||
@@ -313,21 +390,30 @@ return i === 0 ? current.backgroundPadding.top : undefined; | ||
const style = getStyles(props.style, assign({}, props, { text })); | ||
const backgroundStyle = getBackgroundStyles( | ||
props.backgroundStyle, | ||
assign({}, props, { text, style }) | ||
); | ||
const backgroundPadding = getBackgroundPadding( | ||
assign({}, props, { text, style, backgroundStyle }) | ||
); | ||
const id = Helpers.evaluateProp(props.id, props); | ||
return assign({}, props, { style, text, id }); | ||
return assign({}, props, { backgroundStyle, backgroundPadding, style, text, id }); | ||
}; | ||
const getCalculatedProps = (props) => { | ||
const style = getSingleValue(props.style); | ||
const lineHeight = getLineHeight(props); | ||
const direction = props.direction ? Helpers.evaluateProp(props.direction, props) : "inherit"; | ||
const textAnchor = props.textAnchor ? Helpers.evaluateProp(props.textAnchor, props) : "start"; | ||
const textAnchor = props.textAnchor | ||
? Helpers.evaluateProp(props.textAnchor, props) | ||
: style.textAnchor || "start"; | ||
const verticalAnchor = props.verticalAnchor | ||
? Helpers.evaluateProp(props.verticalAnchor, props) | ||
: "middle"; | ||
: style.verticalAnchor || "middle"; | ||
const dx = props.dx ? Helpers.evaluateProp(props.dx, props) : 0; | ||
const dy = getDy(props, lineHeight); | ||
const dy = getDy(props, verticalAnchor, lineHeight); | ||
const transform = getTransform(props); | ||
const x = props.x !== undefined ? props.x : getPosition(props, "x"); | ||
const y = props.y !== undefined ? props.y : getPosition(props, "y"); | ||
const backgroundPadding = getBackgroundPadding(props); | ||
return { | ||
return assign({}, props, { | ||
lineHeight, | ||
@@ -339,12 +425,29 @@ direction, | ||
dy, | ||
backgroundPadding, | ||
originalDy: props.dy, | ||
transform, | ||
x, | ||
y | ||
}; | ||
}); | ||
}; | ||
const renderLabel = (props, calculatedProps, tspanValues) => { | ||
const { inline, className, title, events, direction, text } = props; | ||
const { textAnchor, dx, dy, transform, x, y } = calculatedProps; | ||
const renderLabel = (calculatedProps, tspanValues) => { | ||
const { | ||
inline, | ||
className, | ||
title, | ||
events, | ||
direction, | ||
text, | ||
textAnchor, | ||
dx, | ||
dy, | ||
transform, | ||
x, | ||
y, | ||
desc, | ||
tabIndex, | ||
id, | ||
tspanComponent, | ||
textComponent | ||
} = calculatedProps; | ||
@@ -361,5 +464,5 @@ const textProps = { | ||
title, | ||
desc: Helpers.evaluateProp(props.desc, props), | ||
tabIndex: Helpers.evaluateProp(props.tabIndex, props), | ||
id: props.id | ||
desc: Helpers.evaluateProp(desc, calculatedProps), | ||
tabIndex: Helpers.evaluateProp(tabIndex, calculatedProps), | ||
id | ||
}; | ||
@@ -370,6 +473,6 @@ | ||
const tspanProps = { | ||
key: `${props.id}-key-${i}`, | ||
x: !inline ? props.x : undefined, | ||
dx: dx + tspanValues[i].backgroundPadding.left, | ||
dy: getTSpanDy(tspanValues, props, i), | ||
key: `${id}-key-${i}`, | ||
x: !inline ? x : undefined, | ||
dx: inline ? dx + tspanValues[i].backgroundPadding.left : dx, | ||
dy: getTSpanDy(tspanValues, calculatedProps, i), | ||
textAnchor: currentStyle.textAnchor || textAnchor, | ||
@@ -379,6 +482,6 @@ style: currentStyle, | ||
}; | ||
return React.cloneElement(props.tspanComponent, tspanProps); | ||
return React.cloneElement(tspanComponent, tspanProps); | ||
}); | ||
return React.cloneElement(props.textComponent, textProps, tspans); | ||
return React.cloneElement(textComponent, textProps, tspans); | ||
}; | ||
@@ -393,9 +496,8 @@ | ||
const calculatedProps = getCalculatedProps(props); | ||
const { text, style, capHeight } = props; | ||
const { backgroundPadding, lineHeight } = calculatedProps; | ||
const { text, style, capHeight, backgroundPadding, lineHeight } = calculatedProps; | ||
const tspanValues = text.map((line, i) => { | ||
const currentStyle = style[i] || style[0]; | ||
const currentStyle = getSingleValue(style, i); | ||
const capHeightPx = TextSize.convertLengthToPixels(`${capHeight}em`, currentStyle.fontSize); | ||
const currentLineHeight = lineHeight[i] || lineHeight[0]; | ||
const currentLineHeight = getSingleValue(lineHeight, i); | ||
return { | ||
@@ -406,11 +508,12 @@ style: currentStyle, | ||
text: line, | ||
textSize: TextSize.approximateTextSize(line, currentStyle), | ||
lineHeight: currentLineHeight, | ||
backgroundPadding: getBackgroundPaddingProp(i, backgroundPadding) | ||
backgroundPadding: getSingleValue(backgroundPadding, i) | ||
}; | ||
}); | ||
const label = renderLabel(props, calculatedProps, tspanValues); | ||
const label = renderLabel(calculatedProps, tspanValues); | ||
if (props.backgroundStyle) { | ||
const backgroundElement = getBackgroundElement(props, calculatedProps, tspanValues); | ||
const backgroundElement = getBackgroundElement(calculatedProps, tspanValues); | ||
const children = [backgroundElement, label]; | ||
@@ -417,0 +520,0 @@ const backgroundWithLabel = React.cloneElement(props.groupComponent, {}, children); |
@@ -13,3 +13,3 @@ import { assign } from "lodash"; | ||
// * | ||
const sansSerif = "'Gill Sans', 'Gill Sans MT', 'Seravek', 'Trebuchet MS', sans-serif"; | ||
const sansSerif = "'Gill Sans', 'Seravek', 'Trebuchet MS', sans-serif"; | ||
const letterSpacing = "normal"; | ||
@@ -102,11 +102,11 @@ const fontSize = 14; | ||
max: { padding: 8, stroke: charcoal, strokeWidth: 1 }, | ||
maxLabels: baseLabelStyles, | ||
maxLabels: assign({}, baseLabelStyles, { padding: 3 }), | ||
median: { padding: 8, stroke: charcoal, strokeWidth: 1 }, | ||
medianLabels: baseLabelStyles, | ||
medianLabels: assign({}, baseLabelStyles, { padding: 3 }), | ||
min: { padding: 8, stroke: charcoal, strokeWidth: 1 }, | ||
minLabels: baseLabelStyles, | ||
minLabels: assign({}, baseLabelStyles, { padding: 3 }), | ||
q1: { padding: 8, fill: grey }, | ||
q1Labels: baseLabelStyles, | ||
q1Labels: assign({}, baseLabelStyles, { padding: 3 }), | ||
q3: { padding: 8, fill: grey }, | ||
q3Labels: baseLabelStyles | ||
q3Labels: assign({}, baseLabelStyles, { padding: 3 }) | ||
}, | ||
@@ -124,3 +124,3 @@ boxWidth: 20 | ||
}, | ||
labels: baseLabelStyles | ||
labels: assign({}, baseLabelStyles, { padding: 5 }) | ||
}, | ||
@@ -228,3 +228,3 @@ candleColors: { | ||
tooltip: { | ||
style: assign({}, baseLabelStyles, { padding: 5, pointerEvents: "none" }), | ||
style: assign({}, baseLabelStyles, { padding: 0, pointerEvents: "none" }), | ||
flyoutStyle: { | ||
@@ -236,2 +236,3 @@ stroke: charcoal, | ||
}, | ||
flyoutPadding: 5, | ||
cornerRadius: 5, | ||
@@ -238,0 +239,0 @@ pointerLength: 10 |
@@ -20,3 +20,3 @@ import { assign } from "lodash"; | ||
// * | ||
const sansSerif = "'Roboto', 'Helvetica Neue', Helvetica, sans-serif"; | ||
const sansSerif = "'Helvetica Neue', 'Helvetica', sans-serif"; | ||
const letterSpacing = "normal"; | ||
@@ -103,2 +103,11 @@ const fontSize = 12; | ||
), | ||
polarDependentAxis: assign({ | ||
style: { | ||
ticks: { | ||
fill: "transparent", | ||
size: 1, | ||
stroke: "transparent" | ||
} | ||
} | ||
}), | ||
bar: assign( | ||
@@ -121,11 +130,11 @@ { | ||
max: { padding, stroke: blueGrey700, strokeWidth: 1 }, | ||
maxLabels: baseLabelStyles, | ||
maxLabels: assign({}, baseLabelStyles, { padding: 3 }), | ||
median: { padding, stroke: blueGrey700, strokeWidth: 1 }, | ||
medianLabels: baseLabelStyles, | ||
medianLabels: assign({}, baseLabelStyles, { padding: 3 }), | ||
min: { padding, stroke: blueGrey700, strokeWidth: 1 }, | ||
minLabels: baseLabelStyles, | ||
minLabels: assign({}, baseLabelStyles, { padding: 3 }), | ||
q1: { padding, fill: blueGrey700 }, | ||
q1Labels: baseLabelStyles, | ||
q1Labels: assign({}, baseLabelStyles, { padding: 3 }), | ||
q3: { padding, fill: blueGrey700 }, | ||
q3Labels: baseLabelStyles | ||
q3Labels: assign({}, baseLabelStyles, { padding: 3 }) | ||
}, | ||
@@ -142,3 +151,3 @@ boxWidth: 20 | ||
}, | ||
labels: baseLabelStyles | ||
labels: assign({}, baseLabelStyles, { padding: 5 }) | ||
}, | ||
@@ -249,3 +258,3 @@ candleColors: { | ||
tooltip: { | ||
style: assign({}, baseLabelStyles, { padding: 5, pointerEvents: "none" }), | ||
style: assign({}, baseLabelStyles, { padding: 0, pointerEvents: "none" }), | ||
flyoutStyle: { | ||
@@ -257,2 +266,3 @@ stroke: grey900, | ||
}, | ||
flyoutPadding: 5, | ||
cornerRadius: 5, | ||
@@ -259,0 +269,0 @@ pointerLength: 10 |
@@ -93,2 +93,18 @@ /* eslint-disable func-style */ | ||
function isTooltip(component) { | ||
const labelRole = component && component.type && component.type.role; | ||
return labelRole === "tooltip"; | ||
} | ||
function getDefaultStyles(props, role) { | ||
const { theme = {}, labelComponent } = props; | ||
const defaultStyles = (theme[role] && theme[role].style) || {}; | ||
if (!isTooltip(labelComponent)) { | ||
return defaultStyles; | ||
} | ||
const tooltipStyle = (theme.tooltip && theme.tooltip.style) || {}; | ||
const labelStyle = defaults({}, tooltipStyle, defaultStyles.labels); | ||
return defaults({}, { labels: labelStyle }, defaultStyles); | ||
} | ||
function getStyles(style, defaultStyles) { | ||
@@ -278,2 +294,3 @@ const width = "100%"; | ||
getPadding, | ||
getDefaultStyles, | ||
getStyles, | ||
@@ -291,3 +308,4 @@ evaluateProp, | ||
reduceChildren, | ||
isHorizontal | ||
isHorizontal, | ||
isTooltip | ||
}; |
/* eslint-disable func-style */ | ||
/* eslint-disable no-use-before-define */ | ||
import Helpers from "./helpers"; | ||
import { defaults } from "lodash"; | ||
@@ -148,5 +149,5 @@ // Private Functions | ||
} | ||
const degrees = baseAngle !== undefined ? baseAngle : getDegrees(props, datum); | ||
const degrees = baseAngle !== undefined ? baseAngle % 360 : getDegrees(props, datum); | ||
const sign = (degrees > 90 && degrees < 180) || degrees > 270 ? 1 : -1; | ||
let angle; | ||
let angle = 0; | ||
if (degrees === 0 || degrees === 180) { | ||
@@ -165,7 +166,7 @@ angle = 90; | ||
const { x } = Helpers.getPoint(datum); | ||
return Helpers.radiansToDegrees(props.scale.x(x)); | ||
return Helpers.radiansToDegrees(props.scale.x(x)) % 360; | ||
} | ||
function getProps(props, index) { | ||
const { scale, data, style, horizontal, polar, width, height } = props; | ||
const { scale, data, style, horizontal, polar, width, height, theme, labelComponent } = props; | ||
const datum = data[index]; | ||
@@ -182,3 +183,3 @@ const degrees = getDegrees(props, datum); | ||
const { dx, dy } = getOffset(props, datum); | ||
return { | ||
const labelProps = { | ||
angle, | ||
@@ -203,2 +204,7 @@ data, | ||
}; | ||
if (!Helpers.isTooltip(labelComponent)) { | ||
return labelProps; | ||
} | ||
const tooltipTheme = (theme && theme.tooltip) || {}; | ||
return defaults({}, labelProps, Helpers.omit(tooltipTheme, ["style"])); | ||
} | ||
@@ -205,0 +211,0 @@ |
@@ -5,24 +5,100 @@ // http://www.pearsonified.com/2012/01/characters-per-line.php | ||
const fontDictionary = { | ||
"American Typewriter": 2.09, | ||
Baskerville: 2.51, | ||
Georgia: 2.27, | ||
"Hoefler Text": 2.39, | ||
Palatino: 2.26, | ||
"Times New Roman": 2.48, | ||
Arial: 2.26, | ||
"Gill Sans": 2.47, | ||
"Gill Sans 300": 2.58, | ||
"Helvetica Neue": 2.24, | ||
"Lucida Grande": 2.05, | ||
Tahoma: 2.25, | ||
"Trebuchet MS": 2.2, | ||
Verdana: 1.96, | ||
"Courier New": 1.67, | ||
cursive: 1.84, | ||
fantasy: 2.09, | ||
monospace: 1.81, | ||
serif: 2.04, | ||
"sans-serif": 1.89 | ||
}; | ||
// Based on measuring specific character widths | ||
// as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf | ||
//prettier-ignore | ||
const fonts = { | ||
"American Typewriter": { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.25,0.4203125,0.3296875,0.6,0.6375,0.8015625,0.8203125,0.1875,0.45625,0.45625,0.6375,0.5,0.2734375,0.309375,0.2734375,0.4390625,0.6375,0.6375,0.6375,0.6375,0.6375,0.6375,0.6375,0.6375,0.6375,0.6375,0.2734375,0.2734375,0.5,0.5,0.5,0.6,0.6921875,0.7640625,0.6921875,0.6375,0.728125,0.6734375,0.6203125,0.7109375,0.784375,0.3828125,0.6421875,0.7859375,0.6375,0.9484375,0.7640625,0.65625,0.6375,0.65625,0.7296875,0.6203125,0.6375,0.7109375,0.740625,0.940625,0.784375,0.7578125,0.6203125,0.4375,0.5,0.4375,0.5,0.5,0.4921875,0.5734375,0.5890625,0.5109375,0.6,0.528125,0.43125,0.5578125,0.6375,0.3109375,0.40625,0.6234375,0.309375,0.928125,0.6375,0.546875,0.6,0.58125,0.4921875,0.4921875,0.4,0.6203125,0.625,0.825,0.6375,0.640625,0.528125,0.5,0.5,0.5,0.6671875], | ||
avg: 0.5793421052631578 | ||
}, | ||
Arial: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.278125,0.278125,0.35625,0.55625,0.55625,0.890625,0.6671875,0.1921875,0.334375,0.334375,0.390625,0.584375,0.278125,0.334375,0.278125,0.278125,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.278125,0.278125,0.584375,0.584375,0.584375,0.55625,1.015625,0.6703125,0.6671875,0.7234375,0.7234375,0.6671875,0.6109375,0.778125,0.7234375,0.278125,0.5,0.6671875,0.55625,0.834375,0.7234375,0.778125,0.6671875,0.778125,0.7234375,0.6671875,0.6109375,0.7234375,0.6671875,0.9453125,0.6671875,0.6671875,0.6109375,0.278125,0.278125,0.278125,0.4703125,0.584375,0.334375,0.55625,0.55625,0.5,0.55625,0.55625,0.3125,0.55625,0.55625,0.2234375,0.2703125,0.5,0.2234375,0.834375,0.55625,0.55625,0.55625,0.55625,0.346875,0.5,0.278125,0.55625,0.5,0.7234375,0.5,0.5,0.5,0.334375,0.2609375,0.334375,0.584375], | ||
avg: 0.528733552631579 | ||
}, | ||
"Arial Black": { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.33125,0.334375,0.5,0.6609375,0.6671875,1,0.890625,0.278125,0.390625,0.390625,0.55625,0.6609375,0.334375,0.334375,0.334375,0.28125,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.334375,0.334375,0.6609375,0.6609375,0.6609375,0.6109375,0.7453125,0.78125,0.778125,0.778125,0.778125,0.7234375,0.6671875,0.834375,0.834375,0.390625,0.6671875,0.834375,0.6671875,0.9453125,0.834375,0.834375,0.7234375,0.834375,0.78125,0.7234375,0.7234375,0.834375,0.7796875,1.003125,0.78125,0.78125,0.7234375,0.390625,0.28125,0.390625,0.6609375,0.5125,0.334375,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.41875,0.6671875,0.6671875,0.334375,0.384375,0.6671875,0.334375,1,0.6671875,0.6671875,0.6671875,0.6671875,0.4703125,0.6109375,0.4453125,0.6671875,0.6140625,0.946875,0.6671875,0.615625,0.55625,0.390625,0.278125,0.390625,0.6609375], | ||
avg: 0.6213157894736842 | ||
}, | ||
Baskerville: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.25,0.25,0.40625,0.6671875,0.490625,0.875,0.7015625,0.178125,0.2453125,0.246875,0.4171875,0.6671875,0.25,0.3125,0.25,0.521875,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.25,0.25,0.6671875,0.6671875,0.6671875,0.396875,0.9171875,0.684375,0.615625,0.71875,0.7609375,0.625,0.553125,0.771875,0.803125,0.3546875,0.515625,0.78125,0.6046875,0.928125,0.75,0.8234375,0.5625,0.96875,0.7296875,0.5421875,0.6984375,0.771875,0.7296875,0.9484375,0.771875,0.678125,0.6359375,0.3640625,0.521875,0.3640625,0.46875,0.5125,0.334375,0.46875,0.521875,0.428125,0.521875,0.4375,0.3890625,0.4765625,0.53125,0.25,0.359375,0.4640625,0.240625,0.803125,0.53125,0.5,0.521875,0.521875,0.365625,0.334375,0.2921875,0.521875,0.4640625,0.678125,0.4796875,0.465625,0.428125,0.4796875,0.5109375,0.4796875,0.6671875], | ||
avg: 0.5323519736842108 | ||
}, | ||
Courier: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.5984375,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6078125,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.61875,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.615625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6140625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625], | ||
avg: 0.6020559210526316 | ||
}, | ||
"Courier New": { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.5984375,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625], | ||
avg: 0.6015296052631579 | ||
}, | ||
cursive: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.1921875,0.24375,0.40625,0.5671875,0.3984375,0.721875,0.909375,0.2328125,0.434375,0.365625,0.4734375,0.5578125,0.19375,0.3484375,0.19375,0.7734375,0.503125,0.4171875,0.5453125,0.45,0.6046875,0.4703125,0.5984375,0.55625,0.503125,0.5546875,0.20625,0.2,0.5625,0.5546875,0.546875,0.403125,0.70625,0.734375,0.7078125,0.64375,0.85,0.753125,0.75,0.6484375,1.0765625,0.44375,0.5359375,0.8359375,0.653125,1.0109375,1.1515625,0.6796875,0.6984375,1.0625,0.8234375,0.5125,0.9234375,0.8546875,0.70625,0.9109375,0.7421875,0.715625,0.6015625,0.4640625,0.3359375,0.4109375,0.5421875,0.5421875,0.4328125,0.5125,0.5,0.3859375,0.7375,0.359375,0.75625,0.540625,0.5328125,0.3203125,0.5296875,0.5015625,0.484375,0.7890625,0.5640625,0.4203125,0.703125,0.471875,0.4734375,0.35,0.4125,0.5640625,0.471875,0.6484375,0.5296875,0.575,0.4140625,0.415625,0.20625,0.3796875,0.5421875], | ||
avg: 0.5604440789473684 | ||
}, | ||
fantasy: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.215625,0.2625,0.3265625,0.6109375,0.534375,0.7625,0.7828125,0.2,0.4359375,0.4359375,0.3765625,0.5109375,0.2796875,0.4609375,0.2796875,0.5296875,0.6640625,0.253125,0.521875,0.4765625,0.6640625,0.490625,0.528125,0.5546875,0.496875,0.5421875,0.2796875,0.2796875,0.5625,0.4609375,0.5625,0.4828125,0.609375,0.740625,0.7234375,0.740625,0.8265625,0.7234375,0.6171875,0.7359375,0.765625,0.240625,0.5453125,0.715625,0.6078125,0.8640625,0.653125,0.9125,0.6484375,0.946875,0.6921875,0.653125,0.6953125,0.8015625,0.58125,0.784375,0.671875,0.6265625,0.690625,0.4359375,0.5296875,0.4359375,0.53125,0.5,0.2875,0.5375,0.603125,0.4984375,0.60625,0.53125,0.434375,0.6421875,0.56875,0.209375,0.4671875,0.5484375,0.2203125,0.709375,0.55,0.5984375,0.6140625,0.5765625,0.40625,0.4734375,0.3734375,0.559375,0.4421875,0.6421875,0.4890625,0.578125,0.4484375,0.2546875,0.2203125,0.2546875,0.55], | ||
avg: 0.536496710526316 | ||
}, | ||
Geneva: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.3328125,0.3046875,0.5,0.6671875,0.6671875,0.90625,0.728125,0.3046875,0.446875,0.446875,0.5078125,0.6671875,0.3046875,0.3796875,0.3046875,0.5390625,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.6671875,0.3046875,0.3046875,0.6671875,0.6671875,0.6671875,0.56875,0.871875,0.728125,0.6375,0.6515625,0.7015625,0.5765625,0.5546875,0.675,0.690625,0.2421875,0.4921875,0.6640625,0.584375,0.7890625,0.709375,0.7359375,0.584375,0.78125,0.60625,0.60625,0.640625,0.6671875,0.728125,0.946875,0.6109375,0.6109375,0.5765625,0.446875,0.5390625,0.446875,0.6671875,0.6671875,0.5921875,0.5546875,0.6109375,0.546875,0.603125,0.5765625,0.390625,0.6109375,0.584375,0.2359375,0.334375,0.5390625,0.2359375,0.8953125,0.584375,0.60625,0.603125,0.603125,0.3875,0.509375,0.44375,0.584375,0.565625,0.78125,0.53125,0.571875,0.5546875,0.4515625,0.246875,0.4515625,0.6671875], | ||
avg: 0.5762664473684211 | ||
}, | ||
Georgia: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.2421875,0.33125,0.4125,0.64375,0.6109375,0.81875,0.7109375,0.215625,0.375,0.375,0.4734375,0.64375,0.2703125,0.375,0.2703125,0.46875,0.6140625,0.4296875,0.559375,0.553125,0.565625,0.5296875,0.5671875,0.503125,0.596875,0.5671875,0.3125,0.3125,0.64375,0.64375,0.64375,0.4796875,0.9296875,0.715625,0.6546875,0.6421875,0.75,0.6546875,0.6,0.7265625,0.815625,0.390625,0.51875,0.7203125,0.6046875,0.928125,0.7671875,0.7453125,0.6109375,0.7453125,0.7234375,0.5625,0.61875,0.7578125,0.70625,0.99375,0.7125,0.6640625,0.6015625,0.375,0.46875,0.375,0.64375,0.65,0.5,0.5046875,0.56875,0.4546875,0.575,0.484375,0.39375,0.509375,0.5828125,0.29375,0.3671875,0.546875,0.2875,0.88125,0.5921875,0.5390625,0.571875,0.5640625,0.4109375,0.4328125,0.3453125,0.5765625,0.5203125,0.75625,0.50625,0.5171875,0.4453125,0.43125,0.375,0.43125,0.64375], | ||
avg: 0.5551809210526316 | ||
}, | ||
"Gill Sans": { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.2765625,0.271875,0.3546875,0.584375,0.5421875,0.6765625,0.625,0.1890625,0.3234375,0.3234375,0.4171875,0.584375,0.2203125,0.3234375,0.2203125,0.28125,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.2203125,0.2296875,0.584375,0.584375,0.584375,0.334375,1.0109375,0.6671875,0.5640625,0.709375,0.75,0.5,0.4703125,0.740625,0.7296875,0.25,0.3125,0.65625,0.490625,0.78125,0.78125,0.8234375,0.5109375,0.8234375,0.6046875,0.459375,0.6046875,0.709375,0.6046875,1.0421875,0.709375,0.6046875,0.646875,0.334375,0.28125,0.334375,0.4703125,0.5828125,0.334375,0.428125,0.5,0.4390625,0.5109375,0.4796875,0.296875,0.428125,0.5,0.2203125,0.2265625,0.5,0.2203125,0.771875,0.5,0.553125,0.5,0.5,0.3984375,0.3859375,0.334375,0.5,0.4390625,0.7203125,0.5,0.4390625,0.4171875,0.334375,0.2609375,0.334375,0.584375], | ||
avg: 0.4933717105263159 | ||
}, | ||
Helvetica: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.2796875,0.2765625,0.3546875,0.5546875,0.5546875,0.8890625,0.665625,0.190625,0.3328125,0.3328125,0.3890625,0.5828125,0.2765625,0.3328125,0.2765625,0.3015625,0.5546875,0.5546875,0.5546875,0.5546875,0.5546875,0.5546875,0.5546875,0.5546875,0.5546875,0.5546875,0.2765625,0.2765625,0.584375,0.5828125,0.584375,0.5546875,1.0140625,0.665625,0.665625,0.721875,0.721875,0.665625,0.609375,0.7765625,0.721875,0.2765625,0.5,0.665625,0.5546875,0.8328125,0.721875,0.7765625,0.665625,0.7765625,0.721875,0.665625,0.609375,0.721875,0.665625,0.94375,0.665625,0.665625,0.609375,0.2765625,0.3546875,0.2765625,0.4765625,0.5546875,0.3328125,0.5546875,0.5546875,0.5,0.5546875,0.5546875,0.2765625,0.5546875,0.5546875,0.221875,0.240625,0.5,0.221875,0.8328125,0.5546875,0.5546875,0.5546875,0.5546875,0.3328125,0.5,0.2765625,0.5546875,0.5,0.721875,0.5,0.5,0.5,0.3546875,0.259375,0.353125,0.5890625], | ||
avg: 0.5279276315789471 | ||
}, | ||
"Helvetica Neue": { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.278125,0.259375,0.4265625,0.55625,0.55625,1,0.6453125,0.278125,0.2703125,0.26875,0.353125,0.6,0.278125,0.3890625,0.278125,0.36875,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.278125,0.278125,0.6,0.6,0.6,0.55625,0.8,0.6625,0.6859375,0.7234375,0.7046875,0.6125,0.575,0.759375,0.7234375,0.259375,0.5203125,0.6703125,0.55625,0.871875,0.7234375,0.7609375,0.6484375,0.7609375,0.6859375,0.6484375,0.575,0.7234375,0.6140625,0.9265625,0.6125,0.6484375,0.6125,0.259375,0.36875,0.259375,0.6,0.5,0.25625,0.5375,0.59375,0.5375,0.59375,0.5375,0.2984375,0.575,0.55625,0.2234375,0.2375,0.5203125,0.2234375,0.853125,0.55625,0.575,0.59375,0.59375,0.334375,0.5,0.315625,0.55625,0.5,0.759375,0.51875,0.5,0.48125,0.334375,0.2234375,0.334375,0.6], | ||
avg: 0.5279440789473684 | ||
}, | ||
"Hoefler Text": { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.2359375,0.2234375,0.3921875,0.7125,0.49375,0.8859375,0.771875,0.2125,0.3078125,0.309375,0.375,0.4234375,0.234375,0.3125,0.234375,0.3,0.5828125,0.365625,0.434375,0.3921875,0.5234375,0.3984375,0.5125,0.4328125,0.46875,0.5125,0.234375,0.234375,0.515625,0.4234375,0.515625,0.340625,0.7609375,0.7359375,0.6359375,0.721875,0.8125,0.6375,0.5875,0.8078125,0.853125,0.4296875,0.503125,0.78125,0.609375,0.9609375,0.8515625,0.8140625,0.6125,0.8140625,0.71875,0.49375,0.7125,0.76875,0.771875,1.125,0.7765625,0.7734375,0.65625,0.321875,0.3078125,0.321875,0.3546875,0.5,0.3375,0.446875,0.5359375,0.45,0.5296875,0.4546875,0.425,0.4921875,0.54375,0.2671875,0.240625,0.5390625,0.25,0.815625,0.5375,0.5234375,0.5390625,0.5421875,0.365625,0.36875,0.35625,0.5171875,0.5015625,0.75,0.5,0.509375,0.44375,0.2421875,0.14375,0.2421875,0.35], | ||
avg: 0.5116447368421051 | ||
}, | ||
monospace: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.5984375,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6078125,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.61875,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.615625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6140625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625,0.6015625], | ||
avg: 0.6020559210526316 | ||
}, | ||
Palatino: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.25,0.278125,0.371875,0.60625,0.5,0.840625,0.778125,0.209375,0.334375,0.334375,0.390625,0.60625,0.2578125,0.334375,0.25,0.60625,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.25,0.25,0.60625,0.60625,0.60625,0.4453125,0.7484375,0.778125,0.6109375,0.709375,0.775,0.6109375,0.55625,0.7640625,0.8328125,0.3375,0.346875,0.7265625,0.6109375,0.946875,0.83125,0.7875,0.6046875,0.7875,0.66875,0.525,0.6140625,0.778125,0.7234375,1,0.6671875,0.6671875,0.6671875,0.334375,0.60625,0.334375,0.60625,0.5,0.334375,0.5,0.565625,0.4453125,0.6109375,0.4796875,0.340625,0.55625,0.5828125,0.2921875,0.2671875,0.5640625,0.2921875,0.8828125,0.5828125,0.546875,0.6015625,0.5609375,0.3953125,0.425,0.3265625,0.603125,0.565625,0.834375,0.5171875,0.55625,0.5,0.334375,0.60625,0.334375,0.60625], | ||
avg: 0.5408552631578947 | ||
}, | ||
"sans-serif": { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.278125,0.278125,0.35625,0.55625,0.55625,0.890625,0.6671875,0.1921875,0.334375,0.334375,0.390625,0.584375,0.278125,0.334375,0.278125,0.303125,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.55625,0.278125,0.278125,0.5859375,0.584375,0.5859375,0.55625,1.015625,0.6671875,0.6671875,0.7234375,0.7234375,0.6671875,0.6109375,0.778125,0.7234375,0.278125,0.5,0.6671875,0.55625,0.834375,0.7234375,0.778125,0.6671875,0.778125,0.7234375,0.6671875,0.6109375,0.7234375,0.6671875,0.9453125,0.6671875,0.6671875,0.6109375,0.278125,0.35625,0.278125,0.478125,0.55625,0.334375,0.55625,0.55625,0.5,0.55625,0.55625,0.278125,0.55625,0.55625,0.2234375,0.2421875,0.5,0.2234375,0.834375,0.55625,0.55625,0.55625,0.55625,0.334375,0.5,0.278125,0.55625,0.5,0.7234375,0.5,0.5,0.5,0.35625,0.2609375,0.3546875,0.590625], | ||
avg: 0.5293256578947368 | ||
}, | ||
Seravek: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.215625,0.296875,0.4171875,0.6734375,0.4953125,0.9125,0.740625,0.2421875,0.3375,0.3375,0.409375,0.60625,0.2609375,0.35625,0.25625,0.41875,0.5921875,0.3515625,0.475,0.4875,0.5375,0.509375,0.5484375,0.4546875,0.5421875,0.5484375,0.25625,0.2546875,0.5875,0.6171875,0.5875,0.4578125,0.8140625,0.6765625,0.5703125,0.6109375,0.684375,0.5109375,0.4953125,0.678125,0.6859375,0.2625,0.2625,0.5859375,0.4734375,0.846875,0.709375,0.740625,0.509375,0.740625,0.584375,0.5015625,0.528125,0.675,0.5953125,0.9453125,0.596875,0.540625,0.540625,0.359375,0.4203125,0.359375,0.5109375,0.421875,0.4046875,0.5015625,0.5421875,0.446875,0.5453125,0.484375,0.38125,0.5140625,0.5546875,0.240625,0.2640625,0.490625,0.2765625,0.8625,0.5546875,0.546875,0.5453125,0.5453125,0.3625,0.41875,0.3890625,0.5453125,0.4703125,0.7546875,0.4921875,0.4609375,0.453125,0.4015625,0.2640625,0.4015625,0.58125], | ||
avg: 0.5044078947368421 | ||
}, | ||
serif: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.2484375,0.334375,0.409375,0.5,0.5,0.834375,0.778125,0.18125,0.334375,0.334375,0.5,0.5640625,0.25,0.334375,0.25,0.278125,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.278125,0.278125,0.5640625,0.5640625,0.5640625,0.4453125,0.921875,0.7234375,0.6671875,0.6671875,0.7234375,0.6109375,0.55625,0.7234375,0.7234375,0.334375,0.390625,0.7234375,0.6109375,0.890625,0.7234375,0.7234375,0.55625,0.7234375,0.6671875,0.55625,0.6109375,0.7234375,0.7234375,0.9453125,0.7234375,0.7234375,0.6109375,0.334375,0.340625,0.334375,0.4703125,0.5,0.3453125,0.4453125,0.5,0.4453125,0.5,0.4453125,0.3828125,0.5,0.5,0.278125,0.3359375,0.5,0.278125,0.778125,0.5,0.5,0.5,0.5,0.3375,0.390625,0.2796875,0.5,0.5,0.7234375,0.5,0.5,0.4453125,0.48125,0.2015625,0.48125,0.5421875], | ||
avg: 0.5126315789473684 | ||
}, | ||
Tahoma: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.3109375,0.3328125,0.4015625,0.728125,0.546875,0.9765625,0.70625,0.2109375,0.3828125,0.3828125,0.546875,0.728125,0.303125,0.3640625,0.303125,0.3953125,0.546875,0.546875,0.546875,0.546875,0.546875,0.546875,0.546875,0.546875,0.546875,0.546875,0.3546875,0.3546875,0.728125,0.728125,0.728125,0.475,0.909375,0.6109375,0.590625,0.6015625,0.6796875,0.5625,0.521875,0.66875,0.6765625,0.3734375,0.4171875,0.6046875,0.4984375,0.771875,0.66875,0.7078125,0.5515625,0.7078125,0.6375,0.5578125,0.5875,0.65625,0.60625,0.903125,0.58125,0.5890625,0.559375,0.3828125,0.39375,0.3828125,0.728125,0.5625,0.546875,0.525,0.553125,0.4625,0.553125,0.5265625,0.3546875,0.553125,0.5578125,0.2296875,0.328125,0.51875,0.2296875,0.840625,0.5578125,0.54375,0.553125,0.553125,0.3609375,0.446875,0.3359375,0.5578125,0.4984375,0.7421875,0.4953125,0.4984375,0.4453125,0.48125,0.3828125,0.48125,0.728125], | ||
avg: 0.5384374999999998 | ||
}, | ||
"Times New Roman": { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.2484375,0.334375,0.409375,0.5,0.5,0.834375,0.778125,0.18125,0.334375,0.334375,0.5,0.5640625,0.25,0.334375,0.25,0.28125,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.278125,0.278125,0.5640625,0.5640625,0.5640625,0.4453125,0.921875,0.7234375,0.6671875,0.6671875,0.7234375,0.6109375,0.55625,0.7234375,0.7234375,0.334375,0.390625,0.73125,0.6109375,0.890625,0.7375,0.7234375,0.55625,0.7234375,0.6765625,0.55625,0.6109375,0.7234375,0.7234375,0.9453125,0.7234375,0.7234375,0.6109375,0.334375,0.28125,0.334375,0.4703125,0.51875,0.334375,0.4453125,0.503125,0.4453125,0.503125,0.4453125,0.4359375,0.5,0.5,0.278125,0.35625,0.50625,0.278125,0.778125,0.5,0.5,0.5046875,0.5,0.340625,0.390625,0.2796875,0.5,0.5,0.7234375,0.5,0.5,0.4453125,0.48125,0.2015625,0.48125,0.5421875], | ||
avg: 0.5134375 | ||
}, | ||
"Trebuchet MS": { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.3015625,0.3671875,0.325,0.53125,0.525,0.6015625,0.70625,0.1609375,0.3671875,0.3671875,0.3671875,0.525,0.3671875,0.3671875,0.3671875,0.525,0.525,0.525,0.525,0.525,0.525,0.525,0.525,0.525,0.525,0.525,0.3671875,0.3671875,0.525,0.525,0.525,0.3671875,0.771875,0.590625,0.5671875,0.5984375,0.6140625,0.5359375,0.525,0.6765625,0.6546875,0.2796875,0.4765625,0.5765625,0.5078125,0.7109375,0.6390625,0.675,0.5578125,0.7421875,0.5828125,0.48125,0.58125,0.6484375,0.5875,0.853125,0.5578125,0.5703125,0.5515625,0.3671875,0.3578125,0.3671875,0.525,0.53125,0.525,0.5265625,0.5578125,0.4953125,0.5578125,0.546875,0.375,0.503125,0.546875,0.2859375,0.3671875,0.5046875,0.2953125,0.83125,0.546875,0.5375,0.5578125,0.5578125,0.3890625,0.40625,0.396875,0.546875,0.490625,0.7453125,0.5015625,0.49375,0.475,0.3671875,0.525,0.3671875,0.525], | ||
avg: 0.5085197368421052 | ||
}, | ||
Verdana: { | ||
widths: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.35,0.39375,0.459375,0.81875,0.6359375,1.0765625,0.759375,0.26875,0.4546875,0.4546875,0.6359375,0.81875,0.3640625,0.4546875,0.3640625,0.4703125,0.6359375,0.6359375,0.6359375,0.6359375,0.6359375,0.6359375,0.6359375,0.6359375,0.6359375,0.6359375,0.4546875,0.4546875,0.81875,0.81875,0.81875,0.546875,1,0.684375,0.6859375,0.6984375,0.771875,0.6328125,0.575,0.7765625,0.7515625,0.421875,0.4546875,0.69375,0.5578125,0.84375,0.7484375,0.7875,0.603125,0.7875,0.7,0.684375,0.6171875,0.7328125,0.684375,0.9890625,0.6859375,0.615625,0.6859375,0.4546875,0.46875,0.4546875,0.81875,0.6421875,0.6359375,0.6015625,0.6234375,0.521875,0.6234375,0.596875,0.384375,0.6234375,0.6328125,0.275,0.3765625,0.5921875,0.275,0.9734375,0.6328125,0.6078125,0.6234375,0.6234375,0.43125,0.521875,0.3953125,0.6328125,0.5921875,0.81875,0.5921875,0.5921875,0.5265625,0.6359375,0.4546875,0.6359375,0.81875], | ||
avg: 0.6171875000000003 | ||
} | ||
} | ||
//https://developer.mozilla.org/en/docs/Web/CSS/length | ||
@@ -44,7 +120,4 @@ // Absolute sizes in pixels for obsolete measurement units. | ||
const coefficients = { | ||
averageFontConstant: 2.1675, // Average pixels per glyph in existing font. | ||
widthOverlapCoef: 1.25, // Coefficient for width value to prevent overlap. | ||
heightOverlapCoef: 1.05, // Coefficient for height value to prevent overlap. | ||
lineCapitalCoef: 1.15, // Coefficient for height value. Reserve space for capital chars. | ||
lineSpaceHeightCoef: 0.2 // Coefficient for height value. Reserve space between lines. | ||
lineCapitalCoef: 1.15 // Coefficient for height value. Reserve space for capital chars. | ||
}; | ||
@@ -61,5 +134,6 @@ const defaultStyle = { | ||
const _getFontCharacterConstant = (fontFamily) => { | ||
const firstFont = fontFamily.split(",")[0].replace(/'|"/g, ""); | ||
return fontDictionary[firstFont] || coefficients.averageFontConstant; | ||
const _getFontData = (fontFamily) => { | ||
const possibleFonts = fontFamily.split(",").map((f) => f.replace(/'|"/g, "")); | ||
const fontMatch = possibleFonts.find((f) => fonts[f]) || "Helvetica"; | ||
return fonts[fontMatch]; | ||
}; | ||
@@ -85,6 +159,8 @@ | ||
const convertLengthToPixels = (length, fontSize) => { | ||
const attribute = length.match(/[a-zA-Z%]+/)[0]; | ||
const attribute = length.match(/[a-zA-Z%]+/) && length.match(/[a-zA-Z%]+/)[0]; | ||
const value = length.match(/[0-9.,]+/); | ||
let result; | ||
if (absoluteMeasurementUnitsToPixels.hasOwnProperty(attribute)) { | ||
if (!attribute) { | ||
result = value || 0; | ||
} else if (absoluteMeasurementUnitsToPixels.hasOwnProperty(attribute)) { | ||
result = value * absoluteMeasurementUnitsToPixels[attribute]; | ||
@@ -105,4 +181,7 @@ } else if (relativeMeasurementUnitsCoef.hasOwnProperty(attribute)) { | ||
return assign({}, style, { | ||
characterConstant: style.characterConstant || _getFontCharacterConstant(style.fontFamily), | ||
letterSpacing: convertLengthToPixels(style.letterSpacing, style.fontSize), | ||
fontFamily: style.fontFamily, | ||
letterSpacing: | ||
typeof style.letterSpacing === "number" | ||
? style.letterSpacing | ||
: convertLengthToPixels(String(style.letterSpacing), style.fontSize), | ||
fontSize: | ||
@@ -119,6 +198,18 @@ typeof style.fontSize === "number" | ||
} | ||
const widths = _splitToLines(text).map((line, index) => { | ||
const len = line.toString().length; | ||
const { fontSize, characterConstant, letterSpacing } = _prepareParams(style, index); | ||
return (len * fontSize) / characterConstant + letterSpacing * Math.max(len - 1, 0); | ||
const { fontSize, letterSpacing, fontFamily } = _prepareParams(style, index); | ||
const fontData = _getFontData(fontFamily); | ||
const width = | ||
line | ||
.toString() | ||
.split("") | ||
.map((c) => { | ||
return c.charCodeAt(0) < fontData.widths.length | ||
? fontData.widths[c.charCodeAt(0)] | ||
: fontData.avg; | ||
}) | ||
.reduce((cur, acc) => acc + cur) * fontSize; | ||
return width + letterSpacing * Math.max(len - 1, 0); | ||
}); | ||
@@ -138,4 +229,3 @@ return Math.max(...widths); | ||
: lineStyle.fontSize; | ||
const emptySpace = index === 0 ? 0 : lineStyle.fontSize * coefficients.lineSpaceHeightCoef; | ||
return total + lineStyle.lineHeight * (height + emptySpace); | ||
return total + lineStyle.lineHeight * height; | ||
}, 0); | ||
@@ -152,3 +242,2 @@ }; | ||
* @param {string} style.letterSpacing Text letterSpacing(space between letters). | ||
* @param {number} style.characterConstant Average pixels per glyph. | ||
* @param {number} style.lineHeight Line height coefficient. | ||
@@ -164,3 +253,3 @@ * @returns {number} Approximate text label height. | ||
return { | ||
width: widthWithRotate * coefficients.widthOverlapCoef, | ||
width: widthWithRotate, | ||
height: heightWithRotate * coefficients.heightOverlapCoef | ||
@@ -167,0 +256,0 @@ }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
2228417
30286
4
2