fix not working cluster functions when it select japanese lang.

This commit is contained in:
Akihiko Tomokane 2016-11-15 16:34:19 +09:00
parent b14dd56b80
commit 89f0752e5f
2 changed files with 78 additions and 78 deletions

View File

@ -18,25 +18,25 @@
<td> <td>
<div class="binning-controls"><span bind="or_dialog_keying"></span> <div class="binning-controls"><span bind="or_dialog_keying"></span>
<select bind="keyingFunctionSelector"> <select bind="keyingFunctionSelector">
<option selected="true" bind="or_dialog_fingerprint"></option> <option selected="true" bind="or_dialog_fingerprint" value="fingerprint"></option>
<option bind="or_dialog_ngram"></option> <option bind="or_dialog_ngram" value="ngram-fingerprint"></option>
<option bind="or_dialog_metaphone"></option> <option bind="or_dialog_metaphone" value="metaphone3"></option>
<option bind="or_dialog_phonetic"></option> <option bind="or_dialog_phonetic" value="cologne-phonetic"></option>
</select></div> </select></div>
<div class="knn-controls hidden"><span bind="or_dialog_distance"></span> <div class="knn-controls hidden"><span bind="or_dialog_distance"></span>
<select bind="distanceFunctionSelector"> <select bind="distanceFunctionSelector">
<option selected="true" bind="or_dialog_leven"></option> <option selected="true" bind="or_dialog_leven" value="levenshtein"></option>
<option bind="or_dialog_ppm"></option> <option bind="or_dialog_ppm" value="PPM"></option>
</select></div> </select></div>
</td> </td>
<td> <td>
<div id="ngram-fingerprint-params" class="function-params hidden"> <div id="ngram-fingerprint-params" class="function-params hidden">
<span bind="or_dialog_ngramSize"></span><input type="text" value="2" bind="ngramSize" name="ngram-size" size="2" class="param" datatype="int"> <span bind="or_dialog_ngramSize"></span><input type="text" value="2" bind="ngramSize" name="ngram-size" size="2" class="param" datatype="int">
</div> </div>
<div class="knn-controls hidden"> <div class="knn-controls hidden">
<span style="margin-right: 1em"><span bind="or_dialog_radius"></span><input type="text" value="1.0" bind="radius" name="radius" size="2" class="param" datatype="float"></span> <span style="margin-right: 1em"><span bind="or_dialog_radius"></span><input type="text" value="1.0" bind="radius" name="radius" size="2" class="param" datatype="float"></span>
<span><span bind="or_dialog_blockChars"></span><input type="text" value="6" bind="ngramBlock" name="blocking-ngram-size" size="2" class="param" datatype="int"></span> <span><span bind="or_dialog_blockChars"></span><input type="text" value="6" bind="ngramBlock" name="blocking-ngram-size" size="2" class="param" datatype="int"></span>
</div> </div>
</td> </td>
<td bind="resultSummary" style="text-align:right;"> <td bind="resultSummary" style="text-align:right;">
</td> </td>
@ -54,7 +54,7 @@
<td class="left" style="text-align: left"> <td class="left" style="text-align: left">
<button class="button" bind="selectAllButton"></button> <button class="button" bind="selectAllButton"></button>
<button class="button" bind="deselectAllButton"></button> <button class="button" bind="deselectAllButton"></button>
</td> </td>
<td class="right" style="text-align: right"> <td class="right" style="text-align: right">
<button class="button button-primary" bind="applyReClusterButton"></button> <button class="button button-primary" bind="applyReClusterButton"></button>
<button class="button" bind="applyCloseButton"></button> <button class="button" bind="applyCloseButton"></button>

View File

