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);
if (nextBanner === undefined) {
console.log('error banner here', JSON.stringify(pull));
pushToast(t('wish.errorBanner'), 'error');
return null;
}

View File

@ -41,6 +41,8 @@
beginners: 'beginners',
};
let errorProcessingPull = '';
const bannerType = bannerTypes[id];
let bannerChart;
let pieChart;
@ -138,6 +140,8 @@
currentBanner = getNextBanner(pull.time);
if (currentBanner === undefined) {
console.log('error banner here', JSON.stringify(pull));
errorProcessingPull = JSON.stringify(pull);
pushToast($t('wish.errorBanner'), 'error');
return;
}
@ -234,32 +238,32 @@
await tick();
setTimeout(() => {
new Chart(pieChart, {
type: 'pie',
data: {
labels: ['Total Pulls', 'Total 5*', 'Total 4*'],
datasets: [
{
label: 'total',
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)'],
borderColor: ['#6BA1C0', '#FFB13F', '#D28FD6'],
borderWidth: 1,
},
],
},
options: {
responsive: true,
legend: {
display: false,
},
tooltips: {
mode: 'dataset',
new Chart(pieChart, {
type: 'pie',
data: {
labels: ['Total Pulls', 'Total 5*', 'Total 4*'],
datasets: [
{
label: 'total',
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)'],
borderColor: ['#6BA1C0', '#FFB13F', '#D28FD6'],
borderWidth: 1,
},
],
},
options: {
responsive: true,
legend: {
display: false,
},
});
tooltips: {
mode: 'dataset',
},
},
});
if (id === 'character-event' || id === 'weapon-event') {
new Chart(bannerChart, {
type: 'bar',
data: {
@ -319,7 +323,7 @@
},
},
});
}, 500);
}
}
function sortPulls() {
@ -403,6 +407,9 @@
</div>
{#if loading}
<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}
<div class="flex mt-4 wrapper">
<div class="block overflow-x-auto xl:overflow-x-visible whitespace-no-wrap px">