Skip to content

Commit

Permalink
Merge pull request #456 from Kitware/update-datalib
Browse files Browse the repository at this point in the history
Updates datalib to version that supports nested dots
  • Loading branch information
jeffbaumes committed Oct 19, 2016
2 parents 576d3b7 + 8d19a0e commit 3d530ec
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 56 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"onset": "git+https://github.com/Kitware/setvis#506bfccff63b0c8f5c39a81d299ed310e5e8fbff",
"brace": "^0.7.0",
"d3": "^3.5.14",
"datalib": "^1.6.3",
"datalib": "^1.7.3",
"font-awesome": "^4.4.0",
"font-awesome-webpack": "^0.0.4",
"jquery": "^2.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/candela/components/LineUp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import $ from 'jquery';
import datalib from 'datalib';
import d3 from 'd3';
import VisComponent from '../../VisComponent';
import { inferAll } from '../../util';
import { type } from 'datalib';
import LineUpJS from 'LineUpJS/src/main.js';
import 'LineUpJS/dist/style.css';
import './index.styl';
Expand Down Expand Up @@ -266,7 +266,7 @@ export default class LineUp extends VisComponent {
label: 'Combined',
children: []
};
let attributes = inferAll(data);
let attributes = type.inferAll(data);
/* If fields was specified, use them in order (if they exist as data
* attributes). If fields was not specified, use the data attributes. */
let fields = this.options.fields ? this.options.fields : Object.keys(attributes);
Expand Down
5 changes: 2 additions & 3 deletions src/candela/components/UpSet/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import d3 from 'd3';
import { unique } from 'datalib';
import { unique, read } from 'datalib';
import VisComponent from '../../VisComponent';
import { read } from '../../util';
import * as upset from 'UpSet';
import template from './template.html';

Expand Down Expand Up @@ -124,7 +123,7 @@ export default class UpSet extends VisComponent {
// Add metadata fields.
if (this.options.metadata) {
if (!this.options.data.__types__) {
read(this.options.data);
read(this.options.data, {parse: 'auto'});
}
const upsetTypeMap = {
string: 'string',
Expand Down
20 changes: 0 additions & 20 deletions src/candela/util/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { keys, type, read as dlread } from 'datalib';

export function getElementSize (el) {
const style = window.getComputedStyle(el, null);
const width = window.parseInt(style.getPropertyValue('width'));
Expand Down Expand Up @@ -33,21 +31,3 @@ export function minmax (data) {

return range;
}

// Version of datalib.type.inferAll() that handles fields
// with nested periods
export function inferAll (data) {
let fields = keys(data[0]);
let types = {};
for (let i = 0; i < fields.length; i += 1) {
types[fields[i]] = type.infer(data, '[' + fields[i] + ']');
}
return types;
}

// Version of datalib.read() that uses our inferAll() to handle
// fields with nested periods
export function read (data) {
data.__types__ = inferAll(data);
dlread(data, {parse: data.__types__});
}
27 changes: 0 additions & 27 deletions src/candela/util/test/util.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/candela/util/vega/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import d3 from 'd3';
import vg from 'vega';
import { isArray, isString } from 'datalib';
import { isArray, isString, read } from 'datalib';
import axisTemplate from './axis.json';
import { getElementSize, read } from '..';
import { getElementSize } from '..';

let getNestedRec = function (spec, parts) {
if (spec === undefined || parts.length === 0) {
Expand Down Expand Up @@ -214,7 +214,7 @@ let templateFunctions = {
let opt = transform(args[0], options, scope);
if (opt.data && Array.isArray(opt.data) && opt.field) {
if (!opt.data.__types__) {
read(opt.data);
read(opt.data, {parse: 'auto'});
}
let type = opt.data.__types__[opt.field];
if (type === 'string') {
Expand Down

0 comments on commit 3d530ec

Please sign in to comment.