Skip to content

Commit 1e53d57

Browse files
committed
Carpet scaffolding
1 parent 0fc99c6 commit 1e53d57

File tree

13 files changed

+418
-0
lines changed

13 files changed

+418
-0
lines changed

lib/carpet.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright 2012-2016, 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/traces/carpet');

lib/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Plotly.register([
3434

3535
require('./scattermapbox'),
3636

37+
require('./carpet'),
38+
3739
require('./ohlc'),
3840
require('./candlestick')
3941
]);

src/lib/carpet.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright 2012-2016, 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/traces/carpet');

src/traces/carpet/ab_defaults.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright 2012-2016, 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+
10+
'use strict';
11+
12+
// var Lib = require('../../lib');
13+
14+
// var isNumeric = require('fast-isnumeric');
15+
16+
var hasColumns = require('./has_columns');
17+
18+
19+
module.exports = function handleABDefaults(traceIn, traceOut, coerce) {
20+
var a = coerce('a');
21+
22+
if (!a) {
23+
coerce('da');
24+
coerce('a0');
25+
}
26+
27+
var b = coerce('b');
28+
29+
if (!b) {
30+
coerce('db');
31+
coerce('b0');
32+
}
33+
34+
return;
35+
};

src/traces/carpet/attributes.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* Copyright 2012-2016, 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 = {
12+
carpetid: {
13+
valType: 'string',
14+
role: 'info',
15+
description: [
16+
'An identifier for this carpet, so that `scattercarpet` and',
17+
'`scattercontour` traces can specify a carpet plot on which',
18+
'they lie'
19+
].join(' ')
20+
},
21+
x: {
22+
valType: 'data_array',
23+
description: [
24+
'A two dimensional array of x coordinates at each carpet point.',
25+
'If ommitted, the plot is a cheater plot and the xaxis is hidden',
26+
'by default.'
27+
].join(' ')
28+
},
29+
y: {
30+
valType: 'data_array',
31+
descripotion: 'A two dimensional array of y coordinates at each carpet point.'
32+
},
33+
a: {
34+
valType: 'data_array',
35+
description: [
36+
'An array containing values of the first parameter value'
37+
].join(' ')
38+
},
39+
a0: {
40+
valType: 'number',
41+
dflt: 0,
42+
role: 'info',
43+
description: [
44+
'Alternate to `a`.',
45+
'Builds a linear space of a coordinates.',
46+
'Use with `da`',
47+
'where `a0` is the starting coordinate and `da` the step.'
48+
].join(' ')
49+
},
50+
da: {
51+
valType: 'number',
52+
dflt: 1,
53+
role: 'info',
54+
description: [
55+
'Sets the a coordinate step.',
56+
'See `a0` for more info.'
57+
].join(' ')
58+
},
59+
b: {
60+
valType: 'data_array',
61+
descripotion: 'A two dimensional array of y coordinates at each carpet point.'
62+
},
63+
b0: {
64+
valType: 'number',
65+
dflt: 0,
66+
role: 'info',
67+
description: [
68+
'Alternate to `b`.',
69+
'Builds a linear space of a coordinates.',
70+
'Use with `db`',
71+
'where `b0` is the starting coordinate and `db` the step.'
72+
].join(' ')
73+
},
74+
db: {
75+
valType: 'number',
76+
dflt: 1,
77+
role: 'info',
78+
description: [
79+
'Sets the b coordinate step.',
80+
'See `b0` for more info.'
81+
].join(' ')
82+
},
83+
cheaterslope: {
84+
valType: 'number',
85+
dflt: 1,
86+
description: [
87+
'The shift applied to each successive row of data in creating a cheater plot.',
88+
'Only used if `x` is been ommitted.'
89+
].join(' ')
90+
},
91+
};

src/traces/carpet/calc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
/**
3+
* Copyright 2012-2016, Plotly, Inc.
4+
* All rights reserved.
5+
*
6+
* This source code is licensed under the MIT license found in the
7+
* LICENSE file in the root directory of this source tree.
8+
*/
9+
10+
11+
'use strict';
12+
13+
var isNumeric = require('fast-isnumeric');
14+
15+
var Registry = require('../../registry');
16+
var Lib = require('../../lib');
17+
var Axes = require('../../plots/cartesian/axes');
18+
19+
20+
module.exports = function calc(gd, trace) {
21+
// prepare the raw data
22+
console.log('calc!:');
23+
};

