@hpcc-js/react
Advanced tools
Comparing version 0.0.1 to 0.0.5
@@ -1,7 +0,17 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./Orb")); | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./Orb"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./Orb")); | ||
}); | ||
//# sourceMappingURL=index.js.map |
448
lib/Orb.js
@@ -1,60 +0,63 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_format_1 = require("d3-format"); | ||
var React = require("react"); | ||
if (!window.React) { | ||
window.React = React; | ||
} | ||
var ReactOrb = require("orb/dist/orb"); | ||
require("orb/dist/orb.css"); | ||
require("../src/Orb.css"); | ||
var Mapping = (function (_super) { | ||
tslib_1.__extends(Mapping, _super); | ||
function Mapping(owner) { | ||
var _this = _super.call(this) || this; | ||
_this._owner = owner; | ||
return _this; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
return Mapping; | ||
}(common_1.PropertyExt)); | ||
Mapping.prototype._class += " react_Orb.Mapping"; | ||
Mapping.prototype.publish("addField", "", "set", "Show Toolbox or not", function () { return this._owner ? this._owner.columns() : []; }, { optional: true }); | ||
Mapping.prototype.publish("location", true, "set", "Data Location", ["row", "column", "data", "remove"], { tags: ["basic"] }); | ||
Mapping.prototype.publish("aggregateFunc", "", "set", "Aggregate Function type", ["sum", "count", "min", "max", "avg", "prod", "var", "varp", "stdev", "stdevp"], { optional: true }); | ||
Mapping.prototype.publish("formatFunction", "", "string", "Format function"); | ||
var Orb = (function (_super) { | ||
tslib_1.__extends(Orb, _super); | ||
function Orb() { | ||
var _this = _super.call(this) || this; | ||
_this.orbFields = []; | ||
_this.savedField = []; | ||
_this.rowFields = []; | ||
_this.dataFields = []; | ||
_this.columnFields = []; | ||
_this.removeFields = []; | ||
return _this; | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "tslib", "@hpcc-js/common", "d3-format", "react", "orb/dist/orb", "orb/dist/orb.css", "../src/Orb.css"], factory); | ||
} | ||
Orb.prototype.orbConfig = function (ds, fs, rowFields, columnFields, dataFields) { | ||
var config = { | ||
dataSource: ds, | ||
canMoveFields: false, | ||
dataHeadersLocation: "columns", | ||
width: this.tableWidth(), | ||
height: this.tableHeight(), | ||
theme: this.themeColor(), | ||
toolbar: { | ||
visible: this.toolbar() | ||
}, | ||
grandTotal: { | ||
rowsvisible: this.rowGrandTotal(), | ||
columnsvisible: this.columnGrandTotal() | ||
}, | ||
subTotal: { | ||
visible: true, | ||
collapsed: false, | ||
collapsible: true | ||
}, | ||
rowSettings: { | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_format_1 = require("d3-format"); | ||
var React = require("react"); | ||
if (!window.React) { | ||
window.React = React; | ||
} | ||
var ReactOrb = require("orb/dist/orb"); | ||
require("orb/dist/orb.css"); | ||
require("../src/Orb.css"); | ||
var Mapping = (function (_super) { | ||
tslib_1.__extends(Mapping, _super); | ||
function Mapping(owner) { | ||
var _this = _super.call(this) || this; | ||
_this._owner = owner; | ||
return _this; | ||
} | ||
return Mapping; | ||
}(common_1.PropertyExt)); | ||
Mapping.prototype._class += " react_Orb.Mapping"; | ||
Mapping.prototype.publish("addField", "", "set", "Show Toolbox or not", function () { return this._owner ? this._owner.columns() : []; }, { optional: true }); | ||
Mapping.prototype.publish("location", true, "set", "Data Location", ["row", "column", "data", "remove"], { tags: ["basic"] }); | ||
Mapping.prototype.publish("aggregateFunc", "", "set", "Aggregate Function type", ["sum", "count", "min", "max", "avg", "prod", "var", "varp", "stdev", "stdevp"], { optional: true }); | ||
Mapping.prototype.publish("formatFunction", "", "string", "Format function"); | ||
var Orb = (function (_super) { | ||
tslib_1.__extends(Orb, _super); | ||
function Orb() { | ||
var _this = _super.call(this) || this; | ||
_this.orbFields = []; | ||
_this.savedField = []; | ||
_this.rowFields = []; | ||
_this.dataFields = []; | ||
_this.columnFields = []; | ||
_this.removeFields = []; | ||
return _this; | ||
} | ||
Orb.prototype.orbConfig = function (ds, fs, rowFields, columnFields, dataFields) { | ||
var config = { | ||
dataSource: ds, | ||
canMoveFields: false, | ||
dataHeadersLocation: "columns", | ||
width: this.tableWidth(), | ||
height: this.tableHeight(), | ||
theme: this.themeColor(), | ||
toolbar: { | ||
visible: this.toolbar() | ||
}, | ||
grandTotal: { | ||
rowsvisible: this.rowGrandTotal(), | ||
columnsvisible: this.columnGrandTotal() | ||
}, | ||
subTotal: { | ||
@@ -64,178 +67,185 @@ visible: true, | ||
collapsible: true | ||
} | ||
}, | ||
columnSettings: { | ||
subTotal: { | ||
visible: true, | ||
collapsed: false, | ||
collapsible: true | ||
} | ||
}, | ||
fields: fs, | ||
rows: this.rowFields, | ||
columns: this.columnFields, | ||
data: this.dataFields | ||
}, | ||
rowSettings: { | ||
subTotal: { | ||
visible: true, | ||
collapsed: false, | ||
collapsible: true | ||
} | ||
}, | ||
columnSettings: { | ||
subTotal: { | ||
visible: true, | ||
collapsed: false, | ||
collapsible: true | ||
} | ||
}, | ||
fields: fs, | ||
rows: this.rowFields, | ||
columns: this.columnFields, | ||
data: this.dataFields | ||
}; | ||
return config; | ||
}; | ||
return config; | ||
}; | ||
Orb.prototype.enter = function (domNode, element) { | ||
common_1.HTMLWidget.prototype.enter.apply(this, arguments); | ||
this._orbDiv = element.append("div"); | ||
this._orb = new ReactOrb.pgridwidget(this.orbConfig()); | ||
this._orb.render(this._orbDiv.node()); | ||
// var context = this; | ||
// setInterval(function () { | ||
// context.saveOrbConfig(); | ||
// }, 1000); | ||
}; | ||
Orb.prototype.deleteField = function (field) { | ||
var fieldIndex = this.savedField.indexOf(field); | ||
if (fieldIndex > -1) { | ||
this.savedField.splice(fieldIndex); | ||
} | ||
fieldIndex = this.rowFields.indexOf(field); | ||
if (fieldIndex > -1) { | ||
this.rowFields.splice(fieldIndex); | ||
} | ||
fieldIndex = this.columnFields.indexOf(field); | ||
if (fieldIndex > -1) { | ||
this.columnFields.splice(fieldIndex); | ||
} | ||
fieldIndex = this.dataFields.indexOf(field); | ||
if (fieldIndex > -1) { | ||
this.dataFields.splice(fieldIndex); | ||
} | ||
this.orbFields.forEach(function (item, index, object) { | ||
if (item.caption === field) { | ||
object.splice(index, 1); | ||
Orb.prototype.enter = function (domNode, element) { | ||
common_1.HTMLWidget.prototype.enter.apply(this, arguments); | ||
this._orbDiv = element.append("div"); | ||
this._orb = new ReactOrb.pgridwidget(this.orbConfig()); | ||
this._orb.render(this._orbDiv.node()); | ||
// var context = this; | ||
// setInterval(function () { | ||
// context.saveOrbConfig(); | ||
// }, 1000); | ||
}; | ||
Orb.prototype.deleteField = function (field) { | ||
var fieldIndex = this.savedField.indexOf(field); | ||
if (fieldIndex > -1) { | ||
this.savedField.splice(fieldIndex); | ||
} | ||
}); | ||
}; | ||
Orb.prototype.update = function (domNode, element) { | ||
common_1.HTMLWidget.prototype.update.apply(this, arguments); | ||
var ds = this.data(); | ||
var columns = this.columns(); | ||
for (var i = 0; i < this.orbFields.length; i++) { | ||
if (this.savedField.indexOf(this.orbFields[i].caption) === -1) { | ||
this.savedField.push(this.orbFields[i].caption); | ||
fieldIndex = this.rowFields.indexOf(field); | ||
if (fieldIndex > -1) { | ||
this.rowFields.splice(fieldIndex); | ||
} | ||
} | ||
this.newField().forEach(function (row, idx) { | ||
var eachField = row.__prop_addField; | ||
if (this.savedField.indexOf(eachField) === -1) { | ||
var fieldIndex = columns.indexOf(eachField); | ||
if (fieldIndex !== -1) { | ||
this.orbFields.push({ | ||
name: fieldIndex.toString(), | ||
caption: eachField | ||
}); | ||
fieldIndex = this.columnFields.indexOf(field); | ||
if (fieldIndex > -1) { | ||
this.columnFields.splice(fieldIndex); | ||
} | ||
fieldIndex = this.dataFields.indexOf(field); | ||
if (fieldIndex > -1) { | ||
this.dataFields.splice(fieldIndex); | ||
} | ||
this.orbFields.forEach(function (item, index, object) { | ||
if (item.caption === field) { | ||
object.splice(index, 1); | ||
} | ||
}); | ||
}; | ||
Orb.prototype.update = function (domNode, element) { | ||
common_1.HTMLWidget.prototype.update.apply(this, arguments); | ||
var ds = this.data(); | ||
var columns = this.columns(); | ||
for (var i = 0; i < this.orbFields.length; i++) { | ||
if (this.savedField.indexOf(this.orbFields[i].caption) === -1) { | ||
this.savedField.push(this.orbFields[i].caption); | ||
} | ||
} | ||
}, this); | ||
this.newField().forEach(function (row, idx) { | ||
var eachField = row.__prop_addField; | ||
var columnIndex = this.columnFields.indexOf(eachField); | ||
var dataIndex = this.dataFields.indexOf(eachField); | ||
var rowIndex = this.rowFields.indexOf(eachField); | ||
var removeIndex = this.removeFields.indexOf(eachField); | ||
if (eachField !== null) { | ||
switch (row.__prop_location) { | ||
case "row": | ||
if (rowIndex === -1) { | ||
this.rowFields.push(eachField); | ||
if (columnIndex > -1) { | ||
this.columnFields.splice(columnIndex, 1); | ||
this.newField().forEach(function (row, idx) { | ||
var eachField = row.__prop_addField; | ||
if (this.savedField.indexOf(eachField) === -1) { | ||
var fieldIndex = columns.indexOf(eachField); | ||
if (fieldIndex !== -1) { | ||
this.orbFields.push({ | ||
name: fieldIndex.toString(), | ||
caption: eachField | ||
}); | ||
} | ||
} | ||
}, this); | ||
this.newField().forEach(function (row, idx) { | ||
var eachField = row.__prop_addField; | ||
var columnIndex = this.columnFields.indexOf(eachField); | ||
var dataIndex = this.dataFields.indexOf(eachField); | ||
var rowIndex = this.rowFields.indexOf(eachField); | ||
var removeIndex = this.removeFields.indexOf(eachField); | ||
if (eachField !== null) { | ||
switch (row.__prop_location) { | ||
case "row": | ||
if (rowIndex === -1) { | ||
this.rowFields.push(eachField); | ||
if (columnIndex > -1) { | ||
this.columnFields.splice(columnIndex, 1); | ||
} | ||
if (dataIndex > -1) { | ||
this.dataFields.splice(dataIndex, 1); | ||
} | ||
if (removeIndex > -1) { | ||
this.removeFields.splice(removeIndex, 1); | ||
} | ||
} | ||
if (dataIndex > -1) { | ||
this.dataFields.splice(dataIndex, 1); | ||
break; | ||
case "column": | ||
if (columnIndex === -1) { | ||
this.columnFields.push(eachField); | ||
if (rowIndex > -1) { | ||
this.rowFields.splice(columnIndex, 1); | ||
} | ||
if (dataIndex > -1) { | ||
this.dataFields.splice(dataIndex, 1); | ||
} | ||
if (removeIndex > -1) { | ||
this.removeFields.splice(removeIndex, 1); | ||
} | ||
} | ||
if (removeIndex > -1) { | ||
this.removeFields.splice(removeIndex, 1); | ||
break; | ||
case "data": | ||
if (dataIndex === -1) { | ||
this.dataFields.push(eachField); | ||
if (rowIndex > -1) { | ||
this.rowFields.splice(columnIndex, 1); | ||
} | ||
if (columnIndex > -1) { | ||
this.columnFields.splice(dataIndex, 1); | ||
} | ||
if (removeIndex > -1) { | ||
this.removeFields.splice(removeIndex, 1); | ||
} | ||
} | ||
} | ||
break; | ||
case "column": | ||
if (columnIndex === -1) { | ||
this.columnFields.push(eachField); | ||
if (rowIndex > -1) { | ||
this.rowFields.splice(columnIndex, 1); | ||
break; | ||
case "remove": | ||
if (removeIndex === -1) { | ||
this.removeFields.push(eachField); | ||
this.deleteField(eachField); | ||
} | ||
if (dataIndex > -1) { | ||
this.dataFields.splice(dataIndex, 1); | ||
} | ||
if (removeIndex > -1) { | ||
this.removeFields.splice(removeIndex, 1); | ||
} | ||
} | ||
break; | ||
case "data": | ||
if (dataIndex === -1) { | ||
this.dataFields.push(eachField); | ||
if (rowIndex > -1) { | ||
this.rowFields.splice(columnIndex, 1); | ||
} | ||
if (columnIndex > -1) { | ||
this.columnFields.splice(dataIndex, 1); | ||
} | ||
if (removeIndex > -1) { | ||
this.removeFields.splice(removeIndex, 1); | ||
} | ||
} | ||
break; | ||
case "remove": | ||
if (removeIndex === -1) { | ||
this.removeFields.push(eachField); | ||
this.deleteField(eachField); | ||
} | ||
break; | ||
break; | ||
} | ||
} | ||
}, this); | ||
function createFormatFunction(ft) { | ||
return function (value) { | ||
return d3_format_1.format(ft)(value); | ||
}; | ||
} | ||
}, this); | ||
function createFormatFunction(ft) { | ||
return function (value) { | ||
return d3_format_1.format(ft)(value); | ||
}; | ||
} | ||
this.newField().forEach(function (row, idx) { | ||
var eachField = row.__prop_addField; | ||
for (var n = 0; n < this.orbFields.length; n++) { | ||
if (this.orbFields[n].caption === eachField) { | ||
var ft = row.formatFunction(); | ||
this.orbFields[n].dataSettings = { | ||
aggregateFunc: row.aggregateFunc(), | ||
formatFunc: createFormatFunction(ft) | ||
}; | ||
this.newField().forEach(function (row, idx) { | ||
var eachField = row.__prop_addField; | ||
for (var n = 0; n < this.orbFields.length; n++) { | ||
if (this.orbFields[n].caption === eachField) { | ||
var ft = row.formatFunction(); | ||
this.orbFields[n].dataSettings = { | ||
aggregateFunc: row.aggregateFunc(), | ||
formatFunc: createFormatFunction(ft) | ||
}; | ||
} | ||
} | ||
}, this); | ||
var orbCurrentConfig = this.orbConfig(ds, this.orbFields, this.rowFields, this.columnFields, this.dataFields); | ||
if (this.prevOrbConfig !== JSON.stringify(orbCurrentConfig)) { | ||
var react = window.React; | ||
react.unmountComponentAtNode(this._orbDiv.node()); | ||
this.prevOrbConfig = orbCurrentConfig; | ||
} | ||
}, this); | ||
var orbCurrentConfig = this.orbConfig(ds, this.orbFields, this.rowFields, this.columnFields, this.dataFields); | ||
if (this.prevOrbConfig !== JSON.stringify(orbCurrentConfig)) { | ||
var react = window.React; | ||
react.unmountComponentAtNode(this._orbDiv.node()); | ||
this.prevOrbConfig = orbCurrentConfig; | ||
} | ||
this._orbDiv = element.append("div"); | ||
this._orb = new ReactOrb.pgridwidget(orbCurrentConfig); | ||
this._orb.render(this._orbDiv.node()); | ||
this._orb.refreshData(this.data()); | ||
}; | ||
Orb.prototype.exit = function (domNode, element) { | ||
this._orbDiv.remove(); | ||
common_1.HTMLWidget.prototype.exit.apply(this, arguments); | ||
}; | ||
return Orb; | ||
}(common_1.HTMLWidget)); | ||
exports.Orb = Orb; | ||
Orb.prototype._class += " react_Orb"; | ||
Orb.prototype.Mapping = Mapping; | ||
Orb.prototype._OrbTypes = [{ id: "PIVOT", display: "Pivot Table", widgetClass: "react_Orb" }]; | ||
Orb.prototype.publish("stringProp", "defaultValue", "string", "Sample Property"); | ||
Orb.prototype.publish("tableWidth", 2000, "number", "Table width", null, { tags: ["basic"] }); | ||
Orb.prototype.publish("tableHeight", 711, "number", "Table height", null, { tags: ["basic"] }); | ||
Orb.prototype.publish("toolbar", true, "boolean", "Show Toolbox or not", null, { tags: ["basic"] }); | ||
Orb.prototype.publish("themeColor", "blue", "set", "Theme color", ["blue", "red", "black", "green"], { tags: ["basic"] }); | ||
Orb.prototype.publish("newField", [], "propertyArray", "Source Columns", null, { autoExpand: Mapping }); | ||
Orb.prototype.publish("columnGrandTotal", true, "boolean", "Show Grand total or not"); | ||
Orb.prototype.publish("rowGrandTotal", true, "boolean", "Show Grand total or not"); | ||
this._orbDiv = element.append("div"); | ||
this._orb = new ReactOrb.pgridwidget(orbCurrentConfig); | ||
this._orb.render(this._orbDiv.node()); | ||
this._orb.refreshData(this.data()); | ||
}; | ||
Orb.prototype.exit = function (domNode, element) { | ||
this._orbDiv.remove(); | ||
common_1.HTMLWidget.prototype.exit.apply(this, arguments); | ||
}; | ||
return Orb; | ||
}(common_1.HTMLWidget)); | ||
exports.Orb = Orb; | ||
Orb.prototype._class += " react_Orb"; | ||
Orb.prototype.Mapping = Mapping; | ||
Orb.prototype._OrbTypes = [{ id: "PIVOT", display: "Pivot Table", widgetClass: "react_Orb" }]; | ||
Orb.prototype.publish("stringProp", "defaultValue", "string", "Sample Property"); | ||
Orb.prototype.publish("tableWidth", 2000, "number", "Table width", null, { tags: ["basic"] }); | ||
Orb.prototype.publish("tableHeight", 711, "number", "Table height", null, { tags: ["basic"] }); | ||
Orb.prototype.publish("toolbar", true, "boolean", "Show Toolbox or not", null, { tags: ["basic"] }); | ||
Orb.prototype.publish("themeColor", "blue", "set", "Theme color", ["blue", "red", "black", "green"], { tags: ["basic"] }); | ||
Orb.prototype.publish("newField", [], "propertyArray", "Source Columns", null, { autoExpand: Mapping }); | ||
Orb.prototype.publish("columnGrandTotal", true, "boolean", "Show Grand total or not"); | ||
Orb.prototype.publish("rowGrandTotal", true, "boolean", "Show Grand total or not"); | ||
}); | ||
// Orb.prototype.publish("movable", true, "boolean", "Fields can be moved or not"); | ||
//# sourceMappingURL=Orb.js.map |
{ | ||
"name": "@hpcc-js/react", | ||
"version": "0.0.1", | ||
"version": "0.0.5", | ||
"description": "hpcc-js - Viz React", | ||
@@ -20,3 +20,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@hpcc-js/common": "^0.0.1", | ||
"@hpcc-js/common": "^0.0.5", | ||
"d3-format": "^1.2.0", | ||
@@ -43,2 +43,2 @@ "orb": "^1.0.9", | ||
"homepage": "https://github.com/hpcc-systems/Visualization" | ||
} | ||
} |
16081
365
+ Added@hpcc-js/common@0.0.5(transitive)
- Removed@hpcc-js/common@0.0.1(transitive)
Updated@hpcc-js/common@^0.0.5