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: add statistics chart export button #3662

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,18 @@ export default class StatisticsWidget extends DashboardWidget {
</>

{this.noData && <Placeholder text={app.translator.trans(`flarum-statistics.admin.statistics.no_data`)} />}

{!this.noData && !!this.chart && (
<Button
className="StatisticsWidget-chartExport Button"
icon="fas fa-file-export"
onclick={() => {
this.chart.export();
}}
>
{app.translator.trans('flarum-statistics.admin.statistics.export_chart_button')}
</Button>
)}
</div>
);
}
Expand Down
13 changes: 10 additions & 3 deletions extensions/statistics/less/admin.less
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@
.Placeholder {
padding-bottom: 32px;
}

&-chartExport {
position: relative;
z-index: 1;
margin: 16px;
margin-top: -32px;
}
}

/*!
Expand All @@ -119,9 +126,9 @@
position: relative; /* for absolutely positioned tooltip */

/* https://www.smashingmagazine.com/2015/11/using-system-ui-fonts-practical-guide/ */
font-family: -apple-system, BlinkMacSystemFont,
'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',
'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;

.axis,
.chart-label {
Expand Down
1 change: 1 addition & 0 deletions extensions/statistics/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ flarum-statistics:
# These translations are used in the Statistics dashboard widget.
statistics:
discussions_heading: => core.ref.discussions
export_chart_button: Export chart to SVG
last_12_months_label: Last 12 months
last_28_days_label: Last 28 days
last_7_days_label: Last 7 days
Expand Down