Hooked scatterplots up to generate the right facets.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@458 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-04-13 04:48:20 +00:00
parent e232a90a73
commit 666bcdbf8d
2 changed files with 57 additions and 46 deletions

View File

@ -1,8 +1,8 @@
function ScatterplotDialog() { function ScatterplotDialog() {
this._createDialog();
this._plot_method = "lin"; this._plot_method = "lin";
this._plot_size = 20; this._plot_size = 20;
this._dot_size = 0.1; this._dot_size = 0.1;
this._createDialog();
} }
ScatterplotDialog.prototype._createDialog = function() { ScatterplotDialog.prototype._createDialog = function() {
@ -22,7 +22,7 @@ ScatterplotDialog.prototype._createDialog = function() {
).appendTo(frame); ).appendTo(frame);
var html = $( var html = $(
'<div class="grid-layout layout-normal"><table width="100%">' + '<div class="grid-layout layout-normal layout-full"><table>' +
'<tr>' + '<tr>' +
'<td>' + '<td>' +
'<span class="clustering-dialog-controls">Plot type: <select bind="plotSelector">' + '<span class="clustering-dialog-controls">Plot type: <select bind="plotSelector">' +
@ -92,52 +92,63 @@ ScatterplotDialog.prototype._renderMatrix = function() {
if (columns.length > 0) { if (columns.length > 0) {
var table = $('<table></table>').addClass("scatterplot-matrix-table")[0]; var table = $('<table></table>').addClass("scatterplot-matrix-table")[0];
var wrap = function(element,cx,cy) { var createScatterplot = function(i, j) {
return element.click(function() { var cx = columns[i].name;
var options = { var cy = columns[j].name;
"name" : name,
"x_columnName" : cx, var name = cx + ' (x) vs. ' + cy + ' (y)';
"y_columnName" : cy, var link = $('<a href="javascript:{}"></a>')
"x_expression" : "value", .attr("title", name)
"y_expression" : "value", .click(function() {
}; var options = {
ui.browsingEngine.addFacet("scatterplot",options); "name" : name,
//self._dismiss(); "x_columnName" : cx,
}); "y_columnName" : cy,
"x_expression" : "value",
"y_expression" : "value",
};
ui.browsingEngine.addFacet("scatterplot", options);
//self._dismiss();
});
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 plot = $('<img src="' + url + '" />')
.addClass("scatterplot")
.attr("width", self._plot_size)
.attr("height", self._plot_size)
.appendTo(link);
return link;
}; };
for (var i = 0; i < columns.length; i++) { for (var i = 0; i < columns.length; i++) {
var tr = table.insertRow(table.rows.length); var tr = table.insertRow(table.rows.length);
for (var j = 0; j < i; j++) { for (var j = 0; j < i; j++) {
var cx = columns[i].name; $(tr.insertCell(j)).append(createScatterplot(i,j));
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($('<a href="javascript:{}"></a>').attr("title",name),cx,cy);
var plot = $('<img src="' + url + '" />').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(" ");
} }
var tdColumnName = $(tr.insertCell(tr.cells.length));
tdColumnName
.text(columns[i].name)
.css("text-align", "left")
.attr("colspan", columns.length - i);
} }
container.empty().append(table); var width = container.width();
container.empty().css("width", width + "px").append(table);
} else { } else {
container.html( container.html(

View File

@ -1,11 +1,11 @@
.scatterplot-dialog-table-container { .scatterplot-dialog-table-container {
height: 500px; height: 500px;
overflow: auto; overflow: scroll;
border: 1px solid #aaa; border: 1px solid #aaa;
} }
.clustering-dialog-controls { .clustering-dialog-controls {
margin-right: 2em; margin-right: 2em;
} }
table.scatterplot-matrix-table { table.scatterplot-matrix-table {
@ -18,5 +18,5 @@ table.scatterplot-matrix-table > tbody > tr > td {
} }
table.scatterplot-matrix-table img.scatterplot { table.scatterplot-matrix-table img.scatterplot {
border: 1px solid #eee; border: 1px solid #eee;
} }