@influxdata/giraffe
Advanced tools
Comparing version 0.22.0 to 0.23.0
{ | ||
"name": "@influxdata/giraffe", | ||
"version": "0.22.0", | ||
"version": "0.23.0", | ||
"main": "dist/index.js", | ||
@@ -60,3 +60,3 @@ "license": "MIT", | ||
"memoize-one": "^5.0.2", | ||
"prettier": "^1.16.4", | ||
"prettier": "^1.19.1", | ||
"react": "^16.8.0", | ||
@@ -63,0 +63,0 @@ "react-dom": "^16.8.0", |
@@ -5,2 +5,6 @@ # Giraffe | ||
## Demos | ||
[See the visualizations in action using Storybook](https://influxdata.github.io/giraffe) | ||
## Quick Start | ||
@@ -7,0 +11,0 @@ |
@@ -192,7 +192,7 @@ import {formatStatValue} from './formatStatValue' | ||
test('keeps trailing zeroes for the required number of decimal places', () => { | ||
test('keeps trailing zeroes for the required number of decimal places only when not a string', () => { | ||
value = '2.000' | ||
expect( | ||
formatStatValue(value, {decimalPlaces: {isEnforced: true, digits: 3}}) | ||
).toEqual('2.000') | ||
).toEqual(value) | ||
@@ -202,13 +202,8 @@ value = '2.00000000000000000000000000' | ||
formatStatValue(value, {decimalPlaces: {isEnforced: true, digits: 3}}) | ||
).toEqual('2.000') | ||
).toEqual(value) | ||
value = '2.0' | ||
expect( | ||
formatStatValue(value, {decimalPlaces: {isEnforced: true, digits: 3}}) | ||
).toEqual('2.000') | ||
value = '2' | ||
expect( | ||
formatStatValue(value, {decimalPlaces: {isEnforced: true, digits: 3}}) | ||
).toEqual('2.000') | ||
).toEqual(value) | ||
@@ -215,0 +210,0 @@ /* prettier-ignore */ |
@@ -47,3 +47,3 @@ import {isNumber} from './isNumber' | ||
} else if (isString(value)) { | ||
localeFormattedValue = value ? Number(value).toFixed(digits) : value | ||
localeFormattedValue = value | ||
} else { | ||
@@ -50,0 +50,0 @@ return 'Data cannot be displayed' |
@@ -21,2 +21,58 @@ import { | ||
test('handles ante meridiem and post meridiem', () => { | ||
let d = new Date('2019-01-01T00:00Z') | ||
let meridiemFormatter = timeFormatter({ | ||
timeZone: 'Europe/London', | ||
format: 'HH:mm a', | ||
}) | ||
expect(meridiemFormatter(d)).toEqual('12:00 AM') | ||
meridiemFormatter = timeFormatter({ | ||
timeZone: 'Europe/London', | ||
format: 'HH:mm A', | ||
}) | ||
expect(meridiemFormatter(d)).toEqual('12:00 AM') | ||
d = new Date('2019-01-01T13:00Z') | ||
meridiemFormatter = timeFormatter({ | ||
timeZone: 'Europe/London', | ||
format: 'HH:mm a', | ||
}) | ||
expect(meridiemFormatter(d)).toEqual('1:00 PM') | ||
meridiemFormatter = timeFormatter({ | ||
timeZone: 'Europe/London', | ||
format: 'HH:mm A', | ||
}) | ||
expect(meridiemFormatter(d)).toEqual('1:00 PM') | ||
meridiemFormatter = timeFormatter({ | ||
timeZone: 'America/Los_Angeles', | ||
format: 'HH:mm a', | ||
}) | ||
expect(meridiemFormatter(d)).toEqual('5:00 AM') | ||
meridiemFormatter = timeFormatter({ | ||
timeZone: 'America/Los_Angeles', | ||
format: 'HH:mm A', | ||
}) | ||
expect(meridiemFormatter(d)).toEqual('5:00 AM') | ||
d = new Date('2019-01-01T00:00Z') | ||
meridiemFormatter = timeFormatter({ | ||
timeZone: 'America/Los_Angeles', | ||
format: 'HH:mm a', | ||
}) | ||
expect(meridiemFormatter(d)).toEqual('4:00 PM') | ||
meridiemFormatter = timeFormatter({ | ||
timeZone: 'America/Los_Angeles', | ||
format: 'HH:mm A', | ||
}) | ||
expect(meridiemFormatter(d)).toEqual('4:00 PM') | ||
}) | ||
test('uses AM/PM when given "a" in the format regardless of time zone or time format', () => { | ||
@@ -23,0 +79,0 @@ const utcFormatterWithFormat = timeFormatter({ |
@@ -146,3 +146,4 @@ /* | ||
HH: ({lhour}) => { | ||
if (format && format.includes('a')) { | ||
const hasMeridiem = / a/i | ||
if (hasMeridiem.test(format)) { | ||
if (Number(lhour) === 0) { | ||
@@ -149,0 +150,0 @@ return '12' |
@@ -22,3 +22,6 @@ import {getTextMetrics} from './getTextMetrics' | ||
const longestYTick = maxBy(d => d.length, yTicks.map(t => yTickFormatter(t))) | ||
const longestYTick = maxBy( | ||
d => d.length, | ||
yTicks.map(t => yTickFormatter(t)) | ||
) | ||
@@ -25,0 +28,0 @@ const {width: maxTextWidth, height: textHeight} = getTextMetrics( |
@@ -158,3 +158,8 @@ import { | ||
expect(isEqual(() => 2, () => 2)).toBeFalsy() | ||
expect( | ||
isEqual( | ||
() => 2, | ||
() => 2 | ||
) | ||
).toBeFalsy() | ||
@@ -161,0 +166,0 @@ const f = () => 2 |
@@ -88,28 +88,35 @@ type ArrayLike = number[] | Float64Array | ||
) => { | ||
const x0 = xs[i0] | ||
const y0 = ys[i0] | ||
const x1 = xs[i1] | ||
const y1 = ys[i1] | ||
const indexStack = [] | ||
let maxIndex = 0 | ||
let maxDist = -1 | ||
indexStack.push({i0, i1}) | ||
for (let i = i0 + 1; i < i1; i++) { | ||
const sqDist = sqSegmentDist(x0, y0, x1, y1, xs[i], ys[i]) | ||
while (indexStack.length > 0) { | ||
const {i0, i1} = indexStack.pop() | ||
const x0 = xs[i0] | ||
const y0 = ys[i0] | ||
const x1 = xs[i1] | ||
const y1 = ys[i1] | ||
if (sqDist > maxDist) { | ||
maxIndex = i | ||
maxDist = sqDist | ||
} | ||
} | ||
let maxIndex = 0 | ||
let maxDist = -1 | ||
if (maxDist > epsilonSq) { | ||
keep[maxIndex] = 1 | ||
for (let i = i0 + 1; i < i1; i++) { | ||
const sqDist = sqSegmentDist(x0, y0, x1, y1, xs[i], ys[i]) | ||
if (maxIndex - i0 > 1) { | ||
simplifyDouglasPeuckerHelper(xs, ys, epsilonSq, i0, maxIndex, keep) | ||
if (sqDist > maxDist) { | ||
maxIndex = i | ||
maxDist = sqDist | ||
} | ||
} | ||
if (i1 - maxIndex > 1) { | ||
simplifyDouglasPeuckerHelper(xs, ys, epsilonSq, maxIndex, i1, keep) | ||
if (maxDist > epsilonSq) { | ||
keep[maxIndex] = 1 | ||
if (maxIndex - i0 > 1) { | ||
indexStack.push({i0, i1: maxIndex}) | ||
} | ||
if (i1 - maxIndex > 1) { | ||
indexStack.push({i0: maxIndex, i1}) | ||
} | ||
} | ||
@@ -116,0 +123,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1728658
10224
471