Skip to content

Commit

Permalink
Kw/domain (#397)
Browse files Browse the repository at this point in the history
* update yarn.lock

* Update `schema.domain()` to take only `field`

* Bump version
  • Loading branch information
kanitw authored and FelixCodes committed Jul 28, 2017
1 parent 489d980 commit 54c9992
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "compassql",
"version": "0.19.0",
"version": "0.19.1",
"description": "CompassQL visualization query language",
"main": "build/src/cql.js",
"typings": "./build/src/cql",
Expand Down
4 changes: 2 additions & 2 deletions src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ export class Schema {
return true;
}

public domain(fieldQ: FieldQuery): any[] {
public domain(fieldQueryParts: {field: string}): any[] {
// TODO: differentiate for field with bin / timeUnit
const fieldSchema = this._fieldSchemaIndex[fieldQ.field as string];
const fieldSchema = this._fieldSchemaIndex[fieldQueryParts.field as string];
let domain: any[] = keys(fieldSchema.stats.unique);
if (fieldSchema.vlType === VLType.QUANTITATIVE) {
// return [min, max], coerced into number types
Expand Down
10 changes: 5 additions & 5 deletions test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ describe('schema', () => {
];
const domainSchema: Schema = build(domainData);
it('should return an array containing one of each datapoint corresponding to the given EncodingQuery for non-Q data', () => {
const domain: string[] = domainSchema.domain({field: 'c', channel: Channel.X});
const domain: string[] = domainSchema.domain({field: 'c'});
assert.isNotNull(domain);
assert.equal(domain.length, 4);
assert.notEqual(domain.indexOf('a'), -1);
Expand All @@ -494,25 +494,25 @@ describe('schema', () => {
});

it('should only return one copy of datapoints that occur multiple times', () => {
const domain: string[] = domainSchema.domain({field: 'd', channel: Channel.X});
const domain: string[] = domainSchema.domain({field: 'd'});
assert.equal(domain.length, 2);
assert.notEqual(domain.indexOf('a'), -1);
assert.notEqual(domain.indexOf('b'), -1);
});

it('should return an array of length 2 containing min and max for quantitative data', () => {
let domain: number[] = domainSchema.domain({field: 'a', channel: Channel.X});
let domain: number[] = domainSchema.domain({field: 'a'});
assert.equal(domain.length, 2);
assert.equal(domain.indexOf(1), 0);
assert.equal(domain.indexOf(4), 1);
domain = domainSchema.domain({field: 'b', channel: Channel.X});
domain = domainSchema.domain({field: 'b'});
assert.equal(domain.length, 2);
assert.equal(domain.indexOf(1.1), 0);
assert.equal(domain.indexOf(1.4), 1);
});

it('should return a date array containing correctly translated date types', () => {
let domain: Date[] = domainSchema.domain({field: 'e', channel: Channel.X});
let domain: Date[] = domainSchema.domain({field: 'e'});
assert.equal(domain.length, 2);
assert.equal(domain[0].getTime(), new Date('6/14/2016').getTime());
assert.equal(domain[1].getTime(), new Date('7/14/2016').getTime());
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3535,23 +3535,23 @@ vega-datasets@latest:
version "1.8.0"
resolved "https://registry.yarnpkg.com/vega-datasets/-/vega-datasets-1.8.0.tgz#a614ca655164e4f1a5e4477864d1091350d4eac8"

vega-event-selector@^2.0.0-beta:
version "2.0.0-beta"
resolved "https://registry.yarnpkg.com/vega-event-selector/-/vega-event-selector-2.0.0-beta.tgz#7937d06479943e66c3e853f2055db1202c481dc2"
vega-event-selector@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/vega-event-selector/-/vega-event-selector-2.0.0.tgz#6af8dc7345217017ceed74e9155b8d33bad05d42"

[email protected].5:
version "2.0.0-beta.5"
resolved "https://registry.yarnpkg.com/vega-lite/-/vega-lite-2.0.0-beta.5.tgz#a9a040f3a6fba6b747c074850718967c6699b66b"
[email protected].10:
version "2.0.0-beta.10"
resolved "https://registry.yarnpkg.com/vega-lite/-/vega-lite-2.0.0-beta.10.tgz#e7d2eebed6d608b328e9e8faacd50f1e5efaca5d"
dependencies:
json-stable-stringify "^1.0.1"
tslib "^1.7.1"
vega-event-selector "^2.0.0-beta"
vega-util "^1.3.0"
yargs "^8.0.1"
vega-event-selector "^2.0.0"
vega-util "^1.4.1"
yargs "^8.0.2"

vega-util@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/vega-util/-/vega-util-1.3.0.tgz#cf338e0d8210b9d369ce8cfa6727c39a89d4fe9f"
vega-util@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/vega-util/-/vega-util-1.4.1.tgz#3c5bea971aecec552786c190421f87e42165d666"

[email protected]:
version "1.3.6"
Expand Down Expand Up @@ -3714,9 +3714,9 @@ yargs@^6.6.0:
y18n "^3.2.1"
yargs-parser "^4.2.0"

yargs@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-8.0.1.tgz#420ef75e840c1457a80adcca9bc6fa3849de51aa"
yargs@^8.0.2:
version "8.0.2"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-8.0.2.tgz#6299a9055b1cefc969ff7e79c1d918dceb22c360"
dependencies:
camelcase "^4.1.0"
cliui "^3.2.0"
Expand Down

0 comments on commit 54c9992

Please sign in to comment.