Fix chart error

pull/1/head
Made Baruna 2021-03-30 16:40:18 +08:00
parent 922f83d557
commit 41a1d2fdaf
2 changed files with 32 additions and 24 deletions

View File

@ -104,6 +104,7 @@ export function process(id) {
const nextBanner = getNextBanner(pull.time, currentBannerIndex, selectedBanners); const nextBanner = getNextBanner(pull.time, currentBannerIndex, selectedBanners);
if (nextBanner === undefined) { if (nextBanner === undefined) {
console.log('error banner here', JSON.stringify(pull));
pushToast(t('wish.errorBanner'), 'error'); pushToast(t('wish.errorBanner'), 'error');
return null; return null;
} }

View File

@ -41,6 +41,8 @@
beginners: 'beginners', beginners: 'beginners',
}; };
let errorProcessingPull = '';
const bannerType = bannerTypes[id]; const bannerType = bannerTypes[id];
let bannerChart; let bannerChart;
let pieChart; let pieChart;
@ -138,6 +140,8 @@
currentBanner = getNextBanner(pull.time); currentBanner = getNextBanner(pull.time);
if (currentBanner === undefined) { if (currentBanner === undefined) {
console.log('error banner here', JSON.stringify(pull));
errorProcessingPull = JSON.stringify(pull);
pushToast($t('wish.errorBanner'), 'error'); pushToast($t('wish.errorBanner'), 'error');
return; return;
} }
@ -234,32 +238,32 @@
await tick(); await tick();
setTimeout(() => { new Chart(pieChart, {
new Chart(pieChart, { type: 'pie',
type: 'pie', data: {
data: { labels: ['Total Pulls', 'Total 5*', 'Total 4*'],
labels: ['Total Pulls', 'Total 5*', 'Total 4*'], datasets: [
datasets: [ {
{ label: 'total',
label: 'total', data: [currentPulls.length, allLegendary.length, allRare.length],
data: [currentPulls.length, allLegendary.length, allRare.length], backgroundColor: ['rgba(107, 161, 192, 0.7)', 'rgba(255, 177, 63, 0.7)', 'rgba(210, 143, 214, 0.7)'],
backgroundColor: ['rgba(107, 161, 192, 0.7)', 'rgba(255, 177, 63, 0.7)', 'rgba(210, 143, 214, 0.7)'], borderColor: ['#6BA1C0', '#FFB13F', '#D28FD6'],
borderColor: ['#6BA1C0', '#FFB13F', '#D28FD6'], borderWidth: 1,
borderWidth: 1,
},
],
},
options: {
responsive: true,
legend: {
display: false,
},
tooltips: {
mode: 'dataset',
}, },
],
},
options: {
responsive: true,
legend: {
display: false,
}, },
}); tooltips: {
mode: 'dataset',
},
},
});
if (id === 'character-event' || id === 'weapon-event') {
new Chart(bannerChart, { new Chart(bannerChart, {
type: 'bar', type: 'bar',
data: { data: {
@ -319,7 +323,7 @@
}, },
}, },
}); });
}, 500); }
} }
function sortPulls() { function sortPulls() {
@ -403,6 +407,9 @@
</div> </div>
{#if loading} {#if loading}
<div class="text-white pl-4 md:pl-8 mt-4">{$t('wish.detail.loading')}</div> <div class="text-white pl-4 md:pl-8 mt-4">{$t('wish.detail.loading')}</div>
{#if errorProcessingPull !== ''}
Error when getting banner for {errorProcessingPull}
{/if}
{:else} {:else}
<div class="flex mt-4 wrapper"> <div class="flex mt-4 wrapper">
<div class="block overflow-x-auto xl:overflow-x-visible whitespace-no-wrap px"> <div class="block overflow-x-auto xl:overflow-x-visible whitespace-no-wrap px">