Browse Source

fixed dataset bug

css_transitions
Alex de Mulder 10 years ago
parent
commit
ada8e98549
2 changed files with 48 additions and 6 deletions
  1. +25
    -4
      dist/vis.js
  2. +23
    -2
      src/DataSet.js

+ 25
- 4
dist/vis.js View File

@ -4,8 +4,8 @@
* *
* A dynamic, browser-based visualization library. * A dynamic, browser-based visualization library.
* *
* @version @@version
* @date @@date
* @version 1.1.0
* @date 2014-06-16
* *
* @license * @license
* Copyright (C) 2011-2014 Almende B.V, http://almende.com * 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 * Subscribe to an event, add an event listener
* @param {String} event Event name. Available events: 'put', 'update', * @param {String} event Event name. Available events: 'put', 'update',
@ -2075,13 +2096,13 @@ DataSet.prototype.min = function (field) {
DataSet.prototype.distinct = function (field) { DataSet.prototype.distinct = function (field) {
var data = this.data, var data = this.data,
values = [], values = [],
fieldType = this.options.convert[field],
value,
count = 0; count = 0;
for (var prop in data) { for (var prop in data) {
if (data.hasOwnProperty(prop)) { if (data.hasOwnProperty(prop)) {
var item = data[prop]; var item = data[prop];
var value = util.convert(item[field], fieldType);
value = util.convert(item[field], this.convert[field]);
var exists = false; var exists = false;
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
if (values[i] == value) { if (values[i] == value) {

+ 23
- 2
src/DataSet.js View File

@ -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 * Subscribe to an event, add an event listener
* @param {String} event Event name. Available events: 'put', 'update', * @param {String} event Event name. Available events: 'put', 'update',
@ -773,13 +794,13 @@ DataSet.prototype.min = function (field) {
DataSet.prototype.distinct = function (field) { DataSet.prototype.distinct = function (field) {
var data = this.data, var data = this.data,
values = [], values = [],
fieldType = this.options.convert[field],
value,
count = 0; count = 0;
for (var prop in data) { for (var prop in data) {
if (data.hasOwnProperty(prop)) { if (data.hasOwnProperty(prop)) {
var item = data[prop]; var item = data[prop];
var value = util.convert(item[field], fieldType);
value = util.convert(item[field], this.convert[field]);
var exists = false; var exists = false;
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
if (values[i] == value) { if (values[i] == value) {

Loading…
Cancel
Save