Skip to content

Commit 118ea6c

Browse files
committed
compiled files and submodule (wrong commit still)
1 parent fd3a24f commit 118ea6c

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

mpld3/js/mpld3.v0.5.13-dev.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -597,16 +597,12 @@ mpld3_Axis.prototype.filter_ticks = function(domain) {
597597

598598
mpld3.Coordinates = mpld3_Coordinates;
599599

600-
function mpld3_Coordinates(trans, ax) {
600+
function mpld3_Coordinates(trans, ax, fig) {
601601
this.trans = trans;
602-
if (typeof ax === "undefined") {
603-
this.ax = null;
604-
this.fig = null;
605-
if (this.trans !== "display") throw "ax must be defined if transform != 'display'";
606-
} else {
607-
this.ax = ax;
608-
this.fig = ax.fig;
609-
}
602+
this.ax = typeof ax === "undefined" ? null : ax;
603+
this.fig = typeof fig === "undefined" ? this.ax ? this.ax.fig : null : fig;
604+
if (this.ax === null && this.fig === null && this.trans !== "display") throw "ax or fig must be defined if transform != 'display'";
605+
if (this.ax === null && this.trans !== "display" && this.trans !== "figure") throw "ax must be defined if transform != 'display' and transform != 'figure'";
610606
this.zoomable = this.trans === "data";
611607
this.x = this["x_" + this.trans];
612608
this.y = this["y_" + this.trans];
@@ -644,11 +640,11 @@ mpld3_Coordinates.prototype.y_axes = function(y) {
644640
};
645641

646642
mpld3_Coordinates.prototype.x_figure = function(x) {
647-
return x * this.fig.width - this.ax.position[0];
643+
return this.ax ? x * this.fig.width - this.ax.position[0] : x * this.fig.width;
648644
};
649645

650646
mpld3_Coordinates.prototype.y_figure = function(y) {
651-
return (1 - y) * this.fig.height - this.ax.position[1];
647+
return this.ax ? (1 - y) * this.fig.height - this.ax.position[1] : (1 - y) * this.fig.height;
652648
};
653649

654650
mpld3.Path = mpld3_Path;
@@ -980,18 +976,23 @@ function mpld3_Text(ax, props) {
980976
mpld3_PlotElement.call(this, ax, props);
981977
this.text = this.props.text;
982978
this.position = this.props.position;
983-
this.coords = new mpld3_Coordinates(this.props.coordinates, this.ax);
979+
this.coords = new mpld3_Coordinates(this.props.coordinates, this.ax, this.fig);
984980
}
985981

986982
mpld3_Text.prototype.draw = function() {
987-
if (this.props.coordinates == "data") {
988-
if (this.coords.zoomable) {
989-
this.obj = this.ax.paths.append("text");
983+
if (this.ax) {
984+
if (this.props.coordinates == "data") {
985+
if (this.coords.zoomable) {
986+
this.obj = this.ax.paths.append("text");
987+
} else {
988+
this.obj = this.ax.staticPaths.append("text");
989+
}
990990
} else {
991-
this.obj = this.ax.staticPaths.append("text");
991+
this.obj = this.ax.baseaxes.append("text");
992992
}
993993
} else {
994-
this.obj = this.ax.baseaxes.append("text");
994+
var target = this.fig.figureTextGroup || this.fig.canvas;
995+
this.obj = target.append("text");
995996
}
996997
this.obj.attr("class", "mpld3-text").text(this.text).style("text-anchor", this.props.h_anchor).style("dominant-baseline", this.props.v_baseline).style("font-size", this.props.fontsize).style("fill", this.props.color).style("opacity", this.props.alpha);
997998
this.applyTransform();
@@ -1849,6 +1850,7 @@ mpld3_Figure.prototype.requiredProps = [ "width", "height" ];
18491850
mpld3_Figure.prototype.defaultProps = {
18501851
data: {},
18511852
axes: [],
1853+
texts: [],
18521854
plugins: [ {
18531855
type: "reset"
18541856
}, {
@@ -1868,6 +1870,8 @@ function mpld3_Figure(figid, props) {
18681870
this.root = d3.select("#" + figid).append("div").style("position", "relative");
18691871
this.axes = [];
18701872
for (var i = 0; i < this.props.axes.length; i++) this.axes.push(new mpld3_Axes(this, this.props.axes[i]));
1873+
this.figuretexts = [];
1874+
for (var j = 0; j < this.props.texts.length; j++) this.figuretexts.push(new mpld3.Text(this, this.props.texts[j]));
18711875
this.plugins = [];
18721876
this.pluginsByType = {};
18731877
this.props.plugins.forEach(function(plugin) {
@@ -1906,6 +1910,10 @@ mpld3_Figure.prototype.draw = function() {
19061910
for (var i = 0; i < this.axes.length; i++) {
19071911
this.axes[i].draw();
19081912
}
1913+
this.figureTextGroup = this.canvas.append("g").attr("class", "mpld3-figure-texts");
1914+
for (var k = 0; k < this.figuretexts.length; k++) {
1915+
this.figuretexts[k].draw();
1916+
}
19091917
this.disableZoom();
19101918
for (var i = 0; i < this.plugins.length; i++) {
19111919
this.plugins[i].draw();

0 commit comments

Comments
 (0)