@@ -72,38 +72,56 @@ $(function() {
72
72
if ( ! window . data_byprocess . hasOwnProperty ( pname ) )
73
73
continue ;
74
74
var smry = window . data_byprocess [ pname ] ;
75
- co2e_data . push ( { y : norm_units ( smry . co2e ) , name : pname , type :'box' , boxmean : true , boxpoints : false } ) ;
76
- energy_data . push ( { y : norm_units ( smry . energy ) , name : pname , type :'box' , boxmean : true , boxpoints : false } ) ;
75
+ co2e_data . push ( { x : pname , y : norm_units ( smry . co2e ) , name : pname , type :'box' , boxmean : true , boxpoints : false } ) ;
76
+ energy_data . push ( { x : pname , y : norm_units ( smry . energy ) , name : pname , type :'box' , boxmean : true , boxpoints : false } ) ;
77
77
}
78
78
79
79
// Decide yaxis tickformat
80
+ var max_co2e = 0 ;
80
81
co2e_data . forEach ( function ( p ) {
81
- max = 0 ;
82
+ max_co2e = 0 ;
82
83
if ( p != null ) {
83
84
if ( Array . isArray ( p . y ) ) {
84
- max = Math . max ( max , ...p . y ) ;
85
+ max_co2e = Math . max ( max_co2e , ...p . y ) ;
85
86
} else {
86
- max = Math . max ( max , p . y ) ;
87
+ max_co2e = Math . max ( max_co2e , p . y ) ;
87
88
}
88
-
89
89
}
90
90
} ) ;
91
- var co2e_tickformat = ( max <= 4 ) ? ( '.2f' ) : ( '.3s' ) ;
91
+ var co2e_tickformat = ( max_co2e <= 4 ) ? ( '.2f' ) : ( '.3s' ) ;
92
92
energy_data . forEach ( function ( p ) {
93
- max = 0 ;
93
+ max_energy = 0 ;
94
94
if ( p != null ) {
95
95
if ( Array . isArray ( p . y ) ) {
96
- max = Math . max ( max , ...p . y ) ;
96
+ max_energy = Math . max ( max_energy , ...p . y ) ;
97
97
} else {
98
- max = Math . max ( max , p . y ) ;
98
+ max_energy = Math . max ( max_energy , p . y ) ;
99
99
}
100
100
}
101
101
} ) ;
102
- var energy_tickformat = ( max <= 4 ) ? ( '.2f' ) : ( '.3s' ) ;
102
+ var energy_tickformat = ( max_energy <= 4 ) ? ( '.2f' ) : ( '.3s' ) ;
103
103
104
-
105
- Plotly . newPlot ( 'co2eplot' , co2e_data , { title : 'CO2e emission' , yaxis : { title : 'CO2e emission (g)' , tickformat : co2e_tickformat , rangemode : 'tozero' } } ) ;
106
- Plotly . newPlot ( 'energyplot' , energy_data , { title : 'Energy consumption' , yaxis : { title : 'Energy consumption (Wh)' , tickformat : energy_tickformat , rangemode : 'tozero' } } ) ;
104
+ var layout = {
105
+ title : 'CO2e emission & energy consumption' ,
106
+ xaxis : { domain : [ 0.3 , 0.7 ] } ,
107
+ yaxis : { title : 'CO2e emission (g)' ,
108
+ tickformat : co2e_tickformat ,
109
+ range : [ 0 , max_co2e + 1 ]
110
+ } ,
111
+ yaxis2 : {
112
+ title : 'Energy consumption (Wh)' ,
113
+ tickformat : energy_tickformat ,
114
+ range : [ 0 , max_energy + 1 ] ,
115
+ overlaying : 'y' ,
116
+ side : 'left' ,
117
+ anchor : 'free' ,
118
+ position : 0.15
119
+ }
120
+ } ;
121
+
122
+ var data = co2e_data ;
123
+ data . push ( { yaxis :'y2' } ) ;
124
+ Plotly . newPlot ( 'co2eplot' , data , layout ) ;
107
125
108
126
// Convert to readable units
109
127
function readable_units ( value , unit_index ) {
0 commit comments