diff --git a/lib/index-basic.js b/lib/index-basic.js index 590f545eec0..218772bc2f9 100644 --- a/lib/index-basic.js +++ b/lib/index-basic.js @@ -4,6 +4,7 @@ var Plotly = require('./core'); Plotly.register([ // traces + require('./scatter'), require('./bar'), require('./pie'), diff --git a/lib/index-cartesian.js b/lib/index-cartesian.js index db9855a26b6..3735d2de0be 100644 --- a/lib/index-cartesian.js +++ b/lib/index-cartesian.js @@ -4,6 +4,7 @@ var Plotly = require('./core'); Plotly.register([ // traces + require('./scatter'), require('./bar'), require('./box'), require('./heatmap'), diff --git a/lib/index-strict.js b/lib/index-strict.js index e57d825d435..556d1e13f83 100644 --- a/lib/index-strict.js +++ b/lib/index-strict.js @@ -4,6 +4,7 @@ var Plotly = require('./core'); Plotly.register([ // traces + require('./scatter'), require('./bar'), require('./box'), require('./heatmap'), diff --git a/lib/index.js b/lib/index.js index 77d07357c88..8ae96f99c30 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,6 +4,7 @@ var Plotly = require('./core'); Plotly.register([ // traces + require('./scatter'), require('./bar'), require('./box'), require('./heatmap'), diff --git a/src/core.js b/src/core.js index d9ea5c74115..235a16741d8 100644 --- a/src/core.js +++ b/src/core.js @@ -26,9 +26,6 @@ for(var i = 0; i < methodNames.length; i++) { }); } -// scatter is the only trace included by default -register(require('./traces/scatter')); - // register all registrable components modules register([ require('./components/legend'), diff --git a/src/plot_api/plot_schema.js b/src/plot_api/plot_schema.js index 8833e688fd0..a25ba2a7d71 100644 --- a/src/plot_api/plot_schema.js +++ b/src/plot_api/plot_schema.js @@ -273,7 +273,13 @@ exports.getTraceValObject = function(trace, parts) { // first look in the module for this trace // components have already merged their trace attributes in here var _module = trace._module; - if(!_module) _module = (Registry.modules[trace.type || baseAttributes.type.dflt] || {})._module; + if(!_module) _module = (Registry.modules[trace.type] || {})._module; + if(!_module) { + var scatter = Registry.modules[baseAttributes.type.dflt]; + if(scatter) { + _module = scatter._module; + } + } if(!_module) return false; moduleAttrs = _module.attributes; diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index dd35b78a28f..f415f8ae615 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -91,7 +91,7 @@ function expandRange(range) { */ axes.coerceRef = function(containerIn, containerOut, gd, attr, dflt, extraOption) { var axLetter = attr.charAt(attr.length - 1); - var axlist = gd._fullLayout._subplots[axLetter + 'axis']; + var axlist = gd._fullLayout._subplots[axLetter + 'axis'] || []; var refAttr = attr + 'ref'; var attrDef = {}; diff --git a/src/plots/cartesian/axis_ids.js b/src/plots/cartesian/axis_ids.js index efb6fcf7147..efbc8681468 100644 --- a/src/plots/cartesian/axis_ids.js +++ b/src/plots/cartesian/axis_ids.js @@ -72,9 +72,9 @@ exports.listIds = function(gd, axLetter) { var fullLayout = gd._fullLayout; if(!fullLayout) return []; - var subplotLists = fullLayout._subplots; - if(axLetter) return subplotLists[axLetter + 'axis']; - return subplotLists.xaxis.concat(subplotLists.yaxis); + var subplotLists = fullLayout._subplots || {}; + if(axLetter) return subplotLists[axLetter + 'axis'] || []; + return (subplotLists.xaxis || []).concat(subplotLists.yaxis || []); }; // get an axis object from its id 'x','x2' etc diff --git a/src/plots/cartesian/include_components.js b/src/plots/cartesian/include_components.js index ad27aeab79c..fd9981a912d 100644 --- a/src/plots/cartesian/include_components.js +++ b/src/plots/cartesian/include_components.js @@ -3,6 +3,7 @@ var Registry = require('../../registry'); var Lib = require('../../lib'); var axisIds = require('./axis_ids'); +var cartesianIdRegex = require('../../plots/cartesian/constants').idRegex; /** * Factory function for checking component arrays for subplot references. @@ -21,7 +22,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { if(!Array.isArray(array)) return; var Cartesian = Registry.subplotsRegistry.cartesian; - var idRegex = Cartesian.idRegex; + var idRegex = cartesianIdRegex; var subplots = layoutOut._subplots; var xaList = subplots.xaxis; var yaList = subplots.yaxis; diff --git a/src/plots/plots.js b/src/plots/plots.js index b0c4fbfce90..5f735b9eadb 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -843,7 +843,7 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa _fullLayout: newFullLayout }; - var ids = newSubplotList.cartesian.concat(newSubplotList.gl2d || []); + var ids = (newSubplotList.cartesian || []).concat(newSubplotList.gl2d || []); for(i = 0; i < ids.length; i++) { var id = ids[i]; diff --git a/src/registry.js b/src/registry.js index 6fc6bf4d981..479e69c9e81 100644 --- a/src/registry.js +++ b/src/registry.js @@ -7,7 +7,7 @@ var isPlainObject = require('./lib/is_plain_object'); var addStyleRule = require('./lib/dom').addStyleRule; var ExtendModule = require('./lib/extend'); -var basePlotAttributes = require('./plots/attributes'); +var dfltTrace = require('./plots/attributes').type.dflt; var baseLayoutAttributes = require('./plots/layout_attributes'); var extendFlat = ExtendModule.extendFlat; @@ -140,7 +140,13 @@ exports.traceIs = function(traceType, category) { Loggers.log('Unrecognized trace type ' + traceType + '.'); } - _module = exports.modules[basePlotAttributes.type.dflt]; + _module = exports.modules[dfltTrace]; + if(!_module) { + Loggers.log('The default trace type ' + dfltTrace + ' is not registered.'); + + // in case the category starts with no return true otherwise false + return category.indexOf('no') === 0 ? true : false; + } } return !!_module.categories[category]; diff --git a/test/jasmine/assets/check_component.js b/test/jasmine/assets/check_component.js index 24d826af171..1641ddf9a46 100644 --- a/test/jasmine/assets/check_component.js +++ b/test/jasmine/assets/check_component.js @@ -9,12 +9,13 @@ var destroyGraphDiv = require('../assets/destroy_graph_div'); * but the test is that they may have been registered in any order */ module.exports = function checkComponent(Plotly) { - describe('core (svg 2d, scatter) and registered (bar) traces and transforms', function() { + describe('core and registered (bar) traces and transforms', function() { var gd; var mock = { data: [ { + type: 'bar', // x data is date so we coerce a calendar x: ['2001-01-01', '2002-01-01', '2003-01-01'], y: [1, 3, 5] @@ -43,21 +44,14 @@ module.exports = function checkComponent(Plotly) { afterEach(destroyGraphDiv); - it('should graph scatter traces with calendar attributes', function() { - var nodes = d3SelectAll('g.trace.scatter'); - - expect(nodes.size()).toEqual(1); + it('should graph bar traces with calendar attributes', function() { + var nodes = d3SelectAll('g.trace.bars'); - // compare to core_test expect(gd._fullLayout.calendar).toBe('gregorian'); expect(gd._fullLayout.xaxis.calendar).toBe('gregorian'); expect(gd._fullData[0].xcalendar).toBe('gregorian'); - }); - - it('should graph bar traces with calendar attributes', function() { - var nodes = d3SelectAll('g.trace.bars'); - expect(nodes.size()).toEqual(1); + expect(nodes.size()).toEqual(2); expect(gd._fullData[1].xcalendar).toBe('gregorian'); expect(gd._fullData[1].transforms[0].valuecalendar).toBe('nepali'); }); diff --git a/test/jasmine/bundle_tests/bar_test.js b/test/jasmine/bundle_tests/bar_test.js index 03ab0f667d4..3b1366ad819 100644 --- a/test/jasmine/bundle_tests/bar_test.js +++ b/test/jasmine/bundle_tests/bar_test.js @@ -1,18 +1,16 @@ -var d3SelectAll = require('../../strict-d3').selectAll; - var Plotly = require('@lib/core'); -var PlotlyBar = require('@lib/bar'); +var Bar = require('@lib/bar'); +var d3SelectAll = require('../../strict-d3').selectAll; var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); - describe('Bundle with bar', function() { 'use strict'; - Plotly.register(PlotlyBar); + Plotly.register(Bar); - var mock = require('@mocks/bar_line.json'); + var mock = require('@mocks/0.json'); beforeEach(function(done) { Plotly.newPlot(createGraphDiv(), mock.data, mock.layout).then(done); @@ -20,15 +18,9 @@ describe('Bundle with bar', function() { afterEach(destroyGraphDiv); - it('should graph scatter traces', function() { - var nodes = d3SelectAll('g.trace.scatter'); - - expect(nodes.size()).toEqual(1); - }); - it('should graph bar traces', function() { var nodes = d3SelectAll('g.trace.bars'); - expect(nodes.size()).toEqual(1); + expect(nodes.size()).toEqual(3); }); }); diff --git a/test/jasmine/bundle_tests/choropleth_test.js b/test/jasmine/bundle_tests/choropleth_test.js index 221b742c77b..26ceeef28e3 100644 --- a/test/jasmine/bundle_tests/choropleth_test.js +++ b/test/jasmine/bundle_tests/choropleth_test.js @@ -1,19 +1,16 @@ -var d3SelectAll = require('../../strict-d3').selectAll; - var Plotly = require('@lib/core'); -var PlotlyChoropleth = require('@lib/choropleth'); +var Choropleth = require('@lib/choropleth'); +var d3SelectAll = require('../../strict-d3').selectAll; var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); - var LONG_TIMEOUT_INTERVAL = 5 * jasmine.DEFAULT_TIMEOUT_INTERVAL; - describe('Bundle with choropleth', function() { 'use strict'; - Plotly.register(PlotlyChoropleth); + Plotly.register(Choropleth); var gd; diff --git a/test/jasmine/bundle_tests/contour_test.js b/test/jasmine/bundle_tests/contour_test.js index 96a225b5a59..84319755fb8 100644 --- a/test/jasmine/bundle_tests/contour_test.js +++ b/test/jasmine/bundle_tests/contour_test.js @@ -1,18 +1,16 @@ -var d3SelectAll = require('../../strict-d3').selectAll; - var Plotly = require('@lib/core'); -var PlotlyContour = require('@lib/contour'); +var Contour = require('@lib/contour'); +var d3SelectAll = require('../../strict-d3').selectAll; var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); - describe('Bundle with contour', function() { 'use strict'; - Plotly.register(PlotlyContour); + Plotly.register(Contour); - var mock = require('@mocks/contour_scatter.json'); + var mock = require('@mocks/contour_log.json'); beforeEach(function(done) { Plotly.newPlot(createGraphDiv(), mock.data, mock.layout).then(done); @@ -20,15 +18,9 @@ describe('Bundle with contour', function() { afterEach(destroyGraphDiv); - it('should graph scatter traces', function() { - var nodes = d3SelectAll('g.trace.scatter'); - - expect(nodes.size()).toEqual(1); - }); - it('should graph contour traces', function() { var nodes = d3SelectAll('g.contour'); - expect(nodes.size()).toEqual(1); + expect(nodes.size()).toEqual(4); }); }); diff --git a/test/jasmine/bundle_tests/core_test.js b/test/jasmine/bundle_tests/core_test.js index 9140dbbe075..873883a813d 100644 --- a/test/jasmine/bundle_tests/core_test.js +++ b/test/jasmine/bundle_tests/core_test.js @@ -1,13 +1,15 @@ -var d3SelectAll = require('../../strict-d3').selectAll; - var Plotly = require('@lib/core'); +var Scatter = require('@lib/scatter'); +var d3SelectAll = require('../../strict-d3').selectAll; var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); - -describe('Bundle with core only', function() { +describe('Bundle with core and scatter only', function() { 'use strict'; + + Plotly.register(Scatter); + var gd; var mock = require('@mocks/bar_line.json'); diff --git a/test/jasmine/bundle_tests/dynamic_import_test.js b/test/jasmine/bundle_tests/dynamic_import_test.js index 5dc42374ded..3840f0a3cb0 100644 --- a/test/jasmine/bundle_tests/dynamic_import_test.js +++ b/test/jasmine/bundle_tests/dynamic_import_test.js @@ -1,11 +1,15 @@ var Plotly = require('@lib/core'); +var Scatter = require('@lib/scatter'); var d3Select = require('../../strict-d3').select; var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); - describe('Dynamic @lib/ module imports', function() { + 'use strict'; + + Plotly.register(Scatter); + var gd; afterEach(destroyGraphDiv); diff --git a/test/jasmine/bundle_tests/finance_test.js b/test/jasmine/bundle_tests/finance_test.js index 12a5926e10f..57e6dd9bb37 100644 --- a/test/jasmine/bundle_tests/finance_test.js +++ b/test/jasmine/bundle_tests/finance_test.js @@ -1,7 +1,7 @@ var Plots = require('@src/plots/plots'); var Plotly = require('@lib/core'); -var ohlc = require('@lib/ohlc'); -var candlestick = require('@lib/candlestick'); +var Ohlc = require('@lib/ohlc'); +var Candlestick = require('@lib/candlestick'); var d3Select = require('../../strict-d3').select; var createGraphDiv = require('../assets/create_graph_div'); @@ -10,7 +10,7 @@ var destroyGraphDiv = require('../assets/destroy_graph_div'); describe('Bundle with finance trace type', function() { 'use strict'; - Plotly.register([ohlc, candlestick]); + Plotly.register([Ohlc, Candlestick]); var mock = require('@mocks/finance_style.json'); @@ -25,7 +25,7 @@ describe('Bundle with finance trace type', function() { // scatter is registered no matter what // ohlc uses some parts of box by direct require but does not need to register it. - expect(traceModules).toEqual(['scatter', 'ohlc', 'candlestick']); + expect(traceModules).toEqual(['ohlc', 'candlestick']); }); it('should graph ohlc and candlestick traces', function(done) { diff --git a/test/jasmine/bundle_tests/histogram2dcontour_test.js b/test/jasmine/bundle_tests/histogram2dcontour_test.js index d65868e050d..726845d1482 100644 --- a/test/jasmine/bundle_tests/histogram2dcontour_test.js +++ b/test/jasmine/bundle_tests/histogram2dcontour_test.js @@ -1,32 +1,24 @@ -var d3SelectAll = require('../../strict-d3').selectAll; - var Plotly = require('@lib/core'); -var PlotlyHistogram2dContour = require('@lib/histogram2dcontour'); -var PlotlyHistogram = require('@lib/histogram'); +var Histogram2dContour = require('@lib/histogram2dcontour'); +var Histogram = require('@lib/histogram'); +var d3SelectAll = require('../../strict-d3').selectAll; var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); - describe('Bundle with histogram2dcontour and histogram', function() { 'use strict'; - Plotly.register([PlotlyHistogram2dContour, PlotlyHistogram]); + Plotly.register([Histogram2dContour, Histogram]); var mock = require('@mocks/2dhistogram_contour_subplots.json'); beforeEach(function(done) { - Plotly.newPlot(createGraphDiv(), mock.data, mock.layout).then(done); + Plotly.newPlot(createGraphDiv(), mock.data.slice(1), mock.layout).then(done); }); afterEach(destroyGraphDiv); - it('should graph scatter traces', function() { - var nodes = d3SelectAll('g.trace.scatter'); - - expect(nodes.size()).toEqual(1); - }); - it('should graph contour traces', function() { var nodes = d3SelectAll('g.contour'); diff --git a/test/jasmine/bundle_tests/mathjax_test.js b/test/jasmine/bundle_tests/mathjax_test.js index 706e1e61911..28a9030230c 100644 --- a/test/jasmine/bundle_tests/mathjax_test.js +++ b/test/jasmine/bundle_tests/mathjax_test.js @@ -1,11 +1,12 @@ var Plotly = require('@lib/index'); -var d3Select = require('../../strict-d3').select; +var d3Select = require('../../strict-d3').select; var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); - describe('Test MathJax:', function() { + 'use strict'; + var mathJaxScriptTag; // N.B. we have to load MathJax "dynamically" as Karam diff --git a/test/jasmine/bundle_tests/no_webgl_test.js b/test/jasmine/bundle_tests/no_webgl_test.js index 851b22b9d23..e51d9978d3e 100644 --- a/test/jasmine/bundle_tests/no_webgl_test.js +++ b/test/jasmine/bundle_tests/no_webgl_test.js @@ -3,8 +3,9 @@ var Plotly = require('@lib/index'); var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); - describe('Plotly w/o WebGL support:', function() { + 'use strict'; + var gd; beforeEach(function() { diff --git a/test/jasmine/bundle_tests/plotschema_test.js b/test/jasmine/bundle_tests/plotschema_test.js index a8839522a92..29dd8077187 100644 --- a/test/jasmine/bundle_tests/plotschema_test.js +++ b/test/jasmine/bundle_tests/plotschema_test.js @@ -397,6 +397,8 @@ describe('plot schema', function() { }); describe('getTraceValObject', function() { + 'use strict'; + var getTraceValObject = Plotly.PlotSchema.getTraceValObject; it('finds base attributes', function() { @@ -486,6 +488,8 @@ describe('getTraceValObject', function() { }); describe('getLayoutValObject', function() { + 'use strict'; + var getLayoutValObject = Plotly.PlotSchema.getLayoutValObject; var blankLayout = {}; @@ -606,6 +610,8 @@ describe('getLayoutValObject', function() { }); describe('component schemas', function() { + 'use strict'; + it('does not have yaxis-only attributes or mismatched x/yaxis attributes', function() { // in principle either of these should be allowable, but we don't currently // support them so lets simply test that we haven't added them accidentally!