it('should not swap noSwapAttrs', function() { // for reference: // noSwapAttrs = ['anchor', 'domain', 'overlaying', 'position', 'side', 'tickangle']; var gd = { data: [{x: [1,2,3], y: [1,2,3]}], layout: { xaxis: { anchor: 'free', domain: [0, 1], overlaying: false, position: 0.2, tickangle: 60 }, yaxis: { anchor: 'x', domain: [0.1, 0.9] } } }; var expectedLayoutAfter = Plotly.Lib.extendDeep({}, gd.layout); expectedLayoutAfter.xaxis.type = 'linear'; expectedLayoutAfter.yaxis.type = 'linear'; Plotly.Plots.supplyDefaults(gd); Plotly.Axes.swap(gd, [0]); expect(gd.layout.xaxis).toEqual(expectedLayoutAfter.xaxis); expect(gd.layout.yaxis).toEqual(expectedLayoutAfter.yaxis); });
it('should swap most attributes and fix placeholder titles', function() { var gd = { data: [{x: [1,2,3], y: [1,2,3]}], layout: { xaxis: { title: 'A Title!!!', type: 'log', autorange: 'reversed', rangemode: 'tozero', tickmode: 'auto', nticks: 23, ticks: 'outside', mirror: 'ticks', ticklen: 12, tickwidth: 4, tickcolor: '#f00' }, yaxis: { title: 'Click to enter Y axis title', type: 'date' } } }; var expectedYaxis = Plotly.Lib.extendDeep({}, gd.layout.xaxis), expectedXaxis = { title: 'Click to enter X axis title', type: 'date' }; Plotly.Plots.supplyDefaults(gd); Plotly.Axes.swap(gd, [0]); expect(gd.layout.xaxis).toEqual(expectedXaxis); expect(gd.layout.yaxis).toEqual(expectedYaxis); });
function coerce(attr, dflt) { return Plotly.Lib.coerce(axIn, axOut, Plotly.Axes.layoutAttributes, attr, dflt); }