mirror of
https://github.com/beestat/app.git
synced 2025-06-02 21:26:38 -04:00
Fixed #170 - Remove event listeners from temperature profile score cards
Also did some massive cleanup on the home comparisons layer and associated components.
This commit is contained in:
parent
3eda17a366
commit
f61b85e646
@ -1,176 +1,151 @@
|
|||||||
/**
|
beestat.home_comparisons = {};
|
||||||
* Fire off an API call to get the temperature profile using the currently
|
|
||||||
* defined settings. Updates the cache with the response which fires off the
|
/**
|
||||||
* event for anything bound to that data.
|
* Fire off an API call to get the comparison scores using the currently
|
||||||
*
|
* defined settings. Updates the cache with the response which fires off the
|
||||||
* TODO: This can probably be refactored a bit. The API call is now gone
|
* vent for anything bound to that data.
|
||||||
* because it's no longer possible to generate these on the fly as of 1.4.
|
*
|
||||||
*
|
* Note that this fires off a batch API call for heat, cool, and resist
|
||||||
* @param {Function} callback Optional callback to fire when the API call
|
* scores. So if you *only* had the resist card on the dashboard you would
|
||||||
* completes.
|
* still get all three. I think the most common use case is showing all three
|
||||||
*/
|
* scores, so the layer loader will be able to optimize away the duplicate
|
||||||
beestat.generate_temperature_profile = function(callback) {
|
* requests and do one multi API call instead of three distinct API calls.
|
||||||
var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
*
|
||||||
var thermostat_group = beestat.cache.thermostat_group[
|
* @param {Function} callback Optional callback to fire when the API call
|
||||||
thermostat.thermostat_group_id
|
* completes.
|
||||||
];
|
*/
|
||||||
|
beestat.home_comparisons.get_comparison_scores = function(callback) {
|
||||||
beestat.cache.set(
|
var types = [
|
||||||
'data.comparison_temperature_profile',
|
'heat',
|
||||||
thermostat_group.temperature_profile
|
'cool',
|
||||||
);
|
'resist'
|
||||||
|
];
|
||||||
if (callback !== undefined) {
|
|
||||||
callback();
|
var api = new beestat.api();
|
||||||
}
|
types.forEach(function(type) {
|
||||||
};
|
beestat.cache.delete('data.comparison_scores_' + type);
|
||||||
|
api.add_call(
|
||||||
/**
|
'thermostat_group',
|
||||||
* Fire off an API call to get the comparison scores using the currently
|
'get_scores',
|
||||||
* defined settings. Updates the cache with the response which fires off the
|
{
|
||||||
* vent for anything bound to that data.
|
'type': type,
|
||||||
*
|
'attributes': beestat.home_comparisons.get_comparison_attributes(type)
|
||||||
* Note that this fires off a batch API call for heat, cool, and resist
|
},
|
||||||
* scores. So if you *only* had the resist card on the dashboard you would
|
type
|
||||||
* still get all three. I think the most common use case is showing all three
|
);
|
||||||
* scores, so the layer loader will be able to optimize away the duplicate
|
});
|
||||||
* requests and do one multi API call instead of three distinct API calls.
|
|
||||||
*
|
api.set_callback(function(data) {
|
||||||
* @param {Function} callback Optional callback to fire when the API call
|
types.forEach(function(type) {
|
||||||
* completes.
|
beestat.cache.set('data.comparison_scores_' + type, data[type]);
|
||||||
*/
|
});
|
||||||
beestat.get_comparison_scores = function(callback) {
|
|
||||||
var types = [
|
if (callback !== undefined) {
|
||||||
'heat',
|
callback();
|
||||||
'cool',
|
}
|
||||||
'resist'
|
});
|
||||||
];
|
|
||||||
|
api.send();
|
||||||
var api = new beestat.api();
|
};
|
||||||
types.forEach(function(type) {
|
|
||||||
beestat.cache.delete('data.comparison_scores_' + type);
|
/**
|
||||||
api.add_call(
|
* Based on the comparison settings chosen in the GUI, get the proper broken
|
||||||
'thermostat_group',
|
* out comparison attributes needed to make an API call.
|
||||||
'get_scores',
|
*
|
||||||
{
|
* @param {string} type heat|cool|resist
|
||||||
'type': type,
|
*
|
||||||
'attributes': beestat.get_comparison_attributes(type)
|
* @return {Object} The comparison attributes.
|
||||||
},
|
*/
|
||||||
type
|
beestat.home_comparisons.get_comparison_attributes = function(type) {
|
||||||
);
|
var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
||||||
});
|
var thermostat_group =
|
||||||
|
beestat.cache.thermostat_group[thermostat.thermostat_group_id];
|
||||||
api.set_callback(function(data) {
|
|
||||||
types.forEach(function(type) {
|
var attributes = {};
|
||||||
beestat.cache.set('data.comparison_scores_' + type, data[type]);
|
|
||||||
});
|
if (beestat.setting('comparison_property_type') === 'similar') {
|
||||||
|
// Match structure type exactly.
|
||||||
if (callback !== undefined) {
|
if (thermostat_group.property_structure_type !== null) {
|
||||||
callback();
|
attributes.property_structure_type =
|
||||||
}
|
thermostat_group.property_structure_type;
|
||||||
});
|
}
|
||||||
|
|
||||||
api.send();
|
// Always a 10 year age delta on both sides.
|
||||||
};
|
if (thermostat_group.property_age !== null) {
|
||||||
|
var property_age_delta = 10;
|
||||||
/**
|
var min_property_age = Math.max(
|
||||||
* Based on the comparison settings chosen in the GUI, get the proper broken
|
0,
|
||||||
* out comparison attributes needed to make an API call.
|
thermostat_group.property_age - property_age_delta
|
||||||
*
|
);
|
||||||
* @param {string} type heat|cool|resist
|
var max_property_age = thermostat_group.property_age + property_age_delta;
|
||||||
*
|
attributes.property_age = {
|
||||||
* @return {Object} The comparison attributes.
|
'operator': 'between',
|
||||||
*/
|
'value': [
|
||||||
beestat.get_comparison_attributes = function(type) {
|
min_property_age,
|
||||||
var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
max_property_age
|
||||||
var thermostat_group =
|
]
|
||||||
beestat.cache.thermostat_group[thermostat.thermostat_group_id];
|
};
|
||||||
|
}
|
||||||
var attributes = {};
|
|
||||||
|
// Always a 1000sqft size delta on both sides (total 2000 sqft).
|
||||||
if (beestat.setting('comparison_property_type') === 'similar') {
|
if (thermostat_group.property_square_feet !== null) {
|
||||||
// Match structure type exactly.
|
var property_square_feet_delta = 1000;
|
||||||
if (thermostat_group.property_structure_type !== null) {
|
var min_property_square_feet = Math.max(
|
||||||
attributes.property_structure_type =
|
0,
|
||||||
thermostat_group.property_structure_type;
|
thermostat_group.property_square_feet - property_square_feet_delta
|
||||||
}
|
);
|
||||||
|
var max_property_square_feet =
|
||||||
// Always a 10 year age delta on both sides.
|
thermostat_group.property_square_feet +
|
||||||
if (thermostat_group.property_age !== null) {
|
property_square_feet_delta;
|
||||||
var property_age_delta = 10;
|
attributes.property_square_feet = {
|
||||||
var min_property_age = Math.max(
|
'operator': 'between',
|
||||||
0,
|
'value': [
|
||||||
thermostat_group.property_age - property_age_delta
|
min_property_square_feet,
|
||||||
);
|
max_property_square_feet
|
||||||
var max_property_age = thermostat_group.property_age + property_age_delta;
|
]
|
||||||
attributes.property_age = {
|
};
|
||||||
'operator': 'between',
|
}
|
||||||
'value': [
|
|
||||||
min_property_age,
|
/*
|
||||||
max_property_age
|
* If 0 or 1 stories, then 1 story, else just more than one story.
|
||||||
]
|
* Apartments ignore this.
|
||||||
};
|
*/
|
||||||
}
|
if (
|
||||||
|
thermostat_group.property_stories !== null &&
|
||||||
// Always a 1000sqft size delta on both sides (total 2000 sqft).
|
thermostat_group.property_structure_type !== 'apartment'
|
||||||
if (thermostat_group.property_square_feet !== null) {
|
) {
|
||||||
var property_square_feet_delta = 1000;
|
if (thermostat_group.property_stories < 2) {
|
||||||
var min_property_square_feet = Math.max(
|
attributes.property_stories = thermostat_group.property_stories;
|
||||||
0,
|
} else {
|
||||||
thermostat_group.property_square_feet - property_square_feet_delta
|
attributes.property_stories = {
|
||||||
);
|
'operator': '>=',
|
||||||
var max_property_square_feet =
|
'value': thermostat_group.property_stories
|
||||||
thermostat_group.property_square_feet +
|
};
|
||||||
property_square_feet_delta;
|
}
|
||||||
attributes.property_square_feet = {
|
}
|
||||||
'operator': 'between',
|
} else if (beestat.setting('comparison_property_type') === 'same_structure') {
|
||||||
'value': [
|
// Match structure type exactly.
|
||||||
min_property_square_feet,
|
if (thermostat_group.property_structure_type !== null) {
|
||||||
max_property_square_feet
|
attributes.property_structure_type =
|
||||||
]
|
thermostat_group.property_structure_type;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (
|
||||||
* If 0 or 1 stories, then 1 story, else just more than one story.
|
thermostat_group.address_latitude !== null &&
|
||||||
* Apartments ignore this.
|
thermostat_group.address_longitude !== null &&
|
||||||
*/
|
beestat.setting('comparison_region') !== 'global'
|
||||||
if (
|
) {
|
||||||
thermostat_group.property_stories !== null &&
|
attributes.address_latitude = thermostat_group.address_latitude;
|
||||||
thermostat_group.property_structure_type !== 'apartment'
|
attributes.address_longitude = thermostat_group.address_longitude;
|
||||||
) {
|
attributes.address_radius = 250;
|
||||||
if (thermostat_group.property_stories < 2) {
|
}
|
||||||
attributes.property_stories = thermostat_group.property_stories;
|
|
||||||
} else {
|
if (type === 'heat') {
|
||||||
attributes.property_stories = {
|
attributes.system_type_heat = thermostat_group.system_type_heat;
|
||||||
'operator': '>=',
|
} else if (type === 'cool') {
|
||||||
'value': thermostat_group.property_stories
|
attributes.system_type_cool = thermostat_group.system_type_cool;
|
||||||
};
|
}
|
||||||
}
|
|
||||||
}
|
return attributes;
|
||||||
} else if (beestat.setting('comparison_property_type') === 'same_structure') {
|
};
|
||||||
// Match structure type exactly.
|
|
||||||
if (thermostat_group.property_structure_type !== null) {
|
|
||||||
attributes.property_structure_type =
|
|
||||||
thermostat_group.property_structure_type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
thermostat_group.address_latitude !== null &&
|
|
||||||
thermostat_group.address_longitude !== null &&
|
|
||||||
beestat.setting('comparison_region') !== 'global'
|
|
||||||
) {
|
|
||||||
attributes.address_latitude = thermostat_group.address_latitude;
|
|
||||||
attributes.address_longitude = thermostat_group.address_longitude;
|
|
||||||
attributes.address_radius = 250;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === 'heat') {
|
|
||||||
attributes.system_type_heat = thermostat_group.system_type_heat;
|
|
||||||
} else if (type === 'cool') {
|
|
||||||
attributes.system_type_cool = thermostat_group.system_type_cool;
|
|
||||||
}
|
|
||||||
|
|
||||||
return attributes;
|
|
||||||
};
|
|
@ -127,7 +127,7 @@ beestat.component.card.comparison_settings.prototype.decorate_region_ = function
|
|||||||
// Open up the loading window.
|
// Open up the loading window.
|
||||||
self.show_loading_('Calculating Score for ' + region + ' region');
|
self.show_loading_('Calculating Score for ' + region + ' region');
|
||||||
|
|
||||||
beestat.get_comparison_scores(function() {
|
beestat.home_comparisons.get_comparison_scores(function() {
|
||||||
// Rerender to get rid of the loader.
|
// Rerender to get rid of the loader.
|
||||||
self.rerender();
|
self.rerender();
|
||||||
});
|
});
|
||||||
@ -200,7 +200,7 @@ beestat.component.card.comparison_settings.prototype.decorate_property_ = functi
|
|||||||
// Open up the loading window.
|
// Open up the loading window.
|
||||||
self.show_loading_('Calculating Score for ' + property_type.text);
|
self.show_loading_('Calculating Score for ' + property_type.text);
|
||||||
|
|
||||||
beestat.get_comparison_scores(function() {
|
beestat.home_comparisons.get_comparison_scores(function() {
|
||||||
// Rerender to get rid of the loader.
|
// Rerender to get rid of the loader.
|
||||||
self.rerender();
|
self.rerender();
|
||||||
});
|
});
|
||||||
|
@ -14,17 +14,13 @@ beestat.component.card.score = function() {
|
|||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
beestat.dispatcher.addEventListener(
|
beestat.dispatcher.addEventListener(
|
||||||
[
|
'cache.data.comparison_scores_' + this.type_,
|
||||||
'cache.data.comparison_temperature_profile',
|
|
||||||
'cache.data.comparison_scores_' + this.type_
|
|
||||||
],
|
|
||||||
data_change_function
|
data_change_function
|
||||||
);
|
);
|
||||||
|
|
||||||
beestat.component.card.apply(this, arguments);
|
beestat.component.card.apply(this, arguments);
|
||||||
|
|
||||||
this.layer_.register_loader(beestat.generate_temperature_profile);
|
this.layer_.register_loader(beestat.home_comparisons.get_comparison_scores);
|
||||||
this.layer_.register_loader(beestat.get_comparison_scores);
|
|
||||||
};
|
};
|
||||||
beestat.extend(beestat.component.card.score, beestat.component.card);
|
beestat.extend(beestat.component.card.score, beestat.component.card);
|
||||||
|
|
||||||
@ -34,28 +30,12 @@ beestat.extend(beestat.component.card.score, beestat.component.card);
|
|||||||
* @param {rocket.Elements} parent
|
* @param {rocket.Elements} parent
|
||||||
*/
|
*/
|
||||||
beestat.component.card.score.prototype.decorate_contents_ = function(parent) {
|
beestat.component.card.score.prototype.decorate_contents_ = function(parent) {
|
||||||
// this.view_detail_ = true;
|
|
||||||
|
|
||||||
if (this.view_detail_ === true) {
|
|
||||||
this.decorate_detail_(parent);
|
|
||||||
} else {
|
|
||||||
this.decorate_score_(parent);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decorate the score with the circle.
|
|
||||||
*
|
|
||||||
* @param {rocket.Elements} parent
|
|
||||||
*/
|
|
||||||
beestat.component.card.score.prototype.decorate_score_ = function(parent) {
|
|
||||||
var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
||||||
var thermostat_group = beestat.cache.thermostat_group[
|
var thermostat_group = beestat.cache.thermostat_group[
|
||||||
thermostat.thermostat_group_id
|
thermostat.thermostat_group_id
|
||||||
];
|
];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
beestat.cache.data.comparison_temperature_profile === undefined ||
|
|
||||||
beestat.cache.data['comparison_scores_' + this.type_] === undefined
|
beestat.cache.data['comparison_scores_' + this.type_] === undefined
|
||||||
) {
|
) {
|
||||||
// Height buffer so the cards don't resize after they load.
|
// Height buffer so the cards don't resize after they load.
|
||||||
@ -67,11 +47,10 @@ beestat.component.card.score.prototype.decorate_score_ = function(parent) {
|
|||||||
var percentile;
|
var percentile;
|
||||||
if (
|
if (
|
||||||
thermostat_group.temperature_profile[this.type_] !== undefined &&
|
thermostat_group.temperature_profile[this.type_] !== undefined &&
|
||||||
beestat.cache.data['comparison_scores_' + this.type_].length > 2 &&
|
beestat.cache.data['comparison_scores_' + this.type_].length > 2
|
||||||
beestat.cache.data.comparison_temperature_profile[this.type_] !== null
|
|
||||||
) {
|
) {
|
||||||
percentile = this.get_percentile_(
|
percentile = this.get_percentile_(
|
||||||
beestat.cache.data.comparison_temperature_profile[this.type_].score,
|
thermostat_group.temperature_profile[this.type_].score,
|
||||||
beestat.cache.data['comparison_scores_' + this.type_]
|
beestat.cache.data['comparison_scores_' + this.type_]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -190,364 +169,6 @@ beestat.component.card.score.prototype.decorate_score_ = function(parent) {
|
|||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decorate the detail bell curve.
|
|
||||||
*
|
|
||||||
* @param {rocket.Elements} parent
|
|
||||||
*/
|
|
||||||
beestat.component.card.score.prototype.decorate_detail_ = function(parent) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// var self = this;
|
|
||||||
|
|
||||||
this.chart_ = new beestat.component.chart();
|
|
||||||
this.chart_.options.chart.height = 166;
|
|
||||||
|
|
||||||
// if (
|
|
||||||
// beestat.cache.data.comparison_temperature_profile === undefined
|
|
||||||
// ) {
|
|
||||||
// this.chart_.render(parent);
|
|
||||||
// this.show_loading_('Calculating');
|
|
||||||
// } else {
|
|
||||||
// var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
|
||||||
|
|
||||||
// var x_categories = [];
|
|
||||||
// var trendlines = {};
|
|
||||||
// var raw = {};
|
|
||||||
|
|
||||||
// Global x range.
|
|
||||||
/* var x_min = Infinity;
|
|
||||||
var x_max = -Infinity;
|
|
||||||
|
|
||||||
var y_min = Infinity;
|
|
||||||
var y_max = -Infinity;
|
|
||||||
for (var type in beestat.cache.data.comparison_temperature_profile) {
|
|
||||||
var profile = beestat.cache.data.comparison_temperature_profile[type];
|
|
||||||
|
|
||||||
if (profile !== null) {
|
|
||||||
// Convert the data to Celsius if necessary
|
|
||||||
var deltas_converted = {};
|
|
||||||
for (var key in profile.deltas) {
|
|
||||||
deltas_converted[beestat.temperature({'temperature': key})] =
|
|
||||||
beestat.temperature({
|
|
||||||
'temperature': profile.deltas[key],
|
|
||||||
'delta': true,
|
|
||||||
'round': 3
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.deltas = deltas_converted;
|
|
||||||
var linear_trendline = this.get_linear_trendline_(profile.deltas);
|
|
||||||
|
|
||||||
var min_max_keys = Object.keys(profile.deltas);
|
|
||||||
|
|
||||||
// This specific trendline x range.
|
|
||||||
var this_x_min = Math.min.apply(null, min_max_keys);
|
|
||||||
var this_x_max = Math.max.apply(null, min_max_keys);
|
|
||||||
|
|
||||||
// Global x range.
|
|
||||||
x_min = Math.min(x_min, this_x_min);
|
|
||||||
x_max = Math.max(x_max, this_x_max);
|
|
||||||
|
|
||||||
trendlines[type] = [];
|
|
||||||
raw[type] = [];
|
|
||||||
|
|
||||||
*
|
|
||||||
* Data is stored internally as °F with 1 value per degree. That data
|
|
||||||
* gets converted to °C which then requires additional precision
|
|
||||||
* (increment).
|
|
||||||
*
|
|
||||||
* The additional precision introduces floating point error, so
|
|
||||||
* convert the x value to a fixed string.
|
|
||||||
*
|
|
||||||
* The string then needs converted to a number for highcharts, so
|
|
||||||
* later on use parseFloat to get back to that.
|
|
||||||
*
|
|
||||||
* Stupid Celsius.
|
|
||||||
|
|
||||||
var increment;
|
|
||||||
var fixed;
|
|
||||||
if (thermostat.temperature_unit === '°F') {
|
|
||||||
increment = 1;
|
|
||||||
fixed = 0;
|
|
||||||
} else {
|
|
||||||
increment = 0.1;
|
|
||||||
fixed = 1;
|
|
||||||
}
|
|
||||||
for (var x = this_x_min; x <= this_x_max; x += increment) {
|
|
||||||
var x_fixed = x.toFixed(fixed);
|
|
||||||
var y = (linear_trendline.slope * x_fixed) +
|
|
||||||
linear_trendline.intercept;
|
|
||||||
|
|
||||||
trendlines[type].push([
|
|
||||||
parseFloat(x_fixed),
|
|
||||||
y
|
|
||||||
]);
|
|
||||||
if (profile.deltas[x_fixed] !== undefined) {
|
|
||||||
raw[type].push([
|
|
||||||
parseFloat(x_fixed),
|
|
||||||
profile.deltas[x_fixed]
|
|
||||||
]);
|
|
||||||
y_min = Math.min(y_min, profile.deltas[x_fixed]);
|
|
||||||
y_max = Math.max(y_max, profile.deltas[x_fixed]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set y_min and y_max to be equal but opposite so the graph is always
|
|
||||||
// centered.
|
|
||||||
var absolute_y_max = Math.max(Math.abs(y_min), Math.abs(y_max));
|
|
||||||
y_min = absolute_y_max * -1;
|
|
||||||
y_max = absolute_y_max;*/
|
|
||||||
|
|
||||||
// y_min = -5;
|
|
||||||
// y_max = 5;
|
|
||||||
// x_min = Math.min(x_min, 0);
|
|
||||||
// x_max = Math.max(x_max, 100);
|
|
||||||
|
|
||||||
// Chart
|
|
||||||
// this.chart_.options.exporting.chartOptions.title.text = this.get_title_();
|
|
||||||
// this.chart_.options.exporting.chartOptions.subtitle.text = this.get_subtitle_();
|
|
||||||
|
|
||||||
// this.chart_.options.chart.backgroundColor = beestat.style.color.bluegray.base;
|
|
||||||
// this.chart_.options.exporting.filename = this.get_title_();
|
|
||||||
this.chart_.options.chart.zoomType = null;
|
|
||||||
// this.chart_.options.plotOptions.series.connectNulls = true;
|
|
||||||
this.chart_.options.legend = {'enabled': false};
|
|
||||||
|
|
||||||
/* this.chart_.options.xAxis = {
|
|
||||||
'lineWidth': 0,
|
|
||||||
'tickLength': 0,
|
|
||||||
'tickInterval': 5,
|
|
||||||
'gridLineWidth': 1,
|
|
||||||
'gridLineColor': beestat.style.color.bluegray.light,
|
|
||||||
'gridLineDashStyle': 'longdash',
|
|
||||||
'labels': {
|
|
||||||
'style': {'color': beestat.style.color.gray.base},
|
|
||||||
'formatter': function() {
|
|
||||||
return this.value + thermostat.temperature_unit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};*/
|
|
||||||
|
|
||||||
|
|
||||||
this.chart_.options.xAxis = {
|
|
||||||
'title': { 'text': null },
|
|
||||||
'plotLines': [
|
|
||||||
{
|
|
||||||
'color': 'white',
|
|
||||||
'width': 2,
|
|
||||||
'value': beestat.cache.data.comparison_temperature_profile[this.type_].score
|
|
||||||
|
|
||||||
}
|
|
||||||
]
|
|
||||||
// alignTicks: false
|
|
||||||
};
|
|
||||||
this.chart_.options.yAxis = {
|
|
||||||
'title': { 'text': null }
|
|
||||||
};
|
|
||||||
|
|
||||||
/* this.chart_.options.yAxis = [
|
|
||||||
{
|
|
||||||
'alignTicks': false,
|
|
||||||
'gridLineColor': beestat.style.color.bluegray.light,
|
|
||||||
'gridLineDashStyle': 'longdash',
|
|
||||||
'title': {'text': null},
|
|
||||||
'labels': {
|
|
||||||
'style': {'color': beestat.style.color.gray.base},
|
|
||||||
'formatter': function() {
|
|
||||||
return this.value + thermostat.temperature_unit;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'min': y_min,
|
|
||||||
'max': y_max,
|
|
||||||
'plotLines': [
|
|
||||||
{
|
|
||||||
'color': beestat.style.color.bluegray.light,
|
|
||||||
'dashStyle': 'solid',
|
|
||||||
'width': 3,
|
|
||||||
'value': 0,
|
|
||||||
'zIndex': 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];*/
|
|
||||||
|
|
||||||
/* this.chart_.options.tooltip = {
|
|
||||||
'shared': true,
|
|
||||||
'useHTML': true,
|
|
||||||
'borderWidth': 0,
|
|
||||||
'shadow': false,
|
|
||||||
'backgroundColor': null,
|
|
||||||
'followPointer': true,
|
|
||||||
'crosshairs': {
|
|
||||||
'width': 1,
|
|
||||||
'zIndex': 100,
|
|
||||||
'color': beestat.style.color.gray.light,
|
|
||||||
'dashStyle': 'shortDot',
|
|
||||||
'snap': false
|
|
||||||
},
|
|
||||||
'positioner': function(tooltip_width, tooltip_height, point) {
|
|
||||||
return beestat.component.chart.tooltip_positioner(
|
|
||||||
self.chart_.get_chart(),
|
|
||||||
tooltip_width,
|
|
||||||
tooltip_height,
|
|
||||||
point
|
|
||||||
);
|
|
||||||
},
|
|
||||||
'formatter': function() {
|
|
||||||
var sections = [];
|
|
||||||
var section = [];
|
|
||||||
this.points.forEach(function(point) {
|
|
||||||
var series = point.series;
|
|
||||||
|
|
||||||
var value = beestat.temperature({
|
|
||||||
'temperature': point.y,
|
|
||||||
'units': true,
|
|
||||||
'convert': false,
|
|
||||||
'delta': true,
|
|
||||||
'type': 'string'
|
|
||||||
}) + ' / hour';
|
|
||||||
|
|
||||||
// if (series.name.indexOf('Raw') === -1) {
|
|
||||||
section.push({
|
|
||||||
'label': series.name,
|
|
||||||
'value': value,
|
|
||||||
'color': series.color
|
|
||||||
});
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
sections.push(section);
|
|
||||||
|
|
||||||
return beestat.component.chart.tooltip_formatter(
|
|
||||||
'Outdoor Temp: ' +
|
|
||||||
beestat.temperature({
|
|
||||||
'temperature': this.x,
|
|
||||||
'round': 0,
|
|
||||||
'units': true,
|
|
||||||
'convert': false
|
|
||||||
}),
|
|
||||||
sections
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};*/
|
|
||||||
|
|
||||||
// beestat.cache.data['comparison_scores_' + this.type_] = [ 0.4, 0.6, 0.6, 0.7, 0.8, 0.8, 0.8, 0.9, 0.9, 1, 1, 1, 1, 1, 1.1, 1.1, 1.1, 1.1, 1.2, 1.2, 1.2, 1.4, 1.4, 1.5, 1.5, 1.5, 1.5, 1.5, 1.6, 1.7, 1.8, 1.9, 2.3, 2.6, 2.7, 3.3, 3.3, 3.6, 5.9]
|
|
||||||
|
|
||||||
|
|
||||||
console.log(beestat.cache.data['comparison_scores_' + this.type_]);
|
|
||||||
|
|
||||||
var color = this.type_ === 'resist' ? beestat.style.color.gray.base : beestat.series['compressor_' + this.type_ + '_1'].color;
|
|
||||||
|
|
||||||
this.chart_.options.series = [
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
// 'data': trendlines.heat,
|
|
||||||
// 'name': 'Indoor Heat Δ',
|
|
||||||
// 'color': beestat.series.compressor_heat_1.color,
|
|
||||||
// 'marker': {
|
|
||||||
// 'enabled': false,
|
|
||||||
// 'states': {'hover': {'enabled': false}}
|
|
||||||
// },
|
|
||||||
'type': 'bellcurve',
|
|
||||||
'baseSeries': 1,
|
|
||||||
'color': color,
|
|
||||||
|
|
||||||
// Histogram
|
|
||||||
// 'type': 'histogram',
|
|
||||||
// 'binWidth': 0.1,
|
|
||||||
// 'borderWidth': 0,
|
|
||||||
|
|
||||||
// 'data': beestat.cache.data['comparison_scores_' + this.type_]
|
|
||||||
// 'lineWidth': 2,
|
|
||||||
// 'states': {'hover': {'lineWidthPlus': 0}}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'data': beestat.cache.data['comparison_scores_' + this.type_],
|
|
||||||
'visible': false
|
|
||||||
},
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
console.log(parent);
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// Trendline data
|
|
||||||
// this.chart_.options.series.push({
|
|
||||||
// 'data': trendlines.heat,
|
|
||||||
// 'name': 'Indoor Heat Δ',
|
|
||||||
// 'color': beestat.series.compressor_heat_1.color,
|
|
||||||
// 'marker': {
|
|
||||||
// 'enabled': false,
|
|
||||||
// 'states': {'hover': {'enabled': false}}
|
|
||||||
// },
|
|
||||||
// 'type': 'bellcurve',
|
|
||||||
// 'data': beestat.cache.data['comparison_scores_' + this.type_]
|
|
||||||
// 'lineWidth': 2,
|
|
||||||
// 'states': {'hover': {'lineWidthPlus': 0}}
|
|
||||||
// });
|
|
||||||
|
|
||||||
console.log('render chart');
|
|
||||||
this.chart_.render(parent);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -580,14 +201,6 @@ beestat.component.card.score.prototype.decorate_top_right_ = function(parent) {
|
|||||||
|
|
||||||
var menu = (new beestat.component.menu()).render(parent);
|
var menu = (new beestat.component.menu()).render(parent);
|
||||||
|
|
||||||
// menu.add_menu_item(new beestat.component.menu_item()
|
|
||||||
// .set_text('View Detail')
|
|
||||||
// .set_icon('chart_bell_curve')
|
|
||||||
// .set_callback(function() {
|
|
||||||
// self.view_detail_ = true;
|
|
||||||
// self.rerender();
|
|
||||||
// }));
|
|
||||||
|
|
||||||
menu.add_menu_item(new beestat.component.menu_item()
|
menu.add_menu_item(new beestat.component.menu_item()
|
||||||
.set_text('Help')
|
.set_text('Help')
|
||||||
.set_icon('help_circle')
|
.set_icon('help_circle')
|
||||||
@ -602,28 +215,19 @@ beestat.component.card.score.prototype.decorate_top_right_ = function(parent) {
|
|||||||
* @return {string} The subtitle.
|
* @return {string} The subtitle.
|
||||||
*/
|
*/
|
||||||
beestat.component.card.score.prototype.get_subtitle_ = function() {
|
beestat.component.card.score.prototype.get_subtitle_ = function() {
|
||||||
if (this.view_detail_ === true) {
|
var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
||||||
if (
|
var thermostat_group = beestat.cache.thermostat_group[
|
||||||
// beestat.cache.data['comparison_scores_' + this.type_] !== undefined &&
|
thermostat.thermostat_group_id
|
||||||
// beestat.cache.data['comparison_scores_' + this.type_].length > 2 &&
|
];
|
||||||
beestat.cache.data.comparison_temperature_profile !== undefined &&
|
|
||||||
beestat.cache.data.comparison_temperature_profile[this.type_] !== null
|
|
||||||
) {
|
|
||||||
return 'Your raw score: ' + beestat.cache.data.comparison_temperature_profile[this.type_].score;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'N/A';
|
if (
|
||||||
} else {
|
beestat.cache.data['comparison_scores_' + this.type_] !== undefined &&
|
||||||
if (
|
beestat.cache.data['comparison_scores_' + this.type_].length > 2 &&
|
||||||
beestat.cache.data['comparison_scores_' + this.type_] !== undefined &&
|
thermostat_group.temperature_profile[this.type_] !== null
|
||||||
beestat.cache.data['comparison_scores_' + this.type_].length > 2 &&
|
) {
|
||||||
beestat.cache.data.comparison_temperature_profile !== undefined &&
|
return 'Comparing to ' + Number(beestat.cache.data['comparison_scores_' + this.type_].length).toLocaleString() + ' Homes';
|
||||||
beestat.cache.data.comparison_temperature_profile[this.type_] !== null
|
|
||||||
) {
|
|
||||||
return 'Comparing to ' + Number(beestat.cache.data['comparison_scores_' + this.type_].length).toLocaleString() + ' Homes';
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'N/A';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 'N/A';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -2,15 +2,7 @@
|
|||||||
* Temperature profiles.
|
* Temperature profiles.
|
||||||
*/
|
*/
|
||||||
beestat.component.card.temperature_profiles = function() {
|
beestat.component.card.temperature_profiles = function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
beestat.dispatcher.addEventListener('cache.data.comparison_temperature_profile', function() {
|
|
||||||
self.rerender();
|
|
||||||
});
|
|
||||||
|
|
||||||
beestat.component.card.apply(this, arguments);
|
beestat.component.card.apply(this, arguments);
|
||||||
|
|
||||||
this.layer_.register_loader(beestat.generate_temperature_profile);
|
|
||||||
};
|
};
|
||||||
beestat.extend(beestat.component.card.temperature_profiles, beestat.component.card);
|
beestat.extend(beestat.component.card.temperature_profiles, beestat.component.card);
|
||||||
|
|
||||||
@ -22,17 +14,20 @@ beestat.extend(beestat.component.card.temperature_profiles, beestat.component.ca
|
|||||||
beestat.component.card.temperature_profiles.prototype.decorate_contents_ = function(parent) {
|
beestat.component.card.temperature_profiles.prototype.decorate_contents_ = function(parent) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
||||||
|
var thermostat_group = beestat.cache.thermostat_group[
|
||||||
|
thermostat.thermostat_group_id
|
||||||
|
];
|
||||||
|
|
||||||
this.chart_ = new beestat.component.chart();
|
this.chart_ = new beestat.component.chart();
|
||||||
this.chart_.options.chart.height = 300;
|
this.chart_.options.chart.height = 300;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
beestat.cache.data.comparison_temperature_profile === undefined
|
thermostat_group.temperature_profile === null
|
||||||
) {
|
) {
|
||||||
this.chart_.render(parent);
|
this.chart_.render(parent);
|
||||||
this.show_loading_('Calculating');
|
this.show_loading_('Calculating');
|
||||||
} else {
|
} else {
|
||||||
var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
|
||||||
|
|
||||||
// var x_categories = [];
|
// var x_categories = [];
|
||||||
var trendlines = {};
|
var trendlines = {};
|
||||||
var raw = {};
|
var raw = {};
|
||||||
@ -43,10 +38,10 @@ beestat.component.card.temperature_profiles.prototype.decorate_contents_ = funct
|
|||||||
|
|
||||||
var y_min = Infinity;
|
var y_min = Infinity;
|
||||||
var y_max = -Infinity;
|
var y_max = -Infinity;
|
||||||
for (var type in beestat.cache.data.comparison_temperature_profile) {
|
for (var type in thermostat_group.temperature_profile) {
|
||||||
// Cloned because I mutate this data for temperature conversions.
|
// Cloned because I mutate this data for temperature conversions.
|
||||||
var profile = beestat.clone(
|
var profile = beestat.clone(
|
||||||
beestat.cache.data.comparison_temperature_profile[type]
|
thermostat_group.temperature_profile[type]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (profile !== null) {
|
if (profile !== null) {
|
||||||
|
@ -148,7 +148,7 @@ beestat.component.modal.change_system_type.prototype.get_buttons_ = function() {
|
|||||||
|
|
||||||
// Re-run comparison scores as they are invalid for the new system
|
// Re-run comparison scores as they are invalid for the new system
|
||||||
// type.
|
// type.
|
||||||
beestat.get_comparison_scores();
|
beestat.home_comparisons.get_comparison_scores();
|
||||||
|
|
||||||
// Close the modal.
|
// Close the modal.
|
||||||
self.dispose();
|
self.dispose();
|
||||||
|
@ -35,7 +35,7 @@ beestat.component.modal.help_score.prototype.decorate_contents_ = function(paren
|
|||||||
|
|
||||||
var strings = [];
|
var strings = [];
|
||||||
|
|
||||||
var comparison_attributes = beestat.get_comparison_attributes(this.type_);
|
var comparison_attributes = beestat.home_comparisons.get_comparison_attributes(this.type_);
|
||||||
|
|
||||||
if (comparison_attributes.system_type_heat !== undefined) {
|
if (comparison_attributes.system_type_heat !== undefined) {
|
||||||
strings.push('Heat Type: ' + this.get_comparison_string_(comparison_attributes.system_type_heat));
|
strings.push('Heat Type: ' + this.get_comparison_string_(comparison_attributes.system_type_heat));
|
||||||
|
@ -28,7 +28,7 @@ if($setting->get('environment') === 'dev' || $setting->get('environment') === 'd
|
|||||||
echo '<script src="/js/beestat/setting.js"></script>' . PHP_EOL;
|
echo '<script src="/js/beestat/setting.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/beestat/poll.js"></script>' . PHP_EOL;
|
echo '<script src="/js/beestat/poll.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/beestat/google_analytics.js"></script>' . PHP_EOL;
|
echo '<script src="/js/beestat/google_analytics.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/beestat/thermostat_group.js"></script>' . PHP_EOL;
|
echo '<script src="/js/beestat/home_comparisons.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/beestat/highcharts.js"></script>' . PHP_EOL;
|
echo '<script src="/js/beestat/highcharts.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/beestat/get_sync_progress.js"></script>' . PHP_EOL;
|
echo '<script src="/js/beestat/get_sync_progress.js"></script>' . PHP_EOL;
|
||||||
|
|
||||||
|
@ -30,7 +30,11 @@ beestat.layer.prototype.decorate_ = function(parent) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a loader. Components do this. If the same function reference is
|
* Register a loader. Components do this. If the same function reference is
|
||||||
* passed by multiple components, the duplicates will be removed.
|
* passed by multiple components, the duplicates will be removed. The loader
|
||||||
|
* was added so that I could have multiple cards on the same layer that need
|
||||||
|
* the same data. Each card adds a loader and when the layer loads it runs
|
||||||
|
* these functions. This way a layer can get the data one time instead of each
|
||||||
|
* component firing off a duplicate API call.
|
||||||
*
|
*
|
||||||
* @param {Function} loader A function to call when all of the components have
|
* @param {Function} loader A function to call when all of the components have
|
||||||
* been added to the layer.
|
* been added to the layer.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user