Merge pull request #330 from jat255/fix_detail_chart_units

Fix detail chart units
This commit is contained in:
Sam 2023-04-05 21:58:05 +02:00 committed by GitHub
commit 12950358ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 41 deletions

View File

@ -36,7 +36,9 @@ export const getDatasets = (
const coordinates: TCoordinates[] = []
chartData.map((data) => {
distance_labels.push(data.distance)
distance_labels.push(
convertStatsDistance('km', data.distance, useImperialUnits)
)
duration_labels.push(data.duration)
datasets.speed.data.push(
convertStatsDistance('km', data.speed, useImperialUnits)

View File

@ -54,37 +54,37 @@ describe('getDatasets', () => {
time: 'Sun, 12 Sep 2021 13:29:24 GMT',
},
{
distance: 0,
duration: 1,
elevation: 83.7,
latitude: 48.845578,
longitude: 2.373732,
speed: 1.56,
time: 'Sun, 12 Sep 2021 13:29:25 GMT',
distance: 0.66,
duration: 493.855,
elevation: 95.4,
latitude: 48.846386,
longitude: 2.379495,
speed: 20.64,
time: 'Sun, 12 Sep 2021 13:37:38 GMT',
},
{
distance: 0.01,
duration: 96,
elevation: 84.3,
latitude: 48.845591,
longitude: 2.373811,
speed: 14.73,
time: 'Sun, 12 Sep 2021 13:31:00 GMT',
distance: 1.25,
duration: 637.864,
elevation: 91.1,
latitude: 48.84733,
longitude: 2.387452,
speed: 13.03,
time: 'Sun, 12 Sep 2021 13:40:02 GMT',
},
],
locale: 'en',
useImperialUnits: false,
},
expected: {
distance_labels: [0, 0, 0.01],
duration_labels: [0, 1, 96],
distance_labels: [0, 0.66, 1.25],
duration_labels: [0, 493.855, 637.864],
datasets: {
speed: {
label: 'speed',
backgroundColor: ['#FFFFFF'],
borderColor: ['#8884d8'],
borderWidth: 2,
data: [2.89, 1.56, 14.73],
data: [2.89, 20.64, 13.03],
yAxisID: 'ySpeed',
},
elevation: {
@ -93,14 +93,14 @@ describe('getDatasets', () => {
borderColor: ['#cccccc'],
borderWidth: 1,
fill: true,
data: [83.6, 83.7, 84.3],
data: [83.6, 95.4, 91.1],
yAxisID: 'yElevation',
},
},
coordinates: [
{ latitude: 48.845574, longitude: 2.373723 },
{ latitude: 48.845578, longitude: 2.373732 },
{ latitude: 48.845591, longitude: 2.373811 },
{ latitude: 48.846386, longitude: 2.379495 },
{ latitude: 48.84733, longitude: 2.387452 },
],
},
},
@ -118,37 +118,37 @@ describe('getDatasets', () => {
time: 'Sun, 12 Sep 2021 13:29:24 GMT',
},
{
distance: 0,
duration: 1,
elevation: 83.7,
latitude: 48.845578,
longitude: 2.373732,
speed: 1.56,
time: 'Sun, 12 Sep 2021 13:29:25 GMT',
distance: 0.66,
duration: 493.855,
elevation: 95.4,
latitude: 48.846386,
longitude: 2.379495,
speed: 20.64,
time: 'Sun, 12 Sep 2021 13:37:38 GMT',
},
{
distance: 0.01,
duration: 96,
elevation: 84.3,
latitude: 48.845591,
longitude: 2.373811,
speed: 14.73,
time: 'Sun, 12 Sep 2021 13:31:00 GMT',
distance: 1.25,
duration: 637.864,
elevation: 91.1,
latitude: 48.84733,
longitude: 2.387452,
speed: 13.03,
time: 'Sun, 12 Sep 2021 13:40:02 GMT',
},
],
locale: 'en',
useImperialUnits: true,
},
expected: {
distance_labels: [0, 0, 0.01],
duration_labels: [0, 1, 96],
distance_labels: [0, 0.41, 0.78],
duration_labels: [0, 493.855, 637.864],
datasets: {
speed: {
label: 'speed',
backgroundColor: ['#FFFFFF'],
borderColor: ['#8884d8'],
borderWidth: 2,
data: [1.8, 0.97, 9.15],
data: [1.8, 12.83, 8.1],
yAxisID: 'ySpeed',
},
elevation: {
@ -157,14 +157,14 @@ describe('getDatasets', () => {
borderColor: ['#cccccc'],
borderWidth: 1,
fill: true,
data: [274.28, 274.61, 276.57],
data: [274.28, 312.99, 298.88],
yAxisID: 'yElevation',
},
},
coordinates: [
{ latitude: 48.845574, longitude: 2.373723 },
{ latitude: 48.845578, longitude: 2.373732 },
{ latitude: 48.845591, longitude: 2.373811 },
{ latitude: 48.846386, longitude: 2.379495 },
{ latitude: 48.84733, longitude: 2.387452 },
],
},
},