Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rum-oversight): date range picker #662

Merged
merged 28 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8f1a7de
feat: first shot of time range picker
kptdobe Sep 13, 2024
4e14f7d
feat: first shot of time range picker
kptdobe Sep 13, 2024
e960ceb
feat: optimized chart
kptdobe Sep 17, 2024
c1632f5
Merge branch 'main' into timerange-picker
kptdobe Sep 17, 2024
ab9b4a7
feat: more
kptdobe Sep 19, 2024
b16da21
feat: no time
kptdobe Sep 19, 2024
da1a621
chore: rename
kptdobe Sep 19, 2024
1f66635
chore: refactor
kptdobe Sep 19, 2024
b784af4
chore: simplify dom
kptdobe Sep 19, 2024
961ed10
feat: fine tuning
kptdobe Sep 19, 2024
5a4aaaf
feat: start date
kptdobe Sep 19, 2024
1ef1067
chore: initial state
kptdobe Sep 19, 2024
ada416b
feat: styling
kptdobe Sep 19, 2024
8b2bbce
fix: week to custom toggle
kptdobe Sep 19, 2024
3be8e84
chore: adjust range
kptdobe Sep 19, 2024
f65dd9d
fix: adjust boundaries
kptdobe Sep 19, 2024
f2d37d5
feat: swap from and to if not chronological
kptdobe Sep 23, 2024
d287f08
feat: mobile
kptdobe Sep 24, 2024
6e59d49
Merge branch 'main' into timerange-picker
kptdobe Sep 24, 2024
c0f9a8a
chore: cleanup
kptdobe Sep 24, 2024
2eea36c
feat: improve elements visibility
kptdobe Sep 24, 2024
96cc8fa
feat: week view up to 3 years
kptdobe Sep 24, 2024
679e9d2
feat: first shot of time range picker
kptdobe Sep 13, 2024
a7fb76b
feat(rum-oversight): date range picker
kptdobe Oct 1, 2024
ff1486a
Merge branch 'main' into timerange-oversight
trieloff Oct 14, 2024
ec7447b
Merge branch 'main' into timerange-oversight
kptdobe Oct 18, 2024
84d7101
fix: wrong date depending on timezone
kptdobe Oct 18, 2024
17ae20f
chore: cleanup
kptdobe Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 62 additions & 13 deletions tools/oversight/charts/skyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ export default class SkylineChart extends AbstractChart {

groupFn.fillerFn = (existing) => {
const endDate = this.chartConfig.endDate ? new Date(this.chartConfig.endDate) : new Date();
// set start date depending on the unit
let startDate = new Date(endDate);
// roll back to beginning of time
if (this.chartConfig.unit === 'day') startDate.setDate(endDate.getDate() - 30);
if (this.chartConfig.unit === 'hour') startDate.setDate(endDate.getDate() - 7);
if (this.chartConfig.unit === 'week') startDate.setMonth(endDate.getMonth() - 12);
if (this.chartConfig.startDate) {
// nevermind, we have a start date in the config, let's use that

let startDate;
if (!this.chartConfig.startDate) {
// set start date depending on the unit
startDate = new Date(endDate);
// roll back to beginning of time
if (this.chartConfig.unit === 'day') startDate.setDate(endDate.getDate() - 30);
if (this.chartConfig.unit === 'hour') startDate.setDate(endDate.getDate() - 7);
if (this.chartConfig.unit === 'week') startDate.setMonth(endDate.getMonth() - 12);
if (this.chartConfig.unit === 'month') startDate.setMonth(endDate.getMonth() - 1);
} else {
startDate = new Date(this.chartConfig.startDate);
}

const slots = new Set(existing);
const slotTime = new Date(startDate);
// return Array.from(slots);
Expand All @@ -68,6 +72,7 @@ export default class SkylineChart extends AbstractChart {
if (this.chartConfig.unit === 'day') slotTime.setDate(slotTime.getDate() + 1);
if (this.chartConfig.unit === 'hour') slotTime.setHours(slotTime.getHours() + 1);
if (this.chartConfig.unit === 'week') slotTime.setDate(slotTime.getDate() + 7);
if (this.chartConfig.unit === 'month') slotTime.setMonth(slotTime.getMonth() + 1);
maxSlots -= 1;
if (maxSlots < 0) {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -458,12 +463,41 @@ export default class SkylineChart extends AbstractChart {

async draw() {
const params = new URL(window.location).searchParams;
const view = ['week', 'month', 'year'].indexOf(params.get('view')) !== -1
? params.get('view')
: 'week';
// TODO re-add. I think this should be a filter
const view = params.get('view');

// eslint-disable-next-line no-unused-vars
const endDate = params.get('endDate') ? `${params.get('endDate')}T00:00:00` : null;
const startDate = params.get('startDate');
const endDate = params.get('endDate');

let customView = 'year';
let unit = 'month';
let units = 12;
if (view === 'custom') {
const diff = endDate ? new Date(endDate).getTime() - new Date(startDate).getTime() : 0;
if (diff < (1000 * 60 * 60 * 24)) {
// less than a day
customView = 'hour';
unit = 'hour';
units = 24;
} else if (diff <= (1000 * 60 * 60 * 24 * 7)) {
// less than a week
customView = 'week';
unit = 'hour';
units = Math.round(diff / (1000 * 60 * 60));
} else if (diff <= (1000 * 60 * 60 * 24 * 31)) {
// less than a month
customView = 'month';
unit = 'day';
units = 30;
} else if (diff <= (1000 * 60 * 60 * 24 * 365 * 3)) {
// less than 3 years
customView = 'week';
unit = 'week';
units = Math.round(diff / (1000 * 60 * 60 * 24 * 7));
}
}

const focus = params.get('focus');

if (this.dataChunks.filtered.length < 1000) {
this.elems.lowDataWarning.ariaHidden = 'false';
Expand All @@ -476,18 +510,32 @@ export default class SkylineChart extends AbstractChart {
view,
unit: 'day',
units: 30,
focus,
startDate,
endDate,
},
week: {
view,
unit: 'hour',
units: 24 * 7,
focus,
startDate,
endDate,
},
year: {
view,
unit: 'week',
units: 52,
focus,
startDate,
endDate,
},
custom: {
view: customView,
unit,
units,
focus,
startDate,
endDate,
},
};
Expand Down Expand Up @@ -565,6 +613,7 @@ export default class SkylineChart extends AbstractChart {
this.stepSize = undefined;
this.clsAlreadyLabeled = false;
this.lcpAlreadyLabeled = false;

this.chart.update();

// add trend indicators
Expand Down
Loading
Loading