summaryrefslogtreecommitdiff
path: root/src/components/_sila/Global/Chart.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/_sila/Global/Chart.vue')
-rw-r--r--src/components/_sila/Global/Chart.vue148
1 files changed, 96 insertions, 52 deletions
diff --git a/src/components/_sila/Global/Chart.vue b/src/components/_sila/Global/Chart.vue
index 43141a7a..6abf8b07 100644
--- a/src/components/_sila/Global/Chart.vue
+++ b/src/components/_sila/Global/Chart.vue
@@ -35,11 +35,11 @@ export default {
type: Number,
default: null,
},
- notNormal: {
+ critical: {
type: Number,
default: null,
},
- critical: {
+ max: {
type: Number,
default: null,
},
@@ -48,14 +48,6 @@ export default {
default: false,
},
},
- data() {
- return {
- categories: null,
- minRange: null,
- yMax: null,
- minTickInterval: null,
- };
- },
computed: {
readyData() {
let filteredData = this.data.filter((metric) => {
@@ -79,9 +71,11 @@ export default {
return transform;
},
+
step() {
return this.timeScale === 'hour' ? 10 : 60;
},
+
metricData() {
let group = this.readyData.reduce(function (rv, x) {
(rv[x['Sensor']] = rv[x['Sensor']] || []).push(x);
@@ -339,69 +333,114 @@ export default {
}
return plotBands;
},
- },
- async created() {
- this.setOptions();
- this.setChart();
- },
+ yMax() {
+ let yMax = null;
- methods: {
- setOptions() {
- Highcharts.setOptions({
- lang: {
- resetZoom: this.$t('chart.resetZoom'),
- },
- });
+ switch (this.type) {
+ case 'motherboard':
+ case 'memory':
+ case 'processors':
+ yMax = this.max;
+ break;
+ case 'power':
+ yMax = 100;
+ break;
+ case 'voltage-input':
+ yMax = 250;
+ break;
+ case 'voltage-output':
+ yMax = 100;
+ break;
+ case 'current':
+ yMax = 10;
+ break;
+ case 'psu-power':
+ yMax = 125;
+ break;
+ }
+ return yMax;
},
- setChart() {
+ categories() {
+ let categories = null;
+
switch (this.type) {
+ case 'motherboard':
+ categories = this.setCategories(this.setMaxWithInterval(), 'С°');
+ break;
case 'fans':
- this.categories = this.setSpeed(10000);
- this.minRange = 10000;
- this.minTickInterval = 1000;
+ categories = this.setSpeed(this.setMaxWithInterval());
break;
case 'memory':
- this.categories = this.setCategories(101, 'С°');
- this.yMax = 100;
- this.minTickInterval = 25;
+ categories = this.setCategories(this.setMaxWithInterval(), 'С°');
break;
case 'processors':
- this.categories = this.setCategories(101, 'С°');
- this.yMax = 100;
- this.minTickInterval = 25;
- break;
- case 'motherboard':
- this.categories = this.setCategories(101, 'С°');
- this.yMax = 100;
- this.minTickInterval = 25;
+ categories = this.setCategories(this.setMaxWithInterval(), 'С°');
break;
case 'power':
- this.categories = this.setCategories(101, 'Вт');
- this.yMax = 100;
- this.minTickInterval = 25;
+ categories = this.setCategories(101, 'Вт');
break;
case 'voltage-input':
- this.categories = this.setCategories(251, 'В');
- this.yMax = 250;
- this.minTickInterval = 25;
+ categories = this.setCategories(251, 'В');
break;
case 'voltage-output':
- this.categories = this.setCategories(101, 'В');
- this.yMax = 100;
- this.minTickInterval = 25;
+ categories = this.setCategories(101, 'В');
break;
case 'current':
- this.categories = this.setCategories(11, 'A');
- this.yMax = 10;
- this.minTickInterval = 2;
+ categories = this.setCategories(11, 'A');
+ break;
+ case 'psu-power':
+ categories = this.setCategories(126, 'Вт');
+ break;
+ }
+ return categories;
+ },
+
+ minRange() {
+ let minRange = null;
+
+ switch (this.type) {
+ case 'fans':
+ minRange = 10000;
break;
+ }
+ return minRange;
+ },
+
+ minTickInterval() {
+ let minTickInterval = null;
+
+ switch (this.type) {
+ case 'fans':
+ minTickInterval = 1000;
+ break;
+ case 'motherboard':
+ case 'memory':
+ case 'processors':
+ case 'power':
+ case 'voltage-input':
+ case 'voltage-output':
+ case 'current':
case 'psu-power':
- this.categories = this.setCategories(126, 'Вт');
- this.yMax = 125;
- this.minTickInterval = 25;
+ minTickInterval = 25;
+ break;
}
+ return minTickInterval;
+ },
+ },
+
+ async created() {
+ this.setOptions();
+ },
+
+ methods: {
+ setOptions() {
+ Highcharts.setOptions({
+ lang: {
+ resetZoom: this.$t('chart.resetZoom'),
+ },
+ });
},
setCategories(count, desc) {
const arr = [...new Array(count)].map((i, k) => `${k} ${desc}`);
@@ -411,6 +450,11 @@ export default {
const arr = [...new Array(count)].map((i, k) => `${k}`);
return arr;
},
+ setMaxWithInterval() {
+ return (
+ Math.ceil(this.max / this.minTickInterval) * this.minTickInterval + 1
+ );
+ },
},
};
</script>