mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
Fixed empty paid subscriptions chart for fake data (#15440)
- the paid subscribers chart was empty when using with fake data due to missing values of `signups` and `cancellations`
This commit is contained in:
parent
63103c2251
commit
41bf5f1530
@ -198,13 +198,13 @@ export default class PaidBreakdown extends Component {
|
||||
get chartData() {
|
||||
const stats = this.dashboardStats.filledSubscriptionCountStats;
|
||||
const labels = stats.map(stat => stat.date);
|
||||
const newData = stats.map(stat => stat.signups);
|
||||
const canceledData = stats.map(stat => -stat.cancellations);
|
||||
const newData = stats.map(stat => stat.signups || 0);
|
||||
const canceledData = stats.map(stat => -(stat.cancellations || 0));
|
||||
let barThickness = 5;
|
||||
|
||||
if (newData.length >= 30 + 1 && newData.length < 90) {
|
||||
barThickness = 3.5;
|
||||
} else if (newData.length >= 90) {
|
||||
} else if (newData.length >= 90) {
|
||||
barThickness = 1.5;
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ export default class PaidBreakdown extends Component {
|
||||
if (tooltip.opacity === 0) {
|
||||
tooltipEl.style.display = 'none';
|
||||
tooltipEl.style.opacity = 0;
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
let offsetX = 0;
|
||||
@ -284,7 +284,7 @@ export default class PaidBreakdown extends Component {
|
||||
tooltipEl.style.opacity = 1;
|
||||
tooltipEl.style.position = 'absolute';
|
||||
tooltipEl.style.left = tooltip.x - offsetX + 'px';
|
||||
tooltipEl.style.top = '70px';
|
||||
tooltipEl.style.top = '70px';
|
||||
},
|
||||
callbacks: {
|
||||
label: (tooltipItems, data) => {
|
||||
|
@ -294,11 +294,14 @@ export default class DashboardMocksService extends Service {
|
||||
|
||||
this.memberCountStats = stats;
|
||||
this.subscriptionCountStats = stats.map((data) => {
|
||||
const signups = (data.paidSubscribed - data.paidCanceled);
|
||||
return {
|
||||
date: data.date,
|
||||
count: data.paid,
|
||||
positiveDelta: data.paidSubscribed,
|
||||
negativeDelta: data.paidCanceled
|
||||
negativeDelta: data.paidCanceled,
|
||||
signups: signups < 0 ? 0 : signups,
|
||||
cancellations: Math.floor(signups * 0.3) ? Math.floor(signups * 0.3) : 0
|
||||
};
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user