function ScatterplotDialog() {
this._createDialog();
this._plot_method = "lin";
this._plot_size = 20;
this._dot_size = 0.1;
}
ScatterplotDialog.prototype._createDialog = function() {
var self = this;
var frame = DialogSystem.createDialog();
frame.width("1100px");
var header = $('
').addClass("dialog-header").text('Scatterplot Matrix').appendTo(frame);
var body = $('
').addClass("dialog-body").appendTo(frame);
var footer = $(
''
).appendTo(frame);
var html = $(
''
).appendTo(body);
this._elmts = DOM.bind(html);
this._elmts.plotSelector.change(function() {
var selection = $(this).find("option:selected").text();
if (selection == 'linear') {
self._plot_method = "lin";
} else if (selection === 'log-log') {
self._plot_method = "log";
}
self._renderMatrix();
});
this._elmts.plotSize.change(function() {
try {
self._plot_size = parseInt($(this).val())
self._renderMatrix();
} catch (e) {
alert("Must be a number");
}
});
this._elmts.dotSize.change(function() {
try {
self._dot_size = parseFloat($(this).val())
self._renderMatrix();
} catch (e) {
alert("Must be a number");
}
});
var left_footer = footer.find(".left");
var right_footer = footer.find(".right");
$(' ').text("Close").click(function() { self._dismiss(); }).appendTo(right_footer);
this._level = DialogSystem.showDialog(frame);
this._renderMatrix();
};
ScatterplotDialog.prototype._renderMatrix = function() {
var self = this;
var columns = theProject.columnModel.columns;
var container = this._elmts.tableContainer.html(
'Processing...
'
);
if (columns.length > 0) {
var table = $('').addClass("scatterplot-matrix-table")[0];
var wrap = function(element,cx,cy) {
return element.click(function() {
var options = {
"name" : name,
"x_columnName" : cx,
"y_columnName" : cy,
"x_expression" : "value",
"y_expression" : "value",
};
ui.browsingEngine.addFacet("scatterplot",options);
//self._dismiss();
});
};
for (var i = 0; i < columns.length; i++) {
var tr = table.insertRow(table.rows.length);
for (var j = 0; j < i; j++) {
var cx = columns[i].name;
var cy = columns[j].name;
var plotter_params = {
'cx' : cx,
'cy' : cy,
'w' : self._plot_size,
'h' : self._plot_size,
'dot': self._dot_size,
'dim': self._plot_method
};
var params = {
project: theProject.id,
engine: JSON.stringify(ui.browsingEngine.getJSON()),
plotter: JSON.stringify(plotter_params)
}
var url = "/command/get-scatterplot?" + $.param(params);
var name = cx + ' (x) vs. ' + cy + ' (y)';
var cell = $(tr.insertCell(j));
var link = wrap($(' ').attr("title",name),cx,cy);
var plot = $(' ').addClass("scatterplot").appendTo(link);
link.appendTo(cell);
}
$(tr.insertCell(i)).text(columns[i]);
for (var j = i + 1; j < columns.length; j++) {
$(tr.insertCell(j)).text(" ");
}
}
container.empty().append(table);
} else {
container.html(
'There are no columns in this dataset
'
);
}
};
ScatterplotDialog.prototype._dismiss = function() {
DialogSystem.dismissUntil(this._level - 1);
};