@influxdata/giraffe
Advanced tools
Comparing version 0.40.0 to 0.41.0
{ | ||
"name": "@influxdata/giraffe", | ||
"version": "0.40.0", | ||
"version": "0.41.0", | ||
"main": "dist/index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "jest --maxWorkers=2", | ||
"test:watch": "jest --watch --verbose false", | ||
"test": "jest --collectCoverage --maxWorkers=2", | ||
"test:watch": "jest --collectCoverage --watch --verbose false", | ||
"build": "rm -rf dist && NODE_ENV=production rollup -c", | ||
@@ -10,0 +10,0 @@ "start": "rollup -cw", |
# Giraffe | ||
[](https://www.influxdata.com/slack) | ||
A React-based visualization library powering the data visualizations in [InfluxDB 2.0](https://github.com/influxdata/influxdb/) UI. | ||
<img src="./chronogiraffe.png" height="100" alt="giraffe"/> | ||
## Demos | ||
@@ -336,10 +340,12 @@ | ||
- **legendFont**: _string. Optional._ The [_CSS font_](https://developer.mozilla.org/en-US/docs/Web/CSS/font) value for the styling of the legend (tooltip). | ||
- **legendFont**: _string. Optional. Defaults to '10px monospace' when excluded._ The [_CSS font_](https://developer.mozilla.org/en-US/docs/Web/CSS/font) value for the styling of the legend (tooltip). | ||
- **legendFontColor**: _string. Optional._ The _CSS color value_ of the column headers in the legend (tooltip). The rest of the legend will use the color scheme set by the `LayerConfig`'s `colors` options. | ||
- **legendFontColor**: _string. Optional. Defaults to #bec2cc when excluded._ The _CSS color value_ of the column headers in the legend (tooltip). The rest of the legend will use the color scheme set by the `LayerConfig`'s `colors` options. | ||
- **legendFontBrightColor**: _string. Optional. Recommendation: do not include._ The _CSS color value_ of any text that is not a column header or in a row inside the legend (tooltip). Currently no such text exists and may be added in the future. | ||
- **legendFontBrightColor**: _string. Optional. Defaults to #f6f6f8 when excluded._ The _CSS color value_ of any text that is not a column header or in a row inside the legend (tooltip). | ||
- **legendBackgroundColor**: _string. Optional._ The _CSS color value_ of the background in the legend (tooltip). | ||
- **legendBackgroundColor**: _string. Optional. Defaults to #0f0e15 when excluded._ The _CSS color value_ of the background in the legend (tooltip). | ||
- **legendColorizeRows**: _boolean. Optional. Defaults to true when excluded._ Toggles the use of colors for the rows in the legend (tooltip). When _true_ the rows will use colors from the color scheme in the rendered graph. When _false_ the rows will use the **legendFontBrightColor** and include small dots of color in the color scheme of the rendered graph. | ||
- **legendBorder**: _string. Optional._ The [_CSS border_](https://developer.mozilla.org/en-US/docs/Web/CSS/border) value for the styling of the border around the legend (tooltip). | ||
@@ -351,3 +357,3 @@ | ||
- **legendOpacity**: _number. Optional. Defaults to 1.0 when excluded._ The [_CSS opacity_](https://developer.mozilla.org/en-US/docs/Web/CSS/opacity) of the entire `<Tooltip>` element (or legend). 0 means the legend is invisible, while 1.0 means the legend covers anything underneath. | ||
- **legendOpacity**: _number. Optional. Defaults to 1.0 when excluded._ The [_CSS opacity_](https://developer.mozilla.org/en-US/docs/Web/CSS/opacity) of the legend (tooltip). 0 means the legend is invisible, while 1.0 means the legend covers anything underneath. | ||
@@ -354,0 +360,0 @@ - **legendOrientationThreshold**: _number. Optional. Defaults to undefined when excluded._ The number of columns in the legend that will determine the direction of columns in the legend. When _undefined_ or when the total number of columns is less than or equal to it, the columns in the tooltip will display horizontally. When the total number of columns is greater, the columns will display vertically. |
@@ -5,3 +5,3 @@ import {heatmapTransform, bin2d} from './heatmap' | ||
describe('heatmapTransform', () => { | ||
test('does not crash when passed zero-width domain', () => { | ||
it('does not crash when passed zero-width domain', () => { | ||
// x domain of this table has a zero-width domain | ||
@@ -20,3 +20,3 @@ const table = newTable(3) | ||
test('does not crash when bin size is the largest among bin size, width, and height', () => { | ||
it('does not crash when bin size is the largest among bin size, width, and height', () => { | ||
const xColKey = '_time' | ||
@@ -53,3 +53,3 @@ const yColKey = '_value' | ||
test('does not crash when bin size is negative 0, positive 0, negative, NaN, negative Infinity, or positive Infinity', () => { | ||
it('does not crash when bin size is negative 0, positive 0, negative, NaN, negative Infinity, or positive Infinity', () => { | ||
const xColKey = '_time' | ||
@@ -56,0 +56,0 @@ const yColKey = '_value' |
@@ -10,3 +10,3 @@ import {extent} from 'd3-array' | ||
describe('bin', () => { | ||
test('with a single group', () => { | ||
it('with a single group', () => { | ||
const table = newTable(10) | ||
@@ -26,3 +26,3 @@ .addColumn('_value', 'double', 'number', valueData) | ||
test('with four groups', () => { | ||
it('with four groups', () => { | ||
const table = newTable(10) | ||
@@ -83,3 +83,3 @@ .addColumn('_value', 'double', 'number', valueData) | ||
test('with overlaid positioning', () => { | ||
it('with overlaid positioning', () => { | ||
const table = newTable(10) | ||
@@ -122,3 +122,3 @@ .addColumn('_value', 'double', 'number', valueData) | ||
test('with a widened x domain', () => { | ||
it('with a widened x domain', () => { | ||
const table = newTable(10) | ||
@@ -156,3 +156,3 @@ .addColumn('_value', 'double', 'number', valueData) | ||
test('with a narrowed x domain', () => { | ||
it('with a narrowed x domain', () => { | ||
const table = newTable(10) | ||
@@ -173,3 +173,3 @@ .addColumn('_value', 'double', 'number', valueData) | ||
describe('histogramTransform', () => { | ||
test('does not crash when passed zero-width domain', () => { | ||
it('does not crash when passed zero-width domain', () => { | ||
// x domain of this table has a zero-width domain | ||
@@ -176,0 +176,0 @@ const table = newTable(3) |
@@ -7,3 +7,3 @@ import {getBandColorScale} from './' | ||
test('uses the same color when bandIndexMap has no rowIndices', () => { | ||
it('uses the same color when bandIndexMap has no rowIndices', () => { | ||
const scale = getBandColorScale( | ||
@@ -27,3 +27,3 @@ {rowIndices: [], lowerIndices: [], upperIndices: []}, | ||
test('uses more than 1 color when bandIndexMap.rowIndices has length greater than 0', () => { | ||
it('uses more than 1 color when bandIndexMap.rowIndices has length greater than 0', () => { | ||
let scale = getBandColorScale( | ||
@@ -69,3 +69,3 @@ {rowIndices: [0], lowerIndices: [], upperIndices: []}, | ||
test('upper and lower indicies have no effect on the colors when rowIndices are empty', () => { | ||
it('upper and lower indicies have no effect on the colors when rowIndices are empty', () => { | ||
let scale = getBandColorScale( | ||
@@ -117,3 +117,3 @@ {rowIndices: [], lowerIndices: [0, 1], upperIndices: []}, | ||
test('upper and lower indicies have no effect on the colors when rowIndices are not empty', () => { | ||
it('upper and lower indicies have no effect on the colors when rowIndices are not empty', () => { | ||
let scale = getBandColorScale( | ||
@@ -120,0 +120,0 @@ {rowIndices: [4, 5], lowerIndices: [0, 1], upperIndices: []}, |
@@ -60,3 +60,3 @@ import {parseResponse} from './fluxParsing' | ||
describe('parseResponse', () => { | ||
test('parseResponse into the right number of tables', () => { | ||
it('parseResponse into the right number of tables', () => { | ||
const result = parseResponse(MULTI_SCHEMA_RESPONSE) | ||
@@ -67,3 +67,3 @@ expect(result).toHaveLength(4) | ||
describe('result name', () => { | ||
test('uses the result name from the result column if present', () => { | ||
it('uses the result name from the result column if present', () => { | ||
const resp = `#group,false,false,false,false,false,false,true,true,true | ||
@@ -84,3 +84,3 @@ #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,string,string,string | ||
test('uses the result name from the default annotation if result columns are empty', () => { | ||
it('uses the result name from the default annotation if result columns are empty', () => { | ||
const resp = `#group,false,false,false,false,false,false,true,true,true | ||
@@ -113,3 +113,3 @@ #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,string,string,string | ||
describe('headers', () => { | ||
test('throws when no metadata is present', () => { | ||
it('throws when no metadata is present', () => { | ||
expect(() => { | ||
@@ -120,3 +120,3 @@ parseResponse(RESPONSE_NO_METADATA) | ||
test('can parse headers when metadata is present', () => { | ||
it('can parse headers when metadata is present', () => { | ||
const actual = parseResponse(RESPONSE_METADATA)[0].data[0] | ||
@@ -128,3 +128,3 @@ expect(actual).toEqual(EXPECTED_COLUMNS) | ||
describe('group key', () => { | ||
test('parses the group key properly', () => { | ||
it('parses the group key properly', () => { | ||
const actual = parseResponse(MULTI_SCHEMA_RESPONSE)[0].groupKey | ||
@@ -142,3 +142,3 @@ const expected = { | ||
describe('partial responses', () => { | ||
test('should discard tables without any non-annotation rows', () => { | ||
it('should discard tables without any non-annotation rows', () => { | ||
const actual = parseResponse(TRUNCATED_RESPONSE) | ||
@@ -145,0 +145,0 @@ |
@@ -9,3 +9,3 @@ import {formatStatValue} from './formatStatValue' | ||
describe('handles bad input gracefully', () => { | ||
test('does not throw an error when decimal places is greater than 100', () => { | ||
it('does not throw an error when decimal places is greater than 100', () => { | ||
expect(() => | ||
@@ -18,3 +18,3 @@ formatStatValue('2.00', { | ||
test('handles undefined', () => { | ||
it('handles undefined', () => { | ||
prefix = 'LOL' | ||
@@ -33,3 +33,3 @@ value = undefined | ||
test('handles null', () => { | ||
it('handles null', () => { | ||
prefix = ':-(' | ||
@@ -49,3 +49,3 @@ value = null | ||
test('formats NaN', () => { | ||
it('formats NaN', () => { | ||
prefix = 'My nanny is ' | ||
@@ -63,3 +63,3 @@ value = NaN | ||
test('formats Infinity', () => { | ||
it('formats Infinity', () => { | ||
prefix = 'To ' | ||
@@ -79,3 +79,3 @@ value = Infinity | ||
test('formats negative Infinity', () => { | ||
it('formats negative Infinity', () => { | ||
prefix = 'To ' | ||
@@ -95,3 +95,3 @@ value = -Infinity | ||
test('formats 0 with trailing decimal 0s', () => { | ||
it('formats 0 with trailing decimal 0s', () => { | ||
prefix = '' | ||
@@ -120,3 +120,3 @@ value = 0 | ||
test('formats an integer value', () => { | ||
it('formats an integer value', () => { | ||
prefix = 'we have ' | ||
@@ -152,3 +152,3 @@ value = 123 | ||
test('formats a float value', () => { | ||
it('formats a float value', () => { | ||
prefix = 'abc ' | ||
@@ -175,3 +175,3 @@ value = 123.456789 | ||
test('formats an empty string value', () => { | ||
it('formats an empty string value', () => { | ||
prefix = '' | ||
@@ -189,3 +189,3 @@ value = '' | ||
test('formats a non-empty string value', () => { | ||
it('formats a non-empty string value', () => { | ||
prefix = 'Negative ' | ||
@@ -203,3 +203,3 @@ value = '-666.666' | ||
test('keeps trailing zeroes for the required number of decimal places only when not a string', () => { | ||
it('keeps trailing zeroes for the required number of decimal places only when not a string', () => { | ||
value = '2.000' | ||
@@ -239,3 +239,3 @@ expect( | ||
test('has commas as separator for large numbers', () => { | ||
it('has commas as separator for large numbers', () => { | ||
value = 1234567 | ||
@@ -242,0 +242,0 @@ expect(formatStatValue(value)).toEqual('1,234,567') |
@@ -8,3 +8,3 @@ import { | ||
describe('timeFormatter', () => { | ||
test('defaults to 12 hour time unless timezone is UTC', () => { | ||
it('defaults to 12 hour time unless timezone is UTC', () => { | ||
const utcFormatter = timeFormatter({timeZone: 'UTC'}) | ||
@@ -22,3 +22,3 @@ const nonUTCFormatter = timeFormatter({timeZone: 'America/Los_Angeles'}) | ||
test('handles ante meridiem and post meridiem', () => { | ||
it('handles ante meridiem and post meridiem', () => { | ||
let d = new Date('2019-01-01T00:00Z') | ||
@@ -79,3 +79,3 @@ | ||
test('uses AM/PM when given "a" in the format regardless of time zone or time format', () => { | ||
it('uses AM/PM when given "a" in the format regardless of time zone or time format', () => { | ||
const utcFormatterWithFormat = timeFormatter({ | ||
@@ -110,3 +110,3 @@ timeZone: 'UTC', | ||
test('24 hour format and UTC format without "a" should not show "24" for midnight', () => { | ||
it('24 hour format and UTC format without "a" should not show "24" for midnight', () => { | ||
const utcFormatterWithFormat = timeFormatter({ | ||
@@ -134,3 +134,3 @@ timeZone: 'UTC', | ||
test('24 hour format and UTC format without "a" should display correctly', () => { | ||
it('24 hour format and UTC format without "a" should display correctly', () => { | ||
const utcFormatterWithFormat = timeFormatter({ | ||
@@ -155,3 +155,3 @@ timeZone: 'UTC', | ||
test('can format times with format strings', () => { | ||
it('can format times with format strings', () => { | ||
const tests = [ | ||
@@ -180,3 +180,3 @@ ['YYYY-MM-DD HH:mm:ss', '2019-01-01 00:00:00'], | ||
test('it can format times with a variable level of detail', () => { | ||
it('it can format times with a variable level of detail', () => { | ||
const formatter = timeFormatter({timeZone: 'UTC'}) | ||
@@ -198,3 +198,3 @@ | ||
describe('siPrefixFormatter', () => { | ||
test('can format numbers with SI unit prefixes', () => { | ||
it('can format numbers with SI unit prefixes', () => { | ||
const f = siPrefixFormatter({significantDigits: 6}) | ||
@@ -207,3 +207,3 @@ | ||
test('can format numbers with a unit suffix', () => { | ||
it('can format numbers with a unit suffix', () => { | ||
const f = siPrefixFormatter({suffix: 'm'}) | ||
@@ -214,3 +214,3 @@ | ||
test('can format numbers with a prefix', () => { | ||
it('can format numbers with a prefix', () => { | ||
const f = siPrefixFormatter({prefix: 'howdy'}) | ||
@@ -221,3 +221,3 @@ | ||
test('can specify zeros are always included', () => { | ||
it('can specify zeros are always included', () => { | ||
const f = siPrefixFormatter({trimZeros: false, significantDigits: 4}) | ||
@@ -231,3 +231,3 @@ | ||
describe('binaryPrefixFormatter', () => { | ||
test('can format numbers with binary unit prefixes', () => { | ||
it('can format numbers with binary unit prefixes', () => { | ||
const f = binaryPrefixFormatter() | ||
@@ -240,3 +240,3 @@ | ||
test('can format negative numbers with a binary unit prefix', () => { | ||
it('can format negative numbers with a binary unit prefix', () => { | ||
const f = binaryPrefixFormatter() | ||
@@ -247,3 +247,3 @@ | ||
test('formats small numbers without unit prefixes', () => { | ||
it('formats small numbers without unit prefixes', () => { | ||
const f = binaryPrefixFormatter() | ||
@@ -255,3 +255,3 @@ | ||
test('can add a prefix to formatted numbers', () => { | ||
it('can add a prefix to formatted numbers', () => { | ||
const f = binaryPrefixFormatter({prefix: 'my favorite number '}) | ||
@@ -262,3 +262,3 @@ | ||
test('can add a suffix to formatted numbers', () => { | ||
it('can add a suffix to formatted numbers', () => { | ||
const f = binaryPrefixFormatter({suffix: ' snorp'}) | ||
@@ -269,3 +269,3 @@ | ||
test('can configure the significant digits for formatted number', () => { | ||
it('can configure the significant digits for formatted number', () => { | ||
const f = binaryPrefixFormatter({significantDigits: 1}) | ||
@@ -272,0 +272,0 @@ const g = binaryPrefixFormatter({significantDigits: 8}) |
@@ -298,3 +298,3 @@ import {fromFlux, fromFluxWithSchema} from './fromFlux' | ||
}) | ||
test('can parse a Flux CSV with mismatched schemas', () => { | ||
it('can parse a Flux CSV with mismatched schemas', () => { | ||
const CSV = `#group,false,false,true,true,false,true,true,true,true,true | ||
@@ -404,3 +404,3 @@ #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string | ||
test('should error out gracefully when an error is thrown in the fromFlux parser', () => { | ||
it('should error out gracefully when an error is thrown in the fromFlux parser', () => { | ||
const CSV = | ||
@@ -416,3 +416,3 @@ '#group,false,false,true,true,false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true' | ||
test('uses the default annotation to fill in empty values', () => { | ||
it('uses the default annotation to fill in empty values', () => { | ||
const CSV = `#group,false,false,true,true,true,true | ||
@@ -434,3 +434,3 @@ #datatype,string,long,string,string,long,long | ||
test('returns a group key union', () => { | ||
it('returns a group key union', () => { | ||
const CSV = `#group,true,false,false,true | ||
@@ -451,3 +451,3 @@ #datatype,string,string,string,string | ||
test('parses empty numeric values as null', () => { | ||
it('parses empty numeric values as null', () => { | ||
const CSV = `#group,false,false,true,true,false,true,true,true,true,true | ||
@@ -465,3 +465,3 @@ #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string | ||
test('handles newlines inside string values', () => { | ||
it('handles newlines inside string values', () => { | ||
const CSV = `#group,false,false,false,false | ||
@@ -468,0 +468,0 @@ #datatype,string,long,string,long |
@@ -5,3 +5,3 @@ import {fromRows} from './fromRows' | ||
describe('fromRows', () => { | ||
test('it can infer column types', () => { | ||
it('it can infer column types', () => { | ||
const rows = [ | ||
@@ -30,3 +30,3 @@ {foo: 1, bar: new Date(0), baz: false, a: 'A'}, | ||
test('it can accept an explicit schema definition', () => { | ||
it('it can accept an explicit schema definition', () => { | ||
const rows = [ | ||
@@ -64,3 +64,3 @@ {foo: 1, bar: 0, baz: 0, a: 'A', b: '1'}, | ||
test('with sparse data', () => { | ||
it('with sparse data', () => { | ||
const rows = [ | ||
@@ -87,3 +87,3 @@ {foo: 1, baz: 3}, | ||
test('throws an error when encountering a mismatched schema', () => { | ||
it('throws an error when encountering a mismatched schema', () => { | ||
const rows = [{foo: 'bar'}, {foo: 1}] | ||
@@ -96,3 +96,3 @@ | ||
test('throws an error when encountering a value of unknown ColumnType', () => { | ||
it('throws an error when encountering a value of unknown ColumnType', () => { | ||
const rows = [{foo: {some: 'object'}}] | ||
@@ -99,0 +99,0 @@ |
import {getJavaScriptTag} from './getJavaScriptTag' | ||
describe('getJavaScriptTag', () => { | ||
test('get tag for Undefined', () => { | ||
it('get tag for Undefined', () => { | ||
expect(getJavaScriptTag(undefined)).toEqual('[object Undefined]') | ||
}) | ||
test('get tag for Null', () => { | ||
it('get tag for Null', () => { | ||
expect(getJavaScriptTag(null)).toEqual('[object Null]') | ||
}) | ||
test('get tag for Object', () => { | ||
it('get tag for Object', () => { | ||
expect(getJavaScriptTag({})).toEqual('[object Object]') | ||
}) | ||
test('get tag for Array', () => { | ||
it('get tag for Array', () => { | ||
expect(getJavaScriptTag([])).toEqual('[object Array]') | ||
}) | ||
test('get tag for Function', () => { | ||
it('get tag for Function', () => { | ||
expect(getJavaScriptTag(() => {})).toEqual('[object Function]') | ||
}) | ||
test('get tag for String', () => { | ||
it('get tag for String', () => { | ||
expect(getJavaScriptTag('')).toEqual('[object String]') | ||
}) | ||
test('get tag for Number', () => { | ||
it('get tag for Number', () => { | ||
expect(getJavaScriptTag(1)).toEqual('[object Number]') | ||
}) | ||
test('get tag for Boolean', () => { | ||
it('get tag for Boolean', () => { | ||
expect(getJavaScriptTag(true)).toEqual('[object Boolean]') | ||
}) | ||
test('get tag for Symbol', () => { | ||
it('get tag for Symbol', () => { | ||
expect(getJavaScriptTag(Symbol())).toEqual('[object Symbol]') | ||
}) | ||
}) |
@@ -5,3 +5,3 @@ import {getLatestValues} from './getLatestValues' | ||
describe('getLatestValues', () => { | ||
test('gives an empty array when table is empty', () => { | ||
it('gives an empty array when table is empty', () => { | ||
const table = newTable(0) | ||
@@ -14,3 +14,3 @@ const result = getLatestValues(table) | ||
test('finds the value when timestamp column is missing and only 1 row exists in the table', () => { | ||
it('finds the value when timestamp column is missing and only 1 row exists in the table', () => { | ||
const yColKey = '_value' | ||
@@ -24,3 +24,3 @@ const table = newTable(1).addColumn(yColKey, 'system', 'number', [3.99]) | ||
test('gives an empty array when timestamp column is missing and there are multiple rows in the table', () => { | ||
it('gives an empty array when timestamp column is missing and there are multiple rows in the table', () => { | ||
const yColKey = '_value' | ||
@@ -39,3 +39,3 @@ const table = newTable(4).addColumn(yColKey, 'system', 'number', [ | ||
test('finds the correct value even when timestamp column is not ordered', () => { | ||
it('finds the correct value even when timestamp column is not ordered', () => { | ||
const xColKey = '_time' | ||
@@ -59,3 +59,3 @@ const yColKey = '_value' | ||
test('finds the value associated with the most recent timestamp', () => { | ||
it('finds the value associated with the most recent timestamp', () => { | ||
const xColKey = '_time' | ||
@@ -78,3 +78,3 @@ const yColKey = '_value' | ||
test('ignores columns with invalid types', () => { | ||
it('ignores columns with invalid types', () => { | ||
const xColKey = '_time' | ||
@@ -81,0 +81,0 @@ const yColKey = '_value' |
@@ -20,2 +20,19 @@ import {FormatterType} from '../types' | ||
it('should handle unusual domain values', () => { | ||
expect(generateTicks([], VALUE, NaN, NaN, NaN).length).toEqual(0) | ||
expect(generateTicks([NaN, NaN], VALUE, NaN, NaN, NaN).length).toEqual( | ||
0 | ||
) | ||
expect( | ||
generateTicks([null, null], VALUE, NaN, NaN, NaN).length | ||
).toEqual(0) | ||
expect(generateTicks([100, 0], VALUE, NaN, NaN, NaN).length).toEqual(0) | ||
expect(generateTicks([100, 99], VALUE, 1, 100, -50).length).toEqual(0) | ||
expect(generateTicks([100, 100], VALUE, 1, 100, -50).length).toEqual(1) | ||
expect(generateTicks([0, 0], VALUE, 1, 100, -0.01).length).toEqual(1) | ||
}) | ||
it('should generate no ticks when total ticks, tick start, and tick step are not finite numbers', () => { | ||
@@ -286,3 +303,3 @@ expect(generateTicks(valueDomain, VALUE, NaN, NaN, NaN).length).toEqual( | ||
) | ||
expect(result.length).toEqual(0) | ||
expect(result.length).toEqual(1) | ||
}) | ||
@@ -289,0 +306,0 @@ }) |
@@ -129,7 +129,12 @@ // Libraries | ||
const generatedTicks = [] | ||
const [start, end] = domain | ||
const [start = 0, end = 0] = domain | ||
const stepStart = isFiniteNumber(tickStart) ? tickStart : start | ||
const step = isFiniteNumber(tickStep) | ||
? tickStep | ||
: (end - stepStart) / (totalTicks + 1) | ||
let step = tickStep | ||
if (!isFiniteNumber(tickStep)) { | ||
const parts = | ||
isFiniteNumber(totalTicks) && totalTicks !== 0 ? totalTicks : 1 | ||
step = (end - stepStart) / (isFiniteNumber(tickStart) ? parts : parts + 1) | ||
} | ||
const tickCountLimit = isFiniteNumber(totalTicks) ? totalTicks : Infinity | ||
@@ -144,11 +149,19 @@ | ||
) { | ||
/* | ||
- When 'step' marks the ticks to the right (or up) on the axis | ||
it is a positive number and should stop at 'end' | ||
- When 'step' marks the ticks to the left (or down) on the axis | ||
it is a negative number and should stop at 'start' | ||
*/ | ||
while ( | ||
generatedTick >= start && | ||
generatedTick <= end && | ||
((step > 0 && generatedTick <= end) || | ||
(step < 0 && generatedTick >= start)) && | ||
generatedTicks.length < tickCountLimit | ||
) { | ||
if (columnKey === TIME) { | ||
generatedTicks.push(new Date(generatedTick)) | ||
} else { | ||
generatedTicks.push(generatedTick) | ||
if (generatedTick >= start && generatedTick <= end) { | ||
if (columnKey === TIME) { | ||
generatedTicks.push(new Date(generatedTick)) | ||
} else { | ||
generatedTicks.push(generatedTick) | ||
} | ||
} | ||
@@ -155,0 +168,0 @@ counter += 1 |
@@ -10,3 +10,3 @@ import { | ||
describe('identityMerge', () => { | ||
test('can merge two objects', () => { | ||
it('can merge two objects', () => { | ||
const source = { | ||
@@ -52,3 +52,3 @@ key1: 'PRIMATIVE_VALUE', | ||
test('returns source when source and target are logically equal', () => { | ||
it('returns source when source and target are logically equal', () => { | ||
const source = {foo: 'a', bar: 'b', baz: ['a', 'b', 'c']} | ||
@@ -62,3 +62,3 @@ const target = {foo: 'a', bar: 'b', baz: ['a', 'b', 'c']} | ||
test('can maintain reference equality of a function with a property', () => { | ||
it('can maintain reference equality of a function with a property', () => { | ||
const f = () => 2 | ||
@@ -78,3 +78,3 @@ | ||
describe('enumeratePaths', () => { | ||
test('enumerates the paths in a tree according to preorder traversal', () => { | ||
it('enumerates the paths in a tree according to preorder traversal', () => { | ||
const target = { | ||
@@ -106,3 +106,3 @@ root: { | ||
describe('getByPath', () => { | ||
test('can access existant and nonexistant properties', () => { | ||
it('can access existant and nonexistant properties', () => { | ||
expect(getByPath({a: {b: {c: 2}}}, ['a', 'b', 'c'])).toEqual(2) | ||
@@ -113,3 +113,3 @@ expect(getByPath({a: false}, ['a'])).toEqual(false) | ||
test('can safely attempt property access on null, undefined values, and primative values', () => { | ||
it('can safely attempt property access on null, undefined values, and primative values', () => { | ||
expect(getByPath(null, ['a', 'b'])).toBeUndefined() | ||
@@ -124,3 +124,3 @@ expect(getByPath(undefined, ['a', 'b'])).toBeUndefined() | ||
describe('setByPath', () => { | ||
test('can set deep non-existant paths in an object', () => { | ||
it('can set deep non-existant paths in an object', () => { | ||
const target = {a: '1'} | ||
@@ -133,3 +133,3 @@ | ||
test('can set deep existant paths in an object', () => { | ||
it('can set deep existant paths in an object', () => { | ||
const target = {a: '1', b: {c: 2}} | ||
@@ -142,7 +142,7 @@ | ||
test('throws an error when attempting to set on null', () => { | ||
it('throws an error when attempting to set on null', () => { | ||
expect(() => setByPath(null, ['a', 'b'], 2)).toThrow() | ||
}) | ||
test('throws an error when attempting to set an empty path', () => { | ||
it('throws an error when attempting to set an empty path', () => { | ||
expect(() => setByPath({a: 'b'}, [], 2)).toThrow() | ||
@@ -153,3 +153,3 @@ }) | ||
describe('isEqual', () => { | ||
test('checks if objects are equal according to their logical identity', () => { | ||
it('checks if objects are equal according to their logical identity', () => { | ||
expect(isEqual('4', '4')).toBeTruthy() | ||
@@ -156,0 +156,0 @@ expect(isEqual('4', '5')).toBeFalsy() |
import {isNumber} from './isNumber' | ||
describe('isNumber', () => { | ||
test('the value created from the Number constructor is a number', () => { | ||
it('the value created from the Number constructor is a number', () => { | ||
const value = new Number() | ||
@@ -11,3 +11,3 @@ | ||
test('the value created from the Number function is a number', () => { | ||
it('the value created from the Number function is a number', () => { | ||
const value = Number() | ||
@@ -19,3 +19,3 @@ | ||
test('a literal number is a number', () => { | ||
it('a literal number is a number', () => { | ||
expect(isNumber(1)).toEqual(true) | ||
@@ -27,3 +27,3 @@ expect(isNumber(123456789)).toEqual(true) | ||
test('Infinity and negative Infinity are numbers', () => { | ||
it('Infinity and negative Infinity are numbers', () => { | ||
expect(isNumber(Infinity)).toEqual(true) | ||
@@ -33,7 +33,7 @@ expect(isNumber(-Infinity)).toEqual(true) | ||
test('the value NaN is a number', () => { | ||
it('the value NaN is a number', () => { | ||
expect(isNumber(NaN)).toEqual(true) | ||
}) | ||
test('anything else is not a number', () => { | ||
it('anything else is not a number', () => { | ||
expect(isNumber(undefined)).toEqual(false) | ||
@@ -40,0 +40,0 @@ expect(isNumber(null)).toEqual(false) |
import {isString} from './isString' | ||
describe('isString', () => { | ||
test('the value created from the String constructor is a string', () => { | ||
it('the value created from the String constructor is a string', () => { | ||
const value = new String() | ||
@@ -11,3 +11,3 @@ | ||
test('the value created from the String function is a string', () => { | ||
it('the value created from the String function is a string', () => { | ||
const value = String() | ||
@@ -19,3 +19,3 @@ | ||
test('a literal string is a string', () => { | ||
it('a literal string is a string', () => { | ||
expect( | ||
@@ -29,3 +29,3 @@ isString('@#$^@#$@ ; \n\nerer /.,.. abc one two three!!!!! #_+[]') | ||
test('anything else is not a string', () => { | ||
it('anything else is not a string', () => { | ||
expect(isString(undefined)).toEqual(false) | ||
@@ -32,0 +32,0 @@ expect(isString(null)).toEqual(false) |
import {isSymbol} from './isSymbol' | ||
describe('isSymbol', () => { | ||
test('a value created from the Symbol function is a Symbol', () => { | ||
it('a value created from the Symbol function is a Symbol', () => { | ||
expect(isSymbol(Symbol())).toEqual(true) | ||
@@ -13,3 +13,3 @@ expect(isSymbol(Symbol(''))).toEqual(true) | ||
test('an object wrapping a value created from the Symbol function is a Symbol', () => { | ||
it('an object wrapping a value created from the Symbol function is a Symbol', () => { | ||
const symbol = Symbol('a real symbol') | ||
@@ -20,3 +20,3 @@ const wrapper = Object(symbol) | ||
test('anything else is not a Symbol', () => { | ||
it('anything else is not a Symbol', () => { | ||
expect(isSymbol('is this a symbol?')).toEqual(false) | ||
@@ -23,0 +23,0 @@ expect(isSymbol(undefined)).toEqual(false) |
@@ -13,3 +13,3 @@ import {DomainLabel} from '../types' | ||
describe('line graph performance', () => { | ||
test('fixture should be greater than or equal to REASONABLE_LIMIT', () => { | ||
it('fixture should be greater than or equal to REASONABLE_LIMIT', () => { | ||
expect(dataSize).toBeGreaterThanOrEqual(REASONABLE_LIMIT) | ||
@@ -16,0 +16,0 @@ }) |
@@ -32,3 +32,3 @@ /* | ||
test('updates xScale when xDomain is updated', () => { | ||
it('updates xScale when xDomain is updated', () => { | ||
const plotEnv = new PlotEnv() | ||
@@ -66,3 +66,3 @@ | ||
test('runs bin stat when x domain changes', () => { | ||
it('runs bin stat when x domain changes', () => { | ||
const plotEnv = new PlotEnv() | ||
@@ -100,3 +100,3 @@ | ||
test('runs bin stat when histogram layer x mapping changes', () => { | ||
it('runs bin stat when histogram layer x mapping changes', () => { | ||
const plotEnv = new PlotEnv() | ||
@@ -137,3 +137,3 @@ | ||
test('does not run bin stat when histogram fillOpacity change', () => { | ||
it('does not run bin stat when histogram fillOpacity change', () => { | ||
const plotEnv = new PlotEnv() | ||
@@ -169,3 +169,3 @@ | ||
test('updating line interpolation should not reset the x domain', () => { | ||
it('updating line interpolation should not reset the x domain', () => { | ||
const plotEnv = new PlotEnv() | ||
@@ -201,3 +201,3 @@ | ||
test('does not run line stat when x domain changes', () => { | ||
it('does not run line stat when x domain changes', () => { | ||
const plotEnv = new PlotEnv() | ||
@@ -236,3 +236,3 @@ | ||
test('resets uncontrolled domain state when x mapping changes', () => { | ||
it('resets uncontrolled domain state when x mapping changes', () => { | ||
const plotEnv = new PlotEnv() | ||
@@ -239,0 +239,0 @@ |
@@ -8,3 +8,3 @@ import {range} from './range' | ||
describe('uses increment when end is greater than start', () => { | ||
test('uses an increment of 1 when not specified or explicitly undefined', () => { | ||
it('uses an increment of 1 when not specified or explicitly undefined', () => { | ||
expect(range(0, 5)).toEqual([0, 1, 2, 3, 4]) | ||
@@ -14,3 +14,3 @@ expect(range(0, 5, undefined)).toEqual([0, 1, 2, 3, 4]) | ||
test('uses an increment of 0 when increment is NaN or null', () => { | ||
it('uses an increment of 0 when increment is NaN or null', () => { | ||
expect(range(0, 5, NaN)).toEqual([0, 0, 0, 0, 0]) | ||
@@ -20,7 +20,7 @@ expect(range(0, 5, null)).toEqual([0, 0, 0, 0, 0]) | ||
test('uses a max integer for increment when increment is Infinity', () => { | ||
it('uses a max integer for increment when increment is Infinity', () => { | ||
expect(range(0, MAX_INTEGER, Infinity)).toEqual([0]) | ||
}) | ||
test('throws an error when start is negative Infinity, end is Infinity, or both', () => { | ||
it('throws an error when start is negative Infinity, end is Infinity, or both', () => { | ||
expect(() => range(0, Infinity)).toThrow() | ||
@@ -31,3 +31,3 @@ expect(() => range(-Infinity, 0)).toThrow() | ||
test('uses the increment when specified', () => { | ||
it('uses the increment when specified', () => { | ||
expect(range(0, 10, 2)).toEqual([0, 2, 4, 6, 8]) | ||
@@ -38,3 +38,3 @@ }) | ||
describe('uses decrement when start is greater than end', () => { | ||
test('returns empty range when decrement is not specified, explicitly undefined, null, or NaN', () => { | ||
it('returns empty range when decrement is not specified, explicitly undefined, null, or NaN', () => { | ||
expect(range(5, 0)).toEqual(emptyRange) | ||
@@ -46,7 +46,7 @@ expect(range(5, 0, undefined)).toEqual(emptyRange) | ||
test('uses a max integer for decrement when decrement is -Infinity', () => { | ||
it('uses a max integer for decrement when decrement is -Infinity', () => { | ||
expect(range(0, -MAX_INTEGER, -Infinity)).toEqual([0]) | ||
}) | ||
test('throws an error when start is Infinity, end is negative Infinity, or both', () => { | ||
it('throws an error when start is Infinity, end is negative Infinity, or both', () => { | ||
expect(() => range(Infinity, 0, -1)).toThrow() | ||
@@ -57,3 +57,3 @@ expect(() => range(0, -Infinity, -1)).toThrow() | ||
test('uses the decrement when specified', () => { | ||
it('uses the decrement when specified', () => { | ||
expect(range(5, 0, -1)).toEqual([5, 4, 3, 2, 1]) | ||
@@ -63,3 +63,3 @@ }) | ||
test('gives a range that includes start and excludes end', () => { | ||
it('gives a range that includes start and excludes end', () => { | ||
expect(range(0, 1)).toEqual([0]) | ||
@@ -69,3 +69,3 @@ expect(range(-1, -2, -1)).toEqual([-1]) | ||
test('gives an empty range when start and end are equal', () => { | ||
it('gives an empty range when start and end are equal', () => { | ||
expect(range(0, 0)).toEqual(emptyRange) | ||
@@ -77,3 +77,3 @@ expect(range(20, 20)).toEqual(emptyRange) | ||
test('interprets start as 0 when start is NaN', () => { | ||
it('interprets start as 0 when start is NaN', () => { | ||
expect(range(NaN, 5)).toEqual([0, 1, 2, 3, 4]) | ||
@@ -83,3 +83,3 @@ expect(range(NaN, -5, -1)).toEqual([0, -1, -2, -3, -4]) | ||
test('interprets end as 0 when end is NaN', () => { | ||
it('interprets end as 0 when end is NaN', () => { | ||
expect(range(-5, NaN)).toEqual([-5, -4, -3, -2, -1]) | ||
@@ -89,3 +89,3 @@ expect(range(5, NaN, -1)).toEqual([5, 4, 3, 2, 1]) | ||
test('interprets start and end as 0 when both are NaN', () => { | ||
it('interprets start and end as 0 when both are NaN', () => { | ||
expect(range(NaN, NaN)).toEqual(emptyRange) | ||
@@ -92,0 +92,0 @@ expect(range(NaN, NaN, -1)).toEqual(emptyRange) |
import {parseFiles, parseFilesWithObjects} from './rawFluxDataTable' | ||
describe('parseFiles', () => { | ||
test('can parse multi-csv response', () => { | ||
it('can parse multi-csv response', () => { | ||
const CSV = ` | ||
@@ -49,3 +49,3 @@ #group,false,false,false,false | ||
test('can parse multi-csv response with values containing newlines', () => { | ||
it('can parse multi-csv response with values containing newlines', () => { | ||
const CSV = ` | ||
@@ -101,3 +101,3 @@ #group,false,false,false,false | ||
describe('parseFilesWithObjects', () => { | ||
test('can parse objects in CSV', () => { | ||
it('can parse objects in CSV', () => { | ||
const CSV = `#group,false,false,true,true,false,false,true,true,true,true,true,true,true,true,true,true,true | ||
@@ -225,3 +225,3 @@ #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string,string,string,string,string,string,string,string,string | ||
test('can parse nested objects in CSV', () => { | ||
it('can parse nested objects in CSV', () => { | ||
const CSV = `#group,false,false,true,true,false,false,true,true,true,true,true,true,true,true,true,true,true | ||
@@ -349,3 +349,3 @@ #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string,string,string,string,string,string,string,string,string | ||
test('can parse objects in multi-csv response', () => { | ||
it('can parse objects in multi-csv response', () => { | ||
const CSV = `#group,false,false,true,true,false,false,true,true,true,true,true,true,true,true,true,true,true | ||
@@ -352,0 +352,0 @@ #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string,string,string,string,string,string,string,string,string |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
8387655
428
30378
700