|
11 | 11 | var Lib = require('../lib');
|
12 | 12 | var Registry = require('../registry');
|
13 | 13 | var PlotSchema = require('../plot_api/plot_schema');
|
14 |
| -var axisIds = require('../plots/cartesian/axis_ids'); |
15 |
| -var autoType = require('../plots/cartesian/axis_autotype'); |
16 |
| -var setConvert = require('../plots/cartesian/set_convert'); |
| 14 | +var Axes = require('../plots/cartesian/axes'); |
17 | 15 |
|
18 | 16 | var COMPARISON_OPS = ['=', '!=', '<', '>=', '>', '<='];
|
19 | 17 | var INTERVAL_OPS = ['[]', '()', '[)', '(]', '][', ')(', '](', ')['];
|
@@ -159,13 +157,8 @@ exports.calcTransform = function(gd, trace, opts) {
|
159 | 157 | if(attrTargetCalendar) targetCalendar = attrTargetCalendar;
|
160 | 158 | }
|
161 | 159 |
|
162 |
| - // if target points to an axis, use the type we already have for that |
163 |
| - // axis to find the data type. Otherwise use the values to autotype. |
164 |
| - var d2cTarget = (target === 'x' || target === 'y' || target === 'z') ? |
165 |
| - target : filterArray; |
166 |
| - |
167 |
| - var dataToCoord = getDataToCoordFunc(gd, trace, d2cTarget); |
168 |
| - var filterFunc = getFilterFunc(opts, dataToCoord, targetCalendar); |
| 160 | + var d2c = Axes.getDataToCoordFunc(gd, trace, target, targetArray); |
| 161 | + var filterFunc = getFilterFunc(opts, d2c, targetCalendar); |
169 | 162 | var arrayAttrs = PlotSchema.findArrayAttributes(trace);
|
170 | 163 | var originalArrays = {};
|
171 | 164 |
|
@@ -203,60 +196,11 @@ exports.calcTransform = function(gd, trace, opts) {
|
203 | 196 |
|
204 | 197 | // loop through filter array, fill trace arrays if passed
|
205 | 198 | for(var i = 0; i < len; i++) {
|
206 |
| - var passed = filterFunc(filterArray[i]); |
| 199 | + var passed = filterFunc(targetArray[i]); |
207 | 200 | if(passed) forAllAttrs(fillFn, i);
|
208 | 201 | }
|
209 | 202 | };
|
210 | 203 |
|
211 |
| -function getFilterArray(trace, target) { |
212 |
| - if(typeof target === 'string' && target) { |
213 |
| - var array = Lib.nestedProperty(trace, target).get(); |
214 |
| - |
215 |
| - return Array.isArray(array) ? array : []; |
216 |
| - } |
217 |
| - else if(Array.isArray(target)) return target.slice(); |
218 |
| - |
219 |
| - return false; |
220 |
| -} |
221 |
| - |
222 |
| -function getDataToCoordFunc(gd, trace, target) { |
223 |
| - var ax; |
224 |
| - |
225 |
| - // In the case of an array target, make a mock data array |
226 |
| - // and call supplyDefaults to the data type and |
227 |
| - // setup the data-to-calc method. |
228 |
| - if(Array.isArray(target)) { |
229 |
| - ax = { |
230 |
| - type: autoType(target), |
231 |
| - _categories: [] |
232 |
| - }; |
233 |
| - |
234 |
| - setConvert(ax); |
235 |
| - |
236 |
| - if(ax.type === 'category') { |
237 |
| - // build up ax._categories (usually done during ax.makeCalcdata() |
238 |
| - for(var i = 0; i < target.length; i++) { |
239 |
| - ax.d2c(target[i]); |
240 |
| - } |
241 |
| - } |
242 |
| - } |
243 |
| - else { |
244 |
| - ax = axisIds.getFromTrace(gd, trace, target); |
245 |
| - } |
246 |
| - |
247 |
| - // if 'target' has corresponding axis |
248 |
| - // -> use setConvert method |
249 |
| - if(ax) return ax.d2c; |
250 |
| - |
251 |
| - // special case for 'ids' |
252 |
| - // -> cast to String |
253 |
| - if(target === 'ids') return function(v) { return String(v); }; |
254 |
| - |
255 |
| - // otherwise (e.g. numeric-array of 'marker.color' or 'marker.size') |
256 |
| - // -> cast to Number |
257 |
| - return function(v) { return +v; }; |
258 |
| -} |
259 |
| - |
260 | 204 | function getFilterFunc(opts, d2c, targetCalendar) {
|
261 | 205 | var operation = opts.operation,
|
262 | 206 | value = opts.value,
|
|
0 commit comments