src/traces/carpet/constants.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Copyright 2012-2016, 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+
10+
'use strict';
11+
12+
module.exports = {
13+
};

src/traces/carpet/defaults.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright 2012-2016, 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+
10+
'use strict';
11+
12+
var Lib = require('../../lib');
13+
14+
var attributes = require('./attributes');
15+
var constants = require('./constants');
16+
var handleXYDefaults = require('./xy_defaults');
17+
var handleABDefaults = require('./ab_defaults');
18+
19+
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
20+
function coerce(attr, dflt) {
21+
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
22+
}
23+
24+
coerce('carpetid');
25+
26+
var len = handleXYDefaults(traceIn, traceOut, coerce);
27+
28+
if (!len) {
29+
traceOut.visible = false;
30+
return;
31+
}
32+
33+
handleABDefaults(traceIn, traceOut, coerce);
34+
35+
coerce('cheaterslope');
36+
};

src/traces/carpet/has_columns.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright 2012-2016, 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+
10+
'use strict';
11+
12+
module.exports = function(data) {
13+
return Array.isArray(data[0]);
14+
};

src/traces/carpet/index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2012-2016, 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+
10+
'use strict';
11+
12+
var Carpet = {};
13+
14+
Carpet.attributes = require('./attributes');
15+
Carpet.supplyDefaults = require('./defaults');
16+
Carpet.plot = require('./plot');
17+
Carpet.calc = require('./calc');
18+
Carpet.animatable = false;
19+
20+
Carpet.moduleType = 'trace';
21+
Carpet.name = 'carpet';
22+
Carpet.basePlotModule = require('../../plots/cartesian');
23+
Carpet.categories = ['cartesian', 'symbols', 'markerColorscale'];
24+
Carpet.meta = {
25+
description: [
26+
'The scatter trace type encompasses line charts, scatter charts, text charts, and bubble charts.',
27+
'The data visualized as scatter point or lines is set in `x` and `y`.',
28+
'Text (appearing either on the chart or on hover only) is via `text`.',
29+
'Bubble charts are achieved by setting `marker.size` and/or `marker.color`',
30+
'to numerical arrays.'
31+
].join(' ')
32+
};
33+
34+
module.exports = Carpet;

src/traces/carpet/plot.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright 2012-2016, 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+
10+
'use strict';
11+
12+
var d3 = require('d3');
13+
14+
var Lib = require('../../lib');
15+
var Drawing = require('../../components/drawing');
16+
17+
module.exports = function plot(gd, plotinfo, cdscatter) {
18+
};

src/traces/carpet/xy_defaults.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* Copyright 2012-2016, 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+
10+
'use strict';
11+
12+
// var Lib = require('../../lib');
13+
14+
// var isNumeric = require('fast-isnumeric');
15+
16+
var hasColumns = require('./has_columns');
17+
18+
19+
module.exports = function handleXYDefaults(traceIn, traceOut, coerce) {
20+
var x = coerce('x');
21+
22+
if (x && !hasColumns(x)) {
23+
// x absent is valid, but x present is only valid
24+
// if x has columns
25+
return 0;
26+
}
27+
28+
traceOut._cheater = !x;
29+
30+
var y = coerce('y');
31+
32+
// y must be both present *and* must have columns
33+
if (!y || !hasColumns(y)) {
34+
return 0;
35+
}
36+
37+
return y.length;
38+
};
39+
40+
/*
41+
function isValidZ(z) {
42+
var allRowsAreArrays = true,
43+
oneRowIsFilled = false,
44+
hasOneNumber = false,
45+
zi;
46+
47+
48+
// Without this step:
49+
//
50+
// hasOneNumber = false breaks contour but not heatmap
51+
// allRowsAreArrays = false breaks contour but not heatmap
52+
// oneRowIsFilled = false breaks both
53+
54+
for(var i = 0; i < z.length; i++) {
55+
zi = z[i];
56+
if(!Array.isArray(zi)) {
57+
allRowsAreArrays = false;
58+
break;
59+
}
60+
if(zi.length > 0) oneRowIsFilled = true;
61+
for(var j = 0; j < zi.length; j++) {
62+
if(isNumeric(zi[j])) {
63+
hasOneNumber = true;
64+
break;
65+
}
66+
}
67+
}
68+
69+
return (allRowsAreArrays && oneRowIsFilled && hasOneNumber);
70+
}
71+
*/

0 commit comments

Comments
 (0)