File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -381,6 +381,42 @@ var colorLegendWidget = function (arg) {
381381 return d3 . format ( '.' + precision + 'f' ) ( number ) ;
382382 } ;
383383
384+ /**
385+ * Get/Set width.
386+ *
387+ * @param {number } [width] If not specified, return the current width. If
388+ * specified, set a new width.
389+ * @returns {this|number }
390+ */
391+ this . width = function ( width ) {
392+ if ( width === undefined ) {
393+ return m_width ;
394+ } else if ( width !== m_width ) {
395+ m_width = width ;
396+ m_this . _prepareCategories ( m_categories ) ;
397+ m_this . _draw ( ) ;
398+ }
399+ return m_this ;
400+ } ;
401+
402+ /**
403+ * Get/Set ticks.
404+ *
405+ * @param {number } [ticks] If not specified, return the current ticks. If
406+ * specified, set a new ticks.
407+ * @returns {this|number }
408+ */
409+ this . ticks = function ( ticks ) {
410+ if ( ticks === undefined ) {
411+ return m_ticks ;
412+ } else if ( ticks !== m_ticks ) {
413+ m_ticks = ticks ;
414+ m_this . _prepareCategories ( m_categories ) ;
415+ m_this . _draw ( ) ;
416+ }
417+ return m_this ;
418+ } ;
419+
384420 /**
385421 * Show the popup based on current mouse event.
386422 * @param {d3.event } event The triggering d3 event.
Original file line number Diff line number Diff line change @@ -229,4 +229,17 @@ describe('color legend', function () {
229229 expect ( Math . abs ( $ ( container ) . find ( '.color-legend-popup' ) . text ( ) - 320 ) ) . toBeLessThan ( 2 ) ;
230230 $ ( legends [ 1 ] ) . find ( 'svg>rect' ) [ 0 ] . dispatchEvent ( mouseout ) ;
231231 } ) ;
232+
233+ it ( 'width and ticks' , function ( ) {
234+ expect ( legendWidget . width ( ) ) . toBe ( 300 ) ;
235+ expect ( legendWidget . width ( 400 ) ) . toBe ( legendWidget ) ;
236+ expect ( legendWidget . width ( ) ) . toBe ( 400 ) ;
237+ expect ( legendWidget . width ( 400 ) ) . toBe ( legendWidget ) ;
238+ expect ( legendWidget . width ( ) ) . toBe ( 400 ) ;
239+ expect ( legendWidget . ticks ( ) ) . toBe ( 6 ) ;
240+ expect ( legendWidget . ticks ( 8 ) ) . toBe ( legendWidget ) ;
241+ expect ( legendWidget . ticks ( ) ) . toBe ( 8 ) ;
242+ expect ( legendWidget . ticks ( 8 ) ) . toBe ( legendWidget ) ;
243+ expect ( legendWidget . ticks ( ) ) . toBe ( 8 ) ;
244+ } ) ;
232245} ) ;
You can’t perform that action at this time.
0 commit comments