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 = $( '
' + '' + '' + '' + '' + '' + '' + '
' + 'Plot type: ' + 'Plot Size: px' + 'Dot Size: px' + '
' + '
' + '
' ).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]; 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]; var cy = columns[j]; var plotter_params = { 'cx' : cx.name, 'cy' : cy.name, '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.name + '(x) vs. ' + cy.name + '(y)'; var cell = $(tr.insertCell(j)); var link = $('').attr("title",name).click(function() { ui.browsingEngine.addFacet( "scatterplot", { "name" : name, "x_column" : cx.name, "y_column" : cy.name, "expression" : "value", "mode" : "scatterplot" } ); //self._dismiss(); }); 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); };