Skip to content

Commit c3a0f5a

Browse files
committed
add support for finance traces on multicategory axes
1 parent bf52cd7 commit c3a0f5a

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

src/traces/ohlc/ohlc_defaults.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var Registry = require('../../registry');
13-
12+
var Lib = require('../../lib');
1413

1514
module.exports = function handleOHLC(traceIn, traceOut, coerce, layout) {
1615
var x = coerce('x');
@@ -27,9 +26,7 @@ module.exports = function handleOHLC(traceIn, traceOut, coerce, layout) {
2726
if(!(open && high && low && close)) return;
2827

2928
var len = Math.min(open.length, high.length, low.length, close.length);
30-
31-
if(x) len = Math.min(len, x.length);
32-
29+
if(x) len = Math.min(len, Lib.minRowLength(x));
3330
traceOut._length = len;
3431

3532
return len;
26.8 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"data": [
3+
{
4+
"name": "ohlc",
5+
"type": "ohlc",
6+
"open": [ 10, 11, 12, 13, 12, 13, 14, 15, 16 ],
7+
"high": [ 15, 16, 17, 18, 17, 18, 19, 20, 21 ],
8+
"low": [ 7, 8, 9, 10, 9, 10, 11, 12, 13 ],
9+
"close": [ 9, 10, 12, 13, 13, 12, 14, 14, 17 ],
10+
"x": [
11+
[ "Group 1", "Group 1", "Group 1", "Group 2", "Group 2", "Group 2", "Group 3", "Group 3", "Group 3" ],
12+
[ "a", "b", "c", "a", "b", "c", "a", "b", "c" ]
13+
]
14+
},
15+
{
16+
"name": "candlestick",
17+
"type": "candlestick",
18+
"open": [ 20, 21, 22, 23, 22, 23, 24, 25, 26 ],
19+
"high": [ 25, 26, 27, 28, 27, 28, 29, 30, 31 ],
20+
"low": [ 17, 18, 19, 20, 19, 20, 21, 22, 23 ],
21+
"close": [ 19, 20, 22, 23, 23, 22, 24, 24, 27 ],
22+
"x": [
23+
[ "Group 1", "Group 1", "Group 1", "Group 2", "Group 2", "Group 2", "Group 3", "Group 3", "Group 3" ],
24+
[ "a", "b", "c", "a", "b", "c", "a", "b", "c" ]
25+
]
26+
}
27+
],
28+
"layout": {
29+
"title": {
30+
"text": "Finance traces on multicategory x-axis",
31+
"xref": "paper",
32+
"x": 0
33+
},
34+
"legend": {
35+
"x": 1,
36+
"xanchor": "right",
37+
"y": 1,
38+
"yanchor": "bottom"
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)