diff --git a/dist/vis.js b/dist/vis.js index c9ae7863..912c1897 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -4,8 +4,8 @@ * * A dynamic, browser-based visualization library. * - * @version @@version - * @date @@date + * @version 1.1.0 + * @date 2014-06-16 * * @license * Copyright (C) 2011-2014 Almende B.V, http://almende.com @@ -1376,6 +1376,27 @@ function DataSet (data, options) { } } +DataSet.prototype.setOptions = function(options) { + if (options.fieldId !== undefined) {this.fieldId = options.fieldId;}; + if (options.showInternalIds !== undefined) {this.showInternalIds = options.fieldId;}; + + if (options.convert) { + this.options.convert = options.convert; + + for (var field in options.convert) { + if (options.convert.hasOwnProperty(field)) { + var value = options.convert[field]; + if (value == 'Date' || value == 'ISODate' || value == 'ASPDate') { + this.convert[field] = 'Date'; + } + else { + this.convert[field] = value; + } + } + } + } +}; + /** * Subscribe to an event, add an event listener * @param {String} event Event name. Available events: 'put', 'update', @@ -2075,13 +2096,13 @@ DataSet.prototype.min = function (field) { DataSet.prototype.distinct = function (field) { var data = this.data, values = [], - fieldType = this.options.convert[field], + value, count = 0; for (var prop in data) { if (data.hasOwnProperty(prop)) { var item = data[prop]; - var value = util.convert(item[field], fieldType); + value = util.convert(item[field], this.convert[field]); var exists = false; for (var i = 0; i < count; i++) { if (values[i] == value) { diff --git a/src/DataSet.js b/src/DataSet.js index 40c16504..f65325df 100644 --- a/src/DataSet.js +++ b/src/DataSet.js @@ -74,6 +74,27 @@ function DataSet (data, options) { } } +DataSet.prototype.setOptions = function(options) { + if (options.fieldId !== undefined) {this.fieldId = options.fieldId;}; + if (options.showInternalIds !== undefined) {this.showInternalIds = options.fieldId;}; + + if (options.convert) { + this.options.convert = options.convert; + + for (var field in options.convert) { + if (options.convert.hasOwnProperty(field)) { + var value = options.convert[field]; + if (value == 'Date' || value == 'ISODate' || value == 'ASPDate') { + this.convert[field] = 'Date'; + } + else { + this.convert[field] = value; + } + } + } + } +}; + /** * Subscribe to an event, add an event listener * @param {String} event Event name. Available events: 'put', 'update', @@ -773,13 +794,13 @@ DataSet.prototype.min = function (field) { DataSet.prototype.distinct = function (field) { var data = this.data, values = [], - fieldType = this.options.convert[field], + value, count = 0; for (var prop in data) { if (data.hasOwnProperty(prop)) { var item = data[prop]; - var value = util.convert(item[field], fieldType); + value = util.convert(item[field], this.convert[field]); var exists = false; for (var i = 0; i < count; i++) { if (values[i] == value) {