Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
feat: Add chart zooming options for recent activities
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadalfy committed Jan 31, 2020
1 parent 3280571 commit 95e6e02
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ <h1 class="panel__title">Members</h1>
<div class="panel">
<div class="panel__head">
<h1 class="panel__title">Data</h1>
<div class="panel__actions" id="zoom-options"></div>
</div>
<div class="panel__content">
<div id="charts"></div>
Expand Down
30 changes: 30 additions & 0 deletions scripts/members.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,40 @@ class Members extends Base {
});
}

prepareChartFilters() {
const dates = [
{
label: 'Last week',
value: 1000 * 60 * 60 * 24 * 7
},
{
label: '2 weeks ago',
value: 1000 * 60 * 60 * 24 * 14
},
{
label: 'Last month',
value: 1000 * 60 * 60 * 24 * 30
},
];
const today = +(new Date());
const zoomOptions = [];
for (const date of dates) {
zoomOptions.push(html`
<button @click=${() => {
this.chart.xAxis[0].setExtremes((today - date.value), today);
this.chart.showResetZoom();
}}>${date.label}</button>
`);
}
const buttons = html`${zoomOptions}`;
render(buttons, document.querySelector('#zoom-options'));
}

async displayEvents(memberId) {
const response = await this.prepaeUserData(memberId);
const { data, memberEvents: { member : { name }} } = response;
this.drawChart(data, name);
this.prepareChartFilters();
}

async appendToChart(memberId) {
Expand Down

0 comments on commit 95e6e02

Please sign in to comment.