Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getTextDimension({
text,
className,
style,
container = document.body,
}) {
const textNode = document.createElementNS(SVG_NS, 'text');
textNode.textContent = text;
if (isDefined(className)) {
textNode.setAttribute('class', className);
}
if (isDefined(style)) {
['font', 'fontWeight', 'fontStyle', 'fontSize', 'fontFamily', 'letterSpacing']
.filter(field => isDefined(style[field]))
.forEach((field) => {
textNode.style[field] = style[field];
});
}
const svg = document.createElementNS(SVG_NS, 'svg');
svg.style.position = 'absolute'; // so it won't disrupt page layout
svg.style.opacity = 0; // and not visible
svg.appendChild(textNode);
container.appendChild(svg);
loadAnnotation(annotationLayer: AnnotationLayerMetadata): Promise {
/* When annotation does not require query */
if (!isDefined(annotationLayer.sourceType)) {
return Promise.resolve({});
}
// TODO: Implement
return Promise.reject(new Error('This feature is not implemented yet.'));
}
loadAnnotation(annotationLayer: AnnotationLayerMetadata): Promise {
/* When annotation does not require query */
if (!isDefined(annotationLayer.sourceType)) {
return Promise.resolve({} as AnnotationData);
}
// TODO: Implement
return Promise.reject(new Error('This feature is not implemented yet.'));
}
if (isDefined(min)) {
data.push({ key: 'Min', valueColumn: formatValue(min) });
}
if (isDefined(max)) {
data.push({ key: 'Max', valueColumn: formatValue(max) });
}
if (isDefined(median)) {
data.push({ key: 'Median', valueColumn: formatValue(median) });
}
if (isDefined(firstQuartile)) {
data.push({ key: '1st Quartile', valueColumn: formatValue(firstQuartile) });
}
if (isDefined(thirdQuartile)) {
data.push({ key: '3rd Quartile', valueColumn: formatValue(thirdQuartile) });
}
if (isDefined(outliers) && outliers.length > 0) {
data.push({ key: '# Outliers', valueColumn: outliers.length });
}
return (
<div>
<strong color="" style="{{">{label}</strong>
</div>
{data.length > 0 && <br>}
);
}
const { channels } = encoder;
const formatValue =
channels.y.definition.type === 'nominal' ? channels.x.formatValue : channels.y.formatValue;
const data = [];
if (isDefined(min)) {
data.push({ key: 'Min', valueColumn: formatValue(min) });
}
if (isDefined(max)) {
data.push({ key: 'Max', valueColumn: formatValue(max) });
}
if (isDefined(median)) {
data.push({ key: 'Median', valueColumn: formatValue(median) });
}
if (isDefined(firstQuartile)) {
data.push({ key: '1st Quartile', valueColumn: formatValue(firstQuartile) });
}
if (isDefined(thirdQuartile)) {
data.push({ key: '3rd Quartile', valueColumn: formatValue(thirdQuartile) });
}
if (isDefined(outliers) && outliers.length > 0) {
data.push({ key: '# Outliers', valueColumn: outliers.length });
}
return (
<div>
<strong color="" style="{{">{label}</strong>
</div>
{data.length > 0 && <br>}
.filter(field => isDefined(style[field]))
.forEach((field) => {
encoder: Encoder;
}) {
const { label, min, max, median, firstQuartile, thirdQuartile, outliers } = datum;
const { channels } = encoder;
const formatValue =
channels.y.definition.type === 'nominal' ? channels.x.formatValue : channels.y.formatValue;
const data = [];
if (isDefined(min)) {
data.push({ key: 'Min', valueColumn: formatValue(min) });
}
if (isDefined(max)) {
data.push({ key: 'Max', valueColumn: formatValue(max) });
}
if (isDefined(median)) {
data.push({ key: 'Median', valueColumn: formatValue(median) });
}
if (isDefined(firstQuartile)) {
data.push({ key: '1st Quartile', valueColumn: formatValue(firstQuartile) });
}
if (isDefined(thirdQuartile)) {
data.push({ key: '3rd Quartile', valueColumn: formatValue(thirdQuartile) });
}
if (isDefined(outliers) && outliers.length > 0) {
data.push({ key: '# Outliers', valueColumn: outliers.length });
}
return (
<div>
<strong color="" style="{{">{label}</strong></div>
function checkNumber(input: any): input is number {
return isDefined(input) && typeof input === 'number';
}
channels.y.definition.type === 'nominal' ? channels.x.formatValue : channels.y.formatValue;
const data = [];
if (isDefined(min)) {
data.push({ key: 'Min', valueColumn: formatValue(min) });
}
if (isDefined(max)) {
data.push({ key: 'Max', valueColumn: formatValue(max) });
}
if (isDefined(median)) {
data.push({ key: 'Median', valueColumn: formatValue(median) });
}
if (isDefined(firstQuartile)) {
data.push({ key: '1st Quartile', valueColumn: formatValue(firstQuartile) });
}
if (isDefined(thirdQuartile)) {
data.push({ key: '3rd Quartile', valueColumn: formatValue(thirdQuartile) });
}
if (isDefined(outliers) && outliers.length > 0) {
data.push({ key: '# Outliers', valueColumn: outliers.length });
}
return (
<div>
<strong color="" style="{{">{label}</strong>
</div>
{data.length > 0 && <br>}
);
}