adding new chart system

This commit is contained in:
Christian Kellner
2025-09-03 14:22:04 +02:00
parent 29026ccad8
commit f8e0376ddd
8 changed files with 44 additions and 76 deletions

View File

@@ -8,4 +8,4 @@ export function format(ts) {
second: 'numeric',
}).format(ts);
}
export const roundToNext5Minute = (ts) => Math.ceil(ts / (1000 * 60 * 5)) * (1000 * 60 * 5);
export const roundToHour = (ts) => Math.ceil(ts / (1000 * 60 * 60)) * (1000 * 60 * 60);

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { roundToNext5Minute } from '../../../services/time/timeService';
import { roundToHour } from '../../../services/time/timeService';
import Headline from '../../../components/headline/Headline';
import { useDispatch, useSelector } from 'react-redux';
import { useParams } from 'react-router-dom';
@@ -26,14 +26,13 @@ const JobInsight = function JobInsight() {
const allTimes = new Set();
const cap = (s) => (s ? s[0].toUpperCase() + s.slice(1) : 'Unknown');
const toDate = (ts) => new Date(ts < 1e12 ? ts * 1000 : ts); // seconds vs ms
providers.forEach((key) => {
const providerName = cap(key);
const tmpTimeObj = {};
Object.values(data[key] || {}).forEach((listingTs) => {
const time = roundToNext5Minute(listingTs);
const time = roundToHour(listingTs);
tmpTimeObj[time] = tmpTimeObj[time] == null ? 1 : tmpTimeObj[time] + 1;
allTimes.add(time);
});
@@ -50,15 +49,20 @@ const JobInsight = function JobInsight() {
sortedTimes.forEach((t) => {
result.push({
listings: Number(t), // Date object for time axis
listings: new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
hour12: false,
}).format(new Date(parseInt(t))),
listingsNumber: bucket[t] || 0, // y value
provider: providerName, // series key
});
});
});
console.log(result);
return result;
};

View File

@@ -11,6 +11,21 @@ const commonSpec = {
yField: 'listingsNumber',
seriesField: 'provider',
legends: { visible: true },
line: {
style: {
lineWidth: 2,
},
},
point: {
visible: false,
},
axes: [
{
orient: 'bottom',
field: 'listings',
zero: false,
},
],
};
const Linechart = function Linechart({ title, series, isLoading = false }) {
@@ -28,7 +43,6 @@ const Linechart = function Linechart({ title, series, isLoading = false }) {
},
data: { values: series },
}}
option={{ mode: 'desktop-browser' }}
/>
)}
</Placeholder>

View File

@@ -30,7 +30,8 @@ export default function ProviderMutator({ onVisibilityChanged, visible = false,
if (selectedProvider.baseUrl.indexOf(url.origin) === -1) {
return 'The url you have copied is not valid.';
}
} catch (Exception) {
/* eslint-disable no-unused-vars */
} catch (ignored) {
return 'The url you have copied is not valid.';
}
return null;

View File

@@ -38,7 +38,8 @@ export default function Login() {
username: username.trim(),
password,
});
} catch (Exception) {
/* eslint-disable no-unused-vars */
} catch (ignored) {
Toast.error('Login unsuccessful…');
return;
}