8000 OHLC and Candlestick trace types by etpinard · Pull Request #1020 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

OHLC and Candlestick trace types #1020

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 32 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e915a29
relax requirement for re-calc
etpinard Oct 7, 2016
cf5da9b
plots: pass user layout to transforms
etpinard Oct 7, 2016
7864fa8
first pass ohlc trace type
etpinard Sep 9, 2016
44f2bec
first pass candlestick trace type
etpinard Sep 9, 2016
df24552
add ohlc and candlestick to main plotly.js lib index
etpinard Sep 9, 2016
6cac3fe
[maybe?] add 'finance' partial bundle
etpinard Sep 9, 2016
0f17423
fixup user-defined transform test
etpinard Oct 7, 2016
61c72cc
finance: replace attribute 't' -> 'x'
etpinard Oct 7, 2016
a9eb7c5
candlestick: rename 'tickwidth' -> 'whiskerwidth' + make it 1 per trace
etpinard Oct 7, 2016
ede8ee2
ohlc: make 'tickwidth' 1 per trace
etpinard Oct 7, 2016
f6c33f2
finance: 2nd iteration
etpinard Oct 7, 2016
96e129a
fix groupby when `enabled: false
etpinard Oct 7, 2016
e32b60f
findArrayAttributes: include array attribute in fullInput module
etpinard Oct 7, 2016
d61afb9
test: first pass finance suite
etpinard Oct 7, 2016
dc8aaea
finace: ensure supplyDefaults is idempotent
etpinard Oct 11, 2016
5c94c05
finance: add re-calc attributes to restyle lists
etpinard Oct 11, 2016
1f574f2
finance: ensure that restyling visible works
etpinard Oct 11, 2016
7b19b74
finance: improve dflt colors
etpinard Oct 11, 2016
2b1918c
finance: improve inc / dec 'name' / 'showlegend' logic
etpinard Oct 11, 2016
fbb299b
legend: add logic for 'ohlc' and 'candlestick' in legend name edits
etpinard Oct 11, 2016
caf390b
doc: add comments about non-trivial logic in ohlc / candlestick
etpinard Oct 11, 2016
672d517
finance: pass trace 'xaxis' & 'yaxis' to generated traces
etpinard Oct 12, 2016
ea3c5a1
finance: make sure computed tickWidth is always positive
etpinard Oct 12, 2016
a892b26
olhc: add custom hover text
etpinard Oct 12, 2016
7e0a382
finance: ensure that user data isn't mutated in Plots.supplyDefaults
etpinard Oct 12, 2016
f6f072f
utils: add filterUnique helper
etpinard Oct 12, 2016
6036045
ohlc: don't force hovermode: 'closest'
etpinard Oct 12, 2016
d26a4b4
ohlc: bump tickwidth dflt to 0.1
etpinard Oct 12, 2016
3803005
finance: add common 'line' style container
etpinard Oct 12, 2016
facbf3d
test: add finance mocks
etpinard Oct 12, 2016
b98835c
ohlc: bump tickwidth dflt to 0.3
etpinard Oct 13, 2016
c9de6c8
test: add finance trace module bundle test
etpinard Oct 13, 2016
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
Prev Previous commit
Next Next commit
finace: ensure supplyDefaults is idempotent
  • Loading branch information
etpinard committed Oct 11, 2016
commit dc8aaea081327dc5783afa50017a3c0e2794d11f
4 changes: 1 addition & 3 deletions src/traces/candlestick/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ var helpers = require('../ohlc/helpers');
var attributes = require('./attributes');

module.exports = function supplyDefaults(traceIn, traceOut) {
helpers.pushDummyTransformOpts(traceIn, traceOut);

function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}

var transformOpts = { type: 'candlestick' };
helpers.prependTransformOpts(traceIn, traceOut, transformOpts);

var len = handleOHLC(traceIn, traceOut, coerce);
if(len === 0) {
traceOut.visible = false;
Expand Down
4 changes: 1 addition & 3 deletions src/traces/ohlc/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ var attributes = require('./attributes');
var helpers = require('./helpers');

module.exports = function supplyDefaults(traceIn, traceOut) {
helpers.pushDummyTransformOpts(traceIn, traceOut);

function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}

var transformOpts = { type: 'ohlc' };
helpers.prependTransformOpts(traceIn, traceOut, transformOpts);

var len = handleOHLC(traceIn, traceOut, coerce);
if(len === 0) {
traceOut.visible = false;
Expand Down
17 changes: 16 additions & 1 deletion src/traces/ohlc/helpers.js
8000
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,23 @@
var Lib = require('../../lib');

// TODO add comment
exports.prependTransformOpts = function(traceIn, traceOut, transformOpts) {
exports.pushDummyTransformOpts = function(traceIn, traceOut) {
var transformOpts = {

// give dummy transform the same type as trace
type: traceOut.type,

// track ephemeral transforms in user data
_ephemeral: true
};

if(Array.isArray(traceIn.transforms)) {
var transformsIn = traceIn.transforms;

for(var i = 0; i < transformsIn.length; i++) {
if(transformsIn[i]._ephemeral) transformsIn.splice(i, 1);
}

traceIn.transforms.push(transformOpts);
}
else {
Expand Down
20 changes: 20 additions & 0 deletions test/jasmine/tests/finance_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ describe('finance charts defaults:', function() {
expect(directions).toEqual(['increasing', 'decreasing', 'increasing', 'decreasing']);
});

it('unfortunately mutates user trace', function() {
var trace0 = Lib.extendDeep({}, mock0, {
type: 'ohlc'
});

var trace1 = Lib.extendDeep({}, mock1, {
type: 'candlestick'
});

var out = _supply([trace0, trace1]);
expect(out.data[0].transforms).toEqual([{ type: 'ohlc', _ephemeral: true }]);
expect(out.data[1].transforms).toEqual([{ type: 'candlestick', _ephemeral: true }]);

// but at least in an idempotent way

var out2 = _supply(out.data);
expect(out2.data[0].transforms).toEqual([{ type: 'ohlc', _ephemeral: true }]);
expect(out2.data[1].transforms).toEqual([{ type: 'candlestick', _ephemeral: true }]);
});

it('should work with transforms', function() {
var trace0 = Lib.extendDeep({}, mock1, {
type: 'ohlc',
Expand Down
0