@hpcc-js/tree
Advanced tools
Comparing version
@@ -1,97 +0,107 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var api_1 = require("@hpcc-js/api"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_hierarchy_1 = require("d3-hierarchy"); | ||
var d3_interpolate_1 = require("d3-interpolate"); | ||
var d3_selection_1 = require("d3-selection"); | ||
require("d3-transition"); | ||
require("../src/CirclePacking.css"); | ||
var CirclePacking = (function (_super) { | ||
tslib_1.__extends(CirclePacking, _super); | ||
function CirclePacking() { | ||
var _this = _super.call(this) || this; | ||
api_1.ITree.call(_this); | ||
return _this; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
CirclePacking.prototype.enter = function (_domNode, element) { | ||
this.diameter = Math.min(this.width(), this.height()); | ||
this.pack = d3_hierarchy_1.pack() | ||
.size([this.diameter - 4, this.diameter - 4]) | ||
.padding(1.5); | ||
this.svg = element | ||
.append("g") | ||
.attr("transform", "rotate(30)"); | ||
}; | ||
CirclePacking.prototype.update = function (_domNode, _element) { | ||
var context = this; | ||
this._palette = this._palette.switch(this.paletteID()); | ||
if (this.useClonedPalette()) { | ||
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id()); | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "tslib", "@hpcc-js/api", "@hpcc-js/common", "d3-hierarchy", "d3-interpolate", "d3-selection", "d3-transition", "../src/CirclePacking.css"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var api_1 = require("@hpcc-js/api"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_hierarchy_1 = require("d3-hierarchy"); | ||
var d3_interpolate_1 = require("d3-interpolate"); | ||
var d3_selection_1 = require("d3-selection"); | ||
require("d3-transition"); | ||
require("../src/CirclePacking.css"); | ||
var CirclePacking = (function (_super) { | ||
tslib_1.__extends(CirclePacking, _super); | ||
function CirclePacking() { | ||
var _this = _super.call(this) || this; | ||
api_1.ITree.call(_this); | ||
return _this; | ||
} | ||
this.svg.selectAll("circle").remove(); | ||
this.svg.selectAll("text").remove(); | ||
var root = d3_hierarchy_1.hierarchy(this.data()) | ||
.sum(function () { | ||
return 1; | ||
}).sort(function (a, b) { | ||
return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0; | ||
}); | ||
this._focus = root; | ||
this.pack(root); | ||
this.circle = this.svg.selectAll("circle").data(root.descendants()) | ||
.enter().append("circle") | ||
.attr("class", function (d) { return d.parent ? d.children ? "node" : "node leaf" : "node root"; }) | ||
.style("fill", function (d) { return context._palette(d.data.label); }) | ||
.on("click", function (d) { context.click(d.data, null, null); }) | ||
.on("dblclick", function (d) { | ||
if (this._focus !== d) { | ||
context.zoom(d); | ||
CirclePacking.prototype.enter = function (_domNode, element) { | ||
this.diameter = Math.min(this.width(), this.height()); | ||
this.pack = d3_hierarchy_1.pack() | ||
.size([this.diameter - 4, this.diameter - 4]) | ||
.padding(1.5); | ||
this.svg = element | ||
.append("g") | ||
.attr("transform", "rotate(30)"); | ||
}; | ||
CirclePacking.prototype.update = function (_domNode, _element) { | ||
var context = this; | ||
this._palette = this._palette.switch(this.paletteID()); | ||
if (this.useClonedPalette()) { | ||
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id()); | ||
} | ||
d3_selection_1.event.stopPropagation(); | ||
}); | ||
this.circle.append("title").text(function (d) { return d.data.label; }); | ||
this.svg.selectAll("text").data(root.descendants()) | ||
.enter().append("text") | ||
.attr("class", "label") | ||
.style("fill-opacity", function (d) { return d.parent === root ? 1 : 0; }) | ||
.style("display", function (d) { return d.parent === root ? null : "none"; }) | ||
.text(function (d) { return d.data.label; }); | ||
this._node = this.svg.selectAll("circle,text"); | ||
this.zoomTo([root.x, root.y, root.r * 2]); | ||
}; | ||
CirclePacking.prototype.zoom = function (newFocus) { | ||
this._focus = newFocus; | ||
var context = this; | ||
var transition = this.svg.transition() | ||
.duration(d3_selection_1.event.altKey ? 7500 : 750) | ||
.tween("zoom", function () { | ||
var i = d3_interpolate_1.interpolateZoom(context.view, [context._focus.x, context._focus.y, context._focus.r * 2]); | ||
return function (t) { context.zoomTo(i(t)); }; | ||
}); | ||
function showText(d) { | ||
return (d === context._focus && !d.children) || d.parent === context._focus; | ||
} | ||
transition.selectAll("text") | ||
.filter(function (d) { return showText(d) || this.style.display === "inline"; }) | ||
.style("fill-opacity", function (d) { return showText(d) ? 1 : 0; }) | ||
.on("start", function (d) { if (showText(d)) | ||
this.style.display = "inline"; }) | ||
.on("end", function (d) { if (!showText(d)) | ||
this.style.display = "none"; }); | ||
}; | ||
CirclePacking.prototype.zoomTo = function (v) { | ||
var k = this.diameter / v[2]; | ||
this.view = v; | ||
this._node.attr("transform", function (d) { return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1]) * k + ")"; }); | ||
this.circle.attr("r", function (d) { return d.r * k; }); | ||
}; | ||
return CirclePacking; | ||
}(common_1.SVGWidget)); | ||
exports.CirclePacking = CirclePacking; | ||
CirclePacking.prototype._class += " tree_CirclePacking"; | ||
CirclePacking.prototype.implements(api_1.ITree.prototype); | ||
CirclePacking.prototype.publish("paletteID", "default", "set", "Palette ID", CirclePacking.prototype._palette.switch(), { tags: ["Basic", "Shared"] }); | ||
CirclePacking.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] }); | ||
this.svg.selectAll("circle").remove(); | ||
this.svg.selectAll("text").remove(); | ||
var root = d3_hierarchy_1.hierarchy(this.data()) | ||
.sum(function () { | ||
return 1; | ||
}).sort(function (a, b) { | ||
return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0; | ||
}); | ||
this._focus = root; | ||
this.pack(root); | ||
this.circle = this.svg.selectAll("circle").data(root.descendants()) | ||
.enter().append("circle") | ||
.attr("class", function (d) { return d.parent ? d.children ? "node" : "node leaf" : "node root"; }) | ||
.style("fill", function (d) { return context._palette(d.data.label); }) | ||
.on("click", function (d) { context.click(d.data, null, null); }) | ||
.on("dblclick", function (d) { | ||
if (this._focus !== d) { | ||
context.zoom(d); | ||
} | ||
d3_selection_1.event.stopPropagation(); | ||
}); | ||
this.circle.append("title").text(function (d) { return d.data.label; }); | ||
this.svg.selectAll("text").data(root.descendants()) | ||
.enter().append("text") | ||
.attr("class", "label") | ||
.style("fill-opacity", function (d) { return d.parent === root ? 1 : 0; }) | ||
.style("display", function (d) { return d.parent === root ? null : "none"; }) | ||
.text(function (d) { return d.data.label; }); | ||
this._node = this.svg.selectAll("circle,text"); | ||
this.zoomTo([root.x, root.y, root.r * 2]); | ||
}; | ||
CirclePacking.prototype.zoom = function (newFocus) { | ||
this._focus = newFocus; | ||
var context = this; | ||
var transition = this.svg.transition() | ||
.duration(d3_selection_1.event.altKey ? 7500 : 750) | ||
.tween("zoom", function () { | ||
var i = d3_interpolate_1.interpolateZoom(context.view, [context._focus.x, context._focus.y, context._focus.r * 2]); | ||
return function (t) { context.zoomTo(i(t)); }; | ||
}); | ||
function showText(d) { | ||
return (d === context._focus && !d.children) || d.parent === context._focus; | ||
} | ||
transition.selectAll("text") | ||
.filter(function (d) { return showText(d) || this.style.display === "inline"; }) | ||
.style("fill-opacity", function (d) { return showText(d) ? 1 : 0; }) | ||
.on("start", function (d) { if (showText(d)) | ||
this.style.display = "inline"; }) | ||
.on("end", function (d) { if (!showText(d)) | ||
this.style.display = "none"; }); | ||
}; | ||
CirclePacking.prototype.zoomTo = function (v) { | ||
var k = this.diameter / v[2]; | ||
this.view = v; | ||
this._node.attr("transform", function (d) { return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1]) * k + ")"; }); | ||
this.circle.attr("r", function (d) { return d.r * k; }); | ||
}; | ||
return CirclePacking; | ||
}(common_1.SVGWidget)); | ||
exports.CirclePacking = CirclePacking; | ||
CirclePacking.prototype._class += " tree_CirclePacking"; | ||
CirclePacking.prototype.implements(api_1.ITree.prototype); | ||
CirclePacking.prototype.publish("paletteID", "default", "set", "Palette ID", CirclePacking.prototype._palette.switch(), { tags: ["Basic", "Shared"] }); | ||
CirclePacking.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] }); | ||
}); | ||
//# sourceMappingURL=CirclePacking.js.map |
@@ -1,224 +0,234 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var api_1 = require("@hpcc-js/api"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_hierarchy_1 = require("d3-hierarchy"); | ||
var d3_selection_1 = require("d3-selection"); | ||
require("../src/Dendrogram.css"); | ||
var DendrogramColumn = (function (_super) { | ||
tslib_1.__extends(DendrogramColumn, _super); | ||
function DendrogramColumn(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 DendrogramColumn; | ||
}(common_1.PropertyExt)); | ||
exports.DendrogramColumn = DendrogramColumn; | ||
DendrogramColumn.prototype._class += " tree_Dendrogram.DendrogramColumn"; | ||
DendrogramColumn.prototype.publish("column", null, "set", "Field", function () { return this._owner ? this._owner.columns() : []; }, { optional: true }); | ||
// === | ||
var Dendrogram = (function (_super) { | ||
tslib_1.__extends(Dendrogram, _super); | ||
function Dendrogram() { | ||
var _this = _super.call(this) || this; | ||
api_1.ITree.call(_this); | ||
common_1.Utility.SimpleSelectionMixin.call(_this); | ||
_this._drawStartPos = "origin"; | ||
_this._d3LayoutCluster = d3_hierarchy_1.cluster(); | ||
_this._d3LayoutTree = d3_hierarchy_1.tree(); | ||
return _this; | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "tslib", "@hpcc-js/api", "@hpcc-js/common", "d3-hierarchy", "d3-selection", "../src/Dendrogram.css"], factory); | ||
} | ||
Dendrogram.prototype.dendrogramData = function () { | ||
if (!this.mappings().filter(function (mapping) { return mapping.column(); }).length) { | ||
return this.data(); | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var api_1 = require("@hpcc-js/api"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_hierarchy_1 = require("d3-hierarchy"); | ||
var d3_selection_1 = require("d3-selection"); | ||
require("../src/Dendrogram.css"); | ||
var DendrogramColumn = (function (_super) { | ||
tslib_1.__extends(DendrogramColumn, _super); | ||
function DendrogramColumn(owner) { | ||
var _this = _super.call(this) || this; | ||
_this._owner = owner; | ||
return _this; | ||
} | ||
var view = this._db.rollupView(this.mappings().map(function (mapping) { return mapping.column(); })); | ||
var retVal = { | ||
key: "root", | ||
values: view.entries() | ||
}; | ||
return formatData(retVal); | ||
function formatData(node) { | ||
return { | ||
label: node.key, | ||
children: node.values.filter(function (value) { return !(value instanceof Array); }).map(function (value) { return formatData(value); }), | ||
origRows: node.values | ||
}; | ||
return DendrogramColumn; | ||
}(common_1.PropertyExt)); | ||
exports.DendrogramColumn = DendrogramColumn; | ||
DendrogramColumn.prototype._class += " tree_Dendrogram.DendrogramColumn"; | ||
DendrogramColumn.prototype.publish("column", null, "set", "Field", function () { return this._owner ? this._owner.columns() : []; }, { optional: true }); | ||
// === | ||
var Dendrogram = (function (_super) { | ||
tslib_1.__extends(Dendrogram, _super); | ||
function Dendrogram() { | ||
var _this = _super.call(this) || this; | ||
api_1.ITree.call(_this); | ||
common_1.Utility.SimpleSelectionMixin.call(_this); | ||
_this._drawStartPos = "origin"; | ||
_this._d3LayoutCluster = d3_hierarchy_1.cluster(); | ||
_this._d3LayoutTree = d3_hierarchy_1.tree(); | ||
return _this; | ||
} | ||
}; | ||
Dendrogram.prototype.enter = function (domNode, element) { | ||
_super.prototype.enter.call(this, domNode, element); | ||
this._renderElement | ||
.attr("opacity", 0) | ||
.transition().duration(500) | ||
.attr("opacity", 1); | ||
this._selection.widgetElement(this._renderElement); | ||
}; | ||
Dendrogram.prototype.update = function (domNode, element) { | ||
_super.prototype.update.call(this, domNode, element); | ||
var context = this; | ||
var isVertical = this.orientation() === "vertical"; | ||
this._palette = this._palette.switch(this.paletteID()); | ||
if (this.useClonedPalette()) { | ||
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id()); | ||
} | ||
this._d3Layout = this.dendrogram() ? this._d3LayoutCluster : this._d3LayoutTree; | ||
if (this.radial()) { | ||
this._d3Layout | ||
.size([360, this.separation() * 2]); | ||
this._d3Layout.separation(function separation(a, b) { | ||
return (a.parent === b.parent ? 1 : 2) / a.depth; | ||
}); | ||
} | ||
else { | ||
this._d3Layout.nodeSize([14, this.separation()]); | ||
this._d3Layout.separation(function separation(a, b) { | ||
return a.parent === b.parent ? 1 : 2; | ||
}); | ||
} | ||
var data = this.dendrogramData(); | ||
var root = d3_hierarchy_1.hierarchy(data); | ||
this._d3Layout(root); | ||
var dataNodes = root.descendants(); | ||
var links = root.descendants().slice(1); | ||
// Lines --- | ||
function linkVertical(d) { | ||
return "M" + d.parent.x + "," + d.parent.y | ||
+ "C" + d.parent.x + "," + (d.parent.y + d.y) / 2 | ||
+ " " + d.x + "," + (d.parent.y + d.y) / 2 | ||
+ " " + d.x + "," + d.y; | ||
} | ||
function linkHorizontal(d) { | ||
return "M" + d.y + "," + d.x | ||
+ "C" + (d.y + d.parent.y) / 2 + "," + d.x | ||
+ " " + (d.y + d.parent.y) / 2 + "," + d.parent.x | ||
+ " " + d.parent.y + "," + d.parent.x; | ||
} | ||
function diagonal(d) { | ||
return isVertical ? linkVertical(d) : linkHorizontal(d); | ||
} | ||
function project(x, y) { | ||
var angle = (x - 90) / 180 * Math.PI; | ||
var radius = y; | ||
return [radius * Math.cos(angle), radius * Math.sin(angle)]; | ||
} | ||
function radialDiagonal(d) { | ||
return "M" + project(d.x, d.y) | ||
+ "C" + project(d.x, (d.y + d.parent.y) / 2) | ||
+ " " + project(d.parent.x, (d.y + d.parent.y) / 2) | ||
+ " " + project(d.parent.x, d.parent.y); | ||
} | ||
var transitionDuration = this._renderCount ? 500 : 0; | ||
var lines = this._renderElement.selectAll(".link").data(links); | ||
lines.enter().append("path") | ||
.attr("class", "link") | ||
.attr("d", this.radial() ? radialDiagonal : diagonal); | ||
lines.transition().duration(transitionDuration) | ||
.attr("d", this.radial() ? radialDiagonal : diagonal); | ||
lines.exit().remove(); | ||
// Nodes --- | ||
var textOffsetX = this.circleRadius() + 2; | ||
function nodeTransform(d) { | ||
if (context.radial()) { | ||
return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; | ||
Dendrogram.prototype.dendrogramData = function () { | ||
if (!this.mappings().filter(function (mapping) { return mapping.column(); }).length) { | ||
return this.data(); | ||
} | ||
return context.orientation() === "horizontal" ? "translate(" + d.y + "," + d.x + ")" : "translate(" + d.x + "," + d.y + ")"; | ||
} | ||
var nodes = this._renderElement.selectAll(".node").data(dataNodes); | ||
nodes.transition().duration(transitionDuration) | ||
.attr("transform", nodeTransform); | ||
var enterNodes = nodes.enter().append("g") | ||
.attr("class", "node") | ||
.attr("transform", nodeTransform) | ||
.call(this._selection.enter.bind(this._selection)) | ||
.on("click", function (d) { | ||
var tmp = d; | ||
while (tmp.children) { | ||
tmp = tmp.children[0]; | ||
var view = this._db.rollupView(this.mappings().map(function (mapping) { return mapping.column(); })); | ||
var retVal = { | ||
key: "root", | ||
values: view.entries() | ||
}; | ||
return formatData(retVal); | ||
function formatData(node) { | ||
return { | ||
label: node.key, | ||
children: node.values.filter(function (value) { return !(value instanceof Array); }).map(function (value) { return formatData(value); }), | ||
origRows: node.values | ||
}; | ||
} | ||
if (d.depth > 0) { | ||
context.click(context.rowToObj(tmp.origRows[0]), context.mappings()[d.depth - 1].column(), true); | ||
}; | ||
Dendrogram.prototype.enter = function (domNode, element) { | ||
_super.prototype.enter.call(this, domNode, element); | ||
this._renderElement | ||
.attr("opacity", 0) | ||
.transition().duration(500) | ||
.attr("opacity", 1); | ||
this._selection.widgetElement(this._renderElement); | ||
}; | ||
Dendrogram.prototype.update = function (domNode, element) { | ||
_super.prototype.update.call(this, domNode, element); | ||
var context = this; | ||
var isVertical = this.orientation() === "vertical"; | ||
this._palette = this._palette.switch(this.paletteID()); | ||
if (this.useClonedPalette()) { | ||
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id()); | ||
} | ||
}) | ||
.on("dblclick", function (d) { | ||
var tmp = d; | ||
while (tmp.children) { | ||
tmp = tmp.children[0]; | ||
this._d3Layout = this.dendrogram() ? this._d3LayoutCluster : this._d3LayoutTree; | ||
if (this.radial()) { | ||
this._d3Layout | ||
.size([360, this.separation() * 2]); | ||
this._d3Layout.separation(function separation(a, b) { | ||
return (a.parent === b.parent ? 1 : 2) / a.depth; | ||
}); | ||
} | ||
if (d.depth > 0) { | ||
context.dblclick(context.rowToObj(tmp.origRows[0]), context.mappings()[d.depth - 1].column(), true); | ||
else { | ||
this._d3Layout.nodeSize([14, this.separation()]); | ||
this._d3Layout.separation(function separation(a, b) { | ||
return a.parent === b.parent ? 1 : 2; | ||
}); | ||
} | ||
}) | ||
.each(function () { | ||
var e = d3_selection_1.select(this); | ||
e.append("circle"); | ||
e.append("text"); | ||
}); | ||
enterNodes.merge(nodes).select("circle") | ||
.attr("r", this.circleRadius()) | ||
.style("fill", function (d) { return context._palette(d.data.label); }) | ||
.append("title") | ||
.text(function (d) { return d.data.label; }); | ||
enterNodes.merge(nodes).select("text") | ||
.attr("dx", function (d) { | ||
if (context.radial()) { | ||
if (d.children) { | ||
return d.x < 180 ? -textOffsetX : textOffsetX; | ||
} | ||
else { | ||
return d.x < 180 ? textOffsetX : -textOffsetX; | ||
} | ||
var data = this.dendrogramData(); | ||
var root = d3_hierarchy_1.hierarchy(data); | ||
this._d3Layout(root); | ||
var dataNodes = root.descendants(); | ||
var links = root.descendants().slice(1); | ||
// Lines --- | ||
function linkVertical(d) { | ||
return "M" + d.parent.x + "," + d.parent.y | ||
+ "C" + d.parent.x + "," + (d.parent.y + d.y) / 2 | ||
+ " " + d.x + "," + (d.parent.y + d.y) / 2 | ||
+ " " + d.x + "," + d.y; | ||
} | ||
else if (isVertical) { | ||
return d.children ? textOffsetX : -textOffsetX; | ||
function linkHorizontal(d) { | ||
return "M" + d.y + "," + d.x | ||
+ "C" + (d.y + d.parent.y) / 2 + "," + d.x | ||
+ " " + (d.y + d.parent.y) / 2 + "," + d.parent.x | ||
+ " " + d.parent.y + "," + d.parent.x; | ||
} | ||
return d.children ? -textOffsetX : textOffsetX; | ||
}) | ||
.attr("dy", "0.25em") | ||
.style("text-anchor", function (d) { | ||
if (context.radial()) { | ||
if (d.children) { | ||
return d.x < 180 ? "end" : "start"; | ||
} | ||
else { | ||
return d.x < 180 ? "start" : "end"; | ||
} | ||
function diagonal(d) { | ||
return isVertical ? linkVertical(d) : linkHorizontal(d); | ||
} | ||
else if (isVertical) { | ||
return d.children ? "start" : "end"; | ||
function project(x, y) { | ||
var angle = (x - 90) / 180 * Math.PI; | ||
var radius = y; | ||
return [radius * Math.cos(angle), radius * Math.sin(angle)]; | ||
} | ||
return d.children ? "end" : "start"; | ||
}) | ||
.attr("transform", function (d) { | ||
if (context.radial()) { | ||
return d.x < 180 ? null : "rotate(180)"; | ||
function radialDiagonal(d) { | ||
return "M" + project(d.x, d.y) | ||
+ "C" + project(d.x, (d.y + d.parent.y) / 2) | ||
+ " " + project(d.parent.x, (d.y + d.parent.y) / 2) | ||
+ " " + project(d.parent.x, d.parent.y); | ||
} | ||
else if (isVertical) { | ||
return "rotate(-66)"; | ||
var transitionDuration = this._renderCount ? 500 : 0; | ||
var lines = this._renderElement.selectAll(".link").data(links); | ||
lines.enter().append("path") | ||
.attr("class", "link") | ||
.attr("d", this.radial() ? radialDiagonal : diagonal); | ||
lines.transition().duration(transitionDuration) | ||
.attr("d", this.radial() ? radialDiagonal : diagonal); | ||
lines.exit().remove(); | ||
// Nodes --- | ||
var textOffsetX = this.circleRadius() + 2; | ||
function nodeTransform(d) { | ||
if (context.radial()) { | ||
return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; | ||
} | ||
return context.orientation() === "horizontal" ? "translate(" + d.y + "," + d.x + ")" : "translate(" + d.x + "," + d.y + ")"; | ||
} | ||
return null; | ||
}) | ||
.text(function (d) { return d.data.label; }); | ||
nodes.exit().remove(); | ||
if (!this._renderCount) { | ||
context.zoomToFit(); | ||
} | ||
}; | ||
return Dendrogram; | ||
}(common_1.SVGZoomWidget)); | ||
exports.Dendrogram = Dendrogram; | ||
Dendrogram.prototype._class += " tree_Dendrogram"; | ||
Dendrogram.prototype.implements(api_1.ITree.prototype); | ||
Dendrogram.prototype.mixin(common_1.Utility.SimpleSelectionMixin); | ||
Dendrogram.prototype.Column = DendrogramColumn; | ||
Dendrogram.prototype.publish("paletteID", "default", "set", "Palette ID", Dendrogram.prototype._palette.switch(), { tags: ["Basic", "Shared"] }); | ||
Dendrogram.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] }); | ||
Dendrogram.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: DendrogramColumn }); | ||
Dendrogram.prototype.publish("circleRadius", 4.5, "number", "Text offset from circle"); | ||
Dendrogram.prototype.publish("separation", 240, "number", "Leaf Separation"); | ||
Dendrogram.prototype.publish("dendrogram", true, "boolean", "Dendrogram"); | ||
Dendrogram.prototype.publish("radial", false, "boolean", "Radial"); | ||
Dendrogram.prototype.publish("orientation", "horizontal", "set", "Orientation", ["horizontal", "vertical"], { tags: ["Private"], disable: function (w) { return w.radial(); } }); | ||
var nodes = this._renderElement.selectAll(".node").data(dataNodes); | ||
nodes.transition().duration(transitionDuration) | ||
.attr("transform", nodeTransform); | ||
var enterNodes = nodes.enter().append("g") | ||
.attr("class", "node") | ||
.attr("transform", nodeTransform) | ||
.call(this._selection.enter.bind(this._selection)) | ||
.on("click", function (d) { | ||
var tmp = d; | ||
while (tmp.children) { | ||
tmp = tmp.children[0]; | ||
} | ||
if (d.depth > 0) { | ||
context.click(context.rowToObj(tmp.origRows[0]), context.mappings()[d.depth - 1].column(), true); | ||
} | ||
}) | ||
.on("dblclick", function (d) { | ||
var tmp = d; | ||
while (tmp.children) { | ||
tmp = tmp.children[0]; | ||
} | ||
if (d.depth > 0) { | ||
context.dblclick(context.rowToObj(tmp.origRows[0]), context.mappings()[d.depth - 1].column(), true); | ||
} | ||
}) | ||
.each(function () { | ||
var e = d3_selection_1.select(this); | ||
e.append("circle"); | ||
e.append("text"); | ||
}); | ||
enterNodes.merge(nodes).select("circle") | ||
.attr("r", this.circleRadius()) | ||
.style("fill", function (d) { return context._palette(d.data.label); }) | ||
.append("title") | ||
.text(function (d) { return d.data.label; }); | ||
enterNodes.merge(nodes).select("text") | ||
.attr("dx", function (d) { | ||
if (context.radial()) { | ||
if (d.children) { | ||
return d.x < 180 ? -textOffsetX : textOffsetX; | ||
} | ||
else { | ||
return d.x < 180 ? textOffsetX : -textOffsetX; | ||
} | ||
} | ||
else if (isVertical) { | ||
return d.children ? textOffsetX : -textOffsetX; | ||
} | ||
return d.children ? -textOffsetX : textOffsetX; | ||
}) | ||
.attr("dy", "0.25em") | ||
.style("text-anchor", function (d) { | ||
if (context.radial()) { | ||
if (d.children) { | ||
return d.x < 180 ? "end" : "start"; | ||
} | ||
else { | ||
return d.x < 180 ? "start" : "end"; | ||
} | ||
} | ||
else if (isVertical) { | ||
return d.children ? "start" : "end"; | ||
} | ||
return d.children ? "end" : "start"; | ||
}) | ||
.attr("transform", function (d) { | ||
if (context.radial()) { | ||
return d.x < 180 ? null : "rotate(180)"; | ||
} | ||
else if (isVertical) { | ||
return "rotate(-66)"; | ||
} | ||
return null; | ||
}) | ||
.text(function (d) { return d.data.label; }); | ||
nodes.exit().remove(); | ||
if (!this._renderCount) { | ||
context.zoomToFit(); | ||
} | ||
}; | ||
return Dendrogram; | ||
}(common_1.SVGZoomWidget)); | ||
exports.Dendrogram = Dendrogram; | ||
Dendrogram.prototype._class += " tree_Dendrogram"; | ||
Dendrogram.prototype.implements(api_1.ITree.prototype); | ||
Dendrogram.prototype.mixin(common_1.Utility.SimpleSelectionMixin); | ||
Dendrogram.prototype.Column = DendrogramColumn; | ||
Dendrogram.prototype.publish("paletteID", "default", "set", "Palette ID", Dendrogram.prototype._palette.switch(), { tags: ["Basic", "Shared"] }); | ||
Dendrogram.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] }); | ||
Dendrogram.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: DendrogramColumn }); | ||
Dendrogram.prototype.publish("circleRadius", 4.5, "number", "Text offset from circle"); | ||
Dendrogram.prototype.publish("separation", 240, "number", "Leaf Separation"); | ||
Dendrogram.prototype.publish("dendrogram", true, "boolean", "Dendrogram"); | ||
Dendrogram.prototype.publish("radial", false, "boolean", "Radial"); | ||
Dendrogram.prototype.publish("orientation", "horizontal", "set", "Orientation", ["horizontal", "vertical"], { tags: ["Private"], disable: function (w) { return w.radial(); } }); | ||
}); | ||
//# sourceMappingURL=Dendrogram.js.map |
@@ -1,229 +0,239 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var api_1 = require("@hpcc-js/api"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_hierarchy_1 = require("d3-hierarchy"); | ||
var d3_selection_1 = require("d3-selection"); | ||
require("../src/Indented.css"); | ||
var IndentedColumn = (function (_super) { | ||
tslib_1.__extends(IndentedColumn, _super); | ||
function IndentedColumn(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 IndentedColumn; | ||
}(common_1.PropertyExt)); | ||
exports.IndentedColumn = IndentedColumn; | ||
IndentedColumn.prototype._class += " tree_Dendrogram.IndentedColumn"; | ||
IndentedColumn.prototype.publish("column", null, "set", "Field", function () { return this._owner ? this._owner.columns() : []; }, { optional: true }); | ||
// === | ||
var Indented = (function (_super) { | ||
tslib_1.__extends(Indented, _super); | ||
function Indented() { | ||
var _this = _super.call(this) || this; | ||
_this._collapsed = {}; | ||
api_1.ITree.call(_this); | ||
common_1.Utility.SimpleSelectionMixin.call(_this); | ||
_this._drawStartPos = "origin"; | ||
_this._d3Tree = d3_hierarchy_1.tree(); | ||
return _this; | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "tslib", "@hpcc-js/api", "@hpcc-js/common", "d3-hierarchy", "d3-selection", "../src/Indented.css"], factory); | ||
} | ||
Indented.prototype.xmlToData = function (xml, id) { | ||
if (id === void 0) { id = ""; } | ||
if (DOMParser) { | ||
var parser = new DOMParser(); | ||
var doc = parser.parseFromString(xml, "text/xml"); | ||
return xmlToJson(doc, id).children[0]; | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var api_1 = require("@hpcc-js/api"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_hierarchy_1 = require("d3-hierarchy"); | ||
var d3_selection_1 = require("d3-selection"); | ||
require("../src/Indented.css"); | ||
var IndentedColumn = (function (_super) { | ||
tslib_1.__extends(IndentedColumn, _super); | ||
function IndentedColumn(owner) { | ||
var _this = _super.call(this) || this; | ||
_this._owner = owner; | ||
return _this; | ||
} | ||
return []; | ||
}; | ||
Indented.prototype.xml = function (_) { | ||
if (!arguments.length) | ||
return this._xml; | ||
this._xml = _; | ||
this.data(this.xmlToData(this._xml)); | ||
return this; | ||
}; | ||
Indented.prototype.IndentedData = function () { | ||
if (this.xmlColumn_exists()) { | ||
var cellIdx_1 = this.columns().indexOf(this.xmlColumn()); | ||
var retVal = { | ||
label: this.xmlColumn(), | ||
children: this.data().map(function (row, idx) { | ||
return this.xmlToData(row[cellIdx_1], "[" + idx + "]"); | ||
}, this) | ||
}; | ||
return retVal.children.length === 1 ? retVal.children[0] : retVal; | ||
return IndentedColumn; | ||
}(common_1.PropertyExt)); | ||
exports.IndentedColumn = IndentedColumn; | ||
IndentedColumn.prototype._class += " tree_Dendrogram.IndentedColumn"; | ||
IndentedColumn.prototype.publish("column", null, "set", "Field", function () { return this._owner ? this._owner.columns() : []; }, { optional: true }); | ||
// === | ||
var Indented = (function (_super) { | ||
tslib_1.__extends(Indented, _super); | ||
function Indented() { | ||
var _this = _super.call(this) || this; | ||
_this._collapsed = {}; | ||
api_1.ITree.call(_this); | ||
common_1.Utility.SimpleSelectionMixin.call(_this); | ||
_this._drawStartPos = "origin"; | ||
_this._d3Tree = d3_hierarchy_1.tree(); | ||
return _this; | ||
} | ||
else { | ||
if (!this.mappings().filter(function (mapping) { return mapping.column(); }).length) { | ||
return this.data(); | ||
Indented.prototype.xmlToData = function (xml, id) { | ||
if (id === void 0) { id = ""; } | ||
if (DOMParser) { | ||
var parser = new DOMParser(); | ||
var doc = parser.parseFromString(xml, "text/xml"); | ||
return xmlToJson(doc, id).children[0]; | ||
} | ||
var view = this._db.rollupView(this.mappings().map(function (mapping) { return mapping.column(); })); | ||
var root = { | ||
key: "root", | ||
values: view.entries() | ||
}; | ||
return formatData(root); | ||
} | ||
function formatData(node) { | ||
if (node.values instanceof Array) { | ||
var children = node.values.filter(function (value) { | ||
return !(value instanceof Array); | ||
}).map(function (value) { | ||
return formatData(value); | ||
}); | ||
return []; | ||
}; | ||
Indented.prototype.xml = function (_) { | ||
if (!arguments.length) | ||
return this._xml; | ||
this._xml = _; | ||
this.data(this.xmlToData(this._xml)); | ||
return this; | ||
}; | ||
Indented.prototype.IndentedData = function () { | ||
if (this.xmlColumn_exists()) { | ||
var cellIdx_1 = this.columns().indexOf(this.xmlColumn()); | ||
var retVal = { | ||
label: node.key | ||
label: this.xmlColumn(), | ||
children: this.data().map(function (row, idx) { | ||
return this.xmlToData(row[cellIdx_1], "[" + idx + "]"); | ||
}, this) | ||
}; | ||
if (children.length) { | ||
retVal.children = children; | ||
return retVal.children.length === 1 ? retVal.children[0] : retVal; | ||
} | ||
else { | ||
if (!this.mappings().filter(function (mapping) { return mapping.column(); }).length) { | ||
return this.data(); | ||
} | ||
else { | ||
retVal.size = 22; | ||
var view = this._db.rollupView(this.mappings().map(function (mapping) { return mapping.column(); })); | ||
var root = { | ||
key: "root", | ||
values: view.entries() | ||
}; | ||
return formatData(root); | ||
} | ||
function formatData(node) { | ||
if (node.values instanceof Array) { | ||
var children = node.values.filter(function (value) { | ||
return !(value instanceof Array); | ||
}).map(function (value) { | ||
return formatData(value); | ||
}); | ||
var retVal = { | ||
label: node.key | ||
}; | ||
if (children.length) { | ||
retVal.children = children; | ||
} | ||
else { | ||
retVal.size = 22; | ||
} | ||
return retVal; | ||
} | ||
return retVal; | ||
return { | ||
label: node.key, | ||
size: node.values.aggregate, | ||
origRows: node.values | ||
}; | ||
} | ||
return { | ||
label: node.key, | ||
size: node.values.aggregate, | ||
origRows: node.values | ||
}; | ||
} | ||
}; | ||
Indented.prototype.enter = function (domNode, element) { | ||
_super.prototype.enter.call(this, domNode, element); | ||
this._svgLinks = this._renderElement.append("g"); | ||
this._svgNodes = this._renderElement.append("g"); | ||
this._selection.widgetElement(this._svgNodes); | ||
}; | ||
Indented.prototype.update = function (domNode, _element) { | ||
var _this = this; | ||
_super.prototype.update.call(this, domNode, _element); | ||
var context = this; | ||
this._d3Tree | ||
.nodeSize([0, this.barHeight()]); | ||
var dataChecksum = this._db.dataChecksum(); | ||
if (this._prevDataChecksum !== dataChecksum) { | ||
this._treeData = this.IndentedData(); | ||
this._prevDataChecksum = dataChecksum; | ||
} | ||
function getID(d) { | ||
return (d.parent ? getID(d.parent) + "." : "") + d.data.label; | ||
} | ||
var root = d3_hierarchy_1.hierarchy(this.data()) | ||
.sum(function (d) { | ||
return d.size || 50; | ||
}).each(function (d) { | ||
if (_this._collapsed[getID(d)]) { | ||
delete (d.children); | ||
}; | ||
Indented.prototype.enter = function (domNode, element) { | ||
_super.prototype.enter.call(this, domNode, element); | ||
this._svgLinks = this._renderElement.append("g"); | ||
this._svgNodes = this._renderElement.append("g"); | ||
this._selection.widgetElement(this._svgNodes); | ||
}; | ||
Indented.prototype.update = function (domNode, _element) { | ||
var _this = this; | ||
_super.prototype.update.call(this, domNode, _element); | ||
var context = this; | ||
this._d3Tree | ||
.nodeSize([0, this.barHeight()]); | ||
var dataChecksum = this._db.dataChecksum(); | ||
if (this._prevDataChecksum !== dataChecksum) { | ||
this._treeData = this.IndentedData(); | ||
this._prevDataChecksum = dataChecksum; | ||
} | ||
}); | ||
var dataNodes = this._d3Tree(root).descendants(); | ||
var links = this._d3Tree(root).descendants().slice(1); | ||
var nodeIdx = 0; | ||
root.eachBefore(function (n) { | ||
n.x = nodeIdx * context.barHeight(); | ||
++nodeIdx; | ||
}); | ||
var boxSize = this.barHeight() - 4; | ||
var transitionDuration = this._renderCount ? 500 : 0; | ||
// Lines --- | ||
var lines = this._svgLinks.selectAll(".link").data(links, function (d) { return getID(d); }); | ||
lines.enter().append("path") | ||
.attr("class", "link") | ||
.attr("d", elbow); | ||
lines.transition().duration(transitionDuration) | ||
.attr("d", elbow); | ||
lines.exit().remove(); | ||
function elbow(d) { | ||
return "M" + d.parent.y + "," + d.parent.x | ||
+ "V" + d.x + ", H" + d.y; | ||
} | ||
// Nodes --- | ||
var nodes = this._svgNodes.selectAll(".node").data(dataNodes, function (d) { return getID(d); }); | ||
nodes.transition().duration(transitionDuration) | ||
.attr("transform", function (d) { return "translate(" + d.y + "," + d.x + ")"; }); | ||
var enterNodes = nodes.enter().append("g") | ||
.attr("class", "node") | ||
.attr("transform", function (d) { return "translate(" + d.y + "," + d.x + ")"; }) | ||
.call(this._selection.enter.bind(this._selection)) | ||
.each(function () { | ||
var element = d3_selection_1.select(this); | ||
element.append("rect") | ||
.attr("height", boxSize) | ||
.attr("width", boxSize) | ||
.on("click", function (d) { | ||
if (context._collapsed[getID(d)]) { | ||
delete context._collapsed[getID(d)]; | ||
function getID(d) { | ||
return (d.parent ? getID(d.parent) + "." : "") + d.data.label; | ||
} | ||
var root = d3_hierarchy_1.hierarchy(this.data()) | ||
.sum(function (d) { | ||
return d.size || 50; | ||
}).each(function (d) { | ||
if (_this._collapsed[getID(d)]) { | ||
delete (d.children); | ||
} | ||
else if (d.children) { | ||
context._collapsed[getID(d)] = true; | ||
}); | ||
var dataNodes = this._d3Tree(root).descendants(); | ||
var links = this._d3Tree(root).descendants().slice(1); | ||
var nodeIdx = 0; | ||
root.eachBefore(function (n) { | ||
n.x = nodeIdx * context.barHeight(); | ||
++nodeIdx; | ||
}); | ||
var boxSize = this.barHeight() - 4; | ||
var transitionDuration = this._renderCount ? 500 : 0; | ||
// Lines --- | ||
var lines = this._svgLinks.selectAll(".link").data(links, function (d) { return getID(d); }); | ||
lines.enter().append("path") | ||
.attr("class", "link") | ||
.attr("d", elbow); | ||
lines.transition().duration(transitionDuration) | ||
.attr("d", elbow); | ||
lines.exit().remove(); | ||
function elbow(d) { | ||
return "M" + d.parent.y + "," + d.parent.x | ||
+ "V" + d.x + ", H" + d.y; | ||
} | ||
// Nodes --- | ||
var nodes = this._svgNodes.selectAll(".node").data(dataNodes, function (d) { return getID(d); }); | ||
nodes.transition().duration(transitionDuration) | ||
.attr("transform", function (d) { return "translate(" + d.y + "," + d.x + ")"; }); | ||
var enterNodes = nodes.enter().append("g") | ||
.attr("class", "node") | ||
.attr("transform", function (d) { return "translate(" + d.y + "," + d.x + ")"; }) | ||
.call(this._selection.enter.bind(this._selection)) | ||
.each(function () { | ||
var element = d3_selection_1.select(this); | ||
element.append("rect") | ||
.attr("height", boxSize) | ||
.attr("width", boxSize) | ||
.on("click", function (d) { | ||
if (context._collapsed[getID(d)]) { | ||
delete context._collapsed[getID(d)]; | ||
} | ||
else if (d.children) { | ||
context._collapsed[getID(d)] = true; | ||
} | ||
context.lazyRender(); | ||
}); | ||
element.append("text"); | ||
}) | ||
.style("opacity", 0); | ||
enterNodes.transition() | ||
.style("opacity", 1); | ||
enterNodes.merge(nodes).select("rect") | ||
.attr("x", -boxSize / 2) | ||
.attr("y", -boxSize / 2) | ||
.style("fill", color); | ||
enterNodes.merge(nodes).select("text") | ||
.attr("dx", boxSize / 2 + 4 + "px") | ||
.attr("dy", "0.33em") | ||
.text(function (d) { return d.data.label; }); | ||
nodes.exit().transition() | ||
.style("opacity", 0) | ||
.remove(); | ||
if (!this._renderCount) { | ||
context.zoomToFit(); | ||
} | ||
function color(d) { | ||
return context._collapsed[getID(d)] ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c"; | ||
} | ||
}; | ||
return Indented; | ||
}(common_1.SVGZoomWidget)); | ||
exports.Indented = Indented; | ||
Indented.prototype._class += " tree_Indented"; | ||
Indented.prototype.implements(api_1.ITree.prototype); | ||
Indented.prototype.mixin(common_1.Utility.SimpleSelectionMixin); | ||
Indented.prototype.Column = IndentedColumn; | ||
Indented.prototype.publish("xmlColumn", null, "set", "Field", function () { return this.columns(); }, { optional: true }); | ||
Indented.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: IndentedColumn, disable: function (w) { return w.xmlColumn_exists(); } }); | ||
Indented.prototype.publish("barHeight", 16, "number", "Bar height"); | ||
function xmlToJson(xml, id) { | ||
if (id === void 0) { id = ""; } | ||
var retVal = { | ||
id: id, | ||
label: "", | ||
attributes: {}, | ||
children: [] | ||
}; | ||
retVal.label = xml.nodeName; | ||
if (xml.nodeType === 1) { | ||
if (xml.attributes.length > 0) { | ||
for (var j = 0; j < xml.attributes.length; j++) { | ||
var attribute = xml.attributes.item(j); | ||
retVal.attributes[attribute.nodeName] = attribute.nodeValue; | ||
} | ||
context.lazyRender(); | ||
}); | ||
element.append("text"); | ||
}) | ||
.style("opacity", 0); | ||
enterNodes.transition() | ||
.style("opacity", 1); | ||
enterNodes.merge(nodes).select("rect") | ||
.attr("x", -boxSize / 2) | ||
.attr("y", -boxSize / 2) | ||
.style("fill", color); | ||
enterNodes.merge(nodes).select("text") | ||
.attr("dx", boxSize / 2 + 4 + "px") | ||
.attr("dy", "0.33em") | ||
.text(function (d) { return d.data.label; }); | ||
nodes.exit().transition() | ||
.style("opacity", 0) | ||
.remove(); | ||
if (!this._renderCount) { | ||
context.zoomToFit(); | ||
} | ||
} | ||
function color(d) { | ||
return context._collapsed[getID(d)] ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c"; | ||
else if (xml.nodeType === 3) { | ||
retVal.label = xml.nodeValue; | ||
} | ||
}; | ||
return Indented; | ||
}(common_1.SVGZoomWidget)); | ||
exports.Indented = Indented; | ||
Indented.prototype._class += " tree_Indented"; | ||
Indented.prototype.implements(api_1.ITree.prototype); | ||
Indented.prototype.mixin(common_1.Utility.SimpleSelectionMixin); | ||
Indented.prototype.Column = IndentedColumn; | ||
Indented.prototype.publish("xmlColumn", null, "set", "Field", function () { return this.columns(); }, { optional: true }); | ||
Indented.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: IndentedColumn, disable: function (w) { return w.xmlColumn_exists(); } }); | ||
Indented.prototype.publish("barHeight", 16, "number", "Bar height"); | ||
function xmlToJson(xml, id) { | ||
if (id === void 0) { id = ""; } | ||
var retVal = { | ||
id: id, | ||
label: "", | ||
attributes: {}, | ||
children: [] | ||
}; | ||
retVal.label = xml.nodeName; | ||
if (xml.nodeType === 1) { | ||
if (xml.attributes.length > 0) { | ||
for (var j = 0; j < xml.attributes.length; j++) { | ||
var attribute = xml.attributes.item(j); | ||
retVal.attributes[attribute.nodeName] = attribute.nodeValue; | ||
if (xml.hasChildNodes()) { | ||
for (var i = 0; i < xml.childNodes.length; i++) { | ||
var item = xml.childNodes.item(i); | ||
var child = xmlToJson(item, id + "[" + retVal.children.length + "]"); | ||
retVal.children.push(child); | ||
} | ||
} | ||
return retVal; | ||
} | ||
else if (xml.nodeType === 3) { | ||
retVal.label = xml.nodeValue; | ||
} | ||
if (xml.hasChildNodes()) { | ||
for (var i = 0; i < xml.childNodes.length; i++) { | ||
var item = xml.childNodes.item(i); | ||
var child = xmlToJson(item, id + "[" + retVal.children.length + "]"); | ||
retVal.children.push(child); | ||
} | ||
} | ||
return retVal; | ||
} | ||
}); | ||
//# sourceMappingURL=Indented.js.map |
@@ -1,11 +0,21 @@ | ||
"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("./CirclePacking")); | ||
__export(require("./Dendrogram")); | ||
__export(require("./Indented")); | ||
__export(require("./SunburstPartition")); | ||
__export(require("./Treemap")); | ||
(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", "./CirclePacking", "./Dendrogram", "./Indented", "./SunburstPartition", "./Treemap"], 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("./CirclePacking")); | ||
__export(require("./Dendrogram")); | ||
__export(require("./Indented")); | ||
__export(require("./SunburstPartition")); | ||
__export(require("./Treemap")); | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -1,115 +0,125 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var api_1 = require("@hpcc-js/api"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_hierarchy_1 = require("d3-hierarchy"); | ||
var d3_interpolate_1 = require("d3-interpolate"); | ||
var d3_scale_1 = require("d3-scale"); | ||
var d3_selection_1 = require("d3-selection"); | ||
var d3_shape_1 = require("d3-shape"); | ||
require("../src/SunburstPartition.css"); | ||
var SunburstPartition = (function (_super) { | ||
tslib_1.__extends(SunburstPartition, _super); | ||
function SunburstPartition() { | ||
var _this = _super.call(this) || this; | ||
api_1.ITree.call(_this); | ||
return _this; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
SunburstPartition.prototype.data = function (_) { | ||
var retVal = common_1.SVGWidget.prototype.data.apply(this, arguments); | ||
if (arguments.length) { | ||
this._resetRoot = true; | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "tslib", "@hpcc-js/api", "@hpcc-js/common", "d3-hierarchy", "d3-interpolate", "d3-scale", "d3-selection", "d3-shape", "../src/SunburstPartition.css"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var api_1 = require("@hpcc-js/api"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_hierarchy_1 = require("d3-hierarchy"); | ||
var d3_interpolate_1 = require("d3-interpolate"); | ||
var d3_scale_1 = require("d3-scale"); | ||
var d3_selection_1 = require("d3-selection"); | ||
var d3_shape_1 = require("d3-shape"); | ||
require("../src/SunburstPartition.css"); | ||
var SunburstPartition = (function (_super) { | ||
tslib_1.__extends(SunburstPartition, _super); | ||
function SunburstPartition() { | ||
var _this = _super.call(this) || this; | ||
api_1.ITree.call(_this); | ||
return _this; | ||
} | ||
return retVal; | ||
}; | ||
SunburstPartition.prototype.enter = function (_domNode, element) { | ||
var context = this; | ||
this.radius = Math.min(this.width(), this.height()) / 2; | ||
this._xScale = d3_scale_1.scaleLinear() | ||
.range([0, 2 * Math.PI]); | ||
this._yScale = d3_scale_1.scaleSqrt() | ||
.range([0, this.radius]); | ||
this.partition = d3_hierarchy_1.partition(); | ||
this.arc = d3_shape_1.arc() | ||
.startAngle(function (d) { | ||
return Math.max(0, Math.min(2 * Math.PI, context._xScale(d.x0))); | ||
}) | ||
.endAngle(function (d) { | ||
return Math.max(0, Math.min(2 * Math.PI, context._xScale(d.x1))); | ||
}) | ||
.innerRadius(function (d) { | ||
return Math.max(0, context._yScale(d.y0)); | ||
}) | ||
.outerRadius(function (d) { | ||
return Math.max(0, context._yScale(d.y1)); | ||
}); | ||
this.svg = element.append("g"); | ||
}; | ||
SunburstPartition.prototype.update = function (_domNode, _element) { | ||
var context = this; | ||
this._palette = this._palette.switch(this.paletteID()); | ||
if (this.useClonedPalette()) { | ||
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id()); | ||
} | ||
this.radius = Math.min(this.width(), this.height()) / 2; | ||
this._yScale.range([0, this.radius]); | ||
var root = d3_hierarchy_1.hierarchy(this.data()) | ||
.sum(function (d) { | ||
return d.size !== undefined ? d.size : 1; | ||
}); | ||
var paths = this.svg.selectAll("path").data(this.partition(root).descendants(), function (d, i) { | ||
return d.data.label !== undefined ? d.data.label : i; | ||
}); | ||
paths.enter().append("path") | ||
.on("click", function (d) { context.click(d.data, null, null); }) | ||
.on("dblclick", function (d) { | ||
if (d3_selection_1.event) { | ||
d3_selection_1.event.stopPropagation(); | ||
SunburstPartition.prototype.data = function (_) { | ||
var retVal = common_1.SVGWidget.prototype.data.apply(this, arguments); | ||
if (arguments.length) { | ||
this._resetRoot = true; | ||
} | ||
context.zoomTo(d); | ||
}) | ||
.each(function () { | ||
var element = d3_selection_1.select(this); | ||
element | ||
.append("title"); | ||
}) | ||
.merge(paths) | ||
.attr("d", this.arc) | ||
.style("fill", function (d) { | ||
return d.data.__viz_fill ? d.data.__viz_fill : context._palette(d.data.label); | ||
}) | ||
.style("stroke", function (d) { | ||
return d.value > 16 ? "white" : "none"; | ||
}) | ||
.select("title") | ||
.text(function (d) { | ||
return d.data.label; | ||
}); | ||
paths.exit().remove(); | ||
if (this._resetRoot) { | ||
this._resetRoot = false; | ||
this.zoomTo(root); | ||
} | ||
}; | ||
SunburstPartition.prototype.zoomTo = function (d) { | ||
var context = this; | ||
this.svg.transition() | ||
.duration(750) | ||
.tween("scale", function () { | ||
var xd = d3_interpolate_1.interpolate(context._xScale.domain(), [d.x0, d.x1]); | ||
var yd = d3_interpolate_1.interpolate(context._yScale.domain(), [d.y0, 1]); | ||
var yr = d3_interpolate_1.interpolate(context._yScale.range(), [d.y0 ? 20 : 0, context.radius]); | ||
return function (t) { context._xScale.domain(xd(t)); context._yScale.domain(yd(t)).range(yr(t)); }; | ||
}) | ||
.selectAll("path") | ||
.attrTween("d", function (d2) { return function () { return context.arc(d2); }; }); | ||
}; | ||
return SunburstPartition; | ||
}(common_1.SVGWidget)); | ||
exports.SunburstPartition = SunburstPartition; | ||
SunburstPartition.prototype._class += " tree_SunburstPartition"; | ||
SunburstPartition.prototype.implements(api_1.ITree.prototype); | ||
SunburstPartition.prototype.publish("paletteID", "default", "set", "Palette ID", SunburstPartition.prototype._palette.switch(), { tags: ["Basic", "Shared"] }); | ||
SunburstPartition.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] }); | ||
return retVal; | ||
}; | ||
SunburstPartition.prototype.enter = function (_domNode, element) { | ||
var context = this; | ||
this.radius = Math.min(this.width(), this.height()) / 2; | ||
this._xScale = d3_scale_1.scaleLinear() | ||
.range([0, 2 * Math.PI]); | ||
this._yScale = d3_scale_1.scaleSqrt() | ||
.range([0, this.radius]); | ||
this.partition = d3_hierarchy_1.partition(); | ||
this.arc = d3_shape_1.arc() | ||
.startAngle(function (d) { | ||
return Math.max(0, Math.min(2 * Math.PI, context._xScale(d.x0))); | ||
}) | ||
.endAngle(function (d) { | ||
return Math.max(0, Math.min(2 * Math.PI, context._xScale(d.x1))); | ||
}) | ||
.innerRadius(function (d) { | ||
return Math.max(0, context._yScale(d.y0)); | ||
}) | ||
.outerRadius(function (d) { | ||
return Math.max(0, context._yScale(d.y1)); | ||
}); | ||
this.svg = element.append("g"); | ||
}; | ||
SunburstPartition.prototype.update = function (_domNode, _element) { | ||
var context = this; | ||
this._palette = this._palette.switch(this.paletteID()); | ||
if (this.useClonedPalette()) { | ||
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id()); | ||
} | ||
this.radius = Math.min(this.width(), this.height()) / 2; | ||
this._yScale.range([0, this.radius]); | ||
var root = d3_hierarchy_1.hierarchy(this.data()) | ||
.sum(function (d) { | ||
return d.size !== undefined ? d.size : 1; | ||
}); | ||
var paths = this.svg.selectAll("path").data(this.partition(root).descendants(), function (d, i) { | ||
return d.data.label !== undefined ? d.data.label : i; | ||
}); | ||
paths.enter().append("path") | ||
.on("click", function (d) { context.click(d.data, null, null); }) | ||
.on("dblclick", function (d) { | ||
if (d3_selection_1.event) { | ||
d3_selection_1.event.stopPropagation(); | ||
} | ||
context.zoomTo(d); | ||
}) | ||
.each(function () { | ||
var element = d3_selection_1.select(this); | ||
element | ||
.append("title"); | ||
}) | ||
.merge(paths) | ||
.attr("d", this.arc) | ||
.style("fill", function (d) { | ||
return d.data.__viz_fill ? d.data.__viz_fill : context._palette(d.data.label); | ||
}) | ||
.style("stroke", function (d) { | ||
return d.value > 16 ? "white" : "none"; | ||
}) | ||
.select("title") | ||
.text(function (d) { | ||
return d.data.label; | ||
}); | ||
paths.exit().remove(); | ||
if (this._resetRoot) { | ||
this._resetRoot = false; | ||
this.zoomTo(root); | ||
} | ||
}; | ||
SunburstPartition.prototype.zoomTo = function (d) { | ||
var context = this; | ||
this.svg.transition() | ||
.duration(750) | ||
.tween("scale", function () { | ||
var xd = d3_interpolate_1.interpolate(context._xScale.domain(), [d.x0, d.x1]); | ||
var yd = d3_interpolate_1.interpolate(context._yScale.domain(), [d.y0, 1]); | ||
var yr = d3_interpolate_1.interpolate(context._yScale.range(), [d.y0 ? 20 : 0, context.radius]); | ||
return function (t) { context._xScale.domain(xd(t)); context._yScale.domain(yd(t)).range(yr(t)); }; | ||
}) | ||
.selectAll("path") | ||
.attrTween("d", function (d2) { return function () { return context.arc(d2); }; }); | ||
}; | ||
return SunburstPartition; | ||
}(common_1.SVGWidget)); | ||
exports.SunburstPartition = SunburstPartition; | ||
SunburstPartition.prototype._class += " tree_SunburstPartition"; | ||
SunburstPartition.prototype.implements(api_1.ITree.prototype); | ||
SunburstPartition.prototype.publish("paletteID", "default", "set", "Palette ID", SunburstPartition.prototype._palette.switch(), { tags: ["Basic", "Shared"] }); | ||
SunburstPartition.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] }); | ||
}); | ||
//# sourceMappingURL=SunburstPartition.js.map |
@@ -1,159 +0,169 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var api_1 = require("@hpcc-js/api"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_hierarchy_1 = require("d3-hierarchy"); | ||
require("../src/Treemap.css"); | ||
var TreemapColumn = (function (_super) { | ||
tslib_1.__extends(TreemapColumn, _super); | ||
function TreemapColumn(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 TreemapColumn; | ||
}(common_1.PropertyExt)); | ||
exports.TreemapColumn = TreemapColumn; | ||
TreemapColumn.prototype._class += " tree_Dendrogram.TreemapColumn"; | ||
TreemapColumn.prototype.publish("column", null, "set", "Field", function () { return this._owner ? this._owner.columns() : []; }, { optional: true }); | ||
// === | ||
var Treemap = (function (_super) { | ||
tslib_1.__extends(Treemap, _super); | ||
function Treemap() { | ||
var _this = _super.call(this) || this; | ||
api_1.ITree.call(_this); | ||
common_1.Utility.SimpleSelectionMixin.call(_this); | ||
return _this; | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "tslib", "@hpcc-js/api", "@hpcc-js/common", "d3-hierarchy", "../src/Treemap.css"], factory); | ||
} | ||
Treemap.prototype.treemapData = function () { | ||
if (!this.mappings().filter(function (mapping) { return mapping.column(); }).length) { | ||
return this.data(); | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var api_1 = require("@hpcc-js/api"); | ||
var common_1 = require("@hpcc-js/common"); | ||
var d3_hierarchy_1 = require("d3-hierarchy"); | ||
require("../src/Treemap.css"); | ||
var TreemapColumn = (function (_super) { | ||
tslib_1.__extends(TreemapColumn, _super); | ||
function TreemapColumn(owner) { | ||
var _this = _super.call(this) || this; | ||
_this._owner = owner; | ||
return _this; | ||
} | ||
var view = this._db.aggregateView(this.mappings().map(function (mapping) { return mapping.column(); }), this.aggrType(), this.aggrColumn()); | ||
var retVal = { | ||
key: "root", | ||
values: view.entries() | ||
}; | ||
return formatData(retVal); | ||
function formatData(node) { | ||
if (node.values instanceof Array) { | ||
var children = node.values.filter(function (value) { | ||
return !(value instanceof Array); | ||
}).map(function (value) { | ||
return formatData(value); | ||
}); | ||
var retVal2 = { | ||
label: node.key | ||
}; | ||
if (children.length) { | ||
retVal2.children = children; | ||
} | ||
else { | ||
retVal2.size = 22; | ||
} | ||
return retVal2; | ||
return TreemapColumn; | ||
}(common_1.PropertyExt)); | ||
exports.TreemapColumn = TreemapColumn; | ||
TreemapColumn.prototype._class += " tree_Dendrogram.TreemapColumn"; | ||
TreemapColumn.prototype.publish("column", null, "set", "Field", function () { return this._owner ? this._owner.columns() : []; }, { optional: true }); | ||
// === | ||
var Treemap = (function (_super) { | ||
tslib_1.__extends(Treemap, _super); | ||
function Treemap() { | ||
var _this = _super.call(this) || this; | ||
api_1.ITree.call(_this); | ||
common_1.Utility.SimpleSelectionMixin.call(_this); | ||
return _this; | ||
} | ||
Treemap.prototype.treemapData = function () { | ||
if (!this.mappings().filter(function (mapping) { return mapping.column(); }).length) { | ||
return this.data(); | ||
} | ||
return { | ||
label: node.key, | ||
size: node.values.aggregate, | ||
origRows: node.values | ||
var view = this._db.aggregateView(this.mappings().map(function (mapping) { return mapping.column(); }), this.aggrType(), this.aggrColumn()); | ||
var retVal = { | ||
key: "root", | ||
values: view.entries() | ||
}; | ||
} | ||
}; | ||
Treemap.prototype.enter = function (_domNode, element) { | ||
common_1.HTMLWidget.prototype.enter.apply(this, arguments); | ||
this._d3Treemap = d3_hierarchy_1.treemap(); | ||
this._elementDIV = element.append("div"); | ||
this._selection.widgetElement(this._elementDIV); | ||
}; | ||
Treemap.prototype.update = function (_domNode, _element) { | ||
common_1.HTMLWidget.prototype.update.apply(this, arguments); | ||
this._palette = this._palette.switch(this.paletteID()); | ||
if (this.useClonedPalette()) { | ||
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id()); | ||
} | ||
var root = d3_hierarchy_1.hierarchy(this.treemapData()) | ||
.sum(function (d) { | ||
return d.size || 50; | ||
}); | ||
this._d3Treemap | ||
.size([this.width(), this.height()]); | ||
this._d3Treemap(root); | ||
this._elementDIV | ||
.style("font-size", this.fontSize_exists() ? this.fontSize() + "px" : null) | ||
.style("line-height", this.fontSize_exists() ? (this.fontSize() + 2) + "px" : null); | ||
var context = this; | ||
var node = this._elementDIV.selectAll(".node").data(root.descendants()); | ||
node.enter().append("div") | ||
.attr("class", "node") | ||
.call(this._selection.enter.bind(this._selection)) | ||
.on("click", function (d) { | ||
if (d && d.origRows) { | ||
var columnLabel_1 = ""; | ||
context.mappings().forEach(function (mapping) { | ||
if (mapping.column()) { | ||
columnLabel_1 = mapping.column(); | ||
return formatData(retVal); | ||
function formatData(node) { | ||
if (node.values instanceof Array) { | ||
var children = node.values.filter(function (value) { | ||
return !(value instanceof Array); | ||
}).map(function (value) { | ||
return formatData(value); | ||
}); | ||
var retVal2 = { | ||
label: node.key | ||
}; | ||
if (children.length) { | ||
retVal2.children = children; | ||
} | ||
}); | ||
context.click(context.rowToObj(d.origRows[0]), columnLabel_1, context._selection.selected(this)); | ||
} | ||
}) | ||
.on("dblclick", function (d) { | ||
if (d && d.origRows) { | ||
var columnLabel_2 = ""; | ||
context.mappings().forEach(function (mapping) { | ||
if (mapping.column()) { | ||
columnLabel_2 = mapping.column(); | ||
else { | ||
retVal2.size = 22; | ||
} | ||
}); | ||
context.dblclick(context.rowToObj(d.origRows[0]), columnLabel_2, context._selection.selected(this)); | ||
return retVal2; | ||
} | ||
return { | ||
label: node.key, | ||
size: node.values.aggregate, | ||
origRows: node.values | ||
}; | ||
} | ||
}) | ||
.style("left", function (d) { return (d.x0 + Math.max(0, d.x1 - d.x0) / 2) + "px"; }) | ||
.style("top", function (d) { return (d.y0 + Math.max(0, d.y1 - d.y0) / 2) + "px"; }) | ||
.style("width", function () { return 0 + "px"; }) | ||
.style("height", function () { return 0 + "px"; }) | ||
.merge(node) | ||
.attr("title", tooltip) | ||
.text(function (d) { return d.children ? null : d.data.label; }) | ||
.style("background", function (d) { return d.children ? context._palette(d.data.label) : null; }) | ||
.transition().duration(this.transitionDuration()) | ||
.style("opacity", function (d) { return d.children ? 1 : null; }) | ||
.style("left", function (d) { return d.x0 + "px"; }) | ||
.style("top", function (d) { return d.y0 + "px"; }) | ||
.style("width", function (d) { return Math.max(0, d.x1 - d.x0) + "px"; }) | ||
.style("height", function (d) { return Math.max(0, d.y1 - d.y0) + "px"; }); | ||
node.exit().transition().duration(this.transitionDuration()) | ||
.style("opacity", 0) | ||
.remove(); | ||
function tooltip(d) { | ||
if (d.children) { | ||
return null; | ||
}; | ||
Treemap.prototype.enter = function (_domNode, element) { | ||
common_1.HTMLWidget.prototype.enter.apply(this, arguments); | ||
this._d3Treemap = d3_hierarchy_1.treemap(); | ||
this._elementDIV = element.append("div"); | ||
this._selection.widgetElement(this._elementDIV); | ||
}; | ||
Treemap.prototype.update = function (_domNode, _element) { | ||
common_1.HTMLWidget.prototype.update.apply(this, arguments); | ||
this._palette = this._palette.switch(this.paletteID()); | ||
if (this.useClonedPalette()) { | ||
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id()); | ||
} | ||
var retVal = d.data.label + " (" + d.value + ")"; | ||
while (d.parent && d.parent.parent) { | ||
retVal = d.parent.data.label + " -> " + retVal; | ||
d = d.parent; | ||
var root = d3_hierarchy_1.hierarchy(this.treemapData()) | ||
.sum(function (d) { | ||
return d.size || 50; | ||
}); | ||
this._d3Treemap | ||
.size([this.width(), this.height()]); | ||
this._d3Treemap(root); | ||
this._elementDIV | ||
.style("font-size", this.fontSize_exists() ? this.fontSize() + "px" : null) | ||
.style("line-height", this.fontSize_exists() ? (this.fontSize() + 2) + "px" : null); | ||
var context = this; | ||
var node = this._elementDIV.selectAll(".node").data(root.descendants()); | ||
node.enter().append("div") | ||
.attr("class", "node") | ||
.call(this._selection.enter.bind(this._selection)) | ||
.on("click", function (d) { | ||
if (d && d.origRows) { | ||
var columnLabel_1 = ""; | ||
context.mappings().forEach(function (mapping) { | ||
if (mapping.column()) { | ||
columnLabel_1 = mapping.column(); | ||
} | ||
}); | ||
context.click(context.rowToObj(d.origRows[0]), columnLabel_1, context._selection.selected(this)); | ||
} | ||
}) | ||
.on("dblclick", function (d) { | ||
if (d && d.origRows) { | ||
var columnLabel_2 = ""; | ||
context.mappings().forEach(function (mapping) { | ||
if (mapping.column()) { | ||
columnLabel_2 = mapping.column(); | ||
} | ||
}); | ||
context.dblclick(context.rowToObj(d.origRows[0]), columnLabel_2, context._selection.selected(this)); | ||
} | ||
}) | ||
.style("left", function (d) { return (d.x0 + Math.max(0, d.x1 - d.x0) / 2) + "px"; }) | ||
.style("top", function (d) { return (d.y0 + Math.max(0, d.y1 - d.y0) / 2) + "px"; }) | ||
.style("width", function () { return 0 + "px"; }) | ||
.style("height", function () { return 0 + "px"; }) | ||
.merge(node) | ||
.attr("title", tooltip) | ||
.text(function (d) { return d.children ? null : d.data.label; }) | ||
.style("background", function (d) { return d.children ? context._palette(d.data.label) : null; }) | ||
.transition().duration(this.transitionDuration()) | ||
.style("opacity", function (d) { return d.children ? 1 : null; }) | ||
.style("left", function (d) { return d.x0 + "px"; }) | ||
.style("top", function (d) { return d.y0 + "px"; }) | ||
.style("width", function (d) { return Math.max(0, d.x1 - d.x0) + "px"; }) | ||
.style("height", function (d) { return Math.max(0, d.y1 - d.y0) + "px"; }); | ||
node.exit().transition().duration(this.transitionDuration()) | ||
.style("opacity", 0) | ||
.remove(); | ||
function tooltip(d) { | ||
if (d.children) { | ||
return null; | ||
} | ||
var retVal = d.data.label + " (" + d.value + ")"; | ||
while (d.parent && d.parent.parent) { | ||
retVal = d.parent.data.label + " -> " + retVal; | ||
d = d.parent; | ||
} | ||
return retVal; | ||
} | ||
return retVal; | ||
} | ||
}; | ||
Treemap.prototype.exit = function (domNode, element) { | ||
_super.prototype.exit.call(this, domNode, element); | ||
}; | ||
return Treemap; | ||
}(common_1.HTMLWidget)); | ||
exports.Treemap = Treemap; | ||
Treemap.prototype._class += " tree_Treemap"; | ||
Treemap.prototype.implements(api_1.ITree.prototype); | ||
Treemap.prototype.mixin(common_1.Utility.SimpleSelectionMixin); | ||
Treemap.prototype.Column = TreemapColumn; | ||
Treemap.prototype.publish("paletteID", "default", "set", "Palette ID", Treemap.prototype._palette.switch(), { tags: ["Basic", "Shared"] }); | ||
Treemap.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] }); | ||
Treemap.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: TreemapColumn }); | ||
Treemap.prototype.publish("aggrType", null, "set", "Aggregation Type", [null, "mean", "median", "sum", "min", "max"], { optional: true }); | ||
Treemap.prototype.publish("aggrColumn", null, "set", "Aggregation Field", function () { return this.columns(); }, { optional: true, disable: function (w) { return !w.aggrType(); } }); | ||
Treemap.prototype.publish("fontSize", null, "number", "Font Size", null, { optional: true }); | ||
Treemap.prototype.publish("transitionDuration", 250, "number", "Transition Duration"); | ||
}; | ||
Treemap.prototype.exit = function (domNode, element) { | ||
_super.prototype.exit.call(this, domNode, element); | ||
}; | ||
return Treemap; | ||
}(common_1.HTMLWidget)); | ||
exports.Treemap = Treemap; | ||
Treemap.prototype._class += " tree_Treemap"; | ||
Treemap.prototype.implements(api_1.ITree.prototype); | ||
Treemap.prototype.mixin(common_1.Utility.SimpleSelectionMixin); | ||
Treemap.prototype.Column = TreemapColumn; | ||
Treemap.prototype.publish("paletteID", "default", "set", "Palette ID", Treemap.prototype._palette.switch(), { tags: ["Basic", "Shared"] }); | ||
Treemap.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] }); | ||
Treemap.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: TreemapColumn }); | ||
Treemap.prototype.publish("aggrType", null, "set", "Aggregation Type", [null, "mean", "median", "sum", "min", "max"], { optional: true }); | ||
Treemap.prototype.publish("aggrColumn", null, "set", "Aggregation Field", function () { return this.columns(); }, { optional: true, disable: function (w) { return !w.aggrType(); } }); | ||
Treemap.prototype.publish("fontSize", null, "number", "Font Size", null, { optional: true }); | ||
Treemap.prototype.publish("transitionDuration", 250, "number", "Transition Duration"); | ||
}); | ||
//# sourceMappingURL=Treemap.js.map |
{ | ||
"name": "@hpcc-js/tree", | ||
"version": "0.0.1", | ||
"version": "0.0.5", | ||
"description": "hpcc-js - Viz Tree", | ||
@@ -20,4 +20,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@hpcc-js/api": "^0.0.1", | ||
"@hpcc-js/common": "^0.0.1", | ||
"@hpcc-js/api": "^0.0.5", | ||
"@hpcc-js/common": "^0.0.5", | ||
"d3-hierarchy": "^1.1.4", | ||
@@ -46,2 +46,2 @@ "d3-interpolate": "^1.1.5", | ||
"homepage": "https://github.com/hpcc-systems/Visualization" | ||
} | ||
} |
49702
13.91%1089
5.83%+ Added
+ Added
- Removed
- Removed
Updated
Updated