21
21
:is-type-proportion =" isTypeProportion"
22
22
:is-type-line =" isTypeLine"
23
23
:is-type-change-since-line =" isTypeChangeSinceLine"
24
+ :is-type-growth-stacked-area =" isTypeGrowthStackedArea"
24
25
:is-y-axis-absolute =" isYAxisAbsolute"
25
26
:is-y-axis-percentage =" isYAxisPercentage"
26
27
:is-y-axis-average-power =" isYAxisAveragePower"
50
51
/>
51
52
52
53
<stacked-area-vis
53
- v-if =" chartShown && (isTypeArea || isTypeProportion)"
54
+ v-if =" chartShown && (isTypeArea || isTypeProportion || isTypeGrowthStackedArea )"
54
55
:read-only =" readOnly"
55
56
:domains =" domains"
56
- :dataset =" stackedAreaDataset"
57
+ :dataset =" isTypeGrowthStackedArea ? growthDataset : stackedAreaDataset"
57
58
:range =" range"
58
59
:interval =" interval"
59
60
:curve =" chartCurve"
60
- :y-min =" isTypeArea ? computedYMin : 0"
61
- :y-max =" isTypeArea ? computedYMax : 100"
61
+ :y-min =" isTypeGrowthStackedArea ? computedGrowthYMin : isTypeArea ? computedYMin : 0"
62
+ :y-max =" isTypeGrowthStackedArea ? computedGrowthYMax : isTypeArea ? computedYMax : 100"
62
63
:vis-height =" visHeight"
63
64
:hover-on =" hoverOn"
64
65
:hover-date =" hoverDate"
88
89
:show-total-line =" chartEnergyNetLine"
89
90
:total-line-domain =" '_total'"
90
91
:class =" { dragging: dragging }"
92
+ :use-offset-diverge =" isTypeGrowthStackedArea ? true : false"
91
93
class =" vis-chart"
92
94
@dateOver =" handleDateHover"
93
95
@domainOver =" handleDomainHover"
150
152
/>
151
153
152
154
<date-brush
153
- v-if =" showDateAxis && chartShown"
155
+ v-if =" showDateAxis && chartShown && isTypeGrowthStackedArea"
156
+ :dataset =" growthDataset"
157
+ :zoom-range =" zoomExtent"
158
+ :x-ticks =" xTicks"
159
+ :tick-format =" tickFormat"
160
+ :second-tick-format =" secondTickFormat"
161
+ :read-only =" readOnly"
162
+ :interval =" interval"
163
+ :filter-period =" filterPeriod"
164
+ :append-datapoint =" isEnergyType"
165
+ class =" date-brush vis-chart"
166
+ @date-hover =" handleDateHover"
167
+ @date-filter =" handleZoomExtent"
168
+ @enter =" handleVisEnter"
169
+ @leave =" handleVisLeave"
170
+ />
171
+ <date-brush
172
+ v-if =" showDateAxis && chartShown && !isTypeGrowthStackedArea"
154
173
:dataset =" dataset"
155
174
:zoom-range =" zoomExtent"
156
175
:x-ticks =" xTicks"
@@ -191,6 +210,7 @@ import * as SI from '@/constants/si.js'
191
210
import { RANGE_ALL_12MTH_ROLLING } from ' @/constants/ranges.js'
192
211
import { LOAD } from ' @/constants/energy-fuel-techs/group-detailed.js'
193
212
import EnergyToAveragePower from ' @/data/transform/energy-to-average-power.js'
213
+ import transformToGrowthTimeSeries from ' ~/data/transform/growth-series.js'
194
214
import DateDisplay from ' @/services/DateDisplay.js'
195
215
import MultiLine from ' @/components/Vis/MultiLine'
196
216
import DateBrush from ' @/components/Vis/DateBrush'
@@ -218,7 +238,8 @@ const energyOptions = {
218
238
OPTIONS .CHART_STACKED ,
219
239
OPTIONS .CHART_PROPORTION ,
220
240
OPTIONS .CHART_LINE ,
221
- OPTIONS .CHART_CHANGE_SINCE_LINE
241
+ OPTIONS .CHART_CHANGE_SINCE_LINE ,
242
+ OPTIONS .CHART_GROWTH_STACKED_AREA
222
243
],
223
244
curve: [
224
245
OPTIONS .CHART_CURVE_SMOOTH ,
@@ -337,13 +358,17 @@ export default {
337
358
visHeight: 330 ,
338
359
draggedHeight: 330 ,
339
360
dragging: false ,
340
- showDivider: false
361
+ showDivider: false ,
362
+
363
+ growthDataset: []
341
364
}
342
365
},
343
366
344
367
computed: {
345
368
... mapGetters ({
346
369
percentContributionTo: ' percentContributionTo' ,
370
+ fuelTechGroupName: ' fuelTechGroupName' ,
371
+
347
372
tabletBreak: ' app/tabletBreak' ,
348
373
349
374
hoverDomain: ' visInteract/hoverDomain' ,
@@ -381,6 +406,7 @@ export default {
381
406
isTypeProportion: ' chartOptionsPowerEnergy/isTypeProportion' ,
382
407
isTypeLine: ' chartOptionsPowerEnergy/isTypeLine' ,
383
408
isTypeChangeSinceLine: ' chartOptionsPowerEnergy/isTypeChangeSinceLine' ,
409
+ isTypeGrowthStackedArea: ' chartOptionsPowerEnergy/isTypeGrowthStackedArea' ,
384
410
allowResize: ' regionEnergy/allowResize'
385
411
}),
386
412
@@ -434,7 +460,7 @@ export default {
434
460
shouldConvertValue () {
435
461
return (
436
462
this .isTypeArea ||
437
- ((this .isTypeLine || this .isTypeChangeSinceLine ) &&
463
+ ((this .isTypeLine || this .isTypeChangeSinceLine || this . isTypeGrowthStackedArea ) &&
438
464
! this .isYAxisPercentage )
439
465
)
440
466
},
@@ -712,6 +738,7 @@ export default {
712
738
this .$emit (' selectedDataset' , ds)
713
739
return ds
714
740
},
741
+
715
742
// yMin() {
716
743
// const loadDomains = this.domains.filter((d) => d.category === LOAD)
717
744
// if (loadDomains.length === 0) {
@@ -741,6 +768,61 @@ export default {
741
768
// })
742
769
// return max(dataset, d => d._stackedTotalMax)
743
770
// },
771
+ computedGrowthYMin () {
772
+ let lowest = 0
773
+
774
+ const filteredDataset =
775
+ this .zoomExtent .length > 0
776
+ ? this .growthDataset .filter (
777
+ (d ) =>
778
+ d .time >= this .zoomExtent [0 ].getTime () &&
779
+ d .time <= this .zoomExtent [1 ].getTime () - 1
780
+ )
781
+ : this .growthDataset
782
+
783
+ filteredDataset .forEach ((d ) => {
784
+ let total = 0
785
+
786
+ this .powerEnergyDomains .forEach ((domain ) => {
787
+ const value = d[domain .id ] || 0
788
+ total += value < 0 ? value : 0
789
+ })
790
+
791
+ if (total < lowest) {
792
+ lowest = total
793
+ }
794
+ })
795
+
796
+ return lowest
797
+ },
798
+
799
+ computedGrowthYMax () {
800
+ let highest = 0
801
+
802
+ const filteredDataset =
803
+ this .zoomExtent .length > 0
804
+ ? this .growthDataset .filter (
805
+ (d ) =>
806
+ d .time >= this .zoomExtent [0 ].getTime () &&
807
+ d .time <= this .zoomExtent [1 ].getTime () - 1
808
+ )
809
+ : this .growthDataset
810
+
811
+ filteredDataset .forEach ((d ) => {
812
+ let total = 0
813
+ this .powerEnergyDomains .forEach ((domain ) => {
814
+ const value = d[domain .id ] || 0
815
+ total += value > 0 ? value : 0
816
+ })
817
+
818
+ if (total > highest) {
819
+ highest = total
820
+ }
821
+ })
822
+
823
+ return highest
824
+ },
825
+
744
826
computedYMin () {
745
827
let lowest = 0
746
828
@@ -858,7 +940,9 @@ export default {
858
940
return null
859
941
}
860
942
const time = date .getTime ()
861
- return this .dataset .find ((d ) => d .time === time)
943
+ return this .isTypeGrowthStackedArea
944
+ ? this .growthDataset .find ((d ) => d .time === time)
945
+ : this .dataset .find ((d ) => d .time === time)
862
946
},
863
947
hoverValue () {
864
948
let value = null
@@ -905,6 +989,7 @@ export default {
905
989
hoverTotal () {
906
990
let total = 0
907
991
let allNulls = true
992
+
908
993
if (this .hoverData ) {
909
994
this .domains .forEach ((d ) => {
910
995
const value = this .hoverData [d .id ]
@@ -941,13 +1026,59 @@ export default {
941
1026
chartUnitPrefix () {
942
1027
this .$emit (' selectedDataset' , this .dataset )
943
1028
},
1029
+
1030
+ zoomExtent () {
1031
+ if (this .isTypeGrowthStackedArea ) {
1032
+ this .updateGrowDataset ()
1033
+ }
1034
+ },
1035
+
1036
+ filterPeriod () {
1037
+ if (this .isTypeGrowthStackedArea ) {
1038
+ this .updateGrowDataset ()
1039
+ }
1040
+ },
1041
+
1042
+ fuelTechGroupName () {
1043
+ if (this .isTypeGrowthStackedArea ) {
1044
+ this .updateGrowDataset ()
1045
+ }
1046
+ },
1047
+
944
1048
interval () {
945
1049
this .handleTypeClick ()
1050
+
1051
+ if (this .isTypeGrowthStackedArea ) {
1052
+ this .updateGrowDataset ()
1053
+ }
1054
+ },
1055
+
1056
+ isTypeGrowthStackedArea (val ) {
1057
+ if (val) {
1058
+ this .updateGrowDataset ()
1059
+ }
1060
+ },
1061
+
1062
+ hiddenDomains () {
1063
+ if (this .isTypeGrowthStackedArea ) {
1064
+ this .updateGrowDataset ()
1065
+ }
946
1066
}
947
1067
},
948
1068
949
1069
mounted () {
950
1070
this .visHeight = this .chartHeight
1071
+
1072
+ if (this .isTypeGrowthStackedArea ) {
1073
+ this .updateGrowDataset ()
1074
+ }
1075
+
1076
+ if (! this .isEnergyType && this .isTypeGrowthStackedArea ) {
1077
+ this .$store .commit (
1078
+ ' chartOptionsPowerEnergy/chartType' ,
1079
+ OPTIONS .CHART_STACKED
1080
+ )
1081
+ }
951
1082
},
952
1083
953
1084
methods: {
@@ -960,6 +1091,12 @@ export default {
960
1091
doUpdateTickFormats: ' visInteract/doUpdateTickFormats'
961
1092
}),
962
1093
1094
+ updateGrowDataset () {
1095
+ this .growthDataset = this .zoomExtent .length > 0 ? this .getGrowthDataset ().filter ((d ) => {
1096
+ return d .date >= this .zoomExtent [0 ] && d .date < this .zoomExtent [1 ]
1097
+ }) : this .getGrowthDataset ()
1098
+ },
1099
+
963
1100
convertValue (value ) {
964
1101
return SI .convertValue (
965
1102
this .chartUnitPrefix ,
@@ -1048,6 +1185,24 @@ export default {
1048
1185
return newDataset
1049
1186
},
1050
1187
1188
+ getGrowthDataset () {
1189
+ let compareIndex = 1
1190
+
1191
+ if (this .isRollingSumRange ) {
1192
+ if (this .interval === ' Season' || this .interval === ' Quarter' ) {
1193
+ compareIndex = 4
1194
+ } else if (this .interval === ' Half Year' ) {
1195
+ compareIndex = 2
1196
+ }
1197
+ }
1198
+
1199
+ const dataset = transformToGrowthTimeSeries (this .powerEnergyDataset , this .domains , compareIndex)
1200
+
1201
+ this .handleTypeClick ()
1202
+
1203
+ return dataset
1204
+ },
1205
+
1051
1206
handleDomainHover (domain ) {
1052
1207
this .setHoverDomain (domain)
1053
1208
},
0 commit comments