function ScatterplotDialog(column) { this._column = column; this._plot_method = "lin"; this._createDialog(); } ScatterplotDialog.prototype._createDialog = function() { var self = this; var frame = DialogSystem.createDialog(); frame.width("1100px"); var header = $('
').addClass("dialog-header").text('Scatterplot Matrix' + ((typeof this._column == "undefined") ? "" : " (focusing on '" + this._column + "')")).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("Done").click(function() { self._dismiss(); }).appendTo(right_footer); this._level = DialogSystem.showDialog(frame); this._renderMatrix(); }; ScatterplotDialog.prototype._renderMatrix = function() { var self = this; var container = this._elmts.tableContainer.html( '
Processing...
' ); if (theProject.columnModel.columns.length > 0) { var params = { project: theProject.id }; $.getJSON("/command/get-columns-info?" + $.param(params),function(data) { if (data == null || typeof data.length == 'undefined') { container.html("Error calling 'get-columns-info'"); return; } var columns = []; for (var i = 0; i < data.length; i++) { if (data[i].is_numeric) { columns.push(data[i]); } } if (typeof self._plot_size == 'undefined') { self._plot_size = Math.max(Math.floor(500 / columns.length / 5) * 5,20); self._dot_size = 0.4; self._elmts.plotSize.val(self._plot_size); self._elmts.dotSize.val(self._dot_size); } var table = ''; var createScatterplot = function(cx, cy) { var title = cx + ' (x) vs. ' + cy + ' (y)'; var link = ''; var plotter_params = { 'cx' : cx, 'cy' : cy, 'w' : self._plot_size * 3, 'h' : self._plot_size * 3, '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); return link + ''; }; for (var i = 0; i < columns.length; i++) { table += ''; var div_class = "column_header"; if (columns[i].name == self._column) div_class += " current_column"; table += '' for (var j = i + 1; j < columns.length; j++) { var cx = columns[i].name; var cy = columns[j].name; var div_class = "scatterplot"; if (cx == self._column || cy == self._column) div_class += " current_column"; table += ''; } table += ''; } table += "
' + columns[i].name + '
' + createScatterplot(cx,cy) + '
"; var width = container.width(); container.empty().css("width", width + "px").append($(table)); container.find("a").click(function() { var options = { "name" : $(this).attr("title"), "x_columnName" : $(this).attr("cx"), "y_columnName" : $(this).attr("cy"), "x_expression" : "value", "y_expression" : "value", "dot" : self._dot_size, "dim" : self._plot_method }; ui.browsingEngine.addFacet("scatterplot", options); //self._dismiss(); }); container.find(".scatterplot").hover( function() { $(this).find('img').addClass("hover"); } , function() { $(this).find('img').removeClass("hover"); } ); }); } else { container.html( '
There are no columns in this dataset
' ); } }; ScatterplotDialog.prototype._dismiss = function() { DialogSystem.dismissUntil(this._level - 1); };