@@ -1498,74 +1498,87 @@ axes.makeClipPaths = function(gd) {
14981498 } ) ;
14991499} ;
15001500
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)
1501+ /** Main multi-axis drawing routine!
15061502 *
15071503 * @param {DOM element } gd : graph div
1508- * @param {object or string or array of strings } arg : polymorphic argument
1504+ * @param {string or array of strings } arg : polymorphic argument
15091505 * @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
15171506 *
1518- * Signature 3 : Axes.doTicks(gd, 'redraw')
1507+ * Signature 1 : Axes.doTicks(gd, 'redraw')
15191508 * use this to clear and redraw all axes on graph
15201509 *
1521- * Signature 4 : Axes.doTicks(gd, '')
1510+ * Signature 2 : Axes.doTicks(gd, '')
15221511 * use this to draw all axes on graph w/o the selectAll().remove()
15231512 * of the 'redraw' signature
15241513 *
1525- * Signature 5 : Axes.doTicks(gd, [axId, axId2, ...])
1514+ * Signature 3 : Axes.doTicks(gd, [axId, axId2, ...])
15261515 * where the items are axis id string,
15271516 * use this to update multiple axes in one call
15281517 *
1529- * N.B signatures 3, 4 and 5 reset :
1518+ * N.B doTicks updates :
15301519 * - ax._r (stored range for use by zoom/pan)
15311520 * - ax._rl (stored linearized range for use by zoom/pan)
15321521 */
15331522axes . doTicks = function ( gd , arg , skipTitle ) {
15341523 var fullLayout = gd . _fullLayout ;
1524+
1525+ if ( arg === 'redraw' ) {
1526+ fullLayout . _paper . selectAll ( 'g.subplot' ) . each ( function ( subplot ) {
1527+ var plotinfo = fullLayout . _plots [ subplot ] ;
1528+ var xa = plotinfo . xaxis ;
1529+ var ya = plotinfo . yaxis ;
1530+
1531+ plotinfo . xaxislayer . selectAll ( '.' + xa . _id + 'tick' ) . remove ( ) ;
1532+ plotinfo . yaxislayer . selectAll ( '.' + ya . _id + 'tick' ) . remove ( ) ;
1533+ if ( plotinfo . gridlayer ) plotinfo . gridlayer . selectAll ( 'path' ) . remove ( ) ;
1534+ if ( plotinfo . zerolinelayer ) plotinfo . zerolinelayer . selectAll ( 'path' ) . remove ( ) ;
1535+ fullLayout . _infolayer . select ( '.g-' + xa . _id + 'title' ) . remove ( ) ;
1536+ fullLayout . _infolayer . select ( '.g-' + ya . _id + 'title' ) . remove ( ) ;
1537+ } ) ;
1538+ }
1539+
1540+ var axList = ( ! arg || arg === 'redraw' ) ? axes . listIds ( gd ) : arg ;
1541+
1542+ Lib . syncOrAsync ( axList . map ( function ( axid ) {
1543+ return function ( ) {
1544+ if ( ! axid ) return ;
1545+
1546+ var axDone = axes . doTicksSingle ( gd , axid , skipTitle ) ;
1547+
1548+ var ax = axes . getFromId ( gd , axid ) ;
1549+ ax . _r = ax . range . slice ( ) ;
1550+ ax . _rl = Lib . simpleMap ( ax . _r , ax . r2l ) ;
1551+
1552+ return axDone ;
1553+ } ;
1554+ } ) ) ;
1555+ } ;
1556+
1557+ /** Per axis drawing routine!
1558+ *
1559+ * This routine draws axis ticks and much more (... grids, labels, title etc.)
1560+ * Supports multiple argument signatures.
1561+ * N.B. this thing is async in general (because of MathJax rendering)
1562+ *
1563+ * @param {DOM element } gd : graph div
1564+ * @param {string or array of strings } arg : polymorphic argument
1565+ * @param {boolean } skipTitle : optional flag to skip axis title draw/update
1566+ * @return {promise }
1567+ *
1568+ * Signature 1: Axes.doTicks(gd, ax)
1569+ * where ax is an axis object as in fullLayout
1570+ *
1571+ * Signature 2: Axes.doTicks(gd, axId)
1572+ * where axId is a axis id string
1573+ */
1574+ axes . doTicksSingle = function ( gd , arg , skipTitle ) {
1575+ var fullLayout = gd . _fullLayout ;
15351576 var independent = false ;
15361577 var ax ;
15371578
15381579 if ( Lib . isPlainObject ( arg ) ) {
15391580 ax = arg ;
15401581 independent = true ;
1541- } else if ( ! arg || arg === 'redraw' || Array . isArray ( arg ) ) {
1542- var axList = ( ! arg || arg === 'redraw' ) ? axes . listIds ( gd ) : arg ;
1543-
1544- if ( arg === 'redraw' ) {
1545- fullLayout . _paper . selectAll ( 'g.subplot' ) . each ( function ( subplot ) {
1546- var plotinfo = fullLayout . _plots [ subplot ] ;
1547- var xa = plotinfo . xaxis ;
1548- var ya = plotinfo . yaxis ;
1549-
1550- plotinfo . xaxislayer . selectAll ( '.' + xa . _id + 'tick' ) . remove ( ) ;
1551- plotinfo . yaxislayer . selectAll ( '.' + ya . _id + 'tick' ) . remove ( ) ;
1552- if ( plotinfo . gridlayer ) plotinfo . gridlayer . selectAll ( 'path' ) . remove ( ) ;
1553- if ( plotinfo . zerolinelayer ) plotinfo . zerolinelayer . selectAll ( 'path' ) . remove ( ) ;
1554- fullLayout . _infolayer . select ( '.g-' + xa . _id + 'title' ) . remove ( ) ;
1555- fullLayout . _infolayer . select ( '.g-' + ya . _id + 'title' ) . remove ( ) ;
1556- } ) ;
1557- }
1558-
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- } ) ) ;
15691582 } else {
15701583 ax = axes . getFromId ( gd , arg ) ;
15711584 }
0 commit comments