2022-04-01 16:53:55 +03:00
|
|
|
import Component from '@glimmer/component';
|
2022-04-06 20:11:46 +03:00
|
|
|
import moment from 'moment';
|
2022-04-01 16:53:55 +03:00
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
2022-04-13 17:19:26 +03:00
|
|
|
const DATE_FORMAT = 'D MMM';
|
2022-04-06 20:11:46 +03:00
|
|
|
|
2022-04-12 18:03:52 +03:00
|
|
|
const DAYS_OPTIONS = [{
|
|
|
|
name: '7 Days',
|
|
|
|
value: 7
|
|
|
|
}, {
|
|
|
|
name: '30 Days',
|
|
|
|
value: 30
|
|
|
|
}, {
|
|
|
|
name: '90 Days',
|
|
|
|
value: 90
|
|
|
|
}, {
|
|
|
|
name: 'All Time',
|
|
|
|
value: 'all'
|
|
|
|
}];
|
|
|
|
|
2022-04-12 12:18:10 +03:00
|
|
|
const PAID_OPTIONS = [{
|
2022-04-14 17:28:45 +03:00
|
|
|
name: 'MRR Total',
|
|
|
|
value: 'mrr'
|
2022-04-12 12:18:10 +03:00
|
|
|
}, {
|
2022-04-14 17:28:45 +03:00
|
|
|
name: 'MRR Deltas',
|
2022-04-13 15:52:12 +03:00
|
|
|
value: 'paid-breakdown'
|
2022-04-12 12:18:10 +03:00
|
|
|
}];
|
|
|
|
|
2022-04-12 15:09:00 +03:00
|
|
|
export default class Anchor extends Component {
|
2022-04-01 16:53:55 +03:00
|
|
|
@service dashboardStats;
|
2022-04-12 19:56:55 +03:00
|
|
|
@service feature;
|
2022-04-01 16:53:55 +03:00
|
|
|
@tracked chartDisplay = 'total';
|
2022-04-12 12:18:10 +03:00
|
|
|
|
2022-04-12 18:03:52 +03:00
|
|
|
daysOptions = DAYS_OPTIONS;
|
2022-04-12 12:18:10 +03:00
|
|
|
paidOptions = PAID_OPTIONS;
|
2022-04-01 16:53:55 +03:00
|
|
|
|
2022-04-12 18:03:52 +03:00
|
|
|
get days() {
|
|
|
|
return this.dashboardStats.chartDays;
|
|
|
|
}
|
|
|
|
|
|
|
|
set days(days) {
|
|
|
|
this.dashboardStats.chartDays = days;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
onInsert() {
|
|
|
|
this.dashboardStats.loadSiteStatus();
|
|
|
|
}
|
|
|
|
|
2022-04-01 16:53:55 +03:00
|
|
|
@action
|
|
|
|
loadCharts() {
|
|
|
|
this.dashboardStats.loadMemberCountStats();
|
|
|
|
this.dashboardStats.loadMrrStats();
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
changeChartDisplay(type) {
|
|
|
|
this.chartDisplay = type;
|
|
|
|
}
|
|
|
|
|
2022-04-12 12:18:10 +03:00
|
|
|
@action
|
2022-04-12 18:03:52 +03:00
|
|
|
onPaidChange(selected) {
|
2022-04-12 12:18:10 +03:00
|
|
|
this.changeChartDisplay(selected.value);
|
2022-04-13 15:52:12 +03:00
|
|
|
|
|
|
|
// The graph won't switch correctly from line -> bar
|
|
|
|
// So we need to recreate it somehow.
|
|
|
|
// Solution: recreate the DOM by using an #if in hbs
|
2022-04-12 12:18:10 +03:00
|
|
|
}
|
|
|
|
|
2022-04-12 18:03:52 +03:00
|
|
|
@action
|
|
|
|
onDaysChange(selected) {
|
|
|
|
this.days = selected.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
get selectedDaysOption() {
|
|
|
|
return this.daysOptions.find(d => d.value === this.days);
|
|
|
|
}
|
|
|
|
|
2022-04-12 12:18:10 +03:00
|
|
|
get selectedPaidOption() {
|
2022-04-13 15:52:12 +03:00
|
|
|
return this.paidOptions.find(d => d.value === this.chartDisplay) ?? this.paidOptions[0];
|
2022-04-12 12:18:10 +03:00
|
|
|
}
|
|
|
|
|
2022-04-01 16:53:55 +03:00
|
|
|
get chartShowingTotal() {
|
|
|
|
return (this.chartDisplay === 'total');
|
|
|
|
}
|
|
|
|
|
|
|
|
get chartShowingPaid() {
|
2022-04-14 17:28:45 +03:00
|
|
|
return (this.chartDisplay === 'paid-total');
|
2022-04-11 19:17:31 +03:00
|
|
|
}
|
|
|
|
|
2022-04-13 15:52:12 +03:00
|
|
|
get chartShowingMrr() {
|
2022-04-14 17:28:45 +03:00
|
|
|
return (this.chartDisplay === 'mrr' || this.chartDisplay === 'paid-breakdown');
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get loading() {
|
|
|
|
if (this.chartDisplay === 'total') {
|
|
|
|
return this.dashboardStats.memberCountStats === null;
|
2022-04-13 15:52:12 +03:00
|
|
|
} else if (this.chartDisplay === 'paid-total') {
|
2022-04-01 16:53:55 +03:00
|
|
|
return this.dashboardStats.memberCountStats === null;
|
2022-04-13 15:52:12 +03:00
|
|
|
} else if (this.chartDisplay === 'paid-breakdown') {
|
2022-04-11 19:17:31 +03:00
|
|
|
return this.dashboardStats.memberCountStats === null;
|
2022-04-13 15:52:12 +03:00
|
|
|
} else if (this.chartDisplay === 'mrr') {
|
2022-04-01 16:53:55 +03:00
|
|
|
return this.dashboardStats.mrrStats === null;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
get totalMembers() {
|
|
|
|
return this.dashboardStats.memberCounts?.total ?? 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get paidMembers() {
|
|
|
|
return this.dashboardStats.memberCounts?.paid ?? 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get freeMembers() {
|
|
|
|
return this.dashboardStats.memberCounts?.free ?? 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get currentMRR() {
|
|
|
|
return this.dashboardStats.currentMRR ?? 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get hasTrends() {
|
2022-04-13 15:52:12 +03:00
|
|
|
return this.dashboardStats.memberCounts !== null
|
|
|
|
&& this.dashboardStats.memberCountsTrend !== null
|
|
|
|
&& this.dashboardStats.currentMRR !== null
|
|
|
|
&& this.dashboardStats.currentMRRTrend !== null;
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get totalMembersTrend() {
|
|
|
|
return this.calculatePercentage(this.dashboardStats.memberCountsTrend.total, this.dashboardStats.memberCounts.total);
|
|
|
|
}
|
|
|
|
|
|
|
|
get paidMembersTrend() {
|
|
|
|
return this.calculatePercentage(this.dashboardStats.memberCountsTrend.paid, this.dashboardStats.memberCounts.paid);
|
|
|
|
}
|
|
|
|
|
|
|
|
get freeMembersTrend() {
|
|
|
|
return this.calculatePercentage(this.dashboardStats.memberCountsTrend.free, this.dashboardStats.memberCounts.free);
|
|
|
|
}
|
|
|
|
|
|
|
|
get mrrTrend() {
|
|
|
|
return this.calculatePercentage(this.dashboardStats.currentMRRTrend, this.dashboardStats.currentMRR);
|
|
|
|
}
|
|
|
|
|
2022-04-01 19:02:30 +03:00
|
|
|
get hasPaidTiers() {
|
|
|
|
return this.dashboardStats.siteStatus?.hasPaidTiers;
|
|
|
|
}
|
|
|
|
|
2022-04-13 17:19:26 +03:00
|
|
|
get chartTitle() {
|
|
|
|
if (this.chartDisplay === 'paid-total' || this.chartDisplay === 'paid-breakdown') {
|
2022-04-14 17:28:45 +03:00
|
|
|
return 'Monthly revenue (MRR) Deltas';
|
2022-04-13 17:19:26 +03:00
|
|
|
} else if (this.chartDisplay === 'mrr') {
|
2022-04-14 17:28:45 +03:00
|
|
|
return 'Monthly revenue (MRR) Total';
|
2022-04-13 17:19:26 +03:00
|
|
|
}
|
|
|
|
return 'Total members';
|
|
|
|
}
|
|
|
|
|
2022-04-01 16:53:55 +03:00
|
|
|
get chartType() {
|
2022-04-13 15:52:12 +03:00
|
|
|
if (this.chartDisplay === 'paid-breakdown') {
|
2022-04-08 19:49:11 +03:00
|
|
|
return 'bar';
|
|
|
|
}
|
2022-04-11 19:17:31 +03:00
|
|
|
|
|
|
|
return 'line';
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get chartData() {
|
2022-04-14 17:28:45 +03:00
|
|
|
let returnable = {};
|
2022-04-11 19:17:31 +03:00
|
|
|
|
2022-04-13 15:52:12 +03:00
|
|
|
if (this.chartDisplay === 'paid-breakdown') {
|
2022-04-14 17:52:22 +03:00
|
|
|
const stats = this.dashboardStats.filledMemberCountStats;
|
|
|
|
const labels = stats.map(stat => stat.date);
|
|
|
|
const newData = stats.map(stat => stat.paidSubscribed);
|
|
|
|
const canceledData = stats.map(stat => -stat.paidCanceled);
|
|
|
|
const netData = stats.map(stat => stat.paidSubscribed - stat.paidCanceled);
|
|
|
|
|
|
|
|
return {
|
2022-04-11 19:17:31 +03:00
|
|
|
labels: labels,
|
|
|
|
datasets: [
|
2022-04-14 17:52:22 +03:00
|
|
|
{
|
|
|
|
type: 'line',
|
|
|
|
data: netData,
|
|
|
|
tension: 0,
|
|
|
|
cubicInterpolationMode: 'monotone',
|
|
|
|
fill: false,
|
|
|
|
pointRadius: 0,
|
|
|
|
pointHitRadius: 10,
|
|
|
|
pointBorderColor: '#14B8FF',
|
|
|
|
pointBackgroundColor: '#14B8FF',
|
|
|
|
pointHoverBackgroundColor: '#14B8FF',
|
|
|
|
pointHoverBorderColor: '#14B8FF',
|
|
|
|
pointHoverRadius: 0,
|
|
|
|
borderColor: '#14B8FF',
|
|
|
|
borderJoinStyle: 'miter'
|
|
|
|
},
|
2022-04-11 19:17:31 +03:00
|
|
|
{
|
|
|
|
data: newData,
|
|
|
|
fill: false,
|
|
|
|
backgroundColor: '#BD96F6',
|
|
|
|
cubicInterpolationMode: 'monotone',
|
2022-04-14 17:28:45 +03:00
|
|
|
barThickness: 18,
|
|
|
|
minBarLength: 3
|
2022-04-11 19:17:31 +03:00
|
|
|
},{
|
|
|
|
data: canceledData,
|
|
|
|
fill: false,
|
|
|
|
backgroundColor: '#FB76B4',
|
|
|
|
cubicInterpolationMode: 'monotone',
|
2022-04-14 17:28:45 +03:00
|
|
|
barThickness: 18,
|
|
|
|
minBarLength: 3
|
2022-04-11 19:17:31 +03:00
|
|
|
}]
|
|
|
|
};
|
|
|
|
}
|
2022-04-01 16:53:55 +03:00
|
|
|
|
|
|
|
if (this.chartDisplay === 'total') {
|
2022-04-14 17:28:45 +03:00
|
|
|
let stats = this.dashboardStats.filledMemberCountStats;
|
|
|
|
let labels = stats.map(stat => stat.date);
|
|
|
|
let data = stats.map(stat => stat.paid + stat.free + stat.comped);
|
|
|
|
let dataPaid = stats.map(stat => stat.paid);
|
2022-04-01 16:53:55 +03:00
|
|
|
|
2022-04-14 17:28:45 +03:00
|
|
|
returnable = {
|
|
|
|
labels: labels,
|
|
|
|
datasets: [{
|
|
|
|
data: data,
|
|
|
|
tension: 0,
|
|
|
|
cubicInterpolationMode: 'monotone',
|
|
|
|
fill: true,
|
|
|
|
fillColor: 'rgba(20, 184, 255, 0.07)',
|
|
|
|
backgroundColor: 'rgba(20, 184, 255, 0.07)',
|
|
|
|
pointRadius: 0,
|
|
|
|
pointHitRadius: 10,
|
|
|
|
pointBorderColor: '#14B8FF',
|
|
|
|
pointBackgroundColor: '#14B8FF',
|
|
|
|
pointHoverBackgroundColor: '#14B8FF',
|
|
|
|
pointHoverBorderColor: '#14B8FF',
|
|
|
|
pointHoverRadius: 0,
|
|
|
|
borderColor: '#14B8FF',
|
|
|
|
borderJoinStyle: 'miter'
|
|
|
|
}, {
|
|
|
|
data: dataPaid,
|
|
|
|
tension: 0,
|
|
|
|
cubicInterpolationMode: 'monotone',
|
|
|
|
fill: true,
|
|
|
|
fillColor: 'rgba(189, 150, 246, 0.3)',
|
|
|
|
backgroundColor: 'rgba(189, 150, 246, 0.3)',
|
|
|
|
pointRadius: 0,
|
|
|
|
pointHitRadius: 10,
|
|
|
|
pointBorderColor: 'rgba(189, 150, 246, 1)',
|
|
|
|
pointBackgroundColor: 'rgba(189, 150, 246, 1)',
|
|
|
|
pointHoverBackgroundColor: 'rgba(189, 150, 246, 1)',
|
|
|
|
pointHoverBorderColor: 'rgba(189, 150, 246, 1)',
|
|
|
|
pointHoverRadius: 0,
|
|
|
|
borderColor: 'rgba(189, 150, 246, 1)',
|
|
|
|
borderJoinStyle: 'miter'
|
|
|
|
}]
|
|
|
|
};
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
2022-04-13 15:52:12 +03:00
|
|
|
if (this.chartDisplay === 'mrr') {
|
2022-04-14 17:28:45 +03:00
|
|
|
let stats = this.dashboardStats.filledMrrStats;
|
|
|
|
let labels = stats.map(stat => stat.date);
|
|
|
|
let data = stats.map(stat => stat.mrr);
|
|
|
|
|
|
|
|
returnable = {
|
|
|
|
labels: labels,
|
|
|
|
datasets: [{
|
|
|
|
data: data,
|
|
|
|
tension: 0,
|
|
|
|
cubicInterpolationMode: 'monotone',
|
|
|
|
fill: true,
|
|
|
|
fillColor: 'rgba(20, 184, 255, 0.07)',
|
|
|
|
backgroundColor: 'rgba(20, 184, 255, 0.07)',
|
|
|
|
pointRadius: 0,
|
|
|
|
pointHitRadius: 10,
|
|
|
|
pointBorderColor: '#14B8FF',
|
|
|
|
pointBackgroundColor: '#14B8FF',
|
|
|
|
pointHoverBackgroundColor: '#14B8FF',
|
|
|
|
pointHoverBorderColor: '#14B8FF',
|
|
|
|
pointHoverRadius: 0,
|
|
|
|
borderColor: '#14B8FF',
|
|
|
|
borderJoinStyle: 'miter'
|
|
|
|
}]
|
|
|
|
};
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
2022-04-14 17:28:45 +03:00
|
|
|
return returnable;
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get chartOptions() {
|
2022-04-14 17:28:45 +03:00
|
|
|
let barColor = this.feature.nightShift ? 'rgba(200, 204, 217, 0.25)' : 'rgba(200, 204, 217, 0.65)';
|
|
|
|
|
2022-04-13 15:52:12 +03:00
|
|
|
if (this.chartDisplay === 'paid-breakdown') {
|
2022-04-11 19:17:31 +03:00
|
|
|
return {
|
|
|
|
responsive: true,
|
|
|
|
maintainAspectRatio: false,
|
|
|
|
title: {
|
|
|
|
display: false
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
display: false
|
|
|
|
},
|
|
|
|
hover: {
|
|
|
|
onHover: function (e) {
|
|
|
|
e.target.style.cursor = 'pointer';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tooltips: {
|
|
|
|
intersect: false,
|
|
|
|
mode: 'index',
|
|
|
|
displayColors: false,
|
|
|
|
backgroundColor: '#15171A',
|
|
|
|
xPadding: 7,
|
|
|
|
yPadding: 7,
|
|
|
|
cornerRadius: 5,
|
|
|
|
caretSize: 7,
|
|
|
|
caretPadding: 5,
|
|
|
|
bodyFontSize: 12.5,
|
|
|
|
titleFontSize: 12,
|
|
|
|
titleFontStyle: 'normal',
|
|
|
|
titleFontColor: 'rgba(255, 255, 255, 0.7)',
|
|
|
|
titleMarginBottom: 3,
|
|
|
|
callbacks: {
|
2022-04-14 17:28:45 +03:00
|
|
|
label: (tooltipItems, data) => {
|
|
|
|
let valueText = data.datasets[tooltipItems.datasetIndex].data[tooltipItems.index].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
|
|
|
|
|
|
if (tooltipItems.datasetIndex === 0) {
|
|
|
|
return `New paid: ${valueText}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tooltipItems.datasetIndex === 1) {
|
|
|
|
return `Canceled paid: ${Math.abs(valueText)}`;
|
|
|
|
}
|
|
|
|
},
|
2022-04-11 19:17:31 +03:00
|
|
|
title: (tooltipItems) => {
|
|
|
|
return moment(tooltipItems[0].xLabel).format(DATE_FORMAT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scales: {
|
|
|
|
yAxes: [{
|
2022-04-13 17:19:26 +03:00
|
|
|
offset: false,
|
2022-04-11 19:17:31 +03:00
|
|
|
gridLines: {
|
|
|
|
drawTicks: false,
|
|
|
|
display: true,
|
|
|
|
drawBorder: false,
|
|
|
|
color: 'rgba(255, 255, 255, 0.1)',
|
|
|
|
lineWidth: 0,
|
2022-04-13 17:19:26 +03:00
|
|
|
zeroLineColor: this.feature.nightShift ? 'rgba(200, 204, 217, 0.25)' : 'rgba(200, 204, 217, 0.65)',
|
2022-04-11 19:17:31 +03:00
|
|
|
zeroLineWidth: 1
|
|
|
|
},
|
|
|
|
ticks: {
|
2022-04-13 17:19:26 +03:00
|
|
|
display: false,
|
2022-04-11 19:17:31 +03:00
|
|
|
maxTicksLimit: 5,
|
|
|
|
fontColor: '#7C8B9A',
|
|
|
|
padding: 8,
|
|
|
|
precision: 0
|
|
|
|
}
|
|
|
|
}],
|
|
|
|
xAxes: [{
|
|
|
|
offset: true,
|
|
|
|
stacked: true,
|
|
|
|
gridLines: {
|
2022-04-14 17:28:45 +03:00
|
|
|
color: barColor,
|
2022-04-11 19:17:31 +03:00
|
|
|
borderDash: [4,4],
|
|
|
|
display: true,
|
2022-04-13 17:19:26 +03:00
|
|
|
drawBorder: false,
|
2022-04-11 19:17:31 +03:00
|
|
|
drawTicks: false,
|
|
|
|
zeroLineWidth: 1,
|
2022-04-14 17:28:45 +03:00
|
|
|
zeroLineColor: barColor,
|
2022-04-11 19:17:31 +03:00
|
|
|
zeroLineBorderDash: [4,4]
|
|
|
|
},
|
|
|
|
ticks: {
|
2022-04-14 17:52:22 +03:00
|
|
|
padding: 20,
|
2022-04-13 17:19:26 +03:00
|
|
|
callback: function (value, index, values) {
|
|
|
|
if (index === 0) {
|
|
|
|
document.getElementById('gh-dashboard5-anchor-date-start').innerHTML = moment(value).format(DATE_FORMAT);
|
|
|
|
}
|
|
|
|
if (index === values.length - 1) {
|
|
|
|
document.getElementById('gh-dashboard5-anchor-date-end').innerHTML = moment(value).format(DATE_FORMAT);
|
|
|
|
}
|
|
|
|
return value;
|
2022-04-11 19:17:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-01 16:53:55 +03:00
|
|
|
return {
|
|
|
|
responsive: true,
|
|
|
|
maintainAspectRatio: false,
|
|
|
|
title: {
|
|
|
|
display: false
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
display: false
|
|
|
|
},
|
|
|
|
layout: {
|
|
|
|
padding: {
|
2022-04-06 20:11:46 +03:00
|
|
|
top: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
hover: {
|
|
|
|
onHover: function (e) {
|
|
|
|
e.target.style.cursor = 'pointer';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tooltips: {
|
|
|
|
intersect: false,
|
|
|
|
mode: 'index',
|
|
|
|
displayColors: false,
|
|
|
|
backgroundColor: '#15171A',
|
|
|
|
xPadding: 7,
|
|
|
|
yPadding: 7,
|
|
|
|
cornerRadius: 5,
|
|
|
|
caretSize: 7,
|
|
|
|
caretPadding: 5,
|
|
|
|
bodyFontSize: 12.5,
|
|
|
|
titleFontSize: 12,
|
|
|
|
titleFontStyle: 'normal',
|
|
|
|
titleFontColor: 'rgba(255, 255, 255, 0.7)',
|
|
|
|
titleMarginBottom: 3,
|
|
|
|
callbacks: {
|
|
|
|
label: (tooltipItems, data) => {
|
|
|
|
let valueText = data.datasets[tooltipItems.datasetIndex].data[tooltipItems.index].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
2022-04-14 17:28:45 +03:00
|
|
|
let returnable = valueText;
|
2022-04-06 20:11:46 +03:00
|
|
|
|
|
|
|
if (this.chartDisplay === 'total') {
|
2022-04-14 17:28:45 +03:00
|
|
|
if (tooltipItems.datasetIndex === 0) {
|
|
|
|
returnable = `Total members: ${valueText}`;
|
|
|
|
} else {
|
|
|
|
returnable = `Paid members: ${valueText}`;
|
|
|
|
}
|
2022-04-06 20:11:46 +03:00
|
|
|
}
|
2022-04-14 17:28:45 +03:00
|
|
|
|
2022-04-13 15:52:12 +03:00
|
|
|
if (this.chartDisplay === 'mrr') {
|
2022-04-14 17:28:45 +03:00
|
|
|
returnable = `Monthly revenue (MRR): $${valueText}`;
|
2022-04-06 20:11:46 +03:00
|
|
|
}
|
2022-04-14 17:28:45 +03:00
|
|
|
|
|
|
|
return returnable;
|
2022-04-06 20:11:46 +03:00
|
|
|
},
|
|
|
|
title: (tooltipItems) => {
|
|
|
|
return moment(tooltipItems[0].xLabel).format(DATE_FORMAT);
|
|
|
|
}
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
scales: {
|
|
|
|
yAxes: [{
|
2022-04-13 17:19:26 +03:00
|
|
|
display: true,
|
2022-04-01 16:53:55 +03:00
|
|
|
gridLines: {
|
|
|
|
drawTicks: false,
|
2022-04-11 19:17:31 +03:00
|
|
|
display: true,
|
|
|
|
drawBorder: false,
|
|
|
|
color: 'transparent',
|
2022-04-14 17:28:45 +03:00
|
|
|
zeroLineColor: barColor,
|
2022-04-11 19:17:31 +03:00
|
|
|
zeroLineWidth: 1
|
2022-04-01 16:53:55 +03:00
|
|
|
},
|
|
|
|
ticks: {
|
2022-04-14 17:28:45 +03:00
|
|
|
display: false
|
2022-04-13 17:19:26 +03:00
|
|
|
}
|
2022-04-01 16:53:55 +03:00
|
|
|
}],
|
|
|
|
xAxes: [{
|
2022-04-13 17:19:26 +03:00
|
|
|
display: true,
|
|
|
|
scaleLabel: {
|
|
|
|
align: 'start'
|
|
|
|
},
|
2022-04-01 16:53:55 +03:00
|
|
|
gridLines: {
|
2022-04-14 17:28:45 +03:00
|
|
|
color: barColor,
|
2022-04-08 19:49:11 +03:00
|
|
|
borderDash: [4,4],
|
|
|
|
display: true,
|
|
|
|
drawBorder: true,
|
2022-04-01 16:53:55 +03:00
|
|
|
drawTicks: false,
|
2022-04-08 19:49:11 +03:00
|
|
|
zeroLineWidth: 1,
|
2022-04-14 17:28:45 +03:00
|
|
|
zeroLineColor: barColor,
|
2022-04-08 19:49:11 +03:00
|
|
|
zeroLineBorderDash: [4,4]
|
2022-04-01 16:53:55 +03:00
|
|
|
},
|
|
|
|
ticks: {
|
2022-04-13 17:19:26 +03:00
|
|
|
display: false,
|
2022-04-14 17:28:45 +03:00
|
|
|
beginAtZero: true,
|
2022-04-13 17:19:26 +03:00
|
|
|
callback: function (value, index, values) {
|
|
|
|
if (index === 0) {
|
|
|
|
document.getElementById('gh-dashboard5-anchor-date-start').innerHTML = moment(value).format(DATE_FORMAT);
|
|
|
|
}
|
|
|
|
if (index === values.length - 1) {
|
|
|
|
document.getElementById('gh-dashboard5-anchor-date-end').innerHTML = moment(value).format(DATE_FORMAT);
|
|
|
|
}
|
|
|
|
return value;
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
2022-04-13 17:19:26 +03:00
|
|
|
}
|
2022-04-01 16:53:55 +03:00
|
|
|
}]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-06 20:11:46 +03:00
|
|
|
get chartHeight() {
|
2022-04-14 17:28:45 +03:00
|
|
|
return 250;
|
2022-04-12 18:03:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get chartHeightSmall() {
|
2022-04-12 19:56:55 +03:00
|
|
|
return 225;
|
2022-04-06 20:11:46 +03:00
|
|
|
}
|
|
|
|
|
2022-04-01 16:53:55 +03:00
|
|
|
calculatePercentage(from, to) {
|
|
|
|
if (from === 0) {
|
|
|
|
if (to > 0) {
|
|
|
|
return 100;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Math.round((to - from) / from * 100);
|
|
|
|
}
|
|
|
|
}
|