Skip to content

Aggregate transforms #1924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/aggregate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = require('../src/transforms/aggregate');
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Plotly.register([
// https://github.com/plotly/plotly.js/pull/978#pullrequestreview-2403353
//
Plotly.register([
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort')
Expand Down
16 changes: 12 additions & 4 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ axes.cleanPosition = function(pos, gd, axRef) {
return cleanPos(pos);
};

axes.getDataToCoordFunc = function(gd, trace, target, targetArray) {
var getDataConversions = axes.getDataConversions = function(gd, trace, target, targetArray) {
var ax;

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

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

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

// otherwise (e.g. numeric-array of 'marker.color' or 'marker.size')
// -> cast to Number
return function(v) { return +v; };

return {d2c: toNum, c2d: toNum};
};

function toNum(v) { return +v; }
function toString(v) { return String(v); }

axes.getDataToCoordFunc = function(gd, trace, target, targetArray) {
return getDataConversions(gd, trace, target, targetArray).d2c;
};

// empty out types for all axes containing these traces
Expand Down
Loading