From 77a54647bbeba5307d1acef491b48ec892ac3694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Mon, 18 Jan 2016 15:48:34 -0500 Subject: [PATCH 1/7] Fix check on subplot `hasXY` --- src/plot_api/plot_schema.js | 2 +- src/plots/plots.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plot_api/plot_schema.js b/src/plot_api/plot_schema.js index af506ecf50f..2a24910dddf 100644 --- a/src/plot_api/plot_schema.js +++ b/src/plot_api/plot_schema.js @@ -286,7 +286,7 @@ function handleSubplotObjs(layoutAttributes) { var subplotRegistry = subplotsRegistry[subplotType], isSubplotObj; - if(subplotType === 'cartesian') { + if(subplotType === 'cartesian' || subplotType === 'gl2d') { isSubplotObj = ( subplotRegistry.attrRegex.x.test(k) || subplotRegistry.attrRegex.y.test(k) diff --git a/src/plots/plots.js b/src/plots/plots.js index 915b4706030..8a2aeba107c 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -140,7 +140,7 @@ plots.registerSubplot = function(_module) { var regexStart = '^', regexEnd = '([2-9]|[1-9][0-9]+)?$', - hasXY = (plotType === 'cartesian' || subplotsRegistry === 'gl2d'); + hasXY = (plotType === 'cartesian' || plotType === 'gl2d'); function makeRegex(mid) { return new RegExp(regexStart + mid + regexEnd); From b0ff48c940174a69214e12583309cf98d9126b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Tue, 19 Jan 2016 12:31:50 -0500 Subject: [PATCH 2/7] Add `basePlotModule` to traces --- src/traces/bar/index.js | 1 + src/traces/box/index.js | 1 + src/traces/choropleth/index.js | 1 + src/traces/contour/index.js | 1 + src/traces/heatmap/index.js | 1 + src/traces/histogram/index.js | 1 + src/traces/histogram2d/index.js | 1 + src/traces/histogram2dcontour/index.js | 1 + src/traces/mesh3d/index.js | 1 + src/traces/pie/index.js | 1 + src/traces/scatter/index.js | 1 + src/traces/scatter3d/index.js | 1 + src/traces/scattergeo/index.js | 1 + src/traces/scattergeo/plot.js | 12 +++++++----- src/traces/scattergl/index.js | 1 + src/traces/surface/index.js | 1 + 16 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/traces/bar/index.js b/src/traces/bar/index.js index ec24b7ec76b..5561f9c6b3c 100644 --- a/src/traces/bar/index.js +++ b/src/traces/bar/index.js @@ -25,6 +25,7 @@ Bar.hoverPoints = require('./hover'); Bar.moduleType = 'trace'; Bar.name = 'bar'; +Bar.basePlotModule = require('../../plots/cartesian'); Bar.categories = ['cartesian', 'bar', 'oriented', 'markerColorscale', 'errorBarsOK', 'showLegend']; Bar.meta = { description: [ diff --git a/src/traces/box/index.js b/src/traces/box/index.js index e97f6c625ee..3ccc5674ca6 100644 --- a/src/traces/box/index.js +++ b/src/traces/box/index.js @@ -22,6 +22,7 @@ Box.hoverPoints = require('./hover'); Box.moduleType = 'trace'; Box.name = 'box'; +Box.basePlotModule = require('../../plots/cartesian'); Box.categories = ['cartesian', 'symbols', 'oriented', 'box', 'showLegend']; Box.meta = { description: [ diff --git a/src/traces/choropleth/index.js b/src/traces/choropleth/index.js index 4999be85ae3..41e45e3c84f 100644 --- a/src/traces/choropleth/index.js +++ b/src/traces/choropleth/index.js @@ -19,6 +19,7 @@ Choropleth.plot = require('./plot').plot; Choropleth.moduleType = 'trace'; Choropleth.name = 'choropleth'; +Choropleth.basePlotModule = require('../../plots/geo'); Choropleth.categories = ['geo', 'noOpacity']; Choropleth.meta = { description: [ diff --git a/src/traces/contour/index.js b/src/traces/contour/index.js index 2a61c9c5db0..65829a71fd7 100644 --- a/src/traces/contour/index.js +++ b/src/traces/contour/index.js @@ -21,6 +21,7 @@ Contour.hoverPoints = require('./hover'); Contour.moduleType = 'trace'; Contour.name = 'contour'; +Contour.basePlotModule = require('../../plots/cartesian'); Contour.categories = ['cartesian', '2dMap', 'contour']; Contour.meta = { description: [ diff --git a/src/traces/heatmap/index.js b/src/traces/heatmap/index.js index fd4f7882296..6ee34baa380 100644 --- a/src/traces/heatmap/index.js +++ b/src/traces/heatmap/index.js @@ -21,6 +21,7 @@ Heatmap.hoverPoints = require('./hover'); Heatmap.moduleType = 'trace'; Heatmap.name = 'heatmap'; +Heatmap.basePlotModule = require('../../plots/cartesian'); Heatmap.categories = ['cartesian', '2dMap']; Heatmap.meta = { description: [ diff --git a/src/traces/histogram/index.js b/src/traces/histogram/index.js index a18eb36b9c2..33864fb5718 100644 --- a/src/traces/histogram/index.js +++ b/src/traces/histogram/index.js @@ -38,6 +38,7 @@ Histogram.hoverPoints = require('../bar/hover'); Histogram.moduleType = 'trace'; Histogram.name = 'histogram'; +Histogram.basePlotModule = require('../../plots/cartesian'); Histogram.categories = ['cartesian', 'bar', 'histogram', 'oriented', 'errorBarsOK', 'showLegend']; Histogram.meta = { description: [ diff --git a/src/traces/histogram2d/index.js b/src/traces/histogram2d/index.js index e555fde47c6..8c7735f1d28 100644 --- a/src/traces/histogram2d/index.js +++ b/src/traces/histogram2d/index.js @@ -21,6 +21,7 @@ Histogram2D.hoverPoints = require('../heatmap/hover'); Histogram2D.moduleType = 'trace'; Histogram2D.name = 'histogram2d'; +Histogram2D.basePlotModule = require('../../plots/cartesian'); Histogram2D.categories = ['cartesian', '2dMap', 'histogram']; Histogram2D.meta = { hrName: 'histogram_2d', diff --git a/src/traces/histogram2dcontour/index.js b/src/traces/histogram2dcontour/index.js index d8c4f5fdd17..63f13b6defd 100644 --- a/src/traces/histogram2dcontour/index.js +++ b/src/traces/histogram2dcontour/index.js @@ -21,6 +21,7 @@ Histogram2dContour.hoverPoints = require('../contour/hover'); Histogram2dContour.moduleType = 'trace'; Histogram2dContour.name = 'histogram2dcontour'; +Histogram2dContour.basePlotModule = require('../../plots/cartesian'); Histogram2dContour.categories = ['cartesian', '2dMap', 'contour', 'histogram']; Histogram2dContour.meta = { hrName: 'histogram_2d_contour', diff --git a/src/traces/mesh3d/index.js b/src/traces/mesh3d/index.js index 63f472aee00..f4b0e2b29c1 100644 --- a/src/traces/mesh3d/index.js +++ b/src/traces/mesh3d/index.js @@ -18,6 +18,7 @@ Mesh3D.plot = require('./convert'); Mesh3D.moduleType = 'trace'; Mesh3D.name = 'mesh3d', +Mesh3D.basePlotModule = require('../../plots/gl3d'); Mesh3D.categories = ['gl3d']; Mesh3D.meta = { description: [ diff --git a/src/traces/pie/index.js b/src/traces/pie/index.js index b11c828968e..c5344071d8e 100644 --- a/src/traces/pie/index.js +++ b/src/traces/pie/index.js @@ -21,6 +21,7 @@ Pie.styleOne = require('./style_one'); Pie.moduleType = 'trace'; Pie.name = 'pie'; +Pie.basePlotModule = require('../../plots/cartesian'); Pie.categories = ['pie', 'showLegend']; Pie.meta = { description: [ diff --git a/src/traces/scatter/index.js b/src/traces/scatter/index.js index 6c3b8629c3d..a7a9cafd08e 100644 --- a/src/traces/scatter/index.js +++ b/src/traces/scatter/index.js @@ -32,6 +32,7 @@ Scatter.selectPoints = require('./select'); Scatter.moduleType = 'trace'; Scatter.name = 'scatter'; +Scatter.basePlotModule = require('../../plots/cartesian'); Scatter.categories = ['cartesian', 'symbols', 'markerColorscale', 'errorBarsOK', 'showLegend']; Scatter.meta = { description: [ diff --git a/src/traces/scatter3d/index.js b/src/traces/scatter3d/index.js index fd866886a83..c75bd947028 100644 --- a/src/traces/scatter3d/index.js +++ b/src/traces/scatter3d/index.js @@ -19,6 +19,7 @@ Scatter3D.calc = require('./calc'); Scatter3D.moduleType = 'trace'; Scatter3D.name = 'scatter3d'; +Scatter3D.basePlotModule = require('../../plots/gl3d'); Scatter3D.categories = ['gl3d', 'symbols', 'markerColorscale', 'showLegend']; Scatter3D.meta = { hrName: 'scatter_3d', diff --git a/src/traces/scattergeo/index.js b/src/traces/scattergeo/index.js index 8d0dd121288..ef515a892f3 100644 --- a/src/traces/scattergeo/index.js +++ b/src/traces/scattergeo/index.js @@ -19,6 +19,7 @@ ScatterGeo.plot = require('./plot').plot; ScatterGeo.moduleType = 'trace'; ScatterGeo.name = 'scattergeo'; +ScatterGeo.basePlotModule = require('../../plots/geo'); ScatterGeo.categories = ['geo', 'symbols', 'markerColorscale', 'showLegend']; ScatterGeo.meta = { hrName: 'scatter_geo', diff --git a/src/traces/scattergeo/plot.js b/src/traces/scattergeo/plot.js index fdaf4ad06d6..9428f580beb 100644 --- a/src/traces/scattergeo/plot.js +++ b/src/traces/scattergeo/plot.js @@ -9,9 +9,11 @@ 'use strict'; -var Plotly = require('../../plotly'); var d3 = require('d3'); +var Fx = require('../../plots/plots'); +var Axes = require('../../plots/cartesian/axes'); + var getTopojsonFeatures = require('../../lib/topojson_utils').getTopojsonFeatures; var locationToFeature = require('../../lib/geo_location_utils').locationToFeature; var arrayToCalcItem = require('../../lib/array_to_calc_item'); @@ -163,7 +165,7 @@ plotScatterGeo.plot = function(geo, scattergeoData) { var xy = geo.projection([d.lon, d.lat]); cleanHoverLabelsFunc(d); - Plotly.Fx.loneHover({ + Fx.loneHover({ x: xy[0], y: xy[1], name: hasNameLabel ? trace.name : undefined, @@ -181,11 +183,11 @@ plotScatterGeo.plot = function(geo, scattergeoData) { .attr('class', 'point') .on('mouseover', handleMouseOver) .on('mouseout', function() { - Plotly.Fx.loneUnhover(geo.hoverContainer); + Fx.loneUnhover(geo.hoverContainer); }) .on('mousedown', function() { // to simulate the 'zoomon' event - Plotly.Fx.loneUnhover(geo.hoverContainer); + Fx.loneUnhover(geo.hoverContainer); }) .on('mouseup', handleMouseOver); // ~ 'zoomend' } @@ -246,7 +248,7 @@ function makeCleanHoverLabelsFunc(geo, trace) { function formatter(val) { var axis = geo.mockAxis; - return Plotly.Axes.tickText(axis, axis.c2l(val), 'hover').text + '\u00B0'; + return Axes.tickText(axis, axis.c2l(val), 'hover').text + '\u00B0'; } return function cleanHoverLabelsFunc(d) { diff --git a/src/traces/scattergl/index.js b/src/traces/scattergl/index.js index 72ba035c019..853e87e9cc1 100644 --- a/src/traces/scattergl/index.js +++ b/src/traces/scattergl/index.js @@ -20,6 +20,7 @@ ScatterGl.plot = require('./convert'); ScatterGl.moduleType = 'trace'; ScatterGl.name = 'scattergl'; +ScatterGl.basePlotModule = require('../../plots/gl2d'); ScatterGl.categories = ['gl2d', 'symbols', 'errorBarsOK', 'markerColorscale', 'showLegend']; ScatterGl.meta = { description: [ diff --git a/src/traces/surface/index.js b/src/traces/surface/index.js index c621ef1521b..9a3c5795f16 100644 --- a/src/traces/surface/index.js +++ b/src/traces/surface/index.js @@ -19,6 +19,7 @@ Surface.plot = require('./convert'); Surface.moduleType = 'trace'; Surface.name = 'surface'; +Surface.basePlotModule = require('../../plots/gl3d'); Surface.categories = ['gl3d', 'noOpacity']; Surface.meta = { description: [ From ba8cbab28903991308356b8ed2b82277491180e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Tue, 19 Jan 2016 12:32:47 -0500 Subject: [PATCH 3/7] Modify tests to work for new plot registration --- test/jasmine/tests/plots_test.js | 4 +++- test/jasmine/tests/register_test.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/jasmine/tests/plots_test.js b/test/jasmine/tests/plots_test.js index 8565ca5c189..a3c4cb7ae4a 100644 --- a/test/jasmine/tests/plots_test.js +++ b/test/jasmine/tests/plots_test.js @@ -206,7 +206,7 @@ describe('Test Plots', function() { revertObj(Plots.allCategories, this.allCategoriesKeys); }); - it('should warn on attempts to reregister a type', function() { + it('should not reregister a type', function() { Plots.register(this.fakeModule2, 'newtype', ['yellow', 'blue']); expect(Plots.allCategories.yellow).toBeUndefined(); }); @@ -239,6 +239,8 @@ describe('Test Plots', function() { name: 'fake', attr: 'abc', idRoot: 'cba', + attrRegex: /^abc([2-9]|[1-9][0-9]+)?$/, + idRegex: /^cba([2-9]|[1-9][0-9]+)?$/, attributes: { stuff: { 'more stuff': 102102 } } }; diff --git a/test/jasmine/tests/register_test.js b/test/jasmine/tests/register_test.js index bedcb79851b..c2f59013d01 100644 --- a/test/jasmine/tests/register_test.js +++ b/test/jasmine/tests/register_test.js @@ -13,6 +13,7 @@ describe('the register function', function() { moduleType: 'trace', name: 'mockTrace1', meta: 'Meta string', + basePlotModule: { name: 'plotModule' }, categories: ['categories', 'array'] }; @@ -28,6 +29,7 @@ describe('the register function', function() { moduleType: 'trace', name: 'mockTrace2', meta: 'Meta string', + basePlotModule: { name: 'plotModule' }, categories: ['categories', 'array'] }; From 970abc2259bea8b3fa028b471193cfdc368d6f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Tue, 19 Jan 2016 12:36:02 -0500 Subject: [PATCH 4/7] Update plots to work as standalone modules --- src/plots/cartesian/index.js | 10 +++++++++ src/plots/cartesian/layout_attributes.js | 12 +++++------ src/plots/geo/geo.js | 19 +++++++++-------- src/plots/geo/index.js | 8 +++++--- src/plots/geo/layout/axis_defaults.js | 6 +++--- src/plots/geo/layout/defaults.js | 7 ++++--- src/plots/gl2d/index.js | 10 +++++++++ src/plots/gl3d/index.js | 4 ++++ src/plots/plots.js | 26 +++--------------------- 9 files changed, 55 insertions(+), 47 deletions(-) diff --git a/src/plots/cartesian/index.js b/src/plots/cartesian/index.js index 2a200d68cc8..15b00009f0f 100644 --- a/src/plots/cartesian/index.js +++ b/src/plots/cartesian/index.js @@ -17,3 +17,13 @@ exports.attr = ['xaxis', 'yaxis']; exports.idRoot = ['x', 'y']; exports.attributes = require('./attributes'); + +exports.idRegex = { + x: /^x([2-9]|[1-9][0-9]+)?$/, + y: /^y([2-9]|[1-9][0-9]+)?$/ +}; + +exports.attrRegex = { + x: /^x([2-9]|[1-9][0-9]+)?$/, + y: /^y([2-9]|[1-9][0-9]+)?$/ +}; diff --git a/src/plots/cartesian/layout_attributes.js b/src/plots/cartesian/layout_attributes.js index ef423607fc4..8ec877fc6a2 100644 --- a/src/plots/cartesian/layout_attributes.js +++ b/src/plots/cartesian/layout_attributes.js @@ -7,13 +7,11 @@ */ 'use strict'; - -var Plotly = require('../../plotly'); +var Cartesian = require('./index'); var fontAttrs = require('../font_attributes'); var colorAttrs = require('../../components/color/attributes'); var extendFlat = require('../../lib/extend').extendFlat; - module.exports = { title: { valType: 'string', @@ -385,8 +383,8 @@ module.exports = { valType: 'enumerated', values: [ 'free', - Plotly.Plots.subplotsRegistry.cartesian.idRegex.x.toString(), - Plotly.Plots.subplotsRegistry.cartesian.idRegex.y.toString() + Cartesian.idRegex.x.toString(), + Cartesian.idRegex.y.toString() ], role: 'info', description: [ @@ -414,8 +412,8 @@ module.exports = { valType: 'enumerated', values: [ 'free', - Plotly.Plots.subplotsRegistry.cartesian.idRegex.x.toString(), - Plotly.Plots.subplotsRegistry.cartesian.idRegex.y.toString() + Cartesian.idRegex.x.toString(), + Cartesian.idRegex.y.toString() ], role: 'info', description: [ diff --git a/src/plots/geo/geo.js b/src/plots/geo/geo.js index 7bd6ed0aa35..022162258e2 100644 --- a/src/plots/geo/geo.js +++ b/src/plots/geo/geo.js @@ -11,10 +11,13 @@ /* global PlotlyGeoAssets:false */ -var Plotly = require('../../plotly'); var d3 = require('d3'); +var Color = require('../../components/color'); +var Drawing = require('../../components/drawing'); + var Plots = require('../../plots/plots'); +var Axes = require('../../plots/cartesian/axes'); var addProjectionsToD3 = require('./projections'); var createGeoScale = require('./set_scale'); @@ -350,7 +353,7 @@ function styleFillLayer(selection, layerName, geoLayout) { selection.select('.' + layerName) .selectAll('path') .attr('stroke', 'none') - .call(Plotly.Color.fill, geoLayout[layerAdj + 'color']); + .call(Color.fill, geoLayout[layerAdj + 'color']); } function styleLineLayer(selection, layerName, geoLayout) { @@ -359,16 +362,16 @@ function styleLineLayer(selection, layerName, geoLayout) { selection.select('.' + layerName) .selectAll('path') .attr('fill', 'none') - .call(Plotly.Color.stroke, geoLayout[layerAdj + 'color']) - .call(Plotly.Drawing.dashLine, '', geoLayout[layerAdj + 'width']); + .call(Color.stroke, geoLayout[layerAdj + 'color']) + .call(Drawing.dashLine, '', geoLayout[layerAdj + 'width']); } function styleGraticule(selection, axisName, geoLayout) { selection.select('.' + axisName + 'graticule') .selectAll('path') .attr('fill', 'none') - .call(Plotly.Color.stroke, geoLayout[axisName].gridcolor) - .call(Plotly.Drawing.dashLine, '', geoLayout[axisName].gridwidth); + .call(Color.stroke, geoLayout[axisName].gridcolor) + .call(Drawing.dashLine, '', geoLayout[axisName].gridwidth); } proto.styleLayer = function(selection, layerName, geoLayout) { @@ -451,10 +454,10 @@ function createMockAxis(fullLayout) { var mockAxis = { type: 'linear', showexponent: 'all', - exponentformat: Plotly.Axes.layoutAttributes.exponentformat.dflt, + exponentformat: Axes.layoutAttributes.exponentformat.dflt, _td: { _fullLayout: fullLayout } }; - Plotly.Axes.setConvert(mockAxis); + Axes.setConvert(mockAxis); return mockAxis; } diff --git a/src/plots/geo/index.js b/src/plots/geo/index.js index 21200af2c0b..772db2ed0c1 100644 --- a/src/plots/geo/index.js +++ b/src/plots/geo/index.js @@ -9,11 +9,9 @@ 'use strict'; -var Plotly = require('../../plotly'); - var Geo = require('./geo'); -var Plots = Plotly.Plots; +var Plots = require('../../plots/plots'); exports.name = 'geo'; @@ -22,6 +20,10 @@ exports.attr = 'geo'; exports.idRoot = 'geo'; +exports.idRegex = /^geo([2-9]|[1-9][0-9]+)?$/; + +exports.attrRegex = /^geo([2-9]|[1-9][0-9]+)?$/; + exports.attributes = require('./layout/attributes'); exports.layoutAttributes = require('./layout/layout_attributes'); diff --git a/src/plots/geo/layout/axis_defaults.js b/src/plots/geo/layout/axis_defaults.js index 429a801393e..087f9898c59 100644 --- a/src/plots/geo/layout/axis_defaults.js +++ b/src/plots/geo/layout/axis_defaults.js @@ -9,7 +9,7 @@ 'use strict'; -var Plotly = require('../../../plotly'); +var Lib = require('../../../lib'); var constants = require('../../../constants/geo_constants'); var axisAttributes = require('./axis_attributes'); @@ -20,7 +20,7 @@ module.exports = function supplyGeoAxisLayoutDefaults(geoLayoutIn, geoLayoutOut) var axisIn, axisOut; function coerce(attr, dflt) { - return Plotly.Lib.coerce(axisIn, axisOut, axisAttributes, attr, dflt); + return Lib.coerce(axisIn, axisOut, axisAttributes, attr, dflt); } function getRangeDflt(axisName) { @@ -55,7 +55,7 @@ module.exports = function supplyGeoAxisLayoutDefaults(geoLayoutIn, geoLayoutOut) var range = coerce('range', rangeDflt); - Plotly.Lib.noneOrAll(axisIn.range, axisOut.range, [0, 1]); + Lib.noneOrAll(axisIn.range, axisOut.range, [0, 1]); coerce('tick0', range[0]); coerce('dtick', axisName==='lonaxis' ? 30 : 10); diff --git a/src/plots/geo/layout/defaults.js b/src/plots/geo/layout/defaults.js index a6c3cccf278..fd889a1bd6f 100644 --- a/src/plots/geo/layout/defaults.js +++ b/src/plots/geo/layout/defaults.js @@ -9,20 +9,21 @@ 'use strict'; -var Plotly = require('../../../plotly'); +var Lib = require('../../../lib'); +var Plots = require('../../plots'); var constants = require('../../../constants/geo_constants'); var layoutAttributes = require('./layout_attributes'); var supplyGeoAxisLayoutDefaults = require('./axis_defaults'); module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { - var geos = Plotly.Plots.getSubplotIdsInData(fullData, 'geo'), + var geos = Plots.getSubplotIdsInData(fullData, 'geo'), geosLength = geos.length; var geoLayoutIn, geoLayoutOut; function coerce(attr, dflt) { - return Plotly.Lib.coerce(geoLayoutIn, geoLayoutOut, layoutAttributes, attr, dflt); + return Lib.coerce(geoLayoutIn, geoLayoutOut, layoutAttributes, attr, dflt); } for(var i = 0; i < geosLength; i++) { diff --git a/src/plots/gl2d/index.js b/src/plots/gl2d/index.js index 20b00ad3b7f..22288ad4d69 100644 --- a/src/plots/gl2d/index.js +++ b/src/plots/gl2d/index.js @@ -22,6 +22,16 @@ exports.attr = ['xaxis', 'yaxis']; exports.idRoot = ['x', 'y']; +exports.idRegex = { + x: /^x([2-9]|[1-9][0-9]+)?$/, + y: /^y([2-9]|[1-9][0-9]+)?$/ +}; + +exports.attrRegex = { + x: /^xaxis([2-9]|[1-9][0-9]+)?$/, + y: /^yaxis([2-9]|[1-9][0-9]+)?$/ +}; + exports.attributes = require('../cartesian/attributes'); exports.plot = function plotGl2d(gd) { diff --git a/src/plots/gl3d/index.js b/src/plots/gl3d/index.js index d7daba44104..beccb231bfc 100644 --- a/src/plots/gl3d/index.js +++ b/src/plots/gl3d/index.js @@ -21,6 +21,10 @@ exports.attr = 'scene'; exports.idRoot = 'scene'; +exports.idRegex = /^scene([2-9]|[1-9][0-9]+)?$/; + +exports.attrRegex = /^scene([2-9]|[1-9][0-9]+)?$/; + exports.attributes = require('./layout/attributes'); exports.layoutAttributes = require('./layout/layout_attributes'); diff --git a/src/plots/plots.js b/src/plots/plots.js index 8a2aeba107c..4c17c31554a 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -41,7 +41,7 @@ plots.fontWeight = 'normal'; */ plots.register = function(_module, thisType, categoriesIn, meta) { if(modules[thisType]) { - console.warn('type ' + thisType + ' already registered'); + console.log('type ' + thisType + ' already registered'); return; } @@ -132,32 +132,12 @@ plots.registerSubplot = function(_module) { var plotType = _module.name; if(subplotsRegistry[plotType]) { - throw new Error('plot type' + plotType + ' already registered'); - } - - var attr = _module.attr, - idRoot = _module.idRoot; - - var regexStart = '^', - regexEnd = '([2-9]|[1-9][0-9]+)?$', - hasXY = (plotType === 'cartesian' || plotType === 'gl2d'); - - function makeRegex(mid) { - return new RegExp(regexStart + mid + regexEnd); + console.log('plot type ' + plotType + ' already registered'); + return; } // not sure what's best for the 'cartesian' type at this point subplotsRegistry[plotType] = _module; - - // register the regex representing the set of all valid attribute names - subplotsRegistry[plotType].attrRegex = hasXY ? - { x: makeRegex(attr[0]), y: makeRegex(attr[1]) } : - makeRegex(attr); - - // register the regex representing the set of all valid attribute ids - subplotsRegistry[plotType].idRegex = hasXY ? - { x: makeRegex(idRoot[0]), y: makeRegex(idRoot[1]) } : - makeRegex(idRoot); }; // TODO separate the 'find subplot' step (which looks in layout) From f1d4490f3444cb5d261198d996afe0ae90ea1385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Tue, 19 Jan 2016 12:36:50 -0500 Subject: [PATCH 5/7] Change require to new path for attributes --- src/components/annotations/attributes.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/annotations/attributes.js b/src/components/annotations/attributes.js index f99a825187d..431efa69de1 100644 --- a/src/components/annotations/attributes.js +++ b/src/components/annotations/attributes.js @@ -8,8 +8,8 @@ 'use strict'; -var Plotly = require('../../plotly'); var ARROWPATHS = require('./arrow_paths'); +var Cartesian = require('../../plots/cartesian'); var fontAttrs = require('../../plots/font_attributes'); var extendFlat = require('../../lib/extend').extendFlat; @@ -156,7 +156,7 @@ module.exports = { valType: 'enumerated', values: [ 'paper', - Plotly.Plots.subplotsRegistry.cartesian.idRegex.x.toString() + Cartesian.idRegex.x.toString() ], role: 'info', description: [ @@ -199,7 +199,7 @@ module.exports = { valType: 'enumerated', values: [ 'paper', - Plotly.Plots.subplotsRegistry.cartesian.idRegex.y.toString() + Cartesian.idRegex.y.toString() ], role: 'info', description: [ From aa8db380dda5e3185726e8f9931f8108b0f8c7c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Tue, 19 Jan 2016 12:38:09 -0500 Subject: [PATCH 6/7] Update register function to load base plot modules as well --- src/plotly.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/plotly.js b/src/plotly.js index cc0f90b584e..5a4bef7291a 100644 --- a/src/plotly.js +++ b/src/plotly.js @@ -36,23 +36,10 @@ exports.defaultConfig = require('./plot_api/plot_config'); // plots var Plots = exports.Plots = require('./plots/plots'); -var Cartesian = require('./plots/cartesian'); -Plots.registerSubplot(Cartesian); - -var Geo = require('./plots/geo'); -Plots.registerSubplot(Geo); - -var Gl3d = require('./plots/gl3d'); -Plots.registerSubplot(Gl3d); - -var Gl2d = require('./plots/gl2d'); -Plots.registerSubplot(Gl2d); - exports.Axes = require('./plots/cartesian/axes'); exports.Fx = require('./plots/cartesian/graph_interact'); exports.micropolar = require('./plots/polar/micropolar'); - // components exports.Color = require('./components/color'); exports.Drawing = require('./components/drawing'); @@ -80,6 +67,10 @@ exports.register = function register(_modules) { throw new Error('Invalid module was attempted to be registered!'); } else { Plots.register(newModule, newModule.name, newModule.categories, newModule.meta); + + if(!Plots.subplotsRegistry[newModule.basePlotModule.name]){ + Plots.registerSubplot(newModule.basePlotModule); + } } } }; From 1007c8aabb22f3e9bc15f9f4e975854077f00d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Tue, 19 Jan 2016 12:43:28 -0500 Subject: [PATCH 7/7] Tis a silly mistake --- src/plots/cartesian/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plots/cartesian/index.js b/src/plots/cartesian/index.js index 15b00009f0f..e32de542552 100644 --- a/src/plots/cartesian/index.js +++ b/src/plots/cartesian/index.js @@ -24,6 +24,6 @@ exports.idRegex = { }; exports.attrRegex = { - x: /^x([2-9]|[1-9][0-9]+)?$/, - y: /^y([2-9]|[1-9][0-9]+)?$/ + x: /^xaxis([2-9]|[1-9][0-9]+)?$/, + y: /^yaxis([2-9]|[1-9][0-9]+)?$/ };