@@ -1498,28 +1498,50 @@ axes.makeClipPaths = function(gd) {
1498
1498
} ) ;
1499
1499
} ;
1500
1500
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 ) {
1509
1534
var fullLayout = gd . _fullLayout ;
1510
- var ax ;
1511
1535
var independent = false ;
1536
+ var ax ;
1512
1537
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 ;
1517
1540
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 ;
1521
1543
1522
- if ( axid === 'redraw' ) {
1544
+ if ( arg === 'redraw' ) {
1523
1545
fullLayout . _paper . selectAll ( 'g.subplot' ) . each ( function ( subplot ) {
1524
1546
var plotinfo = fullLayout . _plots [ subplot ] ;
1525
1547
var xa = plotinfo . xaxis ;
@@ -1534,22 +1556,24 @@ axes.doTicks = function(gd, axid, skipTitle) {
1534
1556
} ) ;
1535
1557
}
1536
1558
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 ) ;
1548
1571
}
1549
1572
1550
1573
// set scaling to pixels
1551
1574
ax . setScale ( ) ;
1552
1575
1576
+ var axid = ax . _id ;
1553
1577
var axLetter = axid . charAt ( 0 ) ;
1554
1578
var counterLetter = axes . counterLetter ( axid ) ;
1555
1579
var vals = ax . _vals = axes . calcTicks ( ax ) ;
0 commit comments