Skip to content

Commit 06d93ae

Browse files
committed
prep to add treemap to the lib
1 parent 320f81a commit 06d93ae

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Plotly.register([
2626

2727
require('./pie'),
2828
require('./sunburst'),
29+
require('./treemap'),
2930
require('./funnelarea'),
3031

3132
require('./scatter3d'),

lib/treemap.js

Lines changed: 11 additions & 0 deletions
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/treemap');

src/lib/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,10 @@ lib.isValidTextValue = function(v) {
11591159
return v || v === 0;
11601160
};
11611161

1162+
/**
1163+
* @param {number} ratio
1164+
* @param {number} n (number of decimal places)
1165+
*/
11621166
lib.formatPercent = function(ratio, n) {
11631167
n = n || 0;
11641168
var str = (Math.round(100 * ratio * Math.pow(10, n)) * Math.pow(0.1, n)).toFixed(n) + '%';

src/plot_api/plot_api.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2450,7 +2450,7 @@ var traceUIControlPatterns = [
24502450
{pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'},
24512451
{pattern: /^dimensions\[\d+\]\.constraintrange/},
24522452
{pattern: /^node\.(x|y|groups)/}, // for Sankey nodes
2453-
{pattern: /^level$/}, // for Sunburst traces
2453+
{pattern: /^level$/}, // for Sunburst & Treemap traces
24542454

24552455
// below this you must be in editable: true mode
24562456
// TODO: I still put name and title with `trace.uirevision`
@@ -3780,6 +3780,9 @@ function makePlotFramework(gd) {
37803780
// single pie layer for the whole plot
37813781
fullLayout._pielayer = fullLayout._paper.append('g').classed('pielayer', true);
37823782

3783+
// single treemap layer for the whole plot
3784+
fullLayout._treemaplayer = fullLayout._paper.append('g').classed('treemaplayer', true);
3785+
37833786
// single sunburst layer for the whole plot
37843787
fullLayout._sunburstlayer = fullLayout._paper.append('g').classed('sunburstlayer', true);
37853788

src/plots/plots.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2773,9 +2773,10 @@ plots.doCalcdata = function(gd, traces) {
27732773
gd._hmpixcount = 0;
27742774
gd._hmlumcount = 0;
27752775

2776-
// for sharing colors across pies / sunbursts / funnelarea (and for legend)
2776+
// for sharing colors across pies / sunbursts / treemap / funnelarea (and for legend)
27772777
fullLayout._piecolormap = {};
27782778
fullLayout._sunburstcolormap = {};
2779+
fullLayout._treemapcolormap = {};
27792780
fullLayout._funnelareacolormap = {};
27802781

27812782
// If traces were specified and this trace was not included,

0 commit comments

Comments
 (0)