1111var Axes = require ( '../../plots/cartesian/axes' ) ;
1212var cheaterBasis = require ( './cheater_basis' ) ;
1313var arrayMinmax = require ( './array_minmax' ) ;
14- var map2dArray = require ( './map_2d_array' ) ;
1514var calcGridlines = require ( './calc_gridlines' ) ;
1615var calcLabels = require ( './calc_labels' ) ;
1716var calcClipPath = require ( './calc_clippath' ) ;
1817var clean2dArray = require ( '../heatmap/clean_2d_array' ) ;
1918var smoothFill2dArray = require ( './smooth_fill_2d_array' ) ;
19+ var hasColumns = require ( './has_columns' ) ;
20+ var convertColumnData = require ( '../heatmap/convert_column_xyz' ) ;
21+ var setConvert = require ( './set_convert' ) ;
2022
2123module . exports = function calc ( gd , trace ) {
22- var xa = Axes . getFromId ( gd , trace . xaxis || 'x' ) ;
23- var ya = Axes . getFromId ( gd , trace . yaxis || 'y' ) ;
24+ var xa = Axes . getFromId ( gd , trace . xaxis ) ;
25+ var ya = Axes . getFromId ( gd , trace . yaxis ) ;
2426 var aax = trace . aaxis ;
2527 var bax = trace . baxis ;
26- var a = trace . _a = trace . a ;
27- var b = trace . _b = trace . b ;
2828
29- var t = { } ;
30- var x ;
29+ var x = trace . x ;
3130 var y = trace . y ;
31+ var cols = [ ] ;
32+ if ( x && ! hasColumns ( x ) ) cols . push ( 'x' ) ;
33+ if ( y && ! hasColumns ( y ) ) cols . push ( 'y' ) ;
34+
35+ if ( cols . length ) {
36+ convertColumnData ( trace , aax , bax , 'a' , 'b' , cols ) ;
37+ }
38+
39+ var a = trace . _a = trace . _a || trace . a ;
40+ var b = trace . _b = trace . _b || trace . b ;
41+ x = trace . _x || trace . x ;
42+ y = trace . _y || trace . y ;
43+
44+ var t = { } ;
3245
3346 if ( trace . _cheater ) {
3447 var avals = aax . cheatertype === 'index' ? a . length : a ;
3548 var bvals = bax . cheatertype === 'index' ? b . length : b ;
3649 x = cheaterBasis ( avals , bvals , trace . cheaterslope ) ;
37- } else {
38- x = trace . x ;
3950 }
4051
4152 trace . _x = x = clean2dArray ( x ) ;
@@ -48,13 +59,11 @@ module.exports = function calc(gd, trace) {
4859 smoothFill2dArray ( x , a , b ) ;
4960 smoothFill2dArray ( y , a , b ) ;
5061
62+ setConvert ( trace ) ;
63+
5164 // create conversion functions that depend on the data
5265 trace . setScale ( ) ;
5366
54- // Convert cartesian-space x/y coordinates to screen space pixel coordinates:
55- t . xp = trace . xp = map2dArray ( trace . xp , x , xa . c2p ) ;
56- t . yp = trace . yp = map2dArray ( trace . yp , y , ya . c2p ) ;
57-
5867 // This is a rather expensive scan. Nothing guarantees monotonicity,
5968 // so we need to scan through all data to get proper ranges:
6069 var xrange = arrayMinmax ( x ) ;
@@ -78,8 +87,8 @@ module.exports = function calc(gd, trace) {
7887
7988 // Enumerate the gridlines, both major and minor, and store them on the trace
8089 // object:
81- calcGridlines ( trace , t , 'a' , 'b' ) ;
82- calcGridlines ( trace , t , 'b' , 'a' ) ;
90+ calcGridlines ( trace , 'a' , 'b' ) ;
91+ calcGridlines ( trace , 'b' , 'a' ) ;
8392
8493 // Calculate the text labels for each major gridline and store them on the
8594 // trace object:
@@ -88,7 +97,7 @@ module.exports = function calc(gd, trace) {
8897
8998 // Tabulate points for the four segments that bound the axes so that we can
9099 // map to pixel coordinates in the plot function and create a clip rect:
91- t . clipsegments = calcClipPath ( trace . xctrl , trace . yctrl , aax , bax ) ;
100+ t . clipsegments = calcClipPath ( trace . _xctrl , trace . _yctrl , aax , bax ) ;
92101
93102 t . x = x ;
94103 t . y = y ;
0 commit comments