70
70
}
71
71
72
72
73
+ # Scales from https://plotly.com/python/builtin-colorscales/
74
+ __COLOR_SCALES__ = {
75
+ "none" : None ,
76
+ "tempo" : px .colors .sequential .tempo ,
77
+ "blues" : px .colors .sequential .Blues ,
78
+ "plasma" : px .colors .sequential .Plasma_r ,
79
+ }
80
+
81
+
73
82
class FetchStyle (Enum ):
74
83
NM = auto ()
75
84
OBJDUMP = auto ()
@@ -358,6 +367,7 @@ def build_treemap(
358
367
symbols : list [Symbol ],
359
368
separator : str ,
360
369
figure_generator : Callable ,
370
+ color : Optional [list [str ]],
361
371
max_depth : int ,
362
372
zoom : Optional [str ],
363
373
strip : Optional [str ],
@@ -459,13 +469,19 @@ def build_treemap(
459
469
460
470
data ["name_with_size" ][idx ] = f"{ short_name } : { data ["size" ][idx ]} "
461
471
472
+ extra_args = {}
473
+ if color is not None :
474
+ extra_args ['color_continuous_scale' ] = color
475
+ extra_args ['color' ] = "size"
476
+
462
477
fig = figure_generator (
463
478
data ,
464
479
names = "name_with_size" ,
465
480
ids = "name" ,
466
481
parents = "parent" ,
467
482
values = "size" ,
468
483
maxdepth = max_depth ,
484
+ ** extra_args ,
469
485
)
470
486
471
487
fig .update_traces (
@@ -771,6 +787,13 @@ def compute_symbol_diff(orig: list[Symbol], base: list[Symbol]) -> list[Symbol]:
771
787
type = click .Choice (list (__CHART_STYLES__ .keys ()), case_sensitive = False ),
772
788
help = "Style of the chart" ,
773
789
)
790
+ @click .option (
791
+ "--color" ,
792
+ default = "None" ,
793
+ show_default = True ,
794
+ type = click .Choice (list (__COLOR_SCALES__ .keys ()), case_sensitive = False ),
795
+ help = "Color display (if any)" ,
796
+ )
774
797
@click .option (
775
798
"--fetch-via" ,
776
799
default = "nm" ,
@@ -806,6 +829,7 @@ def main(
806
829
log_level ,
807
830
elf_file : str ,
808
831
display_type : str ,
832
+ color : str ,
809
833
fetch_via : str ,
810
834
max_depth : int ,
811
835
zoom : Optional [str ],
@@ -824,7 +848,7 @@ def main(
824
848
title = f"{ elf_file } COMPARED TO { diff } "
825
849
826
850
build_treemap (
827
- title , symbols , separator , __CHART_STYLES__ [display_type ], max_depth , zoom , strip
851
+ title , symbols , separator , __CHART_STYLES__ [display_type ], __COLOR_SCALES__ [ color ], max_depth , zoom , strip
828
852
)
829
853
830
854
0 commit comments