Skip to content

Commit a89c713

Browse files
committed
Solved issues of incorrect image creation after resize (didn't update new size); Solved issue of y-Axis domain not showing dates correctly; Solved management of multiple parameters adapting the y-axis to show all; Style change to selection to remove selection shadow which did not look good;
1 parent 80ddffb commit a89c713

File tree

4 files changed

+53
-39
lines changed

4 files changed

+53
-39
lines changed

app/scripts/scatter.js

+50-36
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,18 @@ scatterPlot.prototype.render = function(){
351351
.attr("xmlns", "http://www.w3.org/2000/svg")
352352
.node().innerHTML;
353353

354+
var renderHeight = $(self.scatterEl).height();
355+
var renderWidth = $(self.scatterEl).width();
356+
357+
$("#imagerenderer").attr('width', renderWidth);
358+
$("#imagerenderer").attr('height', renderHeight);
359+
354360
var c = document.querySelector("#imagerenderer");
355361
var ctx = c.getContext('2d');
356362

357-
ctx.drawSvg(svg_html, 0, 0, self.width, self.height);
363+
364+
ctx.drawSvg(svg_html, 0, 0, renderHeight, renderWidth);
365+
358366

359367
//var a = document.createElement("a");
360368
var a = d3.select("#pngdataurl").append("a")[0][0];
@@ -522,20 +530,6 @@ scatterPlot.prototype.render = function(){
522530
.orient("bottom")
523531
.tickFormat(format_x);
524532

525-
// Use first selected element of y axis as definer for axis domain and scale
526-
527-
var firstYSelection = this.sel_y[0];
528-
529-
if (this.col_date.indexOf(firstYSelection) != -1){
530-
yScale = d3.time.scale().range([height, 0]);
531-
//format_y = d3.time.format(self.format_date);
532-
}else if(this.col_ordinal.indexOf(firstYSelection) != -1){
533-
yScale = d3.scale.ordinal().rangePoints([height-this.margin.bottom, 0]);
534-
}else{
535-
yScale = d3.scale.linear().range([height-this.margin.bottom, 0]);
536-
//format_y = d3.format('.3g');
537-
}
538-
539533

540534
if(this.col_vec.indexOf(this.sel_x) != -1){
541535
var length_array = [];
@@ -587,44 +581,63 @@ scatterPlot.prototype.render = function(){
587581

588582
var yScale, format_y;
589583

584+
// Use first selected element of y axis as definer for axis domain and scale
585+
586+
var firstYSelection = this.sel_y[0];
587+
588+
if (this.col_date.indexOf(firstYSelection) != -1){
589+
yScale = d3.time.scale().range([height, 0]);
590+
//format_y = d3.time.format(self.format_date);
591+
}else if(this.col_ordinal.indexOf(firstYSelection) != -1){
592+
yScale = d3.scale.ordinal().rangePoints([height-this.margin.bottom, 0]);
593+
}else{
594+
yScale = d3.scale.linear().range([height-this.margin.bottom, 0]);
595+
//format_y = d3.format('.3g');
596+
}
597+
590598
var yAxis = d3.svg.axis()
591599
.scale(yScale)
592600
.orient("left")
593601
.tickFormat(format_y);
594602

603+
595604
for (var i = this.sel_y.length - 1; i >= 0; i--) {
596605

597-
var tmp_domain;
606+
var tmp_domain, niceDomain;
607+
var par = this.sel_y[i];
598608

599-
if(this.col_ordinal.indexOf(firstYSelection) != -1){
609+
if(this.col_ordinal.indexOf(par) != -1){
600610
tmp_domain = this.data.map(function(d) {
601-
return d[firstYSelection];
611+
return d[par];
602612
});
603613
}else{
604614
tmp_domain = d3.extent(this.data, function(d) {
605-
return d[firstYSelection];
615+
return d[par];
606616
});
607617
}
608618

609619

610-
/*var tmp_domain = d3.extent(this.data, function(d) {
611-
return d[self.sel_y[i]];
612-
});*/
613620

614-
// If the parameter minimum is bigger then a previously set minimum and the
615-
// currently set minimum is not the default 0 overwrite it
616-
if(tmp_domain[0] > yScale.domain()[0] && yScale.domain()[0] != 0){
617-
tmp_domain[0] = yScale.domain()[0];
618-
}
619-
// If the parameter maximum is lower then a previously set maximum overwrite it
620-
// and the currently set maximum is not the default 1 overwrite it
621-
if(tmp_domain[1] < yScale.domain()[1] && yScale.domain()[1] != 1){
622-
tmp_domain[1] = yScale.domain()[1];
623-
}
621+
if (tmp_domain[0] instanceof Date){
622+
// If domain is temporal just return as is
623+
niceDomain = tmp_domain;
624624

625-
// 5% buffer so points are not drawn exactly on axis
626-
var domainBuffer = (Math.abs(tmp_domain[1]-tmp_domain[0])/100)*5;
627-
var niceDomain = [tmp_domain[0]-domainBuffer, tmp_domain[1]+domainBuffer];
625+
}else{
626+
627+
// If the parameter minimum is bigger then a previously set minimum and the
628+
// currently set minimum is not the default 0 overwrite it
629+
if(tmp_domain[0] > yScale.domain()[0] && yScale.domain()[0] != 0){
630+
tmp_domain[0] = yScale.domain()[0];
631+
}
632+
// If the parameter maximum is lower then a previously set maximum overwrite it
633+
// and the currently set maximum is not the default 1 overwrite it
634+
if(tmp_domain[1] < yScale.domain()[1] && yScale.domain()[1] != 1){
635+
tmp_domain[1] = yScale.domain()[1];
636+
}
637+
// 5% buffer so points are not drawn exactly on axis
638+
var domainBuffer = (Math.abs(tmp_domain[1]-tmp_domain[0])/100)*5;
639+
niceDomain = [tmp_domain[0]-domainBuffer, tmp_domain[1]+domainBuffer];
640+
}
628641

629642
yScale.domain(niceDomain);
630643
};
@@ -642,7 +655,8 @@ scatterPlot.prototype.render = function(){
642655
svg.append("rect")
643656
.attr("width", width)
644657
.attr("height", height)
645-
.attr("fill", "transparent");
658+
.attr("fill", "transparent")
659+
.attr("stroke", "none");
646660

647661
// Add clip path so only points in the area are shown
648662
var clippath = svg.append("defs").append("clipPath")

app/styles/sumoselect.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
.SumoSelect {font-size: 0.8em}
2+
.SumoSelect {font-size: 0.8em; outline: none!important;}
33

44
.SumoSelect p {margin: 0}
55

lib/scripts/av.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)