Skip to content

Commit

Permalink
Highcharts tooltips now in station time locale format
Browse files Browse the repository at this point in the history
Updates #56
  • Loading branch information
poblabs committed Feb 7, 2019
1 parent b2b7a41 commit 09ca581
Show file tree
Hide file tree
Showing 4 changed files with 303 additions and 32 deletions.
89 changes: 81 additions & 8 deletions skins/Belchertown/js/highcharts-dayplots.js.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
var moment_locale = "$system_locale".replace(/_/g, '-'); // Replace underscore with dash (e.g. "en_US" becomes "en-US") which is a format that moment.js needs for locale
moment.locale(moment_locale);

// http://stackoverflow.com/a/14887961/1177153
var weatherdirection = {
0: 'N',
Expand Down Expand Up @@ -133,7 +136,17 @@ function daily () {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
// For locale control with moment.js - https://api.highcharts.com/highcharts/tooltip.split
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("LLL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -218,7 +231,17 @@ function daily () {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
// For locale control with moment.js - https://api.highcharts.com/highcharts/tooltip.split
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("LLL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -308,7 +331,17 @@ function daily () {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
// For locale control with moment.js - https://api.highcharts.com/highcharts/tooltip.split
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("LLL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -394,7 +427,17 @@ function daily () {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
// For locale control with moment.js - https://api.highcharts.com/highcharts/tooltip.split
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("LLL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -479,7 +522,17 @@ function daily () {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
// For locale control with moment.js - https://api.highcharts.com/highcharts/tooltip.split
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("LLL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -583,7 +636,7 @@ function daily () {
enabled: true,
//pointFormat: '{series.name}: <b>{point.y}</b>',
formatter: function() {
return Highcharts.dateFormat('%A, %b %e, %H:%M', this.x) +'<br><b>' + get_cardinal_direction( parseFloat(this.point.y).toFixed(2) ) + ' (' + parseFloat(this.point.y).toFixed(2) + '\xBA)';
return moment.unix( this.x / 1000).format("LLL") +'<br><b>' + get_cardinal_direction( parseFloat(this.point.y).toFixed(2) ) + ' (' + parseFloat(this.point.y).toFixed(2) + '\xBA)';
},
valueDecimals: 2,
dateTimeLabelFormats: {
Expand Down Expand Up @@ -787,7 +840,17 @@ function daily () {
valueDecimals: 2,
dateTimeLabelFormats: {
hour: 'hour to %e %b %H:%M'
}
},
// For locale control with moment.js - https://api.highcharts.com/highcharts/tooltip.split
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("LLL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + parseFloat(point.y).toFixed(2);
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -879,7 +942,17 @@ function daily () {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
// For locale control with moment.js - https://api.highcharts.com/highcharts/tooltip.split
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("LLL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down
82 changes: 74 additions & 8 deletions skins/Belchertown/js/highcharts-monthplots.js.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
var moment_locale = "$system_locale".replace(/_/g, '-'); // Replace underscore with dash (e.g. "en_US" becomes "en-US") which is a format that moment.js needs for locale
moment.locale(moment_locale);

// http://stackoverflow.com/a/14887961/1177153
var weatherdirection = {
0: 'N',
Expand Down Expand Up @@ -134,7 +137,16 @@ function monthly() {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("dddd LL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -219,7 +231,16 @@ function monthly() {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("dddd LL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -309,7 +330,16 @@ function monthly() {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("dddd LL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -395,7 +425,16 @@ function monthly() {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("dddd LL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -480,7 +519,16 @@ function monthly() {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("dddd LL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -584,7 +632,7 @@ function monthly() {
enabled: true,
//pointFormat: '{series.name}: <b>{point.y}</b>',
formatter: function() {
return Highcharts.dateFormat('%A, %b %e, %H:%M', this.x) +'<br><b>' + get_cardinal_direction( parseFloat(this.point.y).toFixed(2) ) + ' (' + parseFloat(this.point.y).toFixed(2) + '\xBA)';
return moment.unix( this.x / 1000).format("dddd LL") +'<br><b>' + get_cardinal_direction( parseFloat(this.point.y).toFixed(2) ) + ' (' + parseFloat(this.point.y).toFixed(2) + '\xBA)';
},
valueDecimals: 2,
dateTimeLabelFormats: {
Expand Down Expand Up @@ -695,7 +743,16 @@ function monthly() {
valueDecimals: 2,
dateTimeLabelFormats: {
hour: '%e %b'
}
},
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("dddd LL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + parseFloat(point.y).toFixed(2);
})
);
},
split: true,
},

series: [{}]
Expand Down Expand Up @@ -787,7 +844,16 @@ function monthly() {
enabled: true,
dateTimeLabelFormats: {
hour: '%e %b %H:%M'
}
},
formatter: function () {
// The first returned item is the header, subsequent items are the points
return [moment.unix( this.x / 1000).format("dddd LL")].concat(
this.points.map(function (point) {
return "<span style='color:" + point.series.color + "'>\u25CF</span> " + point.series.name + ': ' + point.y;
})
);
},
split: true,
},

series: [{}]
Expand Down
Loading

0 comments on commit 09ca581

Please sign in to comment.