@@ -1498,28 +1498,50 @@ axes.makeClipPaths = function(gd) {
14981498 } ) ;
14991499} ;
15001500
1501- // doTicks: draw ticks, grids, and tick labels
1502- // axid: 'x', 'y', 'x2' etc,
1503- // blank to do all,
1504- // 'redraw' to force full redraw, and reset:
1505- // ax._r (stored range for use by zoom/pan)
1506- // ax._rl (stored linearized range for use by zoom/pan)
1507- // or can pass in an axis object directly
1508- axes . doTicks = function ( gd , axid , skipTitle ) {
1501+ /** Main axis drawing routine!
1502+ *
1503+ * This routine draws axis ticks and much more (... grids, labels, title etc.)
1504+ * Supports multiple argument signatures.
1505+ * N.B. this thing is async in general (because of MathJax rendering)
1506+ *
1507+ * @param {DOM element } gd : graph div
1508+ * @param {object or string or array of strings } arg : polymorphic argument
1509+ * @param {boolean } skipTitle : optional flag to skip axis title draw/update
1510+ * @return {promise }
1511+ *
1512+ * Signature 1: Axes.doTicks(gd, ax)
1513+ * where ax is an axis object as in fullLayout
1514+ *
1515+ * Signature 2: Axes.doTicks(gd, axId)
1516+ * where axId is a axis id string
1517+ *
1518+ * Signature 3: Axes.doTicks(gd, 'redraw')
1519+ * use this to clear and redraw all axes on graph
1520+ *
1521+ * Signature 4: Axes.doTicks(gd, '')
1522+ * use this to draw all axes on graph w/o the selectAll().remove()
1523+ * of the 'redraw' signature
1524+ *
1525+ * Signature 5: Axes.doTicks(gd, [axId, axId2, ...])
1526+ * where the items are axis id string,
1527+ * use this to update multiple axes in one call
1528+ *
1529+ * N.B signatures 3, 4 and 5 reset:
1530+ * - ax._r (stored range for use by zoom/pan)
1531+ * - ax._rl (stored linearized range for use by zoom/pan)
1532+ */
1533+ axes . doTicks = function ( gd , arg , skipTitle ) {
15091534 var fullLayout = gd . _fullLayout ;
1510- var ax ;
15111535 var independent = false ;
1536+ var ax ;
15121537
1513- // allow passing an independent axis object instead of id
1514- if ( typeof axid === 'object' ) {
1515- ax = axid ;
1516- axid = ax . _id ;
1538+ if ( Lib . isPlainObject ( arg ) ) {
1539+ ax = arg ;
15171540 independent = true ;
1518- }
1519- else {
1520- ax = axes . getFromId ( gd , axid ) ;
1541+ } else if ( ! arg || arg === 'redraw' || Array . isArray ( arg ) ) {
1542+ var axList = ( ! arg || arg === 'redraw' ) ? axes . listIds ( gd ) : arg ;
15211543
1522- if ( axid === 'redraw' ) {
1544+ if ( arg === 'redraw' ) {
15231545 fullLayout . _paper . selectAll ( 'g.subplot' ) . each ( function ( subplot ) {
15241546 var plotinfo = fullLayout . _plots [ subplot ] ;
15251547 var xa = plotinfo . xaxis ;
@@ -1534,22 +1556,24 @@ axes.doTicks = function(gd, axid, skipTitle) {
15341556 } ) ;
15351557 }
15361558
1537- if ( ! axid || axid === 'redraw' ) {
1538- return Lib . syncOrAsync ( axes . list ( gd , '' , true ) . map ( function ( ax ) {
1539- return function ( ) {
1540- if ( ! ax . _id ) return ;
1541- var axDone = axes . doTicks ( gd , ax . _id ) ;
1542- ax . _r = ax . range . slice ( ) ;
1543- ax . _rl = Lib . simpleMap ( ax . _r , ax . r2l ) ;
1544- return axDone ;
1545- } ;
1546- } ) ) ;
1547- }
1559+ return Lib . syncOrAsync ( axList . map ( function ( a ) {
1560+ return function ( ) {
1561+ if ( ! a ) return ;
1562+ var axDone = axes . doTicks ( gd , a ) ;
1563+ var ax = axes . getFromId ( gd , a ) ;
1564+ ax . _r = ax . range . slice ( ) ;
1565+ ax . _rl = Lib . simpleMap ( ax . _r , ax . r2l ) ;
1566+ return axDone ;
1567+ } ;
1568+ } ) ) ;
1569+ } else {
1570+ ax = axes . getFromId ( gd , arg ) ;
15481571 }
15491572
15501573 // set scaling to pixels
15511574 ax . setScale ( ) ;
15521575
1576+ var axid = ax . _id ;
15531577 var axLetter = axid . charAt ( 0 ) ;
15541578 var counterLetter = axes . counterLetter ( axid ) ;
15551579 var vals = ax . _vals = axes . calcTicks ( ax ) ;
0 commit comments