Skip to content

Commit

Permalink
Merge pull request #14 from B-FfF/12-fill-up-harbour-data
Browse files Browse the repository at this point in the history
Fill up port data and add detailed chart for Stadtwerke-Kai vs. Hafen-Ost
  • Loading branch information
Philzen authored May 19, 2024
2 parents 4ff101f + bd2009b commit 4c50fe4
Show file tree
Hide file tree
Showing 6 changed files with 334 additions and 42 deletions.
17 changes: 6 additions & 11 deletions _assets/js/charting/business-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ Highcharts.wrap(Highcharts.PlotLineOrBand.prototype, 'render', function (proceed
otherLiabilities: smz.fn.extractColumn(swflData.Results, "other_liabilities")
};


function mirror(series) {
return series.map(function(value) {return -value})
}

function drawEarningsChart() {

hc.chart('gewinn-entwicklung', {
Expand Down Expand Up @@ -287,36 +282,36 @@ Highcharts.wrap(Highcharts.PlotLineOrBand.prototype, 'render', function (proceed
},{
name: "Andere Verbindlichkeiten",
color: smz.fn.getGradient("#333"),
data: mirror(data.otherLiabilities),
data: smz.fn.mirror(data.otherLiabilities),
stack: "debt",
},{
name: "Rückstellungen",
color: smz.fn.getGradient("#666"),
data: mirror(data.provision),
data: smz.fn.mirror(data.provision),
stack: "debt"
},{ // to fill up missing split data for year 2000
name: "Kredite gesamt",
color: smz.gradient[5],
data: mirror([data.creditLiabilities[0]]),
data: smz.fn.mirror([data.creditLiabilities[0]]),
showInLegend: false,
stack: "debt"
},{
name: "Kredite < 1 Jahr",
color: smz.gradient[6],
description: "Verbindlichkeiten gegenüber Kreditinstituten, Laufzeit < 1 Jahr",
data: mirror(data.creditLiabilitiesShort),
data: smz.fn.mirror(data.creditLiabilitiesShort),
stack: "debt"
},{
name: "Kredite 1 - 5 Jahre",
color: smz.gradient[3],
description: "Verbindlichkeiten gegenüber Kreditinstituten, Laufzeit 1 bis 5 Jahre",
data: mirror(data.creditLiabilitiesMedium),
data: smz.fn.mirror(data.creditLiabilitiesMedium),
stack: "debt"
},{
name: "Kredite > 5 Jahre",
color: smz.gradient[5],
description: "Verbindlichkeiten gegenüber Kreditinstituten, Laufzeit > 5 Jahre",
data: mirror(data.creditLiabilitiesLong),
data: smz.fn.mirror(data.creditLiabilitiesLong),
stack: "debt"
},{
color: smz.gradient[11],
Expand Down
3 changes: 3 additions & 0 deletions _assets/js/charting/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@
},
getEmissionsDataSeries: getSeries,
getGradient: getGradient,
mirror: function (series) {
return series.map(function(value) {return -value})
}
}
}

Expand Down
272 changes: 264 additions & 8 deletions _assets/js/charting/harbour.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
(function(hc, smz, harbourData) {

var startYearDetail = 2004;
var data = {
ships: smz.fn.extractColumn(harbourData, "ships"),
cargo: smz.fn.extractColumn(harbourData, "cargo"),
ships: smz.fn.extractColumn(harbourData, 'ships'),
cargo: smz.fn.extractColumn(harbourData, 'cargo_total'),
coal: smz.fn.extractColumn(harbourData, 'coal_in', startYearDetail),
chips: smz.fn.extractColumn(harbourData, 'chips_in', startYearDetail),
oil_heavy: smz.fn.extractColumn(harbourData, 'oil_heavy_in', startYearDetail),
trafo: smz.fn.extractColumn(harbourData, 'trafo_in', startYearDetail),
grit2: smz.fn.extractColumn(harbourData, 'grit2_in', startYearDetail),
animal_feed_in: smz.fn.extractColumn(harbourData, 'animal_feed_in', startYearDetail),
animal_feed_out: smz.fn.extractColumn(harbourData, 'animal_feed_out', startYearDetail),
grit_in: smz.fn.extractColumn(harbourData, 'grit_in', startYearDetail),
grit_out: smz.fn.extractColumn(harbourData, 'grit_out', startYearDetail),
scrap_in: smz.fn.extractColumn(harbourData, 'scrap_in', startYearDetail),
scrap_out: smz.fn.extractColumn(harbourData, 'scrap_out', startYearDetail),
fertiliser_in: smz.fn.extractColumn(harbourData, 'fertiliser_in', startYearDetail),
fertiliser_out: smz.fn.extractColumn(harbourData, 'fertiliser_out', startYearDetail),
cellulose_in: smz.fn.extractColumn(harbourData, 'cellulose_in', startYearDetail),
cellulose_out: smz.fn.extractColumn(harbourData, 'cellulose_out', startYearDetail),
crop_in: smz.fn.extractColumn(harbourData, 'crop_in', startYearDetail),
crop_out: smz.fn.extractColumn(harbourData, 'crop_out', startYearDetail),
logs_in: smz.fn.extractColumn(harbourData, 'logs_in', startYearDetail),
logs_out: smz.fn.extractColumn(harbourData, 'logs_out', startYearDetail),
other_in: smz.fn.extractColumn(harbourData, 'other_in', startYearDetail),
other_out: smz.fn.extractColumn(harbourData, 'other_out', startYearDetail),
stones_in: smz.fn.extractColumn(harbourData, 'stones_in', startYearDetail),
stones_out: smz.fn.extractColumn(harbourData, 'stones_out', startYearDetail),
sea_grit_in: smz.fn.extractColumn(harbourData, 'sea_grit_in', startYearDetail),
sea_grit_out: smz.fn.extractColumn(harbourData, 'sea_grit_out', startYearDetail),
year: smz.fn.extractColumn(harbourData, 'year', startYearDetail),
};

var harbourChartConfig = {
Expand All @@ -17,29 +44,258 @@
}
},
series: [{
name: "Güterumschlag",
name: 'Güterumschlag',
data: data.cargo.map(function(cargoInThousands){ return cargoInThousands * 1000 || null }),
color: smz.gradient[11],
tooltip: { valueSuffix: ' t' }
},{
name: "Eingelaufene Schiffe",
name: 'Eingelaufene Schiffe',
color: smz.gradient[10],
data: data.ships,
visible: false,
yAxis: 1
}],
subtitle: {
floating: true,
text: 'Stadtwerke-Kai & Hafen-Ost',
style: { fontSize: '0.6em' },
y: 28
},
title: { floating: true, text: 'Gesamtumschlag' },
xAxis: {
missing: [2002, 2003, 2006, 2017, 2018, 2019]
missing: [2002, 2003, 2006, 2017, 2018, 2019, 2020, 2021, 2022, 2023]
},
yAxis: [{
title: { text: "Umschlag in Tonnen" }
endOnTick: false,
max: 700000,
tickInterval: 200000,
title: { text: 'Umschlag in Tonnen' }
},{
title: { text: "Anzahl Schiffe" },
endOnTick: false,
max: 437,
tickInterval: 125,
title: { text: 'Anzahl Schiffe' },
opposite: true
}]
};

var harbourSwflChartConfig = {
chart: {
height: 370,
type: 'column'
},
plotOptions: {
column: {
stacking: 'normal',
tooltip: { valueDecimals: 0, valueSuffix: ' t' },
}
},
series: [{
color: smz.gradient[1],
data: data.coal,
name: 'Steinkohle',
},{
color: smz.gradient[3],
data: data.chips,
name: 'Holzhackschnitzel',
},{
color: smz.gradient[8],
data: data.oil_heavy,
name: 'Schweröl',
},{
color: smz.gradient[7],
data: data.trafo,
name: 'Transformatoren',
},{
color: smz.fn.getGradient('#999'),
data: data.grit2,
name: 'Splitt',
}],
subtitle: {
floating: true,
text: 'nur eingehender Umschlag',
style: { fontSize: '0.6em' },
y: 28
},
title: { floating: true, text: 'Stadtwerke-Kai' },
xAxis: {
categories: data.year
},
yAxis: [{
endOnTick: false,
max: 345000,
min: -25000,
startOnTick: false,
title: { text: 'Umschlag in Tonnen' }
}]
};

var harbourEastChartConfig = {
chart: {
type: 'column'
},
plotOptions: {
column: {
stacking: 'normal'
}
},
tooltip: {
formatter: function() {
var xIdx = this.x - startYearDetail;
var inboundSum = 0, outboundSum = 0;
var inOutTable = this.points.map(function(point) {
if (point.series.linkedParent) return; // skip outbound

var color = point.color.stops !== undefined ? point.color.stops[0][1] : point.color;
var outValue = Math.abs(point.series.linkedSeries[0].yData[xIdx]);

if (!outValue && !point.y) return; // skip empty lines

inboundSum += point.y;
outboundSum += outValue;

return '<tr>'
+ '<th style="padding-right: 20px"><span style="color:' + color + '">●</span>&nbsp;' + point.series.name + '</th>'
+ '<td style="text-align: right; font-weight: 700">' + (point.y ? hc.numberFormat(point.y, 0) + ' t' : '–') + '</td>'
+ '<td style="text-align: right; font-weight: 700">' + (outValue ? hc.numberFormat(outValue, 0) + ' t' : '–') + '</td>'
+ '</tr>';
});

return ''.concat(
'<table>',
'<thead><tr style="font-weight: 700; vertical-align: middle; border-bottom: 1px solid #999">',
'<th style="font-size: 1.5em">', this.x, '</th><th colspan="2" style="text-align: center">Gesamt ', hc.numberFormat(inboundSum + outboundSum, 0), ' t</th>',
'</tr>',
'<tr style="text-align: right"><th></th><th>Eingang</th><th style="padding-left: 8px">Ausgang</th></tr>',
'</thead>',
'<tbody>', inOutTable.join(''),
'<tr style="border-top: 1px solid #ccc; text-align: right; font-weight: 700; "><th style="text-align: center">Summe</th><td>',
hc.numberFormat(inboundSum, 0), ' t</td><td>', hc.numberFormat(outboundSum, 0), ' t</td>',
'</tr>',
'</tbody>',
'</table>'
)
},
},
series: [{
color: smz.gradient[0],
data: data.other_in,
id: 'other',
name: 'Sonstiges',
},{
color: smz.fn.getGradient('#ccc'),
data: data.sea_grit_in,
id: 'sea_grit',
name: 'Seekies',
},{
color: smz.fn.getGradient('#999'),
data: data.grit_in,
id: 'grit',
name: 'Splitt',
},{
color: smz.fn.getGradient('#555'),
data: data.stones_in,
id: 'stones',
name: 'Steine',
},{
color: smz.gradient[1],
data: data.scrap_in,
id: 'scrap',
name: 'Schrott',
},{
color: smz.gradient[8],
data: data.logs_in,
id: 'logs',
name: 'Baumstämme',
},{
color: smz.gradient[6],
data: data.cellulose_in,
id: 'cellulose',
name: 'Zellulose',
},{
color: smz.gradient[3],
data: data.crop_in,
id: 'crop',
name: 'Getreide',
},{
color: smz.gradient[11],
data: data.fertiliser_in,
id: 'fertiliser',
name: 'Düngemittel',
},{
color: smz.gradient[10],
data: data.animal_feed_in,
id: 'animal_feed',
name: 'Futtermittel',
},{
color: hc.defaultOptions.colors[7],
data: smz.fn.mirror(data.other_out),
linkedTo: 'other'
},{
color: '#ccc',
data: smz.fn.mirror(data.sea_grit_out),
linkedTo: 'sea_grit'
},{
color: '#999',
data: smz.fn.mirror(data.grit_out),
linkedTo: 'grit'
},{
color: '#555',
data: smz.fn.mirror(data.stones_out),
linkedTo: 'stones'
},{
color: hc.defaultOptions.colors[1],
data: smz.fn.mirror(data.scrap_out),
linkedTo: 'scrap'
},{
color: hc.defaultOptions.colors[8],
data: smz.fn.mirror(data.logs_out),
linkedTo: 'logs'
},{
color: hc.defaultOptions.colors[6],
data: smz.fn.mirror(data.cellulose_out),
linkedTo: 'cellulose'
},{
color: hc.defaultOptions.colors[3],
data: smz.fn.mirror(data.crop_out),
linkedTo: 'crop'
},{
color: smz.color.swfl.darkGreen,
data: smz.fn.mirror(data.fertiliser_out),
linkedTo: 'fertiliser'
},{
color: smz.color.swfl.lightGreen,
data: smz.fn.mirror(data.animal_feed_out),
label: { format: '' },
linkedTo: 'animal_feed'
}],
subtitle: {
floating: true,
text: 'Eingänge & Ausgänge',
style: { fontSize: '0.6em' },
y: 28
},
title: { floating: true, text: 'Wirtschaftshafen „Hafen-Ost“' },
xAxis: {
categories: data.year
},
yAxis: [{
endOnTick: false,
max: 345000,
min: -25000,
plotLines: [{
value: 0,
color: '#000',
zIndex: 1
}],
startOnTick: false,
title: { text: 'Umschlag in Tonnen' }
}]
};

smz.chart = smz.chart || {};
smz.chart.Harbour = hc.chart("hafen", harbourChartConfig)
smz.chart.Harbour = hc.chart('hafen', harbourChartConfig)
smz.chart.HarbourSwfl = hc.chart('hafen-stadtwerke-kai', harbourSwflChartConfig)
smz.chart.HarbourEast = hc.chart('hafen-ost', harbourEastChartConfig)

})(window.Highcharts, window.smz, window.SWFL.Business.Harbour);
Loading

0 comments on commit 4c50fe4

Please sign in to comment.