Skip to content

Commit 6f0bded

Browse files
authored
Merge pull request #1924 from plotly/aggregateby
Aggregate transforms
2 parents df5face + 572f282 commit 6f0bded

File tree

8 files changed

+759
-24
lines changed

8 files changed

+759
-24
lines changed

lib/aggregate.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright 2012-2017, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
module.exports = require('../src/transforms/aggregate');

lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Plotly.register([
5656
// https://github.com/plotly/plotly.js/pull/978#pullrequestreview-2403353
5757
//
5858
Plotly.register([
59+
require('./aggregate'),
5960
require('./filter'),
6061
require('./groupby'),
6162
require('./sort')

src/plots/cartesian/axes.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ axes.cleanPosition = function(pos, gd, axRef) {
124124
return cleanPos(pos);
125125
};
126126

127-
axes.getDataToCoordFunc = function(gd, trace, target, targetArray) {
127+
var getDataConversions = axes.getDataConversions = function(gd, trace, target, targetArray) {
128128
var ax;
129129

130130
// If target points to an axis, use the type we already have for that
@@ -155,15 +155,23 @@ axes.getDataToCoordFunc = function(gd, trace, target, targetArray) {
155155

156156
// if 'target' has corresponding axis
157157
// -> use setConvert method
158-
if(ax) return ax.d2c;
158+
if(ax) return {d2c: ax.d2c, c2d: ax.c2d};
159159

160160
// special case for 'ids'
161161
// -> cast to String
162-
if(d2cTarget === 'ids') return function(v) { return String(v); };
162+
if(d2cTarget === 'ids') return {d2c: toString, c2d: toString};
163163

164164
// otherwise (e.g. numeric-array of 'marker.color' or 'marker.size')
165165
// -> cast to Number
166-
return function(v) { return +v; };
166+
167+
return {d2c: toNum, c2d: toNum};
168+
};
169+
170+
function toNum(v) { return +v; }
171+
function toString(v) { return String(v); }
172+
173+
axes.getDataToCoordFunc = function(gd, trace, target, targetArray) {
174+
return getDataConversions(gd, trace, target, targetArray).d2c;
167175
};
168176

169177
// empty out types for all axes containing these traces

0 commit comments

Comments
 (0)