@@ -24,17 +24,20 @@ $(function() {
2424 // Create container for axis controls
2525 let container = d3 . select ( this . element . context ) ,
2626 xaxis = container . append ( "div" )
27+ . style ( "user-select" , "none" )
2728 . attr ( "class" , "row" )
2829 . append ( "div" )
2930 . attr ( "class" , "col" ) ,
3031 yaxis = container . append ( "div" )
32+ . style ( "user-select" , "none" )
3133 . attr ( "class" , "row" )
3234 . append ( "div" )
3335 . attr ( "class" , "col" ) ;
3436
3537 // Create x axis controls
3638 xaxis . append ( "label" )
3739 . attr ( "for" , "xmin-text" )
40+ . attr ( "id" , "x-axis-inputs-label" )
3841 . text ( "x axis limits:" ) ;
3942
4043 this . _elements . xmin_text = xaxis . append ( "input" )
@@ -52,9 +55,65 @@ $(function() {
5255 . style ( "margin-left" , "5px" )
5356 . on ( "change" , function ( ) { $ ( "#axes-input" ) . axes_input ( "change_axis_limits" , null , this . value , null , null ) } ) ;
5457
58+ //Appends the "+" svg/button for the xaxis
59+ let x_plus = xaxis . append ( "div" )
60+ . attr ( "title" , "x_plus" )
61+ . style ( "margin-left" , "5px" )
62+ . style ( "display" , "inline-block" )
63+ . style ( "cursor" , "pointer" )
64+ . append ( "svg" )
65+ . attr ( "width" , "24px" )
66+ . attr ( "height" , "20px" )
67+ . attr ( "baseProfile" , "full" )
68+ . attr ( "viewBox" , "0 0 25 26" )
69+ . attr ( "version" , "1.1" )
70+ . attr ( "xmlns" , "http://www.w3.org/2000/svg" )
71+ . on ( "click" , function ( ) {
72+ let value_change = 50 ;
73+ let xmin = parseInt ( $ ( "#axes-input" ) . axes_input ( "get_axis_values" , 1 , value_change ) ) ;
74+ let xmax = parseInt ( $ ( "#axes-input" ) . axes_input ( "get_axis_values" , 0 , value_change ) ) ;
75+ $ ( "#axes-input" ) . axes_input ( "change_axis_limits" , xmin - value_change , xmax + value_change , null , null )
76+ } )
77+
78+ x_plus . append ( "path" )
79+ . attr ( "d" , "m 1 1 l 24 0 l 0 24 l -24 0 l 0 -24 m 4 12 l 14 0 m -6 -8 l 0 16" )
80+ . attr ( "fill" , "none" )
81+ . attr ( "stroke" , "orange" )
82+ . attr ( "stroke-width" , 2 )
83+ . node ( ) ;
84+
85+ //Appends the "-" svg/button for the xaxis
86+ let x_minus = xaxis . append ( "div" )
87+ . attr ( "title" , "x_minus" )
88+ . style ( "margin-left" , "5px" )
89+ . style ( "display" , "inline-block" )
90+ . style ( "cursor" , "pointer" )
91+ . append ( "svg" )
92+ . attr ( "width" , "24px" )
93+ . attr ( "height" , "20px" )
94+ . attr ( "baseProfile" , "full" )
95+ . attr ( "viewBox" , "0 0 25 26" )
96+ . attr ( "version" , "1.1" )
97+ . attr ( "xmlns" , "http://www.w3.org/2000/svg" )
98+ . on ( "click" , function ( ) {
99+ let value_change = 50 ;
100+ let xmin = parseInt ( $ ( "#axes-input" ) . axes_input ( "get_axis_values" , 1 , value_change ) ) ;
101+ let xmax = parseInt ( $ ( "#axes-input" ) . axes_input ( "get_axis_values" , 0 , value_change ) ) ;
102+ $ ( "#axes-input" ) . axes_input ( "change_axis_limits" , xmin + value_change , xmax - value_change , null , null )
103+ } )
104+
105+ x_minus . append ( "path" )
106+ . attr ( "d" , "m 1 1 l 24 0 l 0 24 l -24 0 l 0 -24 m 4 12 l 14 0" )
107+ . attr ( "fill" , "none" )
108+ . attr ( "stroke" , "orange" )
109+ . attr ( "stroke-width" , 2 )
110+ . node ( ) ;
111+
112+
55113 // Create y axis controls
56114 yaxis . append ( "label" )
57115 . attr ( "for" , "ymin-text" )
116+ . attr ( "id" , "y-axis-inputs-label" )
58117 . text ( "y axis limits:" ) ;
59118
60119 this . _elements . ymin_text = yaxis . append ( "input" )
@@ -71,6 +130,60 @@ $(function() {
71130 . style ( "width" , "50px" )
72131 . style ( "margin-left" , "5px" )
73132 . on ( "change" , function ( ) { $ ( "#axes-input" ) . axes_input ( "change_axis_limits" , null , null , null , this . value ) } )
133+
134+ //Appends the "+" svg/button for the yaxis
135+ let y_plus = yaxis . append ( "div" )
136+ . attr ( "title" , "y_plus" )
137+ . style ( "margin-left" , "5px" )
138+ . style ( "display" , "inline-block" )
139+ . style ( "cursor" , "pointer" )
140+ . append ( "svg" )
141+ . attr ( "width" , "24px" )
142+ . attr ( "height" , "20px" )
143+ . attr ( "baseProfile" , "full" )
144+ . attr ( "viewBox" , "0 0 25 26" )
145+ . attr ( "version" , "1.1" )
146+ . attr ( "xmlns" , "http://www.w3.org/2000/svg" )
147+ . on ( "click" , function ( ) {
148+ let value_change = .1 ;
149+ let ymin = parseFloat ( $ ( "#axes-input" ) . axes_input ( "get_axis_values" , 3 , value_change ) ) ;
150+ let ymax = parseFloat ( $ ( "#axes-input" ) . axes_input ( "get_axis_values" , 2 , value_change ) ) ;
151+ $ ( "#axes-input" ) . axes_input ( "change_axis_limits" , null , null , ymin - value_change , ymax + value_change ) ;
152+ } )
153+
154+ y_plus . append ( "path" )
155+ . attr ( "d" , "m 1 1 l 24 0 l 0 24 l -24 0 l 0 -24 m 4 12 l 14 0 m -6 -8 l 0 16" )
156+ . attr ( "fill" , "none" )
157+ . attr ( "stroke" , "orange" )
158+ . attr ( "stroke-width" , 2 )
159+ . node ( ) ;
160+
161+ //Appends the "-" svg/button for the yaxis
162+ let y_minus = yaxis . append ( "div" )
163+ . attr ( "title" , "y_minus" )
164+ . style ( "margin-left" , "5px" )
165+ . style ( "display" , "inline-block" )
166+ . style ( "cursor" , "pointer" )
167+ . append ( "svg" )
168+ . attr ( "width" , "24px" )
169+ . attr ( "height" , "20px" )
170+ . attr ( "baseProfile" , "full" )
171+ . attr ( "viewBox" , "0 0 25 26" )
172+ . attr ( "version" , "1.1" )
173+ . attr ( "xmlns" , "http://www.w3.org/2000/svg" )
174+ . on ( "click" , function ( ) {
175+ let value_change = .1 ;
176+ let ymin = parseFloat ( $ ( "#axes-input" ) . axes_input ( "get_axis_values" , 3 , value_change ) ) ;
177+ let ymax = parseFloat ( $ ( "#axes-input" ) . axes_input ( "get_axis_values" , 2 , value_change ) ) ;
178+ $ ( "#axes-input" ) . axes_input ( "change_axis_limits" , null , null , parseFloat ( ymin + value_change ) , parseFloat ( ymax - value_change ) ) ;
179+ } )
180+
181+ y_minus . append ( "path" )
182+ . attr ( "d" , "m 1 1 l 24 0 l 0 24 l -24 0 l 0 -24 m 4 12 l 14 0" )
183+ . attr ( "fill" , "none" )
184+ . attr ( "stroke" , "orange" )
185+ . attr ( "stroke-width" , 2 )
186+ . node ( ) ;
74187 } ,
75188
76189 change_axis_limits : function ( xmin , xmax , ymin , ymax , change_plot = true ) {
@@ -99,11 +212,11 @@ $(function() {
99212 } ;
100213
101214 // Change the text boxes
102- this . _elements . xmin_text . node ( ) . value = this . xmin ;
103- this . _elements . xmax_text . node ( ) . value = this . xmax ;
215+ this . _elements . xmin_text . node ( ) . value = Math . round ( this . xmin * 100 ) / 100 ;
216+ this . _elements . xmax_text . node ( ) . value = Math . round ( this . xmax * 100 ) / 100 ;
104217 // If the strands are combined, the y axis limit text boxes show 0 for the lower limit and the difference for the upper limit
105- this . _elements . ymin_text . node ( ) . value = this . combined ? 0 : this . ymin ;
106- this . _elements . ymax_text . node ( ) . value = this . combined ? this . ymax - this . ymin : this . ymax ;
218+ this . _elements . ymin_text . node ( ) . value = this . combined ? 0 : Math . round ( this . ymin * 100 ) / 100 ;
219+ this . _elements . ymax_text . node ( ) . value = this . combined ? Math . round ( ( this . ymax - this . ymin ) * 100 ) / 100 : Math . round ( this . ymax * 100 ) / 100 ;
107220
108221 // Change the plot, if requested
109222 if ( change_plot ) {
@@ -112,6 +225,25 @@ $(function() {
112225 }
113226 } ,
114227
228+ //Returns the current value an axis given an integer and a value the axis is being changed by (so the function calling it can default to zero)
229+ get_axis_values : function ( axis , change_val ) {
230+ if ( parseInt ( axis ) == 0 ) {
231+ return ( this . xmax > change_val ) ? this . xmax : change_val ;
232+ }
233+ else if ( parseInt ( axis ) == 1 ) {
234+ return ( this . xmin < - change_val ) ? this . xmin : - change_val ;
235+ }
236+ else if ( parseInt ( axis ) == 2 ) {
237+ return ( this . ymax > change_val ) ? this . ymax : change_val ;
238+ }
239+ else if ( parseInt ( axis ) == 3 ) {
240+ return ( this . ymin < - change_val ) ? this . ymin : - change_val ;
241+ }
242+ else {
243+ return null ;
244+ }
245+ } ,
246+
115247 toggle_combined : function ( combined ) {
116248 this . combined = combined ;
117249 // If the strands are combined, the y axis limit text boxes show 0 for the lower limit and the difference for the upper limit
0 commit comments