Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce35947

Browse files
committed
add test for legends with title and scroll - fix title scroll
1 parent b3765b4 commit ce35947

File tree

3 files changed

+135
-3
lines changed

3 files changed

+135
-3
lines changed

src/components/legend/draw.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,20 @@ module.exports = function draw(gd) {
6363
.call(Color.fill, opts.bgcolor)
6464
.style('stroke-width', opts.borderwidth + 'px');
6565

66+
var scrollBox = Lib.ensureSingle(legend, 'g', 'scrollbox');
6667

6768
var title = opts.title;
6869
opts._titleWidth = 0;
6970
opts._titleHeight = 0;
7071
if(title.text) {
71-
var titleEl = Lib.ensureSingle(legend, 'text', 'legendtitletext');
72+
var titleEl = Lib.ensureSingle(scrollBox, 'text', 'legendtitletext');
7273
titleEl.attr('text-anchor', 'start')
7374
.classed('user-select-none', true)
7475
.call(Drawing.font, title.font)
7576
.text(title.text);
7677

77-
textLayout(titleEl, legend, gd); // handle mathjax or multi-line text and compute title height
78+
textLayout(titleEl, scrollBox, gd); // handle mathjax or multi-line text and compute title height
7879
}
79-
var scrollBox = Lib.ensureSingle(legend, 'g', 'scrollbox');
8080

8181
var scrollBar = Lib.ensureSingle(legend, 'rect', 'scrollbar', function(s) {
8282
s.attr(constants.scrollBarEnterAttrs)
Loading
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"data": [
3+
{
4+
"x": [1,2,3],
5+
"y": [1,2,3],
6+
"type": "scatter"
7+
},
8+
{
9+
"x": [1,2,3],
10+
"y": [2,3,4],
11+
"type": "bar"
12+
},
13+
{
14+
"x": [1,2,3],
15+
"y": [3,4,5],
16+
"type": "scatter"
17+
},
18+
{
19+
"x": [1,2,3],
20+
"y": [4,5,6],
21+
"type": "bar"
22+
},
23+
{
24+
"x": [1,2,3],
25+
"y": [5,6,7],
26+
"type": "scatter"
27+
},
28+
{
29+
"x": [1,2,3],
30+
"y": [6,7,8],
31+
"type": "bar"
32+
},
33+
{
34+
"x": [1,2,3],
35+
"y": [7,8,9],
36+
"type": "scatter"
37+
},
38+
{
39+
"x": [1,2,3],
40+
"y": [8,9,10],
41+
"type": "bar"
42+
},
43+
{
44+
"x": [1,2,3],
45+
"y": [9,10,11],
46+
"type": "scatter"
47+
},
48+
{
49+
"x": [1,2,3],
50+
"y": [10,11,12],
51+
"type": "bar"
52+
},
53+
{
54+
"x": [1,2,3],
55+
"y": [11,12,13],
56+
"type": "scatter"
57+
},
58+
{
59+
"x": [1,2,3],
60+
"y": [12,13,14],
61+
"type": "bar"
62+
},
63+
{
64+
"x": [1,2,3],
65+
"y": [13,14,15],
66+
"type": "scatter"
67+
},
68+
{
69+
"x": [1,2,3],
70+
"y": [14,15,16],
71+
"type": "bar"
72+
},
73+
{
74+
"x": [1,2,3],
75+
"y": [15,16,17],
76+
"type": "scatter"
77+
},
78+
{
79+
"x": [1,2,3],
80+
"y": [16,17,18],
81+
"type": "bar"
82+
},
83+
{
84+
"x": [1,2,3],
85+
"y": [17,18,19],
86+
"type": "scatter"
87+
},
88+
{
89+
"x": [1,2,3],
90+
"y": [18,19,20],
91+
"type": "bar"
92+
},
93+
{
94+
"x": [1,2,3],
95+
"y": [19,20,21],
96+
"type": "scatter"
97+
},
98+
{
99+
"x": [1,2,3],
100+
"y": [20,21,22],
101+
"type": "bar"
102+
},
103+
{
104+
"x": [1,2,3],
105+
"y": [21,22,23],
106+
"type": "scatter"
107+
},
108+
{
109+
"x": [1,2,3],
110+
"y": [22,23,24],
111+
"type": "bar"
112+
},
113+
{
114+
"x": [1,2,3],
115+
"y": [23,24,25],
116+
"type": "scatter"
117+
}
118+
],
119+
"layout": {
120+
"legend": {
121+
"bordercolor": "#000000",
122+
"borderwidth": 1,
123+
"bgcolor": "#eeffee",
124+
"title": {
125+
"text": "<b>Legend title</b>",
126+
"font": {
127+
"size": 20
128+
}
129+
}
130+
}
131+
}
132+
}

0 commit comments

Comments
 (0)