@ -23,8 +23,8 @@ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@ -37,9 +37,9 @@ function ClusteringDialog(columnName, expression) {
this._method = "binning"; this._method = "binning";
this._function = "fingerprint"; this._function = "fingerprint";
this._params = {}; this._params = {};
this._facets = []; this._facets = [];
this._createDialog(); this._createDialog();
this._cluster(); this._cluster();
} }
@ -50,7 +50,7 @@ ClusteringDialog.prototype._createDialog = function() {
this._elmts = DOM.bind(dialog); this._elmts = DOM.bind(dialog);
this._elmts.dialogHeader.text($.i18n._('core-dialogs')["cluster-edit"]+' "' + this._columnName + '"'); this._elmts.dialogHeader.text($.i18n._('core-dialogs')["cluster-edit"]+' "' + this._columnName + '"');
this._elmts.or_dialog_descr.html($.i18n._('core-dialogs')["cluster-descr"]); this._elmts.or_dialog_descr.html($.i18n._('core-dialogs')["cluster-descr"]);
this._elmts.or_dialog_findMore.html($.i18n._('core-dialogs')["find-more"]); this._elmts.or_dialog_findMore.html($.i18n._('core-dialogs')["find-more"]);
this._elmts.or_dialog_method.html($.i18n._('core-dialogs')["method"]); this._elmts.or_dialog_method.html($.i18n._('core-dialogs')["method"]);
@ -66,13 +66,13 @@ ClusteringDialog.prototype._createDialog = function() {
this._elmts.or_dialog_ppm.html($.i18n._('core-dialogs')["ppm"]); this._elmts.or_dialog_ppm.html($.i18n._('core-dialogs')["ppm"]);
this._elmts.or_dialog_ngramSize.html($.i18n._('core-dialogs')["ngram-size"]); this._elmts.or_dialog_ngramSize.html($.i18n._('core-dialogs')["ngram-size"]);
this._elmts.or_dialog_radius.html($.i18n._('core-dialogs')["ngram-radius"]); this._elmts.or_dialog_radius.html($.i18n._('core-dialogs')["ngram-radius"]);
this._elmts.or_dialog_blockChars.html($.i18n._('core-dialogs')["block-chars"]); this._elmts.or_dialog_blockChars.html($.i18n._('core-dialogs')["block-chars"]);
this._elmts.selectAllButton.html($.i18n._('core-buttons')["select-all"]); this._elmts.selectAllButton.html($.i18n._('core-buttons')["select-all"]);
this._elmts.deselectAllButton.html($.i18n._('core-buttons')["unselect-all"]); this._elmts.deselectAllButton.html($.i18n._('core-buttons')["unselect-all"]);
this._elmts.applyReClusterButton.html($.i18n._('core-buttons')["merge-cluster"]); this._elmts.applyReClusterButton.html($.i18n._('core-buttons')["merge-cluster"]);
this._elmts.applyCloseButton.html($.i18n._('core-buttons')["merge-close"]); this._elmts.applyCloseButton.html($.i18n._('core-buttons')["merge-close"]);
this._elmts.closeButton.html($.i18n._('core-buttons')["close"]); this._elmts.closeButton.html($.i18n._('core-buttons')["close"]);
this._elmts.methodSelector.change(function() { this._elmts.methodSelector.change(function() {
var selection = $(this).find("option:selected").text(); var selection = $(this).find("option:selected").text();
if (selection == $.i18n._('core-dialogs')["key-collision"]) { if (selection == $.i18n._('core-dialogs')["key-collision"]) {
@ -87,55 +87,55 @@ ClusteringDialog.prototype._createDialog = function() {
self._elmts.distanceFunctionSelector.change(); self._elmts.distanceFunctionSelector.change();
} }
}); });
var changer = function() { var changer = function() {
self._function = $(this).find("option:selected").text(); self._function = $(this).find("option:selected").val();
$(".function-params").hide(); $(".function-params").hide();
$("#" + self._function + "-params").show(); $("#" + self._function + "-params").show();
params_changer(); params_changer();
}; };
this._elmts.keyingFunctionSelector.change(changer); this._elmts.keyingFunctionSelector.change(changer);
this._elmts.distanceFunctionSelector.change(changer); this._elmts.distanceFunctionSelector.change(changer);
var params_changer = function() { var params_changer = function() {
self._params = {}; self._params = {};
$(".dialog-body input.param:visible").each(function() { $(".dialog-body input.param:visible").each(function() {
var e = $(this); var e = $(this);
var name = e.attr('name'); var name = e.attr('name');
var datatype = e.attr('datatype') || 'string'; var datatype = e.attr('datatype') || 'string';
var value = e.val(); var value = e.val();
if (datatype == 'int') { if (datatype == 'int') {
value = parseInt(value,10); value = parseInt(value,10);
} else if (datatype == 'float') { } else if (datatype == 'float') {
value = parseFloat(value); value = parseFloat(value);
} }
self._params[name] = value; self._params[name] = value;
}); });
self._cluster(); self._cluster();
}; };
this._elmts.ngramSize.change(params_changer); this._elmts.ngramSize.change(params_changer);
this._elmts.radius.change(params_changer); this._elmts.radius.change(params_changer);
this._elmts.ngramBlock.change(params_changer); this._elmts.ngramBlock.change(params_changer);
this._elmts.selectAllButton.click(function() { self._selectAll(); }); this._elmts.selectAllButton.click(function() { self._selectAll(); });
this._elmts.deselectAllButton.click(function() { self._deselectAll(); }); this._elmts.deselectAllButton.click(function() { self._deselectAll(); });
this._elmts.applyReClusterButton.click(function() { self._onApplyReCluster(); }); this._elmts.applyReClusterButton.click(function() { self._onApplyReCluster(); });
this._elmts.applyCloseButton.click(function() { self._onApplyClose(); }); this._elmts.applyCloseButton.click(function() { self._onApplyClose(); });
this._elmts.closeButton.click(function() { self._dismiss(); }); this._elmts.closeButton.click(function() { self._dismiss(); });
this._level = DialogSystem.showDialog(dialog); this._level = DialogSystem.showDialog(dialog);
}; };
ClusteringDialog.prototype._renderTable = function(clusters) { ClusteringDialog.prototype._renderTable = function(clusters) {
var self = this; var self = this;
var container = this._elmts.tableContainer; var container = this._elmts.tableContainer;
if (clusters.length > 0) { if (clusters.length > 0) {
var table = $('<table></table>').addClass("clustering-dialog-entry-table")[0]; var table = $('<table></table>').addClass("clustering-dialog-entry-table")[0];
var trHead = table.insertRow(table.rows.length); var trHead = table.insertRow(table.rows.length);
trHead.className = "header"; trHead.className = "header";
$(trHead.insertCell(0)).text($.i18n._('core-dialogs')["cluster-size"]); $(trHead.insertCell(0)).text($.i18n._('core-dialogs')["cluster-size"]);
@ -147,9 +147,9 @@ ClusteringDialog.prototype._renderTable = function(clusters) {
var renderCluster = function(cluster) { var renderCluster = function(cluster) {
var tr = table.insertRow(table.rows.length); var tr = table.insertRow(table.rows.length);
tr.className = table.rows.length % 2 === 0 ? "odd" : "even"; tr.className = table.rows.length % 2 === 0 ? "odd" : "even";
$(tr.insertCell(0)).text(cluster.choices.length); $(tr.insertCell(0)).text(cluster.choices.length);
$(tr.insertCell(1)).text(cluster.rowCount); $(tr.insertCell(1)).text(cluster.rowCount);
var facet = { var facet = {
@ -165,7 +165,7 @@ ClusteringDialog.prototype._renderTable = function(clusters) {
"s":[ "s":[
] ]
}; };
var ul = $('<ul></ul>'); var ul = $('<ul></ul>');
var choices = cluster.choices; var choices = cluster.choices;
var rowCount = 0; var rowCount = 0;
@ -173,7 +173,7 @@ ClusteringDialog.prototype._renderTable = function(clusters) {
var parent = $(this).closest("tr"); var parent = $(this).closest("tr");
var value = $(this).text(); var value = $(this).text();
cluster.value = value; cluster.value = value;
parent.find("input[type='text']").val(value); parent.find("input[type='text']").val(value);
var checkbox = parent.find("input[type='checkbox']"); var checkbox = parent.find("input[type='checkbox']");
checkbox.prop('checked', true).change(); checkbox.prop('checked', true).change();
@ -193,7 +193,7 @@ ClusteringDialog.prototype._renderTable = function(clusters) {
}; };
li.appendTo(ul); li.appendTo(ul);
} }
var params = [ var params = [
"project=" + encodeURIComponent(theProject.id), "project=" + encodeURIComponent(theProject.id),
"ui=" + encodeURIComponent(JSON.stringify({ "ui=" + encodeURIComponent(JSON.stringify({
@ -203,7 +203,7 @@ ClusteringDialog.prototype._renderTable = function(clusters) {
var url = "project?" + params.join("&"); var url = "project?" + params.join("&");
var div = $('<div></div>').addClass("clustering-dialog-value-focus"); var div = $('<div></div>').addClass("clustering-dialog-value-focus");
var browseLink = $('<a target="_new" title="'+$.i18n._('core-dialogs')["browse-only-these"]+'">'+$.i18n._('core-dialogs')["browse-this-cluster"]+'</a>') var browseLink = $('<a target="_new" title="'+$.i18n._('core-dialogs')["browse-only-these"]+'">'+$.i18n._('core-dialogs')["browse-this-cluster"]+'</a>')
.addClass("clustering-dialog-browse-focus") .addClass("clustering-dialog-browse-focus")
.attr("href",url) .attr("href",url)
@ -215,7 +215,7 @@ ClusteringDialog.prototype._renderTable = function(clusters) {
.mouseleave(function() { browseLink.css("visibility", "hidden"); }) .mouseleave(function() { browseLink.css("visibility", "hidden"); })
.append(ul) .append(ul)
.append(div); .append(div);
var editCheck = $('<input type="checkbox" />') var editCheck = $('<input type="checkbox" />')
.change(function() { .change(function() {
cluster.edit = this.checked; cluster.edit = this.checked;
@ -224,26 +224,26 @@ ClusteringDialog.prototype._renderTable = function(clusters) {
if (cluster.edit) { if (cluster.edit) {
editCheck.attr("checked", "true"); editCheck.attr("checked", "true");
} }
var input = $('<input type="text" size="25" />') var input = $('<input type="text" size="25" />')
.attr("value", cluster.value) .attr("value", cluster.value)
.bind("keyup change input",function() { .bind("keyup change input",function() {
cluster.value = this.value; cluster.value = this.value;
}).appendTo(tr.insertCell(4)); }).appendTo(tr.insertCell(4));
}; };
for (var i = 0; i < clusters.length; i++) { for (var i = 0; i < clusters.length; i++) {
renderCluster(clusters[i]); renderCluster(clusters[i]);
} }
container.empty().append(table); container.empty().append(table);
this._elmts.resultSummary.html( this._elmts.resultSummary.html(
(clusters.length === this._clusters.length) ? (clusters.length === this._clusters.length) ?
("<b>" + this._clusters.length + "</b> cluster" + ((this._clusters.length != 1) ? "s" : "") + " "+$.i18n._('core-dialogs')["found"]) : ("<b>" + this._clusters.length + "</b> cluster" + ((this._clusters.length != 1) ? "s" : "") + " "+$.i18n._('core-dialogs')["found"]) :
("<b>" + clusters.length + "</b> cluster" + ((clusters.length != 1) ? "s" : "") + " "+$.i18n._('core-dialogs')["filtered-from"]+ this._clusters.length +$.i18n._('core-dialogs')["from-total"] ) ("<b>" + clusters.length + "</b> cluster" + ((clusters.length != 1) ? "s" : "") + " "+$.i18n._('core-dialogs')["filtered-from"]+ this._clusters.length +$.i18n._('core-dialogs')["from-total"] )
); );
} else { } else {
container.html( container.html(
'<div style="margin: 2em;"><div style="font-size: 130%; color: #333;">'+$.i18n._('core-dialogs')["no-cluster-found"]+'</div><div style="padding-top: 1em; font-size: 110%; color: #888;">'+$.i18n._('core-dialogs')["try-another-method"]+'</div></div>' '<div style="margin: 2em;"><div style="font-size: 130%; color: #333;">'+$.i18n._('core-dialogs')["no-cluster-found"]+'</div><div style="padding-top: 1em; font-size: 110%; color: #888;">'+$.i18n._('core-dialogs')["try-another-method"]+'</div></div>'
@ -253,23 +253,23 @@ ClusteringDialog.prototype._renderTable = function(clusters) {
ClusteringDialog.prototype._cluster = function() { ClusteringDialog.prototype._cluster = function() {
var self = this; var self = this;
var container = this._elmts.tableContainer.html( var container = this._elmts.tableContainer.html(
'<div style="margin: 1em; font-size: 130%; color: #888;">'+$.i18n._('core-dialogs')["clustering"]+'<img src="images/small-spinner.gif"></div>' '<div style="margin: 1em; font-size: 130%; color: #888;">'+$.i18n._('core-dialogs')["clustering"]+'<img src="images/small-spinner.gif"></div>'
); );
this._elmts.resultSummary.empty(); this._elmts.resultSummary.empty();
$.post( $.post(
"command/core/compute-clusters?" + $.param({ project: theProject.id }), "command/core/compute-clusters?" + $.param({ project: theProject.id }),
{ {
engine: JSON.stringify(ui.browsingEngine.getJSON()), engine: JSON.stringify(ui.browsingEngine.getJSON()),
clusterer: JSON.stringify({ clusterer: JSON.stringify({
'type' : this._method, 'type' : this._method,
'function' : this._function, 'function' : this._function,
'column' : this._columnName, 'column' : this._columnName,
'params' : this._params 'params' : this._params
}) })
}, },
function(data) { function(data) {
self._updateData(data); self._updateData(data);
@ -287,26 +287,26 @@ ClusteringDialog.prototype._updateData = function(data) {
value: this[0].v, value: this[0].v,
size: this.length size: this.length
}; };
var sum = 0; var sum = 0;
var sumSquared = 0; var sumSquared = 0;
var rowCount = 0; var rowCount = 0;
$.each(cluster.choices, function() { $.each(cluster.choices, function() {
rowCount += this.c; rowCount += this.c;
var l = this.v.length; var l = this.v.length;
sum += l; sum += l;
sumSquared += l * l; sumSquared += l * l;
}); });
cluster.rowCount = rowCount; cluster.rowCount = rowCount;
cluster.avg = sum / cluster.choices.length; cluster.avg = sum / cluster.choices.length;
cluster.variance = Math.sqrt(sumSquared / cluster.choices.length - cluster.avg * cluster.avg); cluster.variance = Math.sqrt(sumSquared / cluster.choices.length - cluster.avg * cluster.avg);
clusters.push(cluster); clusters.push(cluster);
}); });
this._clusters = clusters; this._clusters = clusters;
this._resetFacets(); this._resetFacets();
this._updateAll(); this._updateAll();
}; };
@ -320,14 +320,14 @@ ClusteringDialog.prototype._deselectAll = function() {
}; };
ClusteringDialog.prototype._onApplyClose = function() { ClusteringDialog.prototype._onApplyClose = function() {
var self = this; var self = this;
this._apply(function() { this._apply(function() {
self._dismiss(); self._dismiss();
}); });
}; };
ClusteringDialog.prototype._onApplyReCluster = function() { ClusteringDialog.prototype._onApplyReCluster = function() {
var self = this; var self = this;
this._apply(function() { this._apply(function() {
self._cluster(); self._cluster();
}); });
@ -343,14 +343,14 @@ ClusteringDialog.prototype._apply = function(onDone) {
for (var j = 0; j < cluster.choices.length; j++) { for (var j = 0; j < cluster.choices.length; j++) {
values.push(cluster.choices[j].v); values.push(cluster.choices[j].v);
} }
edits.push({ edits.push({
from: values, from: values,
to: cluster.value to: cluster.value
}); });
} }
} }
if (edits.length > 0) { if (edits.length > 0) {
Refine.postCoreProcess( Refine.postCoreProcess(
"mass-edit", "mass-edit",
@ -408,7 +408,7 @@ ClusteringDialog.prototype._resetFacets = function() {
r.elmt.remove(); r.elmt.remove();
} }
this._facets = []; this._facets = [];
this._createFacet($.i18n._('core-dialogs')["choices-in-cluster"], "size"); this._createFacet($.i18n._('core-dialogs')["choices-in-cluster"], "size");
this._createFacet($.i18n._('core-dialogs')["rows-in-cluster"], "rowCount"); this._createFacet($.i18n._('core-dialogs')["rows-in-cluster"], "rowCount");
this._createFacet($.i18n._('core-dialogs')["choice-avg-length"], "avg"); this._createFacet($.i18n._('core-dialogs')["choice-avg-length"], "avg");
@ -426,9 +426,9 @@ ClusteringDialog.prototype._createFacet = function(title, property) {
ClusteringDialog.Facet = function(dialog, title, property, elmt, clusters) { ClusteringDialog.Facet = function(dialog, title, property, elmt, clusters) {
this._dialog = dialog; this._dialog = dialog;
this._property = property; this._property = property;
var self = this; var self = this;
var max = Number.NEGATIVE_INFINITY; var max = Number.NEGATIVE_INFINITY;
var min = Number.POSITIVE_INFINITY; var min = Number.POSITIVE_INFINITY;
for (var i = 0; i < clusters.length; i++) { for (var i = 0; i < clusters.length; i++) {
@ -437,7 +437,7 @@ ClusteringDialog.Facet = function(dialog, title, property, elmt, clusters) {
max = Math.max(max, val); max = Math.max(max, val);
min = Math.min(min, val); min = Math.min(min, val);
} }
this._min = min; this._min = min;
this._max = max; this._max = max;
if (min >= max) { if (min >= max) {
@ -445,7 +445,7 @@ ClusteringDialog.Facet = function(dialog, title, property, elmt, clusters) {
this._baseBins = []; this._baseBins = [];
} else { } else {
var diff = max - min; var diff = max - min;
this._step = 1; this._step = 1;
if (diff > 10) { if (diff > 10) {
while (this._step * 100 < diff) { while (this._step * 100 < diff) {
@ -456,7 +456,7 @@ ClusteringDialog.Facet = function(dialog, title, property, elmt, clusters) {
this._step /= 10; this._step /= 10;
} }
} }
this._min = (Math.floor(this._min / this._step) * this._step); this._min = (Math.floor(this._min / this._step) * this._step);
this._max = (Math.ceil(this._max / this._step) * this._step); this._max = (Math.ceil(this._max / this._step) * this._step);
this._binCount = 1 + Math.ceil((this._max - this._min) / this._step); this._binCount = 1 + Math.ceil((this._max - this._min) / this._step);
@ -469,10 +469,10 @@ ClusteringDialog.Facet = function(dialog, title, property, elmt, clusters) {
this._max = (Math.ceil(this._max / this._step) * this._step); this._max = (Math.ceil(this._max / this._step) * this._step);
} }
this._baseBins = this._computeDistribution(clusters); this._baseBins = this._computeDistribution(clusters);
this._from = this._min; this._from = this._min;
this._to = this._max; this._to = this._max;
elmt.addClass("clustering-dialog-facet"); elmt.addClass("clustering-dialog-facet");
var html = $( var html = $(
'<div class="clustering-dialog-facet-header">' + title + '</div>' + '<div class="clustering-dialog-facet-header">' + title + '</div>' +
@ -481,12 +481,12 @@ ClusteringDialog.Facet = function(dialog, title, property, elmt, clusters) {
'</div>' + '</div>' +
'<div class="clustering-dialog-facet-selection" bind="selectionContainer"></div>' '<div class="clustering-dialog-facet-selection" bind="selectionContainer"></div>'
).appendTo(elmt); ).appendTo(elmt);
this._elmts = DOM.bind(html); this._elmts = DOM.bind(html);
this._histogram = new HistogramWidget(this._elmts.histogramContainer, { binColors: [ "#ccccff", "#6666ff" ] }); this._histogram = new HistogramWidget(this._elmts.histogramContainer, { binColors: [ "#ccccff", "#6666ff" ] });
this._sliderWidget = new SliderWidget(this._elmts.sliderWidgetDiv); this._sliderWidget = new SliderWidget(this._elmts.sliderWidgetDiv);
this._elmts.sliderWidgetDiv.bind("slide", function(evt, data) { this._elmts.sliderWidgetDiv.bind("slide", function(evt, data) {
self._from = data.from; self._from = data.from;
self._to = data.to; self._to = data.to;
@ -509,7 +509,7 @@ ClusteringDialog.Facet.prototype.restrict = function(clusters) {
if (!this._baseBins.length || (this._from == this._min && this._to == this._max)) { if (!this._baseBins.length || (this._from == this._min && this._to == this._max)) {
return clusters; return clusters;
} }
var clusters2 = []; var clusters2 = [];
for (var i = 0; i < clusters.length; i++) { for (var i = 0; i < clusters.length; i++) {
var cluster = clusters[i]; var cluster = clusters[i];
@ -525,20 +525,20 @@ ClusteringDialog.Facet.prototype.update = function(clusters) {
if (!this._baseBins.length) { if (!this._baseBins.length) {
return; return;
} }
var bins = this._computeDistribution(clusters); var bins = this._computeDistribution(clusters);
this._sliderWidget.update( this._sliderWidget.update(
this._min, this._min,
this._max, this._max,
this._step, this._step,
this._from, this._from,
this._to this._to
); );
this._histogram.update( this._histogram.update(
this._min, this._min,
this._max, this._max,
this._step, this._step,
[ this._baseBins, bins ] [ this._baseBins, bins ]
); );
}; };
@ -552,13 +552,13 @@ ClusteringDialog.Facet.prototype._computeDistribution = function(clusters) {
for (var b = 0; b < this._binCount; b++) { for (var b = 0; b < this._binCount; b++) {
bins.push(0); bins.push(0);
} }
for (var i = 0; i < clusters.length; i++) { for (var i = 0; i < clusters.length; i++) {
var cluster = clusters[i]; var cluster = clusters[i];
var val = cluster[this._property]; var val = cluster[this._property];
var bin = Math.round((val - this._min) / this._step); var bin = Math.round((val - this._min) / this._step);
bins[bin]++; bins[bin]++;
} }
return bins; return bins;
}; };