Skip to content

Commit 5546e96

Browse files
committed
Merge branch 'main' into feature/234-site-design-updates
2 parents f85899c + 8123c64 commit 5546e96

13 files changed

+121
-57
lines changed

assets/scss/vis-table.scss

+1-7
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
cursor: pointer;
5858
padding: 3px 5px;
5959
margin-right: 5px;
60-
margin-left: -10px;
6160
border-radius: 3px;
6261

6362
&:hover {
@@ -66,14 +65,9 @@
6665
}
6766

6867
.chart-label {
69-
padding: 2px 0.5rem;
68+
padding: 2px;
7069
display: flex;
7170
align-items: center;
72-
73-
small {
74-
position: relative;
75-
left: 3px;
76-
}
7771
}
7872

7973
.hover-date-value {

components/Charts/EmissionIntensityChartOptions.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
</template>
2222

2323
<template v-slot:label-unit>
24-
<strong>Emission Intensity</strong>
25-
<div
26-
v-show="chartShown"
27-
style="display: flex; gap: 5px; align-items: center;">
28-
<small v-if="is12MthRollingSum">(12-month rolling)</small>
24+
<strong v-show="!chartShown">Emission Intensity</strong>
25+
<div v-show="chartShown">
26+
<strong>Emission Intensity</strong>
27+
<small v-if="is12MthRollingSum">12-month rolling</small>
2928
<small>kgCO₂e/MWh</small>
3029
</div>
3130
</template>
31+
3232
<template
3333
v-slot:average-value
3434
v-if="!readOnly">

components/Charts/EmissionsChart.vue

+30
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
:show-average-value="showAverageValue"
3232
:emissions-options="emissionsOptions"
3333
:show-date-axis="showDateAxis"
34+
:change-since-label="changeSinceLabel"
3435
@type-click="handleTypeClick"
3536
@date-axis="(visible) => showDateAxis = visible"
3637
/>
@@ -696,6 +697,35 @@ export default {
696697
})
697698
}
698699
return this.convertValue(total)
700+
},
701+
702+
changeSinceLabel() {
703+
const ds = this.dataset
704+
705+
if (ds.length === 0) {
706+
return ''
707+
}
708+
709+
if (this.zoomExtent.length > 0) {
710+
return DateDisplay.specialDateFormats(
711+
this.zoomExtent[0].getTime(),
712+
this.range,
713+
this.interval,
714+
false,
715+
false,
716+
false,
717+
true
718+
)
719+
}
720+
return DateDisplay.specialDateFormats(
721+
ds[0].time,
722+
this.range,
723+
this.interval,
724+
false,
725+
false,
726+
false,
727+
true
728+
)
699729
}
700730
},
701731

components/Charts/EmissionsChartOptions.vue

+12-9
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626
</template>
2727

