2022-04-28 18:40:19 +03:00
|
|
|
/* global Chart */
|
|
|
|
|
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';
|
2022-04-14 18:10:56 +03:00
|
|
|
import {getSymbol} from 'ghost-admin/utils/currency';
|
2022-04-01 16:53:55 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2022-04-14 18:10:56 +03:00
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
2022-05-09 13:25:38 +03:00
|
|
|
const DATE_FORMAT = 'D MMM, YYYY';
|
2022-04-06 20:11:46 +03:00
|
|
|
|
2022-04-20 15:43:11 +03:00
|
|
|
const DISPLAY_OPTIONS = [{
|
2022-04-22 18:27:13 +03:00
|
|
|
name: 'Total members',
|
2022-04-20 15:43:11 +03:00
|
|
|
value: 'total'
|
2022-04-12 12:18:10 +03:00
|
|
|
}, {
|
2022-04-20 15:43:11 +03:00
|
|
|
name: 'Paid members',
|
|
|
|
value: 'paid'
|
|
|
|
}, {
|
|
|
|
name: 'Free members',
|
|
|
|
value: 'free'
|
2022-04-12 12:18:10 +03:00
|
|
|
}];
|
|
|
|
|
2022-04-28 18:40:19 +03:00
|
|
|
// custom ChartJS draw function
|
|
|
|
Chart.defaults.hoverLine = Chart.defaults.line;
|
|
|
|
Chart.controllers.hoverLine = Chart.controllers.line.extend({
|
|
|
|
draw: function (ease) {
|
|
|
|
Chart.controllers.line.prototype.draw.call(this, ease);
|
|
|
|
|
|
|
|
if (this.chart.tooltip._active && this.chart.tooltip._active.length) {
|
|
|
|
let activePoint = this.chart.tooltip._active[0],
|
|
|
|
ctx = this.chart.ctx,
|
|
|
|
x = activePoint.tooltipPosition().x,
|
|
|
|
topY = this.chart.legend.bottom,
|
|
|
|
bottomY = this.chart.chartArea.bottom;
|
|
|
|
|
|
|
|
// draw line
|
|
|
|
ctx.save();
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo(x, topY);
|
|
|
|
ctx.lineTo(x, bottomY);
|
|
|
|
ctx.setLineDash([3, 4]);
|
|
|
|
ctx.lineWidth = 1;
|
|
|
|
ctx.strokeStyle = '#7C8B9A';
|
|
|
|
ctx.stroke();
|
|
|
|
ctx.restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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-20 15:43:11 +03:00
|
|
|
displayOptions = DISPLAY_OPTIONS;
|
2022-04-01 16:53:55 +03:00
|
|
|
|
|
|
|
@action
|
|
|
|
loadCharts() {
|
|
|
|
this.dashboardStats.loadMemberCountStats();
|
|
|
|
|
2022-04-20 15:43:11 +03:00
|
|
|
if (this.hasPaidTiers) {
|
|
|
|
this.dashboardStats.loadMrrStats();
|
|
|
|
}
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
2022-04-12 12:18:10 +03:00
|
|
|
@action
|
2022-04-20 15:43:11 +03:00
|
|
|
onDisplayChange(selected) {
|
|
|
|
this.chartDisplay = selected.value;
|
2022-04-12 12:18:10 +03:00
|
|
|
}
|
|
|
|
|
2022-04-20 15:43:11 +03:00
|
|
|
get selectedDisplayOption() {
|
|
|
|
return this.displayOptions.find(d => d.value === this.chartDisplay) ?? this.displayOptions[0];
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get loading() {
|
2022-04-20 15:43:11 +03:00
|
|
|
return this.dashboardStats.memberCountStats === null;
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get totalMembers() {
|
|
|
|
return this.dashboardStats.memberCounts?.total ?? 0;
|
|
|
|
}
|
|
|
|
|
2022-05-06 18:19:16 +03:00
|
|
|
get isTotalMembersZero() {
|
|
|
|
return this.dashboardStats.memberCounts && this.totalMembers === 0;
|
|
|
|
}
|
|
|
|
|
2022-04-01 16:53:55 +03:00
|
|
|
get paidMembers() {
|
|
|
|
return this.dashboardStats.memberCounts?.paid ?? 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get freeMembers() {
|
|
|
|
return this.dashboardStats.memberCounts?.free ?? 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get hasTrends() {
|
2022-04-13 15:52:12 +03:00
|
|
|
return this.dashboardStats.memberCounts !== null
|
2022-04-20 15:43:11 +03:00
|
|
|
&& this.dashboardStats.memberCountsTrend !== 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);
|
|
|
|
}
|
|
|
|
|
2022-04-01 19:02:30 +03:00
|
|
|
get hasPaidTiers() {
|
|
|
|
return this.dashboardStats.siteStatus?.hasPaidTiers;
|
|
|
|
}
|
|
|
|
|
2022-04-01 16:53:55 +03:00
|
|
|
get chartType() {
|
2022-04-28 18:40:19 +03:00
|
|
|
return 'hoverLine'; // uses custom ChartJS draw function
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
2022-04-26 20:54:52 +03:00
|
|
|
get chartTitle() {
|
|
|
|
// paid
|
|
|
|
if (this.chartDisplay === 'paid') {
|
|
|
|
return 'Paid members';
|
|
|
|
// free
|
|
|
|
} else if (this.chartDisplay === 'free') {
|
|
|
|
return 'Free members';
|
|
|
|
}
|
|
|
|
// total
|
|
|
|
return 'Total members';
|
|
|
|
}
|
|
|
|
|
2022-04-01 16:53:55 +03:00
|
|
|
get chartData() {
|
2022-04-14 18:10:56 +03:00
|
|
|
let stats;
|
|
|
|
let labels;
|
|
|
|
let data;
|
2022-04-01 16:53:55 +03:00
|
|
|
|
2022-04-20 15:43:11 +03:00
|
|
|
if (this.chartDisplay === 'paid') {
|
|
|
|
// paid
|
2022-04-14 18:10:56 +03:00
|
|
|
stats = this.dashboardStats.filledMemberCountStats;
|
|
|
|
labels = stats.map(stat => stat.date);
|
2022-04-20 15:43:11 +03:00
|
|
|
data = stats.map(stat => stat.paid + stat.comped);
|
|
|
|
} else if (this.chartDisplay === 'free') {
|
|
|
|
// free
|
|
|
|
stats = this.dashboardStats.filledMemberCountStats;
|
2022-04-14 18:10:56 +03:00
|
|
|
labels = stats.map(stat => stat.date);
|
2022-04-20 15:43:11 +03:00
|
|
|
data = stats.map(stat => stat.free);
|
2022-04-14 18:10:56 +03:00
|
|
|
} else {
|
|
|
|
// total
|
|
|
|
stats = this.dashboardStats.filledMemberCountStats;
|
|
|
|
labels = stats.map(stat => stat.date);
|
|
|
|
data = stats.map(stat => stat.paid + stat.free + stat.comped);
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
2022-05-06 18:19:16 +03:00
|
|
|
// with no members yet, let's show empty state with dummy data
|
|
|
|
if (this.isTotalMembersZero) {
|
|
|
|
stats = this.emptyData.stats;
|
|
|
|
labels = this.emptyData.labels;
|
|
|
|
data = this.emptyData.data;
|
|
|
|
}
|
|
|
|
|
2022-04-26 16:52:46 +03:00
|
|
|
// gradient for line
|
|
|
|
const canvasLine = document.createElement('canvas');
|
|
|
|
const ctxLine = canvasLine.getContext('2d');
|
|
|
|
const gradientLine = ctxLine.createLinearGradient(0, 0, 1000, 0);
|
|
|
|
gradientLine.addColorStop(0, 'rgba(250, 45, 142, 1');
|
|
|
|
gradientLine.addColorStop(1, 'rgba(143, 66, 255, 1');
|
|
|
|
|
|
|
|
// gradient for fill
|
|
|
|
const canvasFill = document.createElement('canvas');
|
|
|
|
const ctxFill = canvasFill.getContext('2d');
|
|
|
|
const gradientFill = ctxFill.createLinearGradient(0, 0, 1000, 0);
|
|
|
|
gradientFill.addColorStop(0, 'rgba(250, 45, 142, 0.2');
|
2022-05-17 12:41:11 +03:00
|
|
|
gradientFill.addColorStop(1, 'rgba(143, 66, 255, 0.1');
|
2022-04-26 16:52:46 +03:00
|
|
|
|
2022-04-14 18:10:56 +03:00
|
|
|
return {
|
|
|
|
labels: labels,
|
|
|
|
datasets: [{
|
|
|
|
data: data,
|
|
|
|
tension: 0,
|
|
|
|
cubicInterpolationMode: 'monotone',
|
|
|
|
fill: true,
|
2022-04-26 16:52:46 +03:00
|
|
|
fillColor: gradientFill,
|
|
|
|
backgroundColor: gradientFill,
|
2022-04-14 18:10:56 +03:00
|
|
|
pointRadius: 0,
|
|
|
|
pointHitRadius: 10,
|
2022-04-20 15:43:11 +03:00
|
|
|
pointBorderColor: '#8E42FF',
|
|
|
|
pointBackgroundColor: '#8E42FF',
|
|
|
|
pointHoverBackgroundColor: '#8E42FF',
|
|
|
|
pointHoverBorderColor: '#8E42FF',
|
2022-04-14 18:10:56 +03:00
|
|
|
pointHoverRadius: 0,
|
2022-04-26 16:52:46 +03:00
|
|
|
borderColor: gradientLine,
|
2022-04-14 18:10:56 +03:00
|
|
|
borderJoinStyle: 'miter'
|
|
|
|
}]
|
|
|
|
};
|
2022-04-01 16:53:55 +03:00
|
|
|
}
|
|
|
|
|
2022-04-14 18:05:01 +03:00
|
|
|
get mrrCurrencySymbol() {
|
|
|
|
if (this.dashboardStats.mrrStats === null) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
const firstCurrency = this.dashboardStats.mrrStats[0] ? this.dashboardStats.mrrStats[0].currency : 'usd';
|
|
|
|
return getSymbol(firstCurrency);
|
|
|
|
}
|
|
|
|
|
2022-04-01 16:53:55 +03:00
|
|
|
get chartOptions() {
|
2022-05-11 18:57:29 +03:00
|
|
|
let activeDays = this.dashboardStats.chartDays;
|
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-26 16:52:46 +03:00
|
|
|
|
2022-04-01 16:53:55 +03:00
|
|
|
return {
|
|
|
|
maintainAspectRatio: false,
|
2022-04-27 16:40:38 +03:00
|
|
|
responsiveAnimationDuration: 1,
|
|
|
|
animation: false,
|
2022-04-01 16:53:55 +03:00
|
|
|
title: {
|
|
|
|
display: false
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
display: false
|
|
|
|
},
|
|
|
|
layout: {
|
|
|
|
padding: {
|
2022-04-14 18:10:56 +03:00
|
|
|
top: 2,
|
2022-04-22 16:49:03 +03:00
|
|
|
bottom: 2,
|
2022-04-28 18:40:19 +03:00
|
|
|
left: 1,
|
|
|
|
right: 1
|
2022-04-06 20:11:46 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
hover: {
|
|
|
|
onHover: function (e) {
|
|
|
|
e.target.style.cursor = 'pointer';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tooltips: {
|
2022-04-26 20:54:52 +03:00
|
|
|
enabled: false,
|
2022-04-06 20:11:46 +03:00
|
|
|
intersect: false,
|
|
|
|
mode: 'index',
|
2022-04-26 20:54:52 +03:00
|
|
|
custom: function (tooltip) {
|
|
|
|
// get tooltip element
|
2022-05-17 10:34:34 +03:00
|
|
|
const tooltipEl = document.getElementById('gh-dashboard-anchor-tooltip');
|
2022-05-11 11:30:15 +03:00
|
|
|
const chartContainerEl = tooltipEl.parentElement;
|
|
|
|
const chartWidth = chartContainerEl.offsetWidth;
|
|
|
|
const tooltipWidth = tooltipEl.offsetWidth;
|
2022-04-26 20:54:52 +03:00
|
|
|
|
|
|
|
// only show tooltip when active
|
|
|
|
if (tooltip.opacity === 0) {
|
|
|
|
tooltipEl.style.opacity = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// update tooltip styles
|
|
|
|
tooltipEl.style.opacity = 1;
|
|
|
|
tooltipEl.style.position = 'absolute';
|
2022-05-11 11:30:15 +03:00
|
|
|
|
|
|
|
let offsetX = 0;
|
|
|
|
if (tooltip.x > chartWidth - tooltipWidth) {
|
|
|
|
offsetX = tooltipWidth - 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
tooltipEl.style.left = tooltip.x - offsetX + 'px';
|
|
|
|
tooltipEl.style.top = tooltip.y + 'px';
|
2022-04-26 20:54:52 +03:00
|
|
|
},
|
2022-04-06 20:11:46 +03:00
|
|
|
callbacks: {
|
|
|
|
label: (tooltipItems, data) => {
|
2022-04-26 20:54:52 +03:00
|
|
|
const value = data.datasets[tooltipItems.datasetIndex].data[tooltipItems.index].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
2022-05-17 10:34:34 +03:00
|
|
|
document.querySelector('#gh-dashboard-anchor-tooltip .gh-dashboard-tooltip-value .value').innerHTML = value;
|
2022-04-06 20:11:46 +03:00
|
|
|
},
|
|
|
|
title: (tooltipItems) => {
|
2022-04-26 20:54:52 +03:00
|
|
|
const value = moment(tooltipItems[0].xLabel).format(DATE_FORMAT);
|
2022-05-17 10:34:34 +03:00
|
|
|
document.querySelector('#gh-dashboard-anchor-tooltip .gh-dashboard-tooltip-label').innerHTML = value;
|
2022-04-06 20:11:46 +03:00
|
|
|
}
|
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-28 18:40:19 +03:00
|
|
|
borderDash: [3,4],
|
2022-04-08 19:49:11 +03:00
|
|
|
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-28 18:40:19 +03:00
|
|
|
zeroLineBorderDash: [3,4]
|
2022-04-01 16:53:55 +03:00
|
|
|
},
|
|
|
|
ticks: {
|
2022-04-13 17:19:26 +03:00
|
|
|
display: false,
|
2022-05-10 18:40:28 +03:00
|
|
|
autoSkip: false,
|
2022-04-13 17:19:26 +03:00
|
|
|
callback: function (value, index, values) {
|
|
|
|
if (index === 0) {
|
2022-05-17 10:34:34 +03:00
|
|
|
document.getElementById('gh-dashboard-anchor-date-start').innerHTML = moment(value).format(DATE_FORMAT);
|
2022-04-13 17:19:26 +03:00
|
|
|
}
|
2022-05-10 18:40:28 +03:00
|
|
|
if (index === (values.length - 1)) {
|
2022-05-17 10:34:34 +03:00
|
|
|
document.getElementById('gh-dashboard-anchor-date-end').innerHTML = moment(value).format(DATE_FORMAT);
|
2022-05-10 18:40:28 +03:00
|
|
|
}
|
2022-05-11 13:15:07 +03:00
|
|
|
|
|
|
|
if (activeDays === (30 + 1)) {
|
|
|
|
if (!(index % 2)) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
} else if (activeDays === (90 + 1)) {
|
|
|
|
if (!(index % 3)) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
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-20 15:43:11 +03:00
|
|
|
return 200;
|
2022-04-12 18:03:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get chartHeightSmall() {
|
2022-04-26 20:54:52 +03:00
|
|
|
return 180;
|
2022-04-06 20:11:46 +03:00
|
|
|
}
|
|
|
|
|
2022-05-06 18:19:16 +03:00
|
|
|
// used for empty state
|
|
|
|
get emptyData() {
|
|
|
|
return {
|
|
|
|
stats: [
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-07',
|
|
|
|
free: 2610,
|
|
|
|
tier1: 295,
|
|
|
|
tier2: 20,
|
|
|
|
paid: 315,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 2,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-08',
|
|
|
|
free: 2765,
|
|
|
|
tier1: 298,
|
|
|
|
tier2: 24,
|
|
|
|
paid: 322,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 7,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-09',
|
|
|
|
free: 3160,
|
|
|
|
tier1: 299,
|
|
|
|
tier2: 28,
|
|
|
|
paid: 327,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 5,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-10',
|
|
|
|
free: 3580,
|
|
|
|
tier1: 300,
|
|
|
|
tier2: 30,
|
|
|
|
paid: 330,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 4,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-11',
|
|
|
|
free: 3583,
|
|
|
|
tier1: 301,
|
|
|
|
tier2: 31,
|
|
|
|
paid: 332,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 2,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-12',
|
|
|
|
free: 3857,
|
|
|
|
tier1: 303,
|
|
|
|
tier2: 36,
|
|
|
|
paid: 339,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 8,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-13',
|
|
|
|
free: 4223,
|
|
|
|
tier1: 304,
|
|
|
|
tier2: 39,
|
|
|
|
paid: 343,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 4,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-14',
|
|
|
|
free: 4289,
|
|
|
|
tier1: 306,
|
|
|
|
tier2: 42,
|
|
|
|
paid: 348,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 6,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-15',
|
|
|
|
free: 4458,
|
|
|
|
tier1: 307,
|
|
|
|
tier2: 49,
|
|
|
|
paid: 356,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 8,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-16',
|
|
|
|
free: 4752,
|
|
|
|
tier1: 307,
|
|
|
|
tier2: 49,
|
|
|
|
paid: 356,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 1,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-17',
|
|
|
|
free: 4947,
|
|
|
|
tier1: 310,
|
|
|
|
tier2: 50,
|
|
|
|
paid: 360,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 5,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-18',
|
|
|
|
free: 5047,
|
|
|
|
tier1: 312,
|
|
|
|
tier2: 49,
|
|
|
|
paid: 361,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 2,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-19',
|
|
|
|
free: 5430,
|
|
|
|
tier1: 314,
|
|
|
|
tier2: 55,
|
|
|
|
paid: 369,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 8,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-20',
|
|
|
|
free: 5760,
|
|
|
|
tier1: 316,
|
|
|
|
tier2: 57,
|
|
|
|
paid: 373,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 4,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-21',
|
|
|
|
free: 6022,
|
|
|
|
tier1: 318,
|
|
|
|
tier2: 63,
|
|
|
|
paid: 381,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 9,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-22',
|
|
|
|
free: 6294,
|
|
|
|
tier1: 319,
|
|
|
|
tier2: 64,
|
|
|
|
paid: 383,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 2,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-23',
|
|
|
|
free: 6664,
|
|
|
|
tier1: 320,
|
|
|
|
tier2: 69,
|
|
|
|
paid: 389,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 6,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-24',
|
|
|
|
free: 6721,
|
|
|
|
tier1: 320,
|
|
|
|
tier2: 70,
|
|
|
|
paid: 390,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 1,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-25',
|
|
|
|
free: 6841,
|
|
|
|
tier1: 321,
|
|
|
|
tier2: 80,
|
|
|
|
paid: 401,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 11,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-26',
|
|
|
|
free: 6880,
|
|
|
|
tier1: 323,
|
|
|
|
tier2: 89,
|
|
|
|
paid: 412,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 11,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-27',
|
|
|
|
free: 7179,
|
|
|
|
tier1: 325,
|
|
|
|
tier2: 92,
|
|
|
|
paid: 417,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 5,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-28',
|
|
|
|
free: 7288,
|
|
|
|
tier1: 325,
|
|
|
|
tier2: 100,
|
|
|
|
paid: 425,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 9,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-29',
|
|
|
|
free: 7430,
|
|
|
|
tier1: 325,
|
|
|
|
tier2: 101,
|
|
|
|
paid: 426,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 2,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-04-30',
|
|
|
|
free: 7458,
|
|
|
|
tier1: 326,
|
|
|
|
tier2: 102,
|
|
|
|
paid: 428,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 2,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-05-01',
|
|
|
|
free: 7621,
|
|
|
|
tier1: 327,
|
|
|
|
tier2: 117,
|
|
|
|
paid: 444,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 17,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-05-02',
|
|
|
|
free: 7721,
|
|
|
|
tier1: 328,
|
|
|
|
tier2: 123,
|
|
|
|
paid: 451,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 8,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-05-03',
|
|
|
|
free: 7897,
|
|
|
|
tier1: 327,
|
|
|
|
tier2: 137,
|
|
|
|
paid: 464,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 14,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-05-04',
|
|
|
|
free: 7937,
|
|
|
|
tier1: 327,
|
|
|
|
tier2: 143,
|
|
|
|
paid: 470,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 6,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-05-05',
|
|
|
|
free: 7961,
|
|
|
|
tier1: 328,
|
|
|
|
tier2: 158,
|
|
|
|
paid: 486,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 16,
|
|
|
|
paidCanceled: 0
|
2022-05-06 18:19:16 +03:00
|
|
|
},
|
|
|
|
{
|
2022-05-09 13:59:09 +03:00
|
|
|
date: '2022-05-06',
|
|
|
|
free: 8006,
|
|
|
|
tier1: 328,
|
|
|
|
tier2: 162,
|
|
|
|
paid: 490,
|
|
|
|
comped: 0,
|
|
|
|
paidSubscribed: 5,
|
|
|
|
paidCanceled: 1
|
2022-05-06 18:19:16 +03:00
|
|
|
}
|
|
|
|
],
|
|
|
|
labels: [
|
2022-05-09 13:59:09 +03:00
|
|
|
'2022-04-07',
|
|
|
|
'2022-04-08',
|
|
|
|
'2022-04-09',
|
|
|
|
'2022-04-10',
|
|
|
|
'2022-04-11',
|
|
|
|
'2022-04-12',
|
|
|
|
'2022-04-13',
|
|
|
|
'2022-04-14',
|
|
|
|
'2022-04-15',
|
|
|
|
'2022-04-16',
|
|
|
|
'2022-04-17',
|
|
|
|
'2022-04-18',
|
|
|
|
'2022-04-19',
|
|
|
|
'2022-04-20',
|
|
|
|
'2022-04-21',
|
|
|
|
'2022-04-22',
|
|
|
|
'2022-04-23',
|
|
|
|
'2022-04-24',
|
|
|
|
'2022-04-25',
|
|
|
|
'2022-04-26',
|
|
|
|
'2022-04-27',
|
|
|
|
'2022-04-28',
|
|
|
|
'2022-04-29',
|
|
|
|
'2022-04-30',
|
|
|
|
'2022-05-01',
|
|
|
|
'2022-05-02',
|
|
|
|
'2022-05-03',
|
|
|
|
'2022-05-04',
|
|
|
|
'2022-05-05',
|
|
|
|
'2022-05-06'
|
2022-05-06 18:19:16 +03:00
|
|
|
],
|
|
|
|
data: [
|
|
|
|
2925,
|
|
|
|
3087,
|
|
|
|
3487,
|
|
|
|
3910,
|
|
|
|
3915,
|
|
|
|
4196,
|
|
|
|
4566,
|
|
|
|
4637,
|
|
|
|
4814,
|
|
|
|
5108,
|
|
|
|
5307,
|
|
|
|
5408,
|
|
|
|
5799,
|
|
|
|
6133,
|
|
|
|
6403,
|
|
|
|
6677,
|
|
|
|
7053,
|
|
|
|
7111,
|
|
|
|
7242,
|
|
|
|
7292,
|
|
|
|
7596,
|
|
|
|
7713,
|
|
|
|
7856,
|
|
|
|
7886,
|
|
|
|
8065,
|
|
|
|
8172,
|
|
|
|
8361,
|
|
|
|
8407,
|
|
|
|
8447,
|
|
|
|
8496
|
|
|
|
]
|
2022-05-09 13:59:09 +03:00
|
|
|
};
|
2022-05-06 18:19:16 +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);
|
|
|
|
}
|
|
|
|
}
|