mirror of
https://github.com/beestat/app.git
synced 2025-07-09 03:04:07 -04:00
Fixed #124 - Temperature Profiles chart axis gets skewed if you reload a previously loaded profile (only in °C)
I was performing the same mutation on an object multiple times because I did not clone it or store the data separately.
This commit is contained in:
parent
729022e85a
commit
98905d6181
10
js/beestat/clone.js
Normal file
10
js/beestat/clone.js
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Performs a deep clone of a simple object.
|
||||
*
|
||||
* @param {Object} object The object to clone.
|
||||
*
|
||||
* @return {Object} The cloned object.
|
||||
*/
|
||||
beestat.clone = function(object) {
|
||||
return JSON.parse(JSON.stringify(object));
|
||||
};
|
@ -44,7 +44,10 @@ beestat.component.card.temperature_profiles.prototype.decorate_contents_ = funct
|
||||
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];
|
||||
// Cloned because I mutate this data for temperature conversions.
|
||||
var profile = beestat.clone(
|
||||
beestat.cache.data.comparison_temperature_profile[type]
|
||||
);
|
||||
|
||||
if (profile !== null) {
|
||||
// Convert the data to Celsius if necessary
|
||||
@ -117,17 +120,14 @@ beestat.component.card.temperature_profiles.prototype.decorate_contents_ = funct
|
||||
}
|
||||
}
|
||||
|
||||
// Set y_min and y_max to be equal but opposite so the graph is always
|
||||
// centered.
|
||||
/*
|
||||
* 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_();
|
||||
@ -139,9 +139,6 @@ beestat.component.card.temperature_profiles.prototype.decorate_contents_ = funct
|
||||
this.chart_.options.legend = {'enabled': false};
|
||||
|
||||
this.chart_.options.xAxis = {
|
||||
// 'categories': x_categories,
|
||||
// 'min': x_min,
|
||||
// 'max': x_max,
|
||||
'lineWidth': 0,
|
||||
'tickLength': 0,
|
||||
'tickInterval': 5,
|
||||
|
Loading…
x
Reference in New Issue
Block a user