8000 ZERO circular dependency by etpinard · Pull Request #2429 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

ZERO circular dependency #2429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
8000 fixes #621 - make x/y/z dependent error bar attributes
... by using utilizing component-to-schema logic,
    instead of punching the error bar attributes into
    the trace declarations.
  • Loading branch information
etpinard committed Mar 1, 2018
commit b08c4020e74e1a2df028afd74f4ec44c44ea1430
63 changes: 49 additions & 14 deletions src/components/errorbars/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,57 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var errorBars = module.exports = {};
var Lib = require('../../lib');
var overrideAll = require('../../plot_api/edit_types').overrideAll;

var attributes = require('./attributes');
var calc = require('./calc');

var xyAttrs = {
error_x: Lib.extendFlat({}, attributes),
error_y: Lib.extendFlat({}, attributes)
};
delete xyAttrs.error_x.copy_zstyle;
delete xyAttrs.error_y.copy_zstyle;
delete xyAttrs.error_y.copy_ystyle;

var xyzAttrs = {
error_x: Lib.extendFlat({}, attributes),
error_y: Lib.extendFlat({}, attributes),
error_z: Lib.extendFlat({}, attributes)
};
delete xyzAttrs.error_x.copy_ystyle;
delete xyzAttrs.error_y.copy_ystyle;
delete xyzAttrs.error_z.copy_ystyle;
delete xyzAttrs.error_z.copy_zstyle;

