@@ -19,69 +19,7 @@ errorBars.attributes = require('./attributes');
1919
2020errorBars . supplyDefaults = require ( './defaults' ) ;
2121
22- // size the error bar itself (for all types except data)
23- function errorval ( type , dataval , errval ) {
24- if ( type === 'percent' ) return Math . abs ( dataval * errval / 100 ) ;
25- if ( type === 'constant' ) return Math . abs ( errval ) ;
26- if ( type === 'sqrt' ) return Math . sqrt ( Math . abs ( dataval ) ) ;
27-
28- return 0 ;
29- }
30-
31- errorBars . calc = function ( gd ) {
32- ( gd . calcdata || [ ] ) . forEach ( function ( cdi ) {
33- var trace = cdi [ 0 ] . trace ;
34-
35- if ( ! Plotly . Plots . traceIs ( trace , 'errorBarsOK' ) ) return ;
36-
37- var xObj = trace . error_x || { } ,
38- yObj = trace . error_y || { } ,
39- xa = Plotly . Axes . getFromId ( gd , trace . xaxis ) ,
40- ya = Plotly . Axes . getFromId ( gd , trace . yaxis ) ,
41- xvis = xObj . visible && [ 'linear' , 'log' ] . indexOf ( xa . type ) !== - 1 ,
42- yvis = yObj . visible && [ 'linear' , 'log' ] . indexOf ( ya . type ) !== - 1 ;
43-
44- if ( ! xvis && ! yvis ) return ;
45-
46- var xvals = [ ] ,
47- yvals = [ ] ;
48-
49- cdi . forEach ( function ( d , j ) {
50- try {
51- if ( isNumeric ( ya . c2l ( d . y ) ) && isNumeric ( xa . c2l ( d . x ) ) ) {
52- [
53- { letter :'x' , obj : xObj , visible : xvis , vals : xvals } ,
54- { letter :'y' , obj : yObj , visible : yvis , vals : yvals }
55- ] . forEach ( function ( o ) {
56- if ( o . visible ) {
57- var dataVal = d [ o . letter ] ,
58- obj = o . obj ,
59- ep , en ;
60- if ( o . obj . type === 'data' ) {
61- ep = Number ( obj . array [ j ] ) ;
62- en = ( obj . symmetric || ! ( 'arrayminus' in obj ) ) ?
63- ep : Number ( obj . arrayminus [ j ] ) ;
64- }
65- else {
66- ep = errorval ( obj . type , dataVal , obj . value ) ;
67- en = ( obj . symmetric || ! ( 'valueminus' in obj ) ) ?
68- ep : errorval ( obj . type , dataVal , obj . valueminus ) ;
69- }
70- if ( isNumeric ( ep ) && isNumeric ( en ) ) {
71- var shoe = d [ o . letter + 'h' ] = dataVal + ep ;
72- var hat = d [ o . letter + 's' ] = dataVal - en ;
73- o . vals . push ( shoe , hat ) ;
74- }
75- }
76- } ) ;
77- }
78- }
79- catch ( e ) { console . log ( e ) ; }
80- } ) ;
81- Plotly . Axes . expand ( ya , yvals , { padded : true } ) ;
82- Plotly . Axes . expand ( xa , xvals , { padded : true } ) ;
83- } ) ;
84- } ;
22+ errorBars . calc = require ( './calc' ) ;
8523
8624errorBars . calcFromTrace = function ( trace , layout ) {
8725 var x = trace . x || [ ] ,
0 commit comments