aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common
diff options
context:
space:
mode:
authorAshutosh Bishnoi <mail2bishnoi@gmail.com>2020-11-27 16:31:49 +0530
committerAshutosh Bishnoi <mail2bishnoi@gmail.com>2020-11-27 16:31:49 +0530
commit9c2dbcf00b944cca546875af4f0bcab695119a40 (patch)
treea6ff401d8ccd615abfd9166f1d45a5626c479ac1 /modern/src/common
parent032d1a787384430a5bd93a3caf7e92bb0a5fa8aa (diff)
downloadtrackermap-web-9c2dbcf00b944cca546875af4f0bcab695119a40.tar.gz
trackermap-web-9c2dbcf00b944cca546875af4f0bcab695119a40.tar.bz2
trackermap-web-9c2dbcf00b944cca546875af4f0bcab695119a40.zip
Chart report code improvements and refactoring
Diffstat (limited to 'modern/src/common')
-rw-r--r--modern/src/common/chartTypes.js7
-rw-r--r--modern/src/common/converter.js24
-rw-r--r--modern/src/common/formatter.js23
3 files changed, 24 insertions, 30 deletions
diff --git a/modern/src/common/chartTypes.js b/modern/src/common/chartTypes.js
deleted file mode 100644
index fa868a96..00000000
--- a/modern/src/common/chartTypes.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import t from '../common/localization';
-
-export const chartTypes = [
- { id: 'speed', name: t('positionSpeed') },
- { id: 'accuracy', name: t('positionAccuracy') },
- { id: 'altitude', name: t('positionAltitude') },
-];
diff --git a/modern/src/common/converter.js b/modern/src/common/converter.js
new file mode 100644
index 00000000..8fdb4b86
--- /dev/null
+++ b/modern/src/common/converter.js
@@ -0,0 +1,24 @@
+const speedConverter = (value, unit) => {
+ let factor;
+ switch (unit) {
+ case 'kmh':
+ factor = 1.852;
+ case 'mph':
+ factor = 1.15078;
+ case 'kn':
+ default:
+ factor = 1;
+ }
+ return (value * factor).toFixed(2);
+};
+
+export const getConverter = (key) => {
+ switch (key) {
+ case 'speed':
+ return speedConverter;
+ default:
+ return function (value) {
+ return value;
+ }
+ }
+}; \ No newline at end of file
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js
index b2f305a0..e41e591e 100644
--- a/modern/src/common/formatter.js
+++ b/modern/src/common/formatter.js
@@ -80,26 +80,3 @@ export const formatVolume = (value, unit) => {
export const formatHours = (value) => {
return moment.duration(value).humanize();
};
-
-const speedConverter = (value, unit) => {
- switch (unit) {
- case 'kmh':
- return (value * 1.852).toFixed(2);
- case 'mph':
- return (value * 1.15078).toFixed(2);
- case 'kn':
- default:
- return (value * 1).toFixed(2);
- }
-};
-
-export const getConverter = (key) => {
- switch (key) {
- case 'speed':
- return speedConverter;
- default:
- return function (value) {
- return value;
- }
- }
-};