@@ -60,7 +60,7 @@ SpectrumChartD3 = function(elem, options) {
60
60
if ( ( typeof this . options . compactXAxis ) !== 'boolean' ) this . options . compactXAxis = false ;
61
61
if ( ( typeof this . options . adjustYAxisPadding ) !== 'boolean' ) this . options . adjustYAxisPadding = true ;
62
62
if ( ( typeof this . options . wheelScrollYAxis ) !== 'boolean' ) this . options . wheelScrollYAxis = true ;
63
-
63
+ if ( ( typeof this . options . noYAxisNumbers ) !== 'boolean' ) this . options . noYAxisNumbers = false ;
64
64
65
65
if ( typeof options . animationDuration !== 'number' || options . animationDuration < 0 ) this . options . animationDuration = 1000 ;
66
66
this . options . showAnimation = ( typeof options . showAnimation == 'boolean' && this . options . animationDuration > 0 ) ? options . showAnimation : false ;
@@ -106,8 +106,7 @@ SpectrumChartD3 = function(elem, options) {
106
106
this . options . backgroundSubtract = ( typeof options . backgroundSubtract == 'boolean' ) ? options . backgroundSubtract : false ;
107
107
this . options . allowDragRoiExtent = ( typeof options . allowDragRoiExtent == 'boolean' ) ? options . allowDragRoiExtent : true ;
108
108
this . options . showSliderCloseBtn = ( typeof options . showSliderCloseBtn == 'boolean' ) ? options . showSliderCloseBtn : false ;
109
-
110
-
109
+
111
110
112
111
self . options . spectrumLineWidth = ( typeof options . spectrumLineWidth == 'number' && options . spectrumLineWidth > 0 && options . spectrumLineWidth < 15 ) ? options . spectrumLineWidth : 1.0 ;
113
112
@@ -135,8 +134,7 @@ SpectrumChartD3 = function(elem, options) {
135
134
// A value of 0 is horizontal, a value of -90 is vertical (i.e. up-and-down). Only tested [0,-90]
136
135
self . options . peakLabelRotation = ( typeof options . peakLabelRotation == 'number' ) ? options . peakLabelRotation : 0 ;
137
136
self . options . logYAxisMin = ( ( typeof options . logYAxisMin == 'number' ) && ( options . logYAxisMin > 0 ) ) ? options . logYAxisMin : 0.1 ;
138
-
139
-
137
+
140
138
self . setLocalizations ( { } , true ) ; //Set default localization strings
141
139
142
140
this . padding = {
@@ -427,7 +425,14 @@ SpectrumChartD3 = function(elem, options) {
427
425
} )
428
426
. on ( "mouseout" , function ( ) {
429
427
d3 . select ( this ) . selectAll ( 'text' ) . style ( "font-weight" , null ) ;
430
- } ) ;
428
+ } )
429
+ . on ( "dblclick" , function ( ) { //toggle between linear and log when user double-clicks axis
430
+ d3 . event . preventDefault ( ) ;
431
+ d3 . event . stopPropagation ( ) ;
432
+ const ytype = ( self . options . yscale === "log" ) ? "lin" : "log" ;
433
+ self . setYAxisType ( ( self . options . yscale === "log" ) ? "lin" : "log" ) ;
434
+ self . WtEmit ( self . chart . id , { name : 'yAxisTypeChanged' } , ytype ) ;
435
+ } ) ;
431
436
432
437
this . xAxis = d3 . svg . axis ( ) . scale ( this . xScale )
433
438
. orient ( "bottom" )
@@ -4972,6 +4977,8 @@ SpectrumChartD3.prototype.yticks = function() {
4972
4977
. forEach ( function ( e ) { ticks . push ( { value :e , major :true , text :formatYNumber ( e ) } ) ; } ) ;
4973
4978
}
4974
4979
4980
+ if ( this . options . noYAxisNumbers )
4981
+ ticks . forEach ( function ( obj ) { obj [ "text" ] = null ; } ) ;
4975
4982
4976
4983
return ticks ;
4977
4984
}
@@ -5051,10 +5058,30 @@ SpectrumChartD3.prototype.setAdjustYAxisPadding = function( adjust, pad ) {
5051
5058
this . handleResize ( false ) ;
5052
5059
}
5053
5060
5061
+
5062
+ SpectrumChartD3 . prototype . setNoYAxisNumbers = function ( d ) {
5063
+ if ( typeof d === "boolean" )
5064
+ this . options . noYAxisNumbers = d ;
5065
+ this . handleResize ( false ) ;
5066
+ }
5067
+
5054
5068
SpectrumChartD3 . prototype . setWheelScrollYAxis = function ( d ) {
5055
5069
this . options . wheelScrollYAxis = d ;
5056
5070
}
5057
5071
5072
+ SpectrumChartD3 . prototype . setChartPadding = function ( d ) {
5073
+ if ( ! d )
5074
+ return ;
5075
+ const allowed_keys = [ "top" , "right" , "bottom" , "left" , "titlePad" , "xTitlePad" , "labelPad" , "label" , "sliderChart" ] ;
5076
+ for ( const key in d )
5077
+ {
5078
+ if ( Object . hasOwnProperty . call ( d , key ) && allowed_keys . includes ( key ) && ( typeof d [ key ] === "number" ) )
5079
+ this . padding [ key ] = d [ key ] ;
5080
+ }
5081
+ this . handleResize ( false ) ;
5082
+ }
5083
+
5084
+
5058
5085
5059
5086
/**
5060
5087
* -------------- Y-axis Scale Functions --------------
0 commit comments