diff --git a/docs/dataset.html b/docs/dataset.html index 110afc0a..2c77c723 100644 --- a/docs/dataset.html +++ b/docs/dataset.html @@ -740,9 +740,10 @@ DataSet.map(callback [, options]);
fields
is defined, only the properties
whose name is specified in fields
will be included
diff --git a/docs/dataview.html b/docs/dataview.html
index 316da77a..eea7d2df 100644
--- a/docs/dataview.html
+++ b/docs/dataview.html
@@ -129,9 +129,10 @@ var data = new vis.DataView(dataset, options)
fields
is defined, only the properties
whose name is specified in fields
will be included
diff --git a/lib/DataSet.js b/lib/DataSet.js
index ccb2c2d6..d002ac4f 100644
--- a/lib/DataSet.js
+++ b/lib/DataSet.js
@@ -663,9 +663,17 @@ DataSet.prototype._filterFields = function (item, fields) {
var filteredItem = {};
- for (var field in item) {
- if (item.hasOwnProperty(field) && (fields.indexOf(field) != -1)) {
- filteredItem[field] = item[field];
+ if(Array.isArray(fields)){
+ for (var field in item) {
+ if (item.hasOwnProperty(field) && (fields.indexOf(field) != -1)) {
+ filteredItem[field] = item[field];
+ }
+ }
+ }else{
+ for (var field in item) {
+ if (item.hasOwnProperty(field) && fields.hasOwnProperty(field)) {
+ filteredItem[fields[field]] = item[field];
+ }
}
}