Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/javascripts/lib/models/chart.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class @Chart extends Backbone.Model

target_series: -> @series.select (s) -> s.get('is_target_line')

year_1990_series: -> @series.select (s) -> s.get('is_1990')
year_1990_series: -> @series.select (s) -> s.get('is_1990') && !s.get('is_target_line')

format_value: (value) =>
Metric.autoscale_value(value, @get('unit'), 2)
Expand Down
4 changes: 3 additions & 1 deletion app/assets/javascripts/lib/views/dashboard_item_view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ class @DashboardItemView extends Backbone.View
Metric.euros_to_string(result)
when 'household_energy_cost'
I18n.toCurrency(result, { precision: 0, unit: '€' })
when 'total_primary_energy', 'co2_reduction', 'local_co2_reduction', 'co2_reduction_relative_to_start_year', 'all_ghg_reduction_relative_to_start_year'
when 'direct_emissions_total_ghg'
Metric.autoscale_value(result, @model.gquery.get('unit'), 1)
when 'total_primary_energy', 'co2_reduction', 'local_co2_reduction', 'co2_reduction_relative_to_start_year', 'all_ghg_reduction_relative_to_start_year', 'direct_emissions_total_ghg_relative_to_1990'
# show + prefix if needed
Metric.ratio_as_percentage(result, true)
when 'net_energy_import', 'profitability'
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/_chart.sass
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ table
div.d3_container
svg
display: block
&.vertical_stacked_bar, &.waterfall, &.target_bar, &.co2_emissions, &.merit_order, &.cost_capacity_bar, &.category_bar, &.hourly_summarized
&.vertical_stacked_bar, &.waterfall, &.target_bar, &.co2_emissions, &.merit_order, &.cost_capacity_bar, &.category_bar, &.hourly_summarized, &.direct_emissions_per_sector
svg
shape-rendering: crispEdges
text
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/charts/Legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class Legend extends Backbone.View {
const clickable = this.options.clickable;

for (const series of this.options.items) {
if (series.get('hide_label')) {
continue;
}

this.el.append(
new LegendItem({
clickable,
Expand Down
13 changes: 10 additions & 3 deletions app/javascript/charts/StackedBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ const stack = d3.stack().offset(d3.stackOffsetDiverging);
* Determines the opacity with which a target line should be drawn.
*/
const targetLineOpacity = (serie) => {
const position = serie.get('target_line_position');
const value =
serie.get('target_line_position') === '1' ? serie.present_value() : serie.future_value();
position === '0' ? serie.present_value() :
position === '1' ? serie.present_value() :
serie.future_value();

return value === null ? 0 : 1;
};
Expand Down Expand Up @@ -129,7 +132,8 @@ class StackedBar extends D3Chart {
.attr('height', 2)
.attr('width', () => this.x.bandwidth() * 1.2)
.attr('x', (s) => {
const year = s.get('target_line_position') === '1' ? this.startYear : this.endYear;
const position = s.get('target_line_position');
const year = position === '0' ? 1990 : position === '1' ? this.startYear : this.endYear;
return this.x(year) - this.x.bandwidth() * 0.1;
})
.attr('y', 0);
Expand Down Expand Up @@ -174,8 +178,11 @@ class StackedBar extends D3Chart {
.style('opacity', targetLineOpacity)
.transition(transition)
.attr('y', (d) => {
const position = d.get('target_line_position');
const value =
d.get('target_line_position') === '1' ? d.safe_present_value() : d.safe_future_value();
position === '0' ? d.safe_present_value() :
position === '1' ? d.safe_present_value() :
d.safe_future_value();

return this.y(value);
});
Expand Down
2 changes: 1 addition & 1 deletion app/models/dashboard_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DashboardItem < YModel::Base
# dashboard views.
GROUPS = %w[
energy_use
co2
emissions
import
costs
footprint
Expand Down
3 changes: 2 additions & 1 deletion app/models/output_element_serie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def json_attributes
group_translated: group_translated, # used to display groups in mekkos's & horizontal_stacked_bar
is_target_line: is_target_line,
target_line_position: target_line_position,
is_1990: is_1990
is_1990: is_1990,
hide_label: hide_label
}
end
# rubocop:enable Metrics/LineLength
Expand Down
127 changes: 76 additions & 51 deletions config/interface/dashboard_items.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,117 @@
---
# primary energy
- key: total_primary_energy
gquery_key: dashboard_energy_demand_primary_of_final_plus_export_losses
group: energy_use
position: 2
position: 1
disabled: false
output_element_key: use_of_primary_energy
dependent_on: ''

# emissions
- key: co2_reduction
gquery_key: dashboard_reduction_of_co2_emissions_versus_1990
group: co2
position: 1
group: emissions
position: 2
disabled: false
output_element_key: co2_emissions
dependent_on: ''
- key: co2_reduction_relative_to_start_year
gquery_key: dashboard_co2_emissions_versus_start_year
group: emissions
position:
disabled: false
output_element_key: co2_emissions
dependent_on: ''
- key: local_co2_reduction
gquery_key: dashboard_reduction_of_local_co2_emissions_versus_1990
group: emissions
position:
disabled: false
output_element_key: co2_emissions
dependent_on: ''
- key: all_ghg_reduction_relative_to_start_year
gquery_key: dashboard_emissions
group: emissions
position:
disabled: false
output_element_key: emissions_overview
- key: direct_emissions_total_ghg_relative_to_1990
gquery_key: dashboard_direct_emissions_reduction_of_total_ghg_emissions_versus_1990
group: emissions
position:
disabled: false
output_element_key: direct_emissions_per_sector
- key: direct_emissions_total_ghg
gquery_key: dashboard_direct_emissions_total_ghg_emissions
group: emissions
position:
disabled: false
output_element_key: direct_emissions_per_sector

# import
- key: net_energy_import
gquery_key: dashboard_energy_import_netto
group: import
position: 6
position: 3
disabled: false
output_element_key:
dependent_on: ''

# costs
- key: total_energy_cost
gquery_key: dashboard_total_costs
group: costs
position: 4
position: 3
disabled: false
output_element_key: costs_overview
dependent_on:
- key: profitability
gquery_key: dashboard_profitability
group: costs
position:
disabled: false
output_element_key: power_plant_economic_performance
dependent_on: has_merit_order

# renewable
- key: renewable_percentage
gquery_key: dashboard_renewability
group: renewable
position: 5
position: 4
disabled: false
output_element_key: renewability
dependent_on: ''
- key: loss_of_load
gquery_key: dashboard_security_of_supply
group: summary
position:
disabled: false
output_element_key: security_of_supply
dependent_on: ''
- key: renewable_electricity_percentage
gquery_key: dashboard_share_of_renewable_electricity
group: renewable
position:
disabled: false
output_element_key: renewable_electricity
dependent_on: ''
- key: profitability
gquery_key: dashboard_profitability
group: costs
position:
disabled: false
output_element_key: power_plant_economic_performance
dependent_on: has_merit_order
- key: local_co2_reduction
gquery_key: dashboard_reduction_of_local_co2_emissions_versus_1990
group: co2
- key: renewable_percentage_households
gquery_key: dashboard_renewability_households
group: renewable
position:
disabled: false
output_element_key: co2_emissions
dependent_on: ''
output_element_key: renewability
dependent_on:

# summary
- key: power_shortage_hours
gquery_key: dashboard_power_shortage_hours
group: summary
position: 7
position: 6
disabled: false
output_element_key: power_shortage
dependent_on: has_merit_order
- key: loss_of_load
gquery_key: dashboard_security_of_supply
group: summary
position:
disabled: false
output_element_key: security_of_supply
dependent_on: ''
- key: total_number_of_excess_events
gquery_key: dashboard_total_number_of_excess_events
group: summary
Expand All @@ -90,20 +133,15 @@
disabled: false
output_element_key: use_of_excess_electricity
dependent_on:
- key: co2_reduction_relative_to_start_year
gquery_key: dashboard_co2_emissions_versus_start_year
group: co2
position:

# biomass
- key: biomass_import_share
gquery_key: dashboard_biomass_import_share
group: footprint
position: 7
disabled: false
output_element_key: co2_emissions
output_element_key: biomass_sankey
dependent_on: ''
- key: renewable_percentage_households
gquery_key: dashboard_renewability_households
group: renewable
position:
disabled: false
output_element_key: renewability
dependent_on:
- key: biomass_primary_demand
gquery_key: dashboard_biomass_primary_demand
group: footprint
Expand All @@ -118,16 +156,3 @@
disabled: false
output_element_key: biomass_demand_by_category
dependent_on: ''
- key: biomass_import_share
gquery_key: dashboard_biomass_import_share
group: footprint
position: 8
disabled: false
output_element_key: biomass_sankey
dependent_on: ''
- key: all_ghg_reduction_relative_to_start_year
gquery_key: dashboard_emissions
group: co2
position:
disabled: false
output_element_key: emissions_overview
2 changes: 1 addition & 1 deletion config/interface/output_element_series/co2_emissions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
is_1990: false
dependent_on:
output_element_key: co2_emissions
key: delayed_co2_emissions
key: delayed_co2_emissions
- label: bunkers
color: "#82589F"
order_by: 50
Expand Down
Loading