mirror of
https://github.com/beestat/app.git
synced 2025-07-09 03:04:07 -04:00
Fixed #255 - Make Thermostat Detail auto-scale y-axis
This commit is contained in:
parent
ef2ba2427a
commit
ed94987db1
@ -16,8 +16,6 @@ beestat.runtime_sensor.get_data = function(thermostat_id, range) {
|
|||||||
'metadata': {
|
'metadata': {
|
||||||
'series': {},
|
'series': {},
|
||||||
'chart': {
|
'chart': {
|
||||||
'y_min': Infinity,
|
|
||||||
'y_max': -Infinity,
|
|
||||||
'sensors': null
|
'sensors': null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,18 +15,7 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range) {
|
|||||||
'series': {},
|
'series': {},
|
||||||
'metadata': {
|
'metadata': {
|
||||||
'series': {},
|
'series': {},
|
||||||
'chart': {
|
'chart': {}
|
||||||
'y_min': Infinity,
|
|
||||||
'y_max': -Infinity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// A couple private helper functions for manipulating the min/max y values.
|
|
||||||
var y_min_max = function(value) {
|
|
||||||
if (value !== null) {
|
|
||||||
data.metadata.chart.y_min = Math.min(data.metadata.chart.y_min, value);
|
|
||||||
data.metadata.chart.y_max = Math.max(data.metadata.chart.y_max, value);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -185,7 +174,6 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range) {
|
|||||||
data.series.outdoor_temperature.push(outdoor_temperature_moving);
|
data.series.outdoor_temperature.push(outdoor_temperature_moving);
|
||||||
data.metadata.series.outdoor_temperature.data[current_m.valueOf()] =
|
data.metadata.series.outdoor_temperature.data[current_m.valueOf()] =
|
||||||
beestat.temperature(runtime_thermostat.outdoor_temperature);
|
beestat.temperature(runtime_thermostat.outdoor_temperature);
|
||||||
y_min_max(outdoor_temperature_moving);
|
|
||||||
data.metadata.series.outdoor_temperature.active = true;
|
data.metadata.series.outdoor_temperature.active = true;
|
||||||
|
|
||||||
var outdoor_humidity_moving = beestat.runtime_thermostat.get_average_(
|
var outdoor_humidity_moving = beestat.runtime_thermostat.get_average_(
|
||||||
@ -211,7 +199,6 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range) {
|
|||||||
data.series.indoor_temperature.push(indoor_temperature);
|
data.series.indoor_temperature.push(indoor_temperature);
|
||||||
data.metadata.series.indoor_temperature.data[current_m.valueOf()] =
|
data.metadata.series.indoor_temperature.data[current_m.valueOf()] =
|
||||||
indoor_temperature;
|
indoor_temperature;
|
||||||
y_min_max(indoor_temperature);
|
|
||||||
data.metadata.series.indoor_temperature.active = true;
|
data.metadata.series.indoor_temperature.active = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -228,9 +215,6 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range) {
|
|||||||
);
|
);
|
||||||
data.series.setpoint_heat.push(setpoint_heat);
|
data.series.setpoint_heat.push(setpoint_heat);
|
||||||
data.metadata.series.setpoint_heat.data[current_m.valueOf()] = setpoint_heat;
|
data.metadata.series.setpoint_heat.data[current_m.valueOf()] = setpoint_heat;
|
||||||
y_min_max(outdoor_temperature_moving);
|
|
||||||
|
|
||||||
y_min_max(setpoint_heat);
|
|
||||||
|
|
||||||
data.metadata.series.setpoint_heat.active = true;
|
data.metadata.series.setpoint_heat.active = true;
|
||||||
|
|
||||||
@ -247,7 +231,6 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range) {
|
|||||||
);
|
);
|
||||||
data.series.setpoint_cool.push(setpoint_cool);
|
data.series.setpoint_cool.push(setpoint_cool);
|
||||||
data.metadata.series.setpoint_heat.data[current_m.valueOf()] = setpoint_cool;
|
data.metadata.series.setpoint_heat.data[current_m.valueOf()] = setpoint_cool;
|
||||||
y_min_max(setpoint_cool);
|
|
||||||
|
|
||||||
data.metadata.series.setpoint_cool.active = true;
|
data.metadata.series.setpoint_cool.active = true;
|
||||||
|
|
||||||
|
@ -121,35 +121,19 @@ beestat.component.chart.runtime_thermostat_detail_temperature.prototype.get_opti
|
|||||||
* @return {Array} The y-axis options.
|
* @return {Array} The y-axis options.
|
||||||
*/
|
*/
|
||||||
beestat.component.chart.runtime_thermostat_detail_temperature.prototype.get_options_yAxis_ = function() {
|
beestat.component.chart.runtime_thermostat_detail_temperature.prototype.get_options_yAxis_ = function() {
|
||||||
/**
|
|
||||||
* Highcharts doesn't seem to respect axis behavior well so just overriding
|
|
||||||
* it completely here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var y_min = Math.floor((this.data_.metadata.chart.y_min) / 10) * 10;
|
|
||||||
var y_max = Math.ceil((this.data_.metadata.chart.y_max) / 10) * 10;
|
|
||||||
var tick_positions = [];
|
|
||||||
var tick_interval = (beestat.setting('temperature_unit') === '°F') ? 10 : 5;
|
|
||||||
var current_tick_position =
|
|
||||||
Math.floor(y_min / tick_interval) * tick_interval;
|
|
||||||
while (current_tick_position <= y_max) {
|
|
||||||
tick_positions.push(current_tick_position);
|
|
||||||
current_tick_position += tick_interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
// Temperature
|
// Temperature
|
||||||
{
|
{
|
||||||
'gridLineColor': beestat.style.color.bluegray.light,
|
'gridLineColor': beestat.style.color.bluegray.light,
|
||||||
'gridLineDashStyle': 'longdash',
|
'gridLineDashStyle': 'longdash',
|
||||||
|
'allowDecimals': false,
|
||||||
'title': {'text': null},
|
'title': {'text': null},
|
||||||
'labels': {
|
'labels': {
|
||||||
'style': {'color': beestat.style.color.gray.base},
|
'style': {'color': beestat.style.color.gray.base},
|
||||||
'formatter': function() {
|
'formatter': function() {
|
||||||
return this.value + beestat.setting('temperature_unit');
|
return this.value + beestat.setting('temperature_unit');
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
'tickPositions': tick_positions
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Humidity
|
// Humidity
|
||||||
|
Loading…
x
Reference in New Issue
Block a user