module.exports = {
moduleType: 'component',
name: 'errorbars',

errorBars.attributes = require('./attributes');
schema: {
traces: {
scatter: xyAttrs,
bar: xyAttrs,
histogram: xyAttrs,
scatter3d: overrideAll(xyzAttrs, 'calc', 'nested'),
scattergl: overrideAll(xyAttrs, 'calc', 'nested')
}
},

errorBars.supplyDefaults = require('./defaults');
supplyDefaults: require('./defaults'),

errorBars.calc = require('./calc');
calc: calc,
calcFromTrace: calcFromTrace,

errorBars.calcFromTrace = function(trace, layout) {
plot: require('./plot'),
style: require('./style'),
hoverInfo: hoverInfo
};

function calcFromTrace(trace, layout) {
var x = trace.x || [],
y = trace.y || [],
len = x.length || y.length;
Expand All @@ -33,19 +72,15 @@ errorBars.calcFromTrace = function(trace, layout) {

calcdataMock[0].trace = trace;

errorBars.calc({
calc({
calcdata: [calcdataMock],
_fullLayout: layout
});

return calcdataMock;
};
}

errorBars.plot = require('./plot');

errorBars.style = require('./style');

errorBars.hoverInfo = function(calcPoint, trace, hoverPoint) {
function hoverInfo(calcPoint, trace, hoverPoint) {
if((trace.error_y || {}).visible) {
hoverPoint.yerr = calcPoint.yh - calcPoint.y;
if(!trace.error_y.symmetric) hoverPoint.yerrneg = calcPoint.y - calcPoint.ys;
Expand All @@ -54,4 +89,4 @@ errorBars.hoverInfo = function(calcPoint, trace, hoverPoint) {
hoverPoint.xerr = calcPoint.xh - calcPoint.x;
if(!trace.error_x.symmetric) hoverPoint.xerrneg = calcPoint.x - calcPoint.xs;
}
};
}
1 change: 1 addition & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ exports.register([
require('./components/rangeslider'),
require('./components/rangeselector'),
require('./components/grid'),
require('./components/errorbars')
]);

// locales en and en-US are required for default behavior
10000 Expand Down
4 changes: 0 additions & 4 deletions src/traces/bar/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

var scatterAttrs = require('../scatter/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');
var errorBarAttrs = require('../../components/errorbars/attributes');
var colorbarAttrs = require('../../components/colorbar/attributes');
var fontAttrs = require('../../plots/font_attributes');

Expand Down Expand Up @@ -190,9 +189,6 @@ module.exports = {
r: scatterAttrs.r,
t: scatterAttrs.t,

error_y: errorBarAttrs,
error_x: errorBarAttrs,

_deprecated: {
bardir: {
valType: 'enumerated',
Expand Down
4 changes: 0 additions & 4 deletions src/traces/histogram/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

var barAttrs = require('../bar/attributes');


module.exports = {
x: {
valType: 'data_array',
Expand Down Expand Up @@ -194,9 +193,6 @@ module.exports = {
selected: barAttrs.selected,
unselected: barAttrs.unselected,

error_y: barAttrs.error_y,
error_x: barAttrs.error_x,

_deprecated: {
bardir: barAttrs._deprecated.bardir
}
Expand Down
6 changes: 1 addition & 5 deletions src/traces/scatter/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
'use strict';

var colorAttributes = require('../../components/colorscale/color_attributes');
var errorBarAttrs = require('../../components/errorbars/attributes');
var colorbarAttrs = require('../../components/colorbar/attributes');
var fontAttrs = require('../../plots/font_attributes');
var dash = require('../../components/drawing/attributes').dash;
Expand Down Expand Up @@ -490,8 +489,5 @@ module.exports = {
'Please switch to *scatterpolar* trace type.',
'Sets the angular coordinates.'
].join('')
},

error_y: errorBarAttrs,
error_x: errorBarAttrs
}
};
5 changes: 0 additions & 5 deletions src/traces/scatter3d/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

var scatterAttrs = require('../scatter/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');
var errorBarAttrs = require('../../components/errorbars/attributes');
var baseAttrs = require('../../plots/attributes');
var DASHES = require('../../constants/gl3d_dashes');

Expand Down Expand Up @@ -169,10 +168,6 @@ var attrs = module.exports = overrideAll({
textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}),
textfont: scatterAttrs.textfont,

error_x: errorBarAttrs,
error_y: errorBarAttrs,
error_z: errorBarAttrs,

hoverinfo: extendFlat({}, baseAttrs.hoverinfo)
}, 'calc', 'nested');

Expand Down
2 changes: 0 additions & 2 deletions src/traces/scattergl/attributes.js
EE56
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ var attrs = module.exports = overrideAll({
editType: 'calc'
}),

error_y: scatterAttrs.error_y,
error_x: scatterAttrs.error_x
}, 'calc', 'nested');

attrs.x.editType = attrs.y.editType = attrs.x0.editType = attrs.y0.editType = 'calc+clearAxisTypes';
26 changes: 26 additions & 0 deletions test/jasmine/tests/plotschema_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,32 @@ describe('plot schema', function() {
expect(plotSchema.frames.items.frames_entry).toBeDefined();
expect(plotSchema.frames.items.frames_entry.role).toEqual('object');
});

it('should list trace-dependent & direction-dependent error bar attributes', function() {
var scatterSchema = plotSchema.traces.scatter.attributes;
expect(scatterSchema.error_x.copy_ystyle).toBeDefined();
expect(scatterSchema.error_x.copy_ystyle.editType).toBe('plot');
expect(scatterSchema.error_x.copy_zstyle).toBeUndefined();
expect(scatterSchema.error_y.copy_ystyle).toBeUndefined();
expect(scatterSchema.error_y.copy_zstyle).toBeUndefined();

var scatter3dSchema = plotSchema.traces.scatter3d.attributes;
expect(scatter3dSchema.error_x.copy_ystyle).toBeUndefined();
expect(scatter3dSchema.error_x.copy_zstyle).toBeDefined();
expect(scatter3dSchema.error_x.copy_zstyle.editType).toBe('calc');
expect(scatter3dSchema.error_y.copy_ystyle).toBeUndefined();
expect(scatter3dSchema.error_y.copy_zstyle).toBeDefined();
expect(scatter3dSchema.error_y.copy_zstyle.editType).toBe('calc');
expect(scatter3dSchema.error_z.copy_ystyle).toBeUndefined();
expect(scatter3dSchema.error_z.copy_zstyle).toBeUndefined();

var scatterglSchema = plotSchema.traces.scattergl.attributes;
expect(scatterglSchema.error_x.copy_ystyle).toBeDefined();
expect(scatterglSchema.error_x.copy_ystyle.editType).toBe('calc');
expect(scatterglSchema.error_x.copy_zstyle).toBeUndefined();
expect(scatterglSchema.error_y.copy_ystyle).toBeUndefined();
expect(scatterglSchema.error_y.copy_zstyle).toBeUndefined();
});
});

describe('getTraceValObject', function() {
Expand Down
0