@@ -128,15 +128,21 @@ const graphDiv = "#test";
128
128
} as PlotData ;
129
129
const data = [ trace1 , trace2 , trace3 ] ;
130
130
const layout = {
131
- title : "Gapminder" ,
131
+ title : {
132
+ text : "Gapminder" ,
133
+ } ,
132
134
xaxis : {
133
- title : "Life Expectancy" ,
135
+ title : {
136
+ text : "Life Expectancy" ,
137
+ } ,
134
138
domain : [ 0 , 0.85 ] ,
135
139
showgrid : false ,
136
140
zeroline : false ,
137
141
} ,
138
142
yaxis : {
139
- title : "GDP per Cap" ,
143
+ title : {
144
+ text : "GDP per Cap" ,
145
+ } ,
140
146
showline : false ,
141
147
domain : [ 0 , 0.85 ] ,
142
148
showgrid : false ,
@@ -165,7 +171,7 @@ const graphDiv = "#test";
165
171
type : "scatter" ,
166
172
} as PlotData ,
167
173
] ;
168
- const layout2 = { title : "Revenue" } ;
174
+ const layout2 = { title : { text : "Revenue" } } ;
169
175
Plotly . newPlot ( graphDiv , data2 , layout2 ) ;
170
176
} ) ( ) ;
171
177
( ( ) => {
@@ -313,7 +319,13 @@ const graphDiv = "#test";
313
319
yanchor : "top" ,
314
320
} ;
315
321
316
- const layout : Partial < Layout > = { showlegend : true , title : "January 2013 Sales Report" , template, modebar, legend } ;
322
+ const layout : Partial < Layout > = {
323
+ showlegend : true ,
324
+ title : { text : "January 2013 Sales Report" } ,
325
+ template,
326
+ modebar,
327
+ legend,
328
+ } ;
317
329
const config : Partial < Config > = {
318
330
modeBarButtons : [
319
331
[
@@ -414,7 +426,9 @@ const graphDiv = "#test";
414
426
} ,
415
427
] ;
416
428
const layout : Partial < Layout > = {
417
- title : "Grouped Box Plot" ,
429
+ title : {
430
+ text : "Grouped Box Plot" ,
431
+ } ,
418
432
boxmode : "overlay" ,
419
433
} ;
420
434
@@ -425,7 +439,9 @@ const graphDiv = "#test";
425
439
const data : Array < Partial < PlotData > > = [
426
440
{
427
441
colorbar : {
428
- title : "Test" ,
442
+ title : {
443
+ text : "Test" ,
444
+ } ,
429
445
} ,
430
446
locationmode : "ISO-3" ,
431
447
locations : [ "USA" , "NLD" ] ,
@@ -436,7 +452,9 @@ const graphDiv = "#test";
436
452
] ;
437
453
const layout : Partial < Layout > = {
438
454
showlegend : true ,
439
- title : "World Map" ,
455
+ title : {
456
+ text : "World Map" ,
457
+ } ,
440
458
geo : {
441
459
projection : { type : "Mercator" } ,
442
460
showcoastlines : true ,
@@ -577,7 +595,9 @@ const graphDiv = "#test";
577
595
// update only values within nested objects
578
596
( ( ) => {
579
597
const update = {
580
- title : "some new title" , // updates the title
598
+ title : { // updates the title
599
+ text : "some new title" ,
600
+ } ,
581
601
"xaxis.range" : [ 0 , 5 ] , // updates the xaxis range
582
602
"yaxis.range[1]" : 15 , // updates the end of the yaxis range
583
603
} as Layout ;
@@ -589,7 +609,9 @@ const graphDiv = "#test";
589
609
marker : { color : "red" } ,
590
610
} ;
591
611
const layout_update = {
592
- title : "some new title" , // updates the title
612
+ title : { // updates the title
613
+ text : "some new title" ,
614
+ } ,
593
615
} ;
594
616
Plotly . update ( graphDiv , data_update , layout_update ) ;
595
617
} ) ( ) ;
@@ -620,7 +642,9 @@ const graphDiv = "#test";
620
642
marker : { color : "red" } ,
621
643
} ;
622
644
const layout_update = {
623
- title : "some new title" , // updates the title
645
+ title : { // updates the title
646
+ text : "some new title" ,
647
+ } ,
624
648
} ;
625
649
Plotly . update ( graphDiv , data_update , layout_update ) ;
626
650
} ) ( ) ;
0 commit comments