mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
Update frappe-charts, use Frontend extender, fix color & comparison CSS
This commit is contained in:
@@ -11,10 +11,10 @@ import DashboardWidget from 'flarum/components/DashboardWidget';
|
||||
import SelectDropdown from 'flarum/components/SelectDropdown';
|
||||
import Button from 'flarum/components/Button';
|
||||
import icon from 'flarum/helpers/icon';
|
||||
import listItems from 'flarum/helpers/listItems';
|
||||
import ItemList from 'flarum/utils/ItemList';
|
||||
import abbreviateNumber from 'flarum/utils/abbreviateNumber';
|
||||
|
||||
import { Chart } from 'frappe-charts/dist/frappe-charts.esm.js';
|
||||
|
||||
export default class StatisticsWidget extends DashboardWidget {
|
||||
init() {
|
||||
super.init();
|
||||
@@ -59,7 +59,7 @@ export default class StatisticsWidget extends DashboardWidget {
|
||||
active={period === this.selectedPeriod}
|
||||
onclick={this.changePeriod.bind(this, period)}
|
||||
icon={period === this.selectedPeriod ? 'fas fa-check' : true}>
|
||||
{app.translator.trans('flarum-statistics.admin.statistics.'+period+'_label')}
|
||||
{app.translator.trans(`flarum-statistics.admin.statistics.${period}_label`)}
|
||||
</Button>
|
||||
))}
|
||||
</SelectDropdown>
|
||||
@@ -130,21 +130,24 @@ export default class StatisticsWidget extends DashboardWidget {
|
||||
{values: lastPeriod},
|
||||
{values: thisPeriod}
|
||||
];
|
||||
const data = {
|
||||
labels,
|
||||
datasets
|
||||
};
|
||||
|
||||
if (!context.chart) {
|
||||
context.chart = new Chart({
|
||||
parent: elm,
|
||||
data: {labels, datasets},
|
||||
context.chart = new Chart(elm, {
|
||||
data,
|
||||
type: 'line',
|
||||
height: 200,
|
||||
x_axis_mode: 'tick',
|
||||
y_axis_mode: 'span',
|
||||
is_series: 1,
|
||||
show_dots: 0,
|
||||
colors: ['rgba(127, 127, 127, 0.2)', app.forum.attribute('themePrimaryColor')]
|
||||
axisOptions: {
|
||||
xAxisMode: 'tick',
|
||||
yAxisMode: 'span'
|
||||
},
|
||||
colors: ['black', app.forum.attribute('themePrimaryColor')]
|
||||
});
|
||||
} else {
|
||||
context.chart.update_values(datasets, labels);
|
||||
context.chart.update(data);
|
||||
}
|
||||
|
||||
context.entity = this.selectedEntity;
|
||||
|
Reference in New Issue
Block a user