2828
<template v-slot:label-unit>
29-
<strong>Emissions Volume</strong>
30-
31-
<div
32-
v-show="chartShown"
33-
style="display: flex; gap: 1px; align-items: center;">
34-
<small v-if="is12MthRollingSum">(12-month rolling)</small>
29+
<strong v-show="!chartShown">Emissions Volume</strong>
30+
<div v-show="chartShown">
31+
<strong>Emissions Volume</strong>
32+
<small v-if="is12MthRollingSum">12-month rolling</small>
3533
<small v-if="isPercentage"> {{ displayUnit }}</small>
3634
<small
3735
v-if="!isPercentage"
@@ -40,8 +38,10 @@
4038
>
4139
{{ displayUnit }}/{{ interval | intervalLabel }}
4240
</small>
41+
<small v-if="isTypeChangeSinceLine">change since {{ changeSinceLabel }}</small>
4342
</div>
4443
</template>
44+
4545
<template
4646
v-slot:average-value
4747
v-if="!readOnly && !isPercentage && showAverageValue"
@@ -185,6 +185,10 @@ export default {
185185
showDateAxis: {
186186
type: Boolean,
187187
default: () => false
188+
},
189+
changeSinceLabel: {
190+
type: String,
191+
default: ''
188192
}
189193
},
190194
data() {
@@ -268,11 +272,10 @@ export default {
268272
<style lang="scss" scoped>
269273
.display-unit {
270274
cursor: pointer;
271-
padding: 2px 4px 1px;
272-
border-radius: 4px;
273275
274276
&:hover {
275-
background-color: rgba(255, 255, 255, 0.7);
277+
text-decoration: underline;
278+
color: black;
276279
}
277280
}
278281
</style>

components/Charts/PowerEnergyChart.vue

+33-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
:single-domain-label="singleDomainLabel"
4848
:show-date-axis="showDateAxis"
4949
:change-since-label="changeSinceLabel"
50+
:growth-label="growthLabel"
5051
@type-click="handleTypeClick"
5152
@date-axis="(visible) => showDateAxis = visible"
5253
/>
@@ -731,6 +732,11 @@ export default {
731732
732733
changeSinceLabel() {
733734
const ds = this.isTypeGrowthStackedArea ? this.growthDataset : this.stackedAreaDataset
735+
736+
if (ds.length === 0) {
737+
return ''
738+
}
739+
734740
if (this.zoomExtent.length > 0) {
735741
return DateDisplay.specialDateFormats(
736742
this.zoomExtent[0].getTime(),
@@ -753,6 +759,15 @@ export default {
753759
)
754760
},
755761
762+
growthLabel() {
763+
const label = this.interval.toLowerCase()
764+
765+
if (this.isRollingSumRange) {
766+
return `${label}-on-previous-year-${label}`
767+
}
768+
return `${label}-on-${label}`
769+
},
770+
756771
dataset() {
757772
let ds = null
758773
if (this.isTypeLine) {
@@ -1054,6 +1069,12 @@ export default {
10541069
this.$emit('selectedDataset', this.dataset)
10551070
},
10561071
1072+
isYAxisAveragePower() {
1073+
if (this.isTypeGrowthStackedArea) {
1074+
this.updateGrowDataset()
1075+
}
1076+
},
1077+
10571078
zoomExtent() {
10581079
if (this.isTypeGrowthStackedArea) {
10591080
this.updateGrowDataset()
@@ -1225,10 +1246,21 @@ export default {
12251246
}
12261247
}
12271248
1228-
const dataset = transformToGrowthTimeSeries(this.powerEnergyDataset, this.domains, compareIndex)
1249+
const ds = this.isYAxisAbsolute
1250+
? this.powerEnergyDataset
1251+
: this.averagePowerDataset
1252+
1253+
const dataset = transformToGrowthTimeSeries(ds, this.domains, compareIndex)
12291254
12301255
this.handleTypeClick()
12311256
1257+
if (this.isRollingSumRange) {
1258+
// only return the data where there are values
1259+
return dataset.slice(compareIndex, dataset.length - 1)
1260+
}
1261+
1262+
// remove first null period
1263+
dataset.shift()
12321264
return dataset
12331265
},
12341266

components/Charts/PowerEnergyChartOptions.vue

+13-13
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,16 @@
2828
</template>
2929

3030
<template v-slot:label-unit>
31-
<strong>{{ displayTitle }}</strong>
32-
<div
33-
v-show="chartShown"
34-
style="display: flex; gap: 1px; align-items: center;">
35-
<small v-if="is12MthRollingSum">(12-month rolling)</small>
31+
<strong v-show="!chartShown">{{ displayTitle }}</strong>
32+
<div v-show="chartShown">
33+
<strong>{{ displayTitle }}</strong>
34+
<small v-if="is12MthRollingSum">12-month rolling</small>
3635
<small
3736
:class="{ 'display-unit': allowDisplayHover }"
3837
@click.stop="handleUnitClick"
39-
>
40-
{{ displayUnit }}
41-
</small>
42-
<small v-if="isTypeChangeSinceLine">(change since {{ changeSinceLabel }})</small>
43-
<small v-if="isTypeGrowthStackedArea">(growth year-on-year)</small>
38+
>{{ displayUnit }}</small>
39+
<small v-if="isTypeChangeSinceLine">change since {{ changeSinceLabel }}</small>
40+
<small v-if="isTypeGrowthStackedArea">growth {{ growthLabel }}</small>
4441
</div>
4542
</template>
4643

@@ -250,6 +247,10 @@ export default {
250247
changeSinceLabel: {
251248
type: String,
252249
default: ''
250+
},
251+
growthLabel: {
252+
type: String,
253+
default: ''
253254
}
254255
},
255256
data() {
@@ -462,11 +463,10 @@ export default {
462463
<style lang="scss" scoped>
463464
.display-unit {
464465
cursor: pointer;
465-
padding: 2px 4px 1px;
466-
border-radius: 4px;
467466
468467
&:hover {
469-
background-color: rgba(255, 255, 255, 0.7);
468+
text-decoration: underline;
469+
color: black;
470470
}
471471
}
472472
</style>

components/Charts/PriceChartOptions.vue

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
</template>
2222

2323
<template v-slot:label-unit>
24-
<strong>Price</strong>
25-
<div
26-
v-show="chartShown"
27-
style="display: flex; gap: 5px; align-items: center;">
28-
<small v-if="is12MthRollingSum">(12-month rolling)</small>
24+
<strong v-show="!chartShown">Price</strong>
25+
<div v-show="chartShown">
26+
<strong>Price</strong>
27+
<small v-if="is12MthRollingSum">12-month rolling</small>
2928
<small>$/MWh</small>
3029
</div>
3130
</template>

components/Energy/Charts/TemperatureChartOptions.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
</template>
2222

2323
<template v-slot:label-unit>
24-
<strong>Temperature</strong>
25-
<div
26-
v-show="chartShown"
27-
style="display: flex; gap: 5px; align-items: center;">
28-
<small v-if="is12MthRollingSum">(12-month rolling)</small>
24+
<strong v-show="!chartShown">Temperature</strong>
25+
<div v-show="chartShown">
26+
<strong>Temperature</strong>
27+
<small v-if="is12MthRollingSum">12-month rolling</small>
2928
<small>°C</small>
3029
</div>
3130
</template>
31+
3232
<template
3333
v-slot:average-value
3434
v-if="!readOnly">

components/Energy/VisSection.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,7 @@ export default {
383383
dateRange[1]
384384
)
385385
if (this.interval === 'Fin Year') {
386-
startTime = addYears(startTime, 2)
387-
endTime = addYears(endTime, 1)
386+
startTime = addYears(startTime, 1)
388387
}
389388
390389
filteredDates = [startTime, endTime]

components/Vis/DateBrush.vue

+13-6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { extent } from 'd3-array'
3333
import { brushX } from 'd3-brush'
3434
import EventBus from '~/plugins/eventBus.js'
3535
import { onBrush, onBrushEnded } from './shared/brushEvents'
36+
import { getNextDateByInterval } from '@/services/datetime-helpers.js'
3637
import * as CONFIG from './shared/config.js'
3738
3839
export default {
@@ -114,19 +115,25 @@ export default {
114115
if (this.dataset.length > 0) {
115116
if (this.appendDatapoint) {
116117
const updated = _cloneDeep(this.dataset)
117-
const lastSecondItem = _cloneDeep(updated[updated.length - 2])
118118
const lastItem = _cloneDeep(updated[updated.length - 1])
119-
const intervalTime = lastItem.time - lastSecondItem.time
120-
lastItem.time = lastItem.time + intervalTime
121-
lastItem.date = new Date(lastItem.time)
119+
120+
const nextDate = getNextDateByInterval(
121+
lastItem.date,
122+
this.interval,
123+
this.filterPeriod !== 'All'
124+
)
125+
lastItem.date = nextDate
126+
lastItem.time = nextDate.getTime()
127+
122128
updated.push(lastItem)
123129
return updated
124-
} else {
125-
return this.dataset
126130
}
131+
132+
return this.dataset
127133
}
128134
return []
129135
},
136+
130137
datasetDateExtent() {
131138
return extent(this.updatedDataset, (d) => new Date(d.date))
132139
}

components/layout/AppHeader.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export default {
280280
const ei = this.emissionIntensityData.find(
281281
(e) => e.time === d.time
282282
)
283-
obj['Emissions Intensity - kgCO₂e/MWh'] = format(ei._emissionIntensity)
283+
obj['Emissions Intensity - kgCO₂e/MWh'] = ei ? format(ei._emissionIntensity) : ''
284284
285285
if (this.isEnergyType) {
286286
if (this.demandPriceDomains.length) {

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opennem",
3-
"version": "4.25.0",
3+
"version": "4.25.3",
44
"description": "An Open Platform for National Electricity Market Data",
55
"author": "Steven Tan",
66
"private": true,

0 commit comments

Comments
 (0)