Skip to content

Commit

Permalink
fix: Ensure all widgets can be re-targeted
Browse files Browse the repository at this point in the history
Added retarget to core unit test.

Signed-off-by: Gordon Smith <gordonjsmith@gmail.com>
  • Loading branch information
GordonSmith committed Feb 19, 2019
1 parent 68e8e76 commit d1f02c2
Show file tree
Hide file tree
Showing 133 changed files with 897 additions and 1,785 deletions.
34 changes: 17 additions & 17 deletions demos/gallery/src-umd/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1652,26 +1652,26 @@ var config = {
"systemjs-babel-build": "https://unpkg.com/systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js",
"d3-array": "https://unpkg.com/d3-array@1.2.1/build/d3-array.js",
"d3-random": "https://unpkg.com/d3-random@1.1.0/build/d3-random.js",
"@hpcc-js/chart": "https://unpkg.com/@hpcc-js/chart@^2.7.0/dist/index.min.js",
"@hpcc-js/codemirror": "https://unpkg.com/@hpcc-js/codemirror@^2.1.5/dist/index.min.js",
"@hpcc-js/common": "https://unpkg.com/@hpcc-js/common@^2.10.0/dist/index.min.js",
"@hpcc-js/comms": "https://unpkg.com/@hpcc-js/comms@^2.0.10/dist/index.min.js",
"@hpcc-js/composite": "https://unpkg.com/@hpcc-js/composite@^2.0.15/dist/index.min.js",
"@hpcc-js/chart": "https://unpkg.com/@hpcc-js/chart@^2.8.0/dist/index.min.js",
"@hpcc-js/codemirror": "https://unpkg.com/@hpcc-js/codemirror@^2.2.0/dist/index.min.js",
"@hpcc-js/common": "https://unpkg.com/@hpcc-js/common@^2.11.0/dist/index.min.js",
"@hpcc-js/comms": "https://unpkg.com/@hpcc-js/comms@^2.1.0/dist/index.min.js",
"@hpcc-js/composite": "https://unpkg.com/@hpcc-js/composite@^2.0.16/dist/index.min.js",
"@hpcc-js/ddl-shim": "https://unpkg.com/@hpcc-js/ddl-shim@^2.1.5/dist/index.min.js",
"@hpcc-js/dgrid": "https://unpkg.com/@hpcc-js/dgrid@^2.0.13/dist/index.min.js",
"@hpcc-js/form": "https://unpkg.com/@hpcc-js/form@^2.2.8/dist/index.min.js",
"@hpcc-js/graph": "https://unpkg.com/@hpcc-js/graph@^2.5.5/dist/index.min.js",
"@hpcc-js/layout": "https://unpkg.com/@hpcc-js/layout@^2.6.2/dist/index.min.js",
"@hpcc-js/map": "https://unpkg.com/@hpcc-js/map@^2.1.0/dist/index.min.js",
"@hpcc-js/other": "https://unpkg.com/@hpcc-js/other@^2.7.0/dist/index.min.js",
"@hpcc-js/phosphor": "https://unpkg.com/@hpcc-js/phosphor@^2.4.2/dist/index.min.js",
"@hpcc-js/util": "https://unpkg.com/@hpcc-js/util@^2.2.0/dist/index.min.js",
"@hpcc-js/api": "https://unpkg.com/@hpcc-js/api@^2.2.7/dist/index.min.js",
"@hpcc-js/dgrid": "https://unpkg.com/@hpcc-js/dgrid@^2.0.14/dist/index.min.js",
"@hpcc-js/form": "https://unpkg.com/@hpcc-js/form@^2.3.0/dist/index.min.js",
"@hpcc-js/graph": "https://unpkg.com/@hpcc-js/graph@^2.5.6/dist/index.min.js",
"@hpcc-js/layout": "https://unpkg.com/@hpcc-js/layout@^2.6.3/dist/index.min.js",
"@hpcc-js/map": "https://unpkg.com/@hpcc-js/map@^2.2.0/dist/index.min.js",
"@hpcc-js/other": "https://unpkg.com/@hpcc-js/other@^2.8.0/dist/index.min.js",
"@hpcc-js/phosphor": "https://unpkg.com/@hpcc-js/phosphor@^2.4.3/dist/index.min.js",
"@hpcc-js/util": "https://unpkg.com/@hpcc-js/util@^2.2.1/dist/index.min.js",
"@hpcc-js/api": "https://unpkg.com/@hpcc-js/api@^2.3.0/dist/index.min.js",
"@hpcc-js/dgrid-shim": "https://unpkg.com/@hpcc-js/dgrid-shim@^2.0.8/dist/index.min.js",
"@hpcc-js/codemirror-shim": "https://unpkg.com/@hpcc-js/codemirror-shim@^2.0.5/dist/index.min.js",
"@hpcc-js/codemirror-shim": "https://unpkg.com/@hpcc-js/codemirror-shim@^2.1.0/dist/index.min.js",
"@hpcc-js/phosphor-shim": "https://unpkg.com/@hpcc-js/phosphor-shim@^2.0.5/dist/index.min.js",
"@hpcc-js/timeline": "https://unpkg.com/@hpcc-js/timeline@^2.0.14/dist/index.min.js",
"@hpcc-js/tree": "https://unpkg.com/@hpcc-js/tree@^2.2.6/dist/index.min.js"
"@hpcc-js/timeline": "https://unpkg.com/@hpcc-js/timeline@^2.1.0/dist/index.min.js",
"@hpcc-js/tree": "https://unpkg.com/@hpcc-js/tree@^2.2.7/dist/index.min.js"
},
"meta": {
"*.css": {
Expand Down
9 changes: 6 additions & 3 deletions packages/api/src/Tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export function tip() {
svg = getSVGNode(vis);
if (!svg) return;
point = svg.createSVGPoint();
rootElement().appendChild(node);
const re = rootElement();
if (!re) return;
if (!node) return;
re.appendChild(node);
};

// Public - show the tooltip on the screen
Expand Down Expand Up @@ -197,7 +200,7 @@ export function tip() {
// Returns root node of tip
tip.rootElement = function (v) {
if (!arguments.length) return rootElement;
rootElement = v == null ? v : functor(v);
rootElement = functor(v);

return tip;
};
Expand Down Expand Up @@ -316,7 +319,7 @@ export function tip() {
if (node == null) {
node = initNode();
// re-add node to DOM
rootElement.appendChild(node);
rootElement().appendChild(node);
}
return select(node);
}
Expand Down
14 changes: 7 additions & 7 deletions packages/chart/src/Axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ export class Axis extends SVGWidget {
return this;
}

enter(_domNode, element) {
SVGWidget.prototype.enter.apply(this, arguments);
enter(domNode, element) {
super.enter(domNode, element);
this.svg = element.append("g");
this.svgAxis = this.svg.append("g")
.attr("class", "axis")
Expand Down Expand Up @@ -533,12 +533,12 @@ export class Axis extends SVGWidget {
this.wrap(text, bandSize, "\n");
}

update(_domNode, _element) {
SVGWidget.prototype.update.apply(this, arguments);
update(domNode, element) {
super.update(domNode, element);

this.svg.style("display", this.hidden() ? "none" : null);

const overlap = this.calcOverflow(_element);
const overlap = this.calcOverflow(element);

const lowerPos: number = this.isHorizontal() ? overlap.left : this.height() - overlap.top - overlap.bottom;
const upperPos: number = this.isHorizontal() ? this.width() - overlap.right : 0;
Expand Down Expand Up @@ -646,8 +646,8 @@ export class Axis extends SVGWidget {
this.svgGuides.call(this.d3Guides);
}

postUpdate(_domNode, _element) {
SVGWidget.prototype.postUpdate.apply(this, arguments);
postUpdate(domNode, element) {
super.postUpdate(domNode, element);
if (this._guideElement) {
this._guideElement
.attr("transform", this._element.attr("transform"))
Expand Down
10 changes: 5 additions & 5 deletions packages/chart/src/Bubble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Bubble extends SVGWidget {
size(): ISize;
size(_): this;
size(_?): ISize | this {
const retVal = SVGWidget.prototype.size.apply(this, arguments);
const retVal = super.size.apply(this, arguments);
if (arguments.length) {
this.d3Pack
.size([this.width(), this.height()])
Expand All @@ -46,8 +46,8 @@ export class Bubble extends SVGWidget {
return retVal;
}

enter(_domNode, element) {
SVGWidget.prototype.enter.apply(this, arguments);
enter(domNode, element) {
super.enter(domNode, element);
this._selection.widgetElement(element);
const context = this;
this
Expand Down Expand Up @@ -146,8 +146,8 @@ export class Bubble extends SVGWidget {
;
}

exit(_domNode, _element) {
SVGWidget.prototype.exit.apply(this, arguments);
exit(domNode, element) {
super.exit(domNode, element);
}

paletteID: { (): string; (_: string): Bubble; };
Expand Down
8 changes: 4 additions & 4 deletions packages/chart/src/Bullet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export class Bullet extends HTMLWidget {
}

enter(domNode, element) {
HTMLWidget.prototype.enter.apply(this, arguments);
super.enter(domNode, element);
d3Select(domNode.parentNode).style("overflow", "auto");
this._selection.widgetElement(element);
}

update(_domNode, element) {
HTMLWidget.prototype.update.apply(this, arguments);
super.update(_domNode, element);
const context = this;

const margin = { left: 2, top: 8, right: 2, bottom: 8 };
Expand Down Expand Up @@ -129,8 +129,8 @@ export class Bullet extends HTMLWidget {
svg.exit().remove();
}

exit(_domNode, _element) {
HTMLWidget.prototype.exit.apply(this, arguments);
exit(domNode, element) {
super.exit(domNode, element);
}

// Events ---
Expand Down
6 changes: 3 additions & 3 deletions packages/chart/src/HexBin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { I2DAggrChart, ITooltip } from "@hpcc-js/api";
import { InputField, SVGWidget } from "@hpcc-js/common";
import { InputField } from "@hpcc-js/common";
import { extent as d3Extent, max as d3Max, min as d3Min } from "d3-array";
import { hexbin as d3HexBin } from "d3-hexbin";
import { XYAxis } from "./XYAxis";
Expand Down Expand Up @@ -106,8 +106,8 @@ export class HexBin extends XYAxis {
;
}

exit(_domNode, _element) {
SVGWidget.prototype.exit.apply(this, arguments);
exit(domNode, element) {
super.exit(domNode, element);
}

// Events ---
Expand Down
6 changes: 3 additions & 3 deletions packages/chart/src/Pie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ export class Pie extends SVGWidget {
});
}

exit(_domNode, _element) {
SVGWidget.prototype.exit.apply(this, arguments);
exit(domNode, element) {
super.exit(domNode, element);
}

updateD3Pie() {
Expand Down Expand Up @@ -410,7 +410,7 @@ export interface Pie {
seriesPercentageFormat(_: string): this;
}
Pie.prototype.publish("showSeriesPercentage", false, "boolean", "Append data series percentage next to label");
Pie.prototype.publish("seriesPercentageFormat", ",.0f", "string", "Number format used for formatting series percentages", null, {disable: w => !w.showSeriesPercentage()});
Pie.prototype.publish("seriesPercentageFormat", ",.0f", "string", "Number format used for formatting series percentages", null, { disable: w => !w.showSeriesPercentage() });
Pie.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Pie.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
Pie.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
Pie.prototype.publish("innerRadius", 0, "number", "Sets inner pie hole radius as a percentage of the radius of the pie chart", null, { tags: ["Basic"], range: { min: 0, step: 1, max: 100 } });
Expand Down
6 changes: 3 additions & 3 deletions packages/chart/src/Scatter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { INDChart, ITooltip } from "@hpcc-js/api";
import { d3SelectionType, InputField, SVGWidget } from "@hpcc-js/common";
import { d3SelectionType, InputField } from "@hpcc-js/common";
import { extent as d3Extent } from "d3-array";
import { scaleLinear as d3ScaleLinear, scaleLog as d3ScaleLog, scalePow as d3ScalePow, scaleSqrt as d3ScaleSqrt } from "d3-scale";
import { select as d3Select } from "d3-selection";
Expand Down Expand Up @@ -301,8 +301,8 @@ export class Scatter extends XYAxis {
lines.exit().remove();
}

exit(_domNode, _element) {
SVGWidget.prototype.exit.apply(this, arguments);
exit(domNode, element) {
super.exit(domNode, element);
}

paletteID: { (): string; (_: string): Scatter; };
Expand Down
12 changes: 6 additions & 6 deletions packages/chart/src/Summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export class Summary extends HTMLWidget {
}, this);
}

enter(_domNode, element) {
HTMLWidget.prototype.enter.apply(this, arguments);
enter(domNode, element) {
super.enter(domNode, element);
this._mainDiv = element.append("div")
;
const context = this;
Expand All @@ -100,8 +100,8 @@ export class Summary extends HTMLWidget {
;
}

update(_domNode, element) {
HTMLWidget.prototype.update.apply(this, arguments);
update(domNode, element) {
super.update(domNode, element);
if (this.data().length) {

}
Expand Down Expand Up @@ -164,8 +164,8 @@ export class Summary extends HTMLWidget {
moreDivs.exit().remove();
}

exit(_domNode, _element) {
HTMLWidget.prototype.exit.apply(this, arguments);
exit(domNode, element) {
super.exit(domNode, element);
}
}
Summary.prototype._class += " chart_Summary";
Expand Down
10 changes: 6 additions & 4 deletions packages/chart/src/XYAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ export class XYAxis extends SVGWidget {
protected svgDataClipRect;
protected svgFocus;
protected svgBrush;
enter(_domNode, element) {
SVGWidget.prototype.enter.apply(this, arguments);
enter(domNode, element) {
super.enter(domNode, element);
this.svg = element.append("g");
this.svgRegions = element.append("g");
this.svgDomainGuide = this.svg.append("g");
Expand Down Expand Up @@ -604,8 +604,10 @@ export class XYAxis extends SVGWidget {
}
}

exit(_domNode, _element) {
SVGWidget.prototype.exit.apply(this, arguments);
exit(domNode, element) {
this.valueAxis.target(null);
this.domainAxis.target(null);
super.exit(domNode, element);
}

selection(_selected) {
Expand Down
15 changes: 11 additions & 4 deletions packages/common/src/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class Entity extends SVGWidget {
}
return retVal || { x: 0, y: 0, width: 0, height: 0 };
}
enter(dn, element) {
super.enter.apply(this, arguments);
enter(domNode, element) {
super.enter(domNode, element);
element
.on("mouseover", () => {
element.classed("hovering", true);
Expand Down Expand Up @@ -82,8 +82,8 @@ export class Entity extends SVGWidget {
this._desc_widget
.target(this._element_desc.node());
}
update(dn, element) {
super.update.apply(this, arguments);
update(domNode, element) {
super.update(domNode, element);
this._desc_widget
.fontSize(this.descriptionFontSize());
const context = this;
Expand Down Expand Up @@ -128,6 +128,13 @@ export class Entity extends SVGWidget {
})
.remove();
}
exit(domNode, element) {
this._desc_widget.target(null);
this._title_widget.target(null);
this._icon_widget.target(null);
this._background_widget.target(null);
super.exit(domNode, element);
}
moveAnnotations(x_offset: number, y_offset: number) {
this._element_anno.attr("transform", `translate(${x_offset}, ${y_offset})`);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/EntityRect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class EntityRectList extends HTMLWidget {
}

enter(domNode, element) {
HTMLWidget.prototype.enter.apply(this, arguments);
super.enter(domNode, element);
d3Select(domNode.parentNode)
.style("overflow-x", "hidden")
.style("overflow-y", "scroll")
Expand All @@ -167,7 +167,7 @@ export class EntityRectList extends HTMLWidget {
}

update(domNode, element) {
HTMLWidget.prototype.update.apply(this, arguments);
super.update(domNode, element);
const context = this;

const margin = { left: 8, top: 8, right: 8, bottom: 8 };
Expand Down Expand Up @@ -217,8 +217,8 @@ export class EntityRectList extends HTMLWidget {
svg.exit().remove();
}

exit(_domNode, _element) {
HTMLWidget.prototype.exit.apply(this, arguments);
exit(domNode, element) {
super.exit(domNode, element);
}

// Events ---
Expand Down
4 changes: 4 additions & 0 deletions packages/common/src/EntityVertex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export class EntityVertex extends Entity {
});
this.moveAnnotations(text_bbox.width / 2, text_bbox.height / 2);
}
exit(domNode, element) {
this._textbox_widget.target(null);
super.exit(domNode, element);
}
}
EntityVertex.prototype._class += " common_EntityVertex";

Expand Down
1 change: 1 addition & 0 deletions packages/common/src/SVGZoomWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export class SVGZoomWidget extends SVGWidget {
}

exit(domNode, element) {
this._iconBar.target(null);
super.exit(domNode, element);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/Surface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Surface extends SVGWidget {
}

enter(_domNode, _element) {
SVGWidget.prototype.enter.apply(this, arguments);
super.enter(_domNode, _element);
const element = _element.append("g").attr("class", "frame");
const domNode = element.node();
this._clipRect = element.append("defs").append("clipPath")
Expand Down Expand Up @@ -248,7 +248,7 @@ export class Surface extends SVGWidget {
}
}

exit(_domNode, _element) {
exit(domNode, element) {
this._titleRectWidget
.target(null)
;
Expand All @@ -267,7 +267,7 @@ export class Surface extends SVGWidget {
if (this.content()) {
this.content().target(null);
}
SVGWidget.prototype.exit.apply(this, arguments);
super.exit(domNode, element);
}

intersection(pointA, pointB) {
Expand Down
Loading

0 comments on commit d1f02c2

Please sign in to comment.