@@ -1456,6 +1456,10 @@ axes.findSubplotsWithAxis = function(subplots, ax) {
14561456// makeClipPaths: prepare clipPaths for all single axes and all possible xy pairings
14571457axes . makeClipPaths = function ( gd ) {
14581458 var fullLayout = gd . _fullLayout ;
1459+
1460+ // for more info: https://github.com/plotly/plotly.js/issues/2595
1461+ if ( fullLayout . _hasOnlyLargeSploms ) return ;
1462+
14591463 var fullWidth = { _offset : 0 , _length : fullLayout . width , _id : '' } ;
14601464 var fullHeight = { _offset : 0 , _length : fullLayout . height , _id : '' } ;
14611465 var xaList = axes . list ( gd , 'x' , true ) ;
@@ -1494,58 +1498,95 @@ axes.makeClipPaths = function(gd) {
14941498 } ) ;
14951499} ;
14961500
1497- // doTicks: draw ticks, grids, and tick labels
1498- // axid: 'x', 'y', 'x2' etc,
1499- // blank to do all,
1500- // 'redraw' to force full redraw, and reset:
1501- // ax._r (stored range for use by zoom/pan)
1502- // ax._rl (stored linearized range for use by zoom/pan)
1503- // or can pass in an axis object directly
1504- axes . doTicks = function ( gd , axid , skipTitle ) {
1501+ /** Main multi-axis drawing routine!
1502+ *
1503+ * @param {DOM element } gd : graph div
1504+ * @param {string or array of strings } arg : polymorphic argument
1505+ * @param {boolean } skipTitle : optional flag to skip axis title draw/update
1506+ *
1507+ * Signature 1: Axes.doTicks(gd, 'redraw')
1508+ * use this to clear and redraw all axes on graph
1509+ *
1510+ * Signature 2: Axes.doTicks(gd, '')
1511+ * use this to draw all axes on graph w/o the selectAll().remove()
1512+ * of the 'redraw' signature
1513+ *
1514+ * Signature 3: Axes.doTicks(gd, [axId, axId2, ...])
1515+ * where the items are axis id string,
1516+ * use this to update multiple axes in one call
1517+ *
1518+ * N.B doTicks updates:
1519+ * - ax._r (stored range for use by zoom/pan)
1520+ * - ax._rl (stored linearized range for use by zoom/pan)
1521+ */
1522+ axes . doTicks = function ( gd , arg , skipTitle ) {
15051523 var fullLayout = gd . _fullLayout ;
1506- var ax ;
1507- var independent = false ;
15081524
1509- // allow passing an independent axis object instead of id
1510- if ( typeof axid === 'object' ) {
1511- ax = axid ;
1512- axid = ax . _id ;
1513- independent = true ;
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+ } ) ;
15141538 }
1515- else {
1516- ax = axes . getFromId ( gd , axid ) ;
1517-
1518- if ( axid === 'redraw' ) {
1519- fullLayout . _paper . selectAll ( 'g.subplot' ) . each ( function ( subplot ) {
1520- var plotinfo = fullLayout . _plots [ subplot ] ;
1521- var xa = plotinfo . xaxis ;
1522- var ya = plotinfo . yaxis ;
1523-
1524- plotinfo . xaxislayer . selectAll ( '.' + xa . _id + 'tick' ) . remove ( ) ;
1525- plotinfo . yaxislayer . selectAll ( '.' + ya . _id + 'tick' ) . remove ( ) ;
1526- if ( plotinfo . gridlayer ) plotinfo . gridlayer . selectAll ( 'path' ) . remove ( ) ;
1527- if ( plotinfo . zerolinelayer ) plotinfo . zerolinelayer . selectAll ( 'path' ) . remove ( ) ;
1528- fullLayout . _infolayer . select ( '.g-' + xa . _id + 'title' ) . remove ( ) ;
1529- fullLayout . _infolayer . select ( '.g-' + ya . _id + 'title' ) . remove ( ) ;
1530- } ) ;
1531- }
15321539
1533- if ( ! axid || axid === 'redraw' ) {
1534- return Lib . syncOrAsync ( axes . list ( gd , '' , true ) . map ( function ( ax ) {
1535- return function ( ) {
1536- if ( ! ax . _id ) return ;
1537- var axDone = axes . doTicks ( gd , ax . _id ) ;
1538- ax . _r = ax . range . slice ( ) ;
1539- ax . _rl = Lib . simpleMap ( ax . _r , ax . r2l ) ;
1540- return axDone ;
1541- } ;
1542- } ) ) ;
1543- }
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 ;
1576+ var independent = false ;
1577+ var ax ;
1578+
1579+ if ( Lib . isPlainObject ( arg ) ) {
1580+ ax = arg ;
1581+ independent = true ;
1582+ } else {
1583+ ax = axes . getFromId ( gd , arg ) ;
15441584 }
15451585
15461586 // set scaling to pixels
15471587 ax . setScale ( ) ;
15481588
1589+ var axid = ax . _id ;
15491590 var axLetter = axid . charAt ( 0 ) ;
15501591 var counterLetter = axes . counterLetter ( axid ) ;
15511592 var vals = ax . _vals = axes . calcTicks ( ax ) ;
0 commit comments