@@ -127,6 +127,8 @@ SpectrumChartD3 = function(elem, options) {
127
127
// The rotation angle of the labels. A negative value rotates it the direction you probably want.
128
128
// A value of 0 is horizontal, a value of -90 is vertical (i.e. up-and-down). Only tested [0,-90]
129
129
self . options . peakLabelRotation = ( typeof options . peakLabelRotation == 'number' ) ? options . peakLabelRotation : 0 ;
130
+ self . options . logYAxisMin = ( ( typeof options . logYAxisMin == 'number' ) && ( options . logYAxisMin > 0 ) ) ? options . logYAxisMin : 0.1 ;
131
+
130
132
131
133
self . setLocalizations ( { } , true ) ; //Set default localization strings
132
134
@@ -4697,6 +4699,7 @@ SpectrumChartD3.prototype.setShowLegend = function( show ) {
4697
4699
* -------------- Y-axis Functions --------------
4698
4700
*/
4699
4701
SpectrumChartD3 . prototype . yticks = function ( ) {
4702
+ const self = this ;
4700
4703
var ticks = [ ] ;
4701
4704
var EPSILON = 1.0E-3 ;
4702
4705
@@ -4705,9 +4708,9 @@ SpectrumChartD3.prototype.yticks = function() {
4705
4708
4706
4709
var formatYNumber = function ( v ) {
4707
4710
/*poorly simulating "%.3g" in snprintf */
4708
- /*SHould get rid of so many regexs, and shorten code (shouldnt there be a builtin function to print to "%.3"?) */
4711
+ /*Should get rid of so many regexs, and shorten code (shouldnt there be a builtin function to print to "%.3"?) */
4709
4712
var t ;
4710
- if ( v >= 1000 || v < 0.1 )
4713
+ if ( v >= 1000 || v < self . options . logYAxisMin )
4711
4714
{
4712
4715
t = v . toPrecision ( 3 ) ;
4713
4716
t = t . replace ( / \. 0 + e / g, "e" ) . replace ( / \. 0 + $ / g, "" ) ;
@@ -4800,9 +4803,11 @@ SpectrumChartD3.prototype.yticks = function() {
4800
4803
4801
4804
if ( this . options . yscale === "log" )
4802
4805
{
4806
+ const yMinPrefPow = Math . floor ( Math . log10 ( this . options . logYAxisMin ) ) ;
4807
+
4803
4808
/*Get the power of 10 just below or equal to rendermin. */
4804
- var minpower = ( renderymin > 0.0 ) ? Math . floor ( Math . log10 ( renderymin ) ) : - 1 ;
4805
-
4809
+ var minpower = ( renderymin > 0.0 ) ? Math . floor ( Math . log10 ( renderymin ) ) : yMinPrefPow ;
4810
+
4806
4811
/*Get the power of 10 just above or equal to renderymax. If renderymax */
4807
4812
/* is less than or equal to 0, set power to be 0. */
4808
4813
var maxpower = ( renderymax > 0.0 ) ? Math . ceil ( Math . log10 ( renderymax ) ) : 0 ;
@@ -4813,12 +4818,12 @@ SpectrumChartD3.prototype.yticks = function() {
4813
4818
/*Happens when renderymin==renderymax which is a power of 10 */
4814
4819
++ maxpower ;
4815
4820
-- minpower ;
4816
- } else if ( maxpower > 2 && minpower < - 1 )
4821
+ } else if ( maxpower > 2 && minpower < yMinPrefPow )
4817
4822
{
4818
4823
/*We had a tiny value (possibly a fraction of a count), as well as a */
4819
4824
/* large value (>1000). */
4820
- minpower = - 1 ;
4821
- } else if ( maxpower >= 0 && minpower < - 1 && ( maxpower - minpower ) > 6 )
4825
+ minpower = yMinPrefPow ;
4826
+ } else if ( maxpower >= 0 && minpower < yMinPrefPow && ( maxpower - minpower ) > 6 )
4822
4827
{
4823
4828
/*we had a tiny power (1.0E-5), as well as one between 1 and 999, */
4824
4829
/* so we will only show the most significant decades */
@@ -8579,6 +8584,10 @@ SpectrumChartD3.prototype.setPeakLabelRotation = function(d) {
8579
8584
this . options . peakLabelRotation = ( typeof d == 'number' ) ? d : 0 ;
8580
8585
}
8581
8586
8587
+ SpectrumChartD3 . prototype . setLogYAxisMin = function ( d ) {
8588
+ this . options . logYAxisMin = ( typeof d == 'number' ) && ( d > 0.0 ) ? d : 0.1 ;
8589
+ }
8590
+
8582
8591
SpectrumChartD3 . prototype . setSearchWindows = function ( ranges ) {
8583
8592
var self = this ;
8584
8593
@@ -10833,7 +10842,7 @@ SpectrumChartD3.prototype.getYAxisDomain = function(){
10833
10842
/* past where the data where hit. */
10834
10843
var yfractop = self . options . logYFracTop , yfracbottom = self . options . logYFracBottom ;
10835
10844
10836
- var y0Intitial = ( ( y0 <= 0.0 ) ? 0.1 : y0 ) ;
10845
+ var y0Intitial = ( ( y0 <= 0.0 ) ? self . options . logYAxisMin : y0 ) ;
10837
10846
var y1Intitial = ( ( y1 <= 0.0 ) ? 1.0 : y1 ) ;
10838
10847
y1Intitial = ( ( y1Intitial <= y0Intitial ) ? 1.1 * y0Intitial : y1Intitial ) ;
10839
10848
@@ -10846,7 +10855,7 @@ SpectrumChartD3.prototype.getYAxisDomain = function(){
10846
10855
var ylower = Math . pow ( 10.0 , logLowerY ) ;
10847
10856
var yupper = Math . pow ( 10.0 , logUpperY ) ;
10848
10857
10849
- y0 = ( ( y0 <= 0.0 ) ? 0.1 : ylower ) ;
10858
+ y0 = ( ( y0 <= 0.0 ) ? self . options . logYAxisMin : ylower ) ;
10850
10859
y1 = ( ( y1 <= 0.0 ) ? 1.0 : yupper ) ;
10851
10860
} else if ( self . options . yscale == "lin" ) {
10852
10861
y0 = ( ( y0 <= 0.0 ) ? ( 1 + self . options . linYFracBottom ) * y0 : ( 1 - self . options . linYFracBottom ) * y0 ) ;
0 commit comments