11
11
var Axes = require ( '../../plots/cartesian/axes' ) ;
12
12
var cheaterBasis = require ( './cheater_basis' ) ;
13
13
var arrayMinmax = require ( './array_minmax' ) ;
14
- var map2dArray = require ( './map_2d_array' ) ;
15
14
var calcGridlines = require ( './calc_gridlines' ) ;
16
15
var calcLabels = require ( './calc_labels' ) ;
17
16
var calcClipPath = require ( './calc_clippath' ) ;
18
17
var clean2dArray = require ( '../heatmap/clean_2d_array' ) ;
19
18
var 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' ) ;
20
22
21
23
module . 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 ) ;
24
26
var aax = trace . aaxis ;
25
27
var bax = trace . baxis ;
26
- var a = trace . _a = trace . a ;
27
- var b = trace . _b = trace . b ;
28
28
29
- var t = { } ;
30
- var x ;
29
+ var x = trace . x ;
31
30
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 = { } ;
32
45
33
46
if ( trace . _cheater ) {
34
47
var avals = aax . cheatertype === 'index' ? a . length : a ;
35
48
var bvals = bax . cheatertype === 'index' ? b . length : b ;
36
49
x = cheaterBasis ( avals , bvals , trace . cheaterslope ) ;
37
- } else {
38
- x = trace . x ;
39
50
}
40
51
41
52
trace . _x = x = clean2dArray ( x ) ;
@@ -48,13 +59,11 @@ module.exports = function calc(gd, trace) {
48
59
smoothFill2dArray ( x , a , b ) ;
49
60
smoothFill2dArray ( y , a , b ) ;
50
61
62
+ setConvert ( trace ) ;
63
+
51
64
// create conversion functions that depend on the data
52
65
trace . setScale ( ) ;
53
66
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
-
58
67
// This is a rather expensive scan. Nothing guarantees monotonicity,
59
68
// so we need to scan through all data to get proper ranges:
60
69
var xrange = arrayMinmax ( x ) ;
@@ -78,8 +87,8 @@ module.exports = function calc(gd, trace) {
78
87
79
88
// Enumerate the gridlines, both major and minor, and store them on the trace
80
89
// object:
81
- calcGridlines ( trace , t , 'a' , 'b' ) ;
82
- calcGridlines ( trace , t , 'b' , 'a' ) ;
90
+ calcGridlines ( trace , 'a' , 'b' ) ;
91
+ calcGridlines ( trace , 'b' , 'a' ) ;
83
92
84
93
// Calculate the text labels for each major gridline and store them on the
85
94
// trace object:
@@ -88,7 +97,7 @@ module.exports = function calc(gd, trace) {
88
97
89
98
// Tabulate points for the four segments that bound the axes so that we can
90
99
// 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 ) ;
92
101
93
102
t . x = x ;
94
103
t . y = y ;
0 commit comments