got scatterfacet to show \.o./

git-svn-id: http://google-refine.googlecode.com/svn/trunk@464 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-04-13 07:26:26 +00:00
parent 84bc49b3d5
commit de9dfbfba7
3 changed files with 43 additions and 34 deletions

View File

@ -76,26 +76,26 @@ ScatterplotFacet.prototype._initializeUI = function() {
}; };
ScatterplotFacet.prototype.updateState = function(data) { ScatterplotFacet.prototype.updateState = function(data) {
if ("min_x" in data && "max_x" in data && "max_y" in data && "min_y" in data) { if ("x_min" in data && "x_max" in data && "x_max" in data && "x_min" in data) {
this._error = false; this._error = false;
this._config.min_x = data.min_x; this._config.x_min = data.x_min;
this._config.max_x = data.max_x; this._config.x_max = data.x_max;
this._config.min_y = data.min_y; this._config.y_min = data.y_min;
this._config.max_y = data.max_y; this._config.y_max = data.y_max;
this._from_x = Math.max(data.from_x, this._config.min_x); this._from_x = Math.max(data.from_x, this._config.x_min);
if ("to_x" in data) { if ("to_x" in data) {
this._to_x = Math.min(data.to_x, this._config.max_x); this._to_x = Math.min(data.to_x, this._config.x_max);
} else { } else {
this._to_x = data.max_x; this._to_x = data.x_max;
} }
this._from_y = Math.max(data.from_y, this._config.min_y); this._from_y = Math.max(data.from_y, this._config.x_min);
if ("to_y" in data) { if ("to_y" in data) {
this._to_y = Math.min(data.to_y, this._config.max_y); this._to_y = Math.min(data.to_y, this._config.x_max);
} else { } else {
this._to_y = data.max_y; this._to_y = data.x_max;
} }
} else { } else {

View File

@ -3,10 +3,10 @@ function ScatterplotWidget(elmt, options) {
this._options = options; this._options = options;
this._plotter = { this._plotter = {
'cx' : options.x_column, 'cx' : options.x_columnName,
'cy' : options.y_column, 'cy' : options.y_columnName,
'ye' : options.x_expression, 'xe' : options.x_expression,
'ye' : options.x_expression, 'ye' : options.y_expression,
}; };
this._range = null; this._range = null;
@ -41,9 +41,9 @@ ScatterplotWidget.prototype.update = function(x_min, x_max, x_from, x_to, y_min,
ScatterplotWidget.prototype._update = function() { ScatterplotWidget.prototype._update = function() {
if (this._highlight !== null) { if (this._highlight !== null) {
this._highlight.from_x = Math.max(this._highlight.from_x, this._range.min_x); this._highlight.from_x = Math.max(this._highlight.from_x, this._range.x_min);
this._highlight.to_x = Math.min(this._highlight.to_x, this._range.max_x); this._highlight.to_x = Math.min(this._highlight.to_x, this._range.max_x);
this._highlight.from_y = Math.max(this._highlight.from_y, this._range.min_y); this._highlight.from_y = Math.max(this._highlight.from_y, this._range.y_min);
this._highlight.to_y = Math.min(this._highlight.to_y, this._range.max_y); this._highlight.to_y = Math.min(this._highlight.to_y, this._range.max_y);
} }
@ -64,7 +64,7 @@ ScatterplotWidget.prototype._initializeUI = function() {
ScatterplotWidget.prototype._resize = function() { ScatterplotWidget.prototype._resize = function() {
this._plotter.w = this._elmts.canvas.width(); this._plotter.w = this._elmts.canvas.width();
this._plotter.h = ("height" in this._options) ? this._options.height : w; this._plotter.h = ("height" in this._options) ? this._options.height : this._plotter.w;
this._elmts.canvas.attr("width", this._plotter.w); this._elmts.canvas.attr("width", this._plotter.w);
this._elmts.canvas.attr("height", this._plotter.h); this._elmts.canvas.attr("height", this._plotter.h);
}; };
@ -81,22 +81,28 @@ ScatterplotWidget.prototype._render = function() {
ctx.save(); ctx.save();
var img = new Image(); var img = new Image();
img.onload = function(){ img.onload = function(){
ctx.drawImage(img,0,0); ctx.drawImage(img,0,0);
var img2 = new Image(); if (self._highlight != null) {
img2.onload = function(){ var img2 = new Image();
ctx.drawImage(img2,0,0); img2.onload = function(){
ctx.drawImage(img2,0,0);
ctx.translate(0, canvas.height);
ctx.scale(1, -1); ctx.translate(0, canvas.height);
ctx.scale(1, -1);
// draw something else
// draw something else
ctx.restore();
} ctx.restore();
img2.src = self._get_image_url(self._plotter) + "&color=000088&dot=0.3"; }
self._plotter.dot = "0.4";
self._plotter.color = "000088";
img2.src = self._get_image_url(self._plotter);
}
} }
img.src = self._get_image_url(self._plotter) + "&color=000000&dot=0.2"; self._plotter.dot = "0.4";
self._plotter.color = "000000";
img.src = self._get_image_url(self._plotter);
}; };
ScatterplotWidget.prototype._get_image_url = function(o) { ScatterplotWidget.prototype._get_image_url = function(o) {

View File

@ -2,8 +2,11 @@
margin: 0; margin: 0;
padding: 0; padding: 0;
position: relative; position: relative;
text-align: left;
} }
.scatterplot-widget canvas { .scatterplot-widget canvas {
width: 100%; width: 120px;
border: 1px solid #f0f0f0;
margin: 0.5em 0.8em;
} }