Skip to content

Commit c0cebfd

Browse files
authored
Merge pull request #3978 from plotly/indicator-pr
trace type `indicator`
2 parents d096307 + 1a991d5 commit c0cebfd

37 files changed

+3174
-10
lines changed

lib/index-finance.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Plotly.register([
1818
require('./ohlc'),
1919
require('./candlestick'),
2020
require('./funnel'),
21-
require('./waterfall')
21+
require('./waterfall'),
22+
require('./indicator')
2223
]);
2324

2425
module.exports = Plotly;

lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Plotly.register([
4949
require('./scattermapbox'),
5050

5151
require('./sankey'),
52+
require('./indicator'),
5253

5354
require('./table'),
5455

lib/indicator.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright 2012-2019, 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/indicator');

src/components/modebar/manage.js

+11
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) {
146146
if(hasCartesian) {
147147
hoverGroup = ['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian'];
148148
}
149+
if(hasNoHover(fullData)) {
150+
hoverGroup = [];
151+
}
149152

150153
if((hasCartesian || hasGL2D) && !allAxesFixed) {
151154
zoomGroup = ['zoomIn2d', 'zoomOut2d', 'autoScale2d'];
@@ -216,6 +219,14 @@ function isSelectable(fullData) {
216219
return selectable;
217220
}
218221

222+
// check whether all trace are 'noHover'
223+
function hasNoHover(fullData) {
224+
for(var i = 0; i < fullData.length; i++) {
225+
if(!Registry.traceIs(fullData[i], 'noHover')) return false;
226+
}
227+
return true;
228+
}
229+
219230
function appendButtonsToGroups(groups, buttons) {
220231
if(buttons.length) {
221232
if(Array.isArray(buttons[0])) {

src/constants/delta.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright 2012-2019, 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+
INCREASING: {
13+
COLOR: '#3D9970',
14+
SYMBOL: '▲'
15+
},
16+
DECREASING: {
17+
COLOR: '#FF4136',
18+
SYMBOL: '▼'
19+
}
20+
};

src/plot_api/plot_api.js

+3
Original file line numberDiff line numberDiff line change
@@ -3779,6 +3779,9 @@ function makePlotFramework(gd) {
37793779
// single sunburst layer for the whole plot
37803780
fullLayout._sunburstlayer = fullLayout._paper.append('g').classed('sunburstlayer', true);
37813781

3782+
// single indicator layer for the whole plot
3783+
fullLayout._indicatorlayer = fullLayout._toppaper.append('g').classed('indicatorlayer', true);
3784+
37823785
// fill in image server scrape-svg
37833786
fullLayout._glimages = fullLayout._paper.append('g').classed('glimages', true);
37843787

src/snapshot/tosvg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = function toSVG(gd, format, scale) {
8888
// fill whatever container it's displayed in regardless of plot size.
8989
svg.node().style.background = '';
9090

91-
svg.selectAll('text')
91+
svg.selectAll('text,tspan')
9292
.attr({'data-unformatted': null, 'data-math': null})
9393
.each(function() {
9494
var txt = d3.select(this);

0 commit comments

Comments
 (0)