@@ -351,10 +351,18 @@ scatterPlot.prototype.render = function(){
351
351
. attr ( "xmlns" , "http://www.w3.org/2000/svg" )
352
352
. node ( ) . innerHTML ;
353
353
354
+ var renderHeight = $ ( self . scatterEl ) . height ( ) ;
355
+ var renderWidth = $ ( self . scatterEl ) . width ( ) ;
356
+
357
+ $ ( "#imagerenderer" ) . attr ( 'width' , renderWidth ) ;
358
+ $ ( "#imagerenderer" ) . attr ( 'height' , renderHeight ) ;
359
+
354
360
var c = document . querySelector ( "#imagerenderer" ) ;
355
361
var ctx = c . getContext ( '2d' ) ;
356
362
357
- ctx . drawSvg ( svg_html , 0 , 0 , self . width , self . height ) ;
363
+
364
+ ctx . drawSvg ( svg_html , 0 , 0 , renderHeight , renderWidth ) ;
365
+
358
366
359
367
//var a = document.createElement("a");
360
368
var a = d3 . select ( "#pngdataurl" ) . append ( "a" ) [ 0 ] [ 0 ] ;
@@ -522,20 +530,6 @@ scatterPlot.prototype.render = function(){
522
530
. orient ( "bottom" )
523
531
. tickFormat ( format_x ) ;
524
532
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
-
539
533
540
534
if ( this . col_vec . indexOf ( this . sel_x ) != - 1 ) {
541
535
var length_array = [ ] ;
@@ -587,44 +581,63 @@ scatterPlot.prototype.render = function(){
587
581
588
582
var yScale , format_y ;
589
583
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
+
590
598
var yAxis = d3 . svg . axis ( )
591
599
. scale ( yScale )
592
600
. orient ( "left" )
593
601
. tickFormat ( format_y ) ;
594
602
603
+
595
604
for ( var i = this . sel_y . length - 1 ; i >= 0 ; i -- ) {
596
605
597
- var tmp_domain ;
606
+ var tmp_domain , niceDomain ;
607
+ var par = this . sel_y [ i ] ;
598
608
599
- if ( this . col_ordinal . indexOf ( firstYSelection ) != - 1 ) {
609
+ if ( this . col_ordinal . indexOf ( par ) != - 1 ) {
600
610
tmp_domain = this . data . map ( function ( d ) {
601
- return d [ firstYSelection ] ;
611
+ return d [ par ] ;
602
612
} ) ;
603
613
} else {
604
614
tmp_domain = d3 . extent ( this . data , function ( d ) {
605
- return d [ firstYSelection ] ;
615
+ return d [ par ] ;
606
616
} ) ;
607
617
}
608
618
609
619
610
- /*var tmp_domain = d3.extent(this.data, function(d) {
611
- return d[self.sel_y[i]];
612
- });*/
613
620
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 ;
624
624
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
+ }
628
641
629
642
yScale . domain ( niceDomain ) ;
630
643
} ;
@@ -642,7 +655,8 @@ scatterPlot.prototype.render = function(){
642
655
svg . append ( "rect" )
643
656
. attr ( "width" , width )
644
657
. attr ( "height" , height )
645
- . attr ( "fill" , "transparent" ) ;
658
+ . attr ( "fill" , "transparent" )
659
+ . attr ( "stroke" , "none" ) ;
646
660
647
661
// Add clip path so only points in the area are shown
648
662
var clippath = svg . append ( "defs" ) . append ( "clipPath" )
0 commit comments