|
49 | 49 | @date-axis="(visible) => showDateAxis = visible"
|
50 | 50 | />
|
51 | 51 |
|
| 52 | + <div |
| 53 | + v-if="isTypeGrowthStackedArea" |
| 54 | + style="position: absolute; top: 3rem; left: 3rem; font-style: italic;"> |
| 55 | + {{ growthDataset.length }} |
| 56 | + </div> |
| 57 | + |
| 58 | + |
| 59 | + <stacked-area-vis |
| 60 | + v-if="chartShown && (isTypeGrowthStackedArea)" |
| 61 | + :read-only="readOnly" |
| 62 | + :domains="domains" |
| 63 | + :dataset="growthDataset" |
| 64 | + :range="range" |
| 65 | + :interval="interval" |
| 66 | + :curve="chartCurve" |
| 67 | + :y-min="computedGrowthYMin" |
| 68 | + :y-max="computedGrowthYMax" |
| 69 | + :vis-height="visHeight" |
| 70 | + :hover-on="hoverOn" |
| 71 | + :hover-date="hoverDate" |
| 72 | + :dynamic-extent="zoomExtent" |
| 73 | + :zoomed="zoomExtent.length > 0" |
| 74 | + :x-guides="xGuides" |
| 75 | + :y-guides="yGuides" |
| 76 | + :x-axis-dy="tabletBreak ? 8 : 12" |
| 77 | + :y-axis-ticks="5" |
| 78 | + :show-x-axis="false" |
| 79 | + :compare-dates="compareDates" |
| 80 | + :focus-date="focusDate" |
| 81 | + :focus-on="focusOn" |
| 82 | + :incomplete-intervals="incompleteIntervals" |
| 83 | + :dataset-two=" |
| 84 | + chartEnergyRenewablesLine ? renewablesPercentageDataset : [] |
| 85 | + " |
| 86 | + :dataset-two-colour="renewablesLineColour" |
| 87 | + :highlight-domain="highlightId" |
| 88 | + :mobile-screen="tabletBreak" |
| 89 | + :display-prefix="chartDisplayPrefix" |
| 90 | + :should-convert-value="false" |
| 91 | + :unit="` ${chartDisplayPrefix}${chartUnit}`" |
| 92 | + :null-check-prop="'_total'" |
| 93 | + :filter-period="filterPeriod" |
| 94 | + :show-total-line="chartEnergyNetLine" |
| 95 | + :total-line-domain="'_total'" |
| 96 | + :class="{ dragging: dragging }" |
| 97 | + :use-offset-diverge="true" |
| 98 | + class="vis-chart" |
| 99 | + @dateOver="handleDateHover" |
| 100 | + @domainOver="handleDomainHover" |
| 101 | + @svgClick="handleSvgClick" |
| 102 | + @enter="handleVisEnter" |
| 103 | + @leave="handleVisLeave" |
| 104 | + @zoomExtent="handleZoomExtent" |
| 105 | + /> |
| 106 | + |
52 | 107 | <stacked-area-vis
|
53 | 108 | v-if="chartShown && (isTypeArea || isTypeProportion)"
|
54 | 109 | :read-only="readOnly"
|
|
149 | 204 | @leave="handleVisLeave"
|
150 | 205 | />
|
151 | 206 |
|
152 |
| - <div v-if="isTypeGrowthStackedArea"> |
153 |
| - {{ growthDataset.length }} |
154 |
| - |
155 |
| - </div> |
156 |
| - |
157 | 207 | <date-brush
|
158 | 208 | v-if="showDateAxis && chartShown"
|
159 | 209 | :dataset="dataset"
|
@@ -343,7 +393,9 @@ export default {
|
343 | 393 | visHeight: 330,
|
344 | 394 | draggedHeight: 330,
|
345 | 395 | dragging: false,
|
346 |
| - showDivider: false |
| 396 | + showDivider: false, |
| 397 | +
|
| 398 | + growthDataset: [] |
347 | 399 | }
|
348 | 400 | },
|
349 | 401 |
|
@@ -541,14 +593,6 @@ export default {
|
541 | 593 | return unit
|
542 | 594 | },
|
543 | 595 |
|
544 |
| - growthDataset() { |
545 |
| - if (this.isTypeGrowthStackedArea) { |
546 |
| - console.log('growthDataset', this.stackedAreaDataset) |
547 |
| - } |
548 |
| -
|
549 |
| - return [] |
550 |
| - }, |
551 |
| -
|
552 | 596 | energyPercentDataset() {
|
553 | 597 | const dataset = _cloneDeep(this.powerEnergyDataset)
|
554 | 598 | dataset.forEach((d, i) => {
|
@@ -727,6 +771,7 @@ export default {
|
727 | 771 | this.$emit('selectedDataset', ds)
|
728 | 772 | return ds
|
729 | 773 | },
|
| 774 | +
|
730 | 775 | // yMin() {
|
731 | 776 | // const loadDomains = this.domains.filter((d) => d.category === LOAD)
|
732 | 777 | // if (loadDomains.length === 0) {
|
@@ -756,6 +801,51 @@ export default {
|
756 | 801 | // })
|
757 | 802 | // return max(dataset, d => d._stackedTotalMax)
|
758 | 803 | // },
|
| 804 | + computedGrowthYMin() { |
| 805 | + let lowest = 0 |
| 806 | +
|
| 807 | + console.log('computedGrowthYMin', this.powerEnergyDomains) |
| 808 | +
|
| 809 | + const loadDomains = this.powerEnergyDomains.filter((d) => d.category === LOAD) |
| 810 | + if (loadDomains.length === 0) { |
| 811 | + console.log('computedGrowthYMin', lowest) |
| 812 | + return lowest |
| 813 | + } else { |
| 814 | + this.growthDataset.forEach((d) => { |
| 815 | + let total = 0 |
| 816 | + loadDomains.forEach((domain) => { |
| 817 | + total += d[domain.id] || 0 |
| 818 | + }) |
| 819 | +
|
| 820 | + if (total < lowest) { |
| 821 | + lowest = total |
| 822 | + } |
| 823 | + }) |
| 824 | +
|
| 825 | + console.log('computedGrowthYMin', lowest) |
| 826 | +
|
| 827 | + return -10 |
| 828 | + } |
| 829 | + }, |
| 830 | + computedGrowthYMax() { |
| 831 | + let highest = 0 |
| 832 | +
|
| 833 | + this.growthDataset.forEach((d) => { |
| 834 | + let total = 0 |
| 835 | + this.powerEnergyDomains.forEach((domain) => { |
| 836 | + total += d[domain.id] || 0 |
| 837 | + }) |
| 838 | +
|
| 839 | + if (total > highest) { |
| 840 | + highest = total |
| 841 | + } |
| 842 | + }) |
| 843 | +
|
| 844 | + console.log('computedGrowthYMax', highest) |
| 845 | +
|
| 846 | + return 10 |
| 847 | + }, |
| 848 | +
|
759 | 849 | computedYMin() {
|
760 | 850 | let lowest = 0
|
761 | 851 |
|
@@ -956,8 +1046,41 @@ export default {
|
956 | 1046 | chartUnitPrefix() {
|
957 | 1047 | this.$emit('selectedDataset', this.dataset)
|
958 | 1048 | },
|
| 1049 | +
|
959 | 1050 | interval() {
|
960 | 1051 | this.handleTypeClick()
|
| 1052 | +
|
| 1053 | + if (this.isTypeGrowthStackedArea) { |
| 1054 | + this.growthDataset = this.zoomExtent.length > 0 ? this.getGrowthDataset().filter((d) => { |
| 1055 | + return d.date >= this.zoomExtent[0] && d.date < this.zoomExtent[1] |
| 1056 | + }) : this.getGrowthDataset() |
| 1057 | +
|
| 1058 | + console.log('growthDataset zoomExtent', this.growthDataset) |
| 1059 | + } |
| 1060 | + }, |
| 1061 | +
|
| 1062 | + zoomExtent(val) { |
| 1063 | + console.log('zoomExtent', val, this.stackedAreaDataset) |
| 1064 | +
|
| 1065 | + if (this.isTypeGrowthStackedArea) { |
| 1066 | + this.growthDataset = val.length > 0 ? this.getGrowthDataset().filter((d) => { |
| 1067 | + return d.date >= val[0] && d.date < val[1] |
| 1068 | + }) : this.getGrowthDataset() |
| 1069 | +
|
| 1070 | + console.log('growthDataset zoomExtent', this.growthDataset) |
| 1071 | + } |
| 1072 | + }, |
| 1073 | +
|
| 1074 | + isTypeGrowthStackedArea(val) { |
| 1075 | + console.log('isTypeGrowthStackedArea', val) |
| 1076 | +
|
| 1077 | + if (val) { |
| 1078 | + this.growthDataset = this.zoomExtent.length > 0 ? this.getGrowthDataset().filter((d) => { |
| 1079 | + return d.date >= this.zoomExtent[0] && d.date < this.zoomExtent[1] |
| 1080 | + }) : this.getGrowthDataset() |
| 1081 | +
|
| 1082 | + console.log('growthDataset isTypeGrowthStackedArea', this.growthDataset) |
| 1083 | + } |
961 | 1084 | }
|
962 | 1085 | },
|
963 | 1086 |
|
@@ -1063,6 +1186,35 @@ export default {
|
1063 | 1186 | return newDataset
|
1064 | 1187 | },
|
1065 | 1188 |
|
| 1189 | + getGrowthDataset() { |
| 1190 | + const dataset= [] |
| 1191 | +
|
| 1192 | + this.stackedAreaDataset.forEach((d, i) => { |
| 1193 | + const obj = { |
| 1194 | + date: d.date, |
| 1195 | + time: d.time |
| 1196 | + } |
| 1197 | +
|
| 1198 | + this.powerEnergyDomains.forEach((domain) => { |
| 1199 | + const ftId = domain.id |
| 1200 | +
|
| 1201 | + if (i === 0) { |
| 1202 | + obj[ftId] = 0 |
| 1203 | + } else { |
| 1204 | + obj[ftId] = d[ftId] - this.stackedAreaDataset[i - 1][ftId] |
| 1205 | + } |
| 1206 | +
|
| 1207 | + }) |
| 1208 | +
|
| 1209 | + dataset.push(obj) |
| 1210 | +
|
| 1211 | + }) |
| 1212 | +
|
| 1213 | + console.log('growthDataset end', dataset) |
| 1214 | +
|
| 1215 | + return dataset |
| 1216 | + }, |
| 1217 | +
|
1066 | 1218 | handleDomainHover(domain) {
|
1067 | 1219 | this.setHoverDomain(domain)
|
1068 | 1220 | },
|
|
0 commit comments