Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
return newRef => {
ref = newRef
if (ref) {
window.addEventListener('resize', update)
// raf needed to wait for glamor css styles
rafHandle = window.requestAnimationFrame(update)
} else {
window.removeEventListener('resize', update)
window.cancelAnimationFrame(rafHandle)
}
}
}
const thousandSeparator = '\u2019'
const swissNumbers = formatLocale({
decimal: ',',
thousands: thousandSeparator,
grouping: [3],
currency: ['CHF\u00a0', '']
})
const formatPow = (tLabel, baseValue) => {
const decimalFormat = swissNumbers.format('.0f')
let [n] = decimalFormat(baseValue).split('.')
let scale = value => value
let suffix = ''
if (n.length > 9) {
scale = value => value / Math.pow(10, 9)
suffix = tLabel(' Mrd.')
} else if (n.length > 6) {
scale = value => value / Math.pow(10, 6)
localeDef = {
decimal: "\u066b",
thousands: "\u066c",
grouping: [3],
currency: ["", ""],
numerals : ["\u0660", "\u0661", "\u0662", "\u0663", "\u0664", "\u0665", "\u0666", "\u0667", "\u0668", "\u0669"]
}
let decimal: string = localeDef.decimal;
let thousands: string = localeDef.thousands;
let grouping: Array = localeDef.grouping;
let currency: [string, string] = localeDef.currency;
let numerals: string[] | undefined = localeDef.numerals;
localeObj = d3Format.formatLocale(localeDef);
localeObj = d3Format.formatDefaultLocale(localeDef);
let formatFactory: (specifier: string) => ((n: number) => string) = localeObj.format;
let formatPrefixFactory: (specifier: string, value: number) => ((n: number) => string) = localeObj.formatPrefix;
localeDef = {
decimal: "\u066b",
thousands: "\u066c",
grouping: [3],
currency: ["", ""],
percent : "\u202f%"
};
let decimal: string = localeDef.decimal;
let thousands: string = localeDef.thousands;
let grouping: number[] = localeDef.grouping;
let currency: [string, string] = localeDef.currency;
let numerals: string[] | undefined = localeDef.numerals;
let percent: string | undefined = localeDef.percent;
localeObj = d3Format.formatLocale(localeDef);
localeObj = d3Format.formatDefaultLocale(localeDef);
let formatFactory: (specifier: string) => ((n: number) => string) = localeObj.format;
let formatPrefixFactory: (specifier: string, value: number) => ((n: number) => string) = localeObj.formatPrefix;
legend.locale = function(_) {
if (!arguments.length) return locale
locale = formatLocale(_)
return legend
}
format.locale = function localeFn(settings) {
locale = formatLocale(settings);
d3format = locale.format(pattern);
return this;
};
function buildD3Format(settings) {
const locale = formatLocale(
getLocaleSettings(parseInt(settings.locale, 10))
);
return locale.format(buildD3FormatSpecifier(settings));
}
import React from 'react'
import {css} from 'glamor'
import {formatLocale} from 'd3-format'
import {groupped, total, totalChf, colors} from './RepublikShareholder.data'
const nbspNumbers = formatLocale({
decimal: ',',
thousands: '\u00a0',
grouping: [3],
currency: ['CHF\u00a0', '']
})
const countFormat = nbspNumbers.format(',.0f')
const percentFormat = nbspNumbers.format(' 05.1%')
const PADDING = 20
const styles = {
num: css({
textAlign: 'right !important',
fontFeatureSettings: '"tnum" 1, "kern" 1'
}),
table: css({
import React from 'react'
import { css } from 'glamor'
import { formatLocale } from 'd3-format'
import { arc } from 'd3-shape'
import { partition } from 'd3-hierarchy'
import { ascending, descending } from 'd3-array'
import { groupped, total, colors } from './data'
import { fontFamilies } from '@project-r/styleguide'
const nbspNumbers = formatLocale({
decimal: ',',
thousands: '\u00a0',
grouping: [3],
currency: ['CHF\u00a0', '']
})
const percentFormat = nbspNumbers.format('.1%')
const styles = {
container: css({
position: 'relative',
height: 0,
width: '100%',
paddingBottom: '100%'
}),
svg: css({
fontFamily: fontFamilies.sansSerifRegular,
legend.locale = function (_) {
if (!arguments.length) return locale;
locale = formatLocale(_);
return legend;
};