replace decades covered with golden era, most common year, and rarity score insights (#3139)
This commit is contained in:
+17
-5
@@ -48,9 +48,15 @@
|
|||||||
<span class="insight-detail" [title]="insights.newestBook.title">{{ insights.newestBook.title }}</span>
|
<span class="insight-detail" [title]="insights.newestBook.title">{{ insights.newestBook.title }}</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<div class="insight-item common-year">
|
||||||
|
<span class="insight-label">{{ t('insightMostCommonYear') }}</span>
|
||||||
|
<span class="insight-value">{{ insights.mostCommonYear.year }}</span>
|
||||||
|
<span class="insight-detail">{{ t('insightMostCommonYearBooks', { count: insights.mostCommonYear.count }) }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="insights-row secondary">
|
<div class="insights-row">
|
||||||
<div class="insight-item timespan">
|
<div class="insight-item timespan">
|
||||||
<span class="insight-label">{{ t('insightTimeSpan') }}</span>
|
<span class="insight-label">{{ t('insightTimeSpan') }}</span>
|
||||||
<span class="insight-value">{{ insights.timeSpan }}</span>
|
<span class="insight-value">{{ insights.timeSpan }}</span>
|
||||||
@@ -63,10 +69,16 @@
|
|||||||
<span class="insight-detail">{{ t('insightPeakDecadeBooks', { count: insights.peakDecadeCount }) }}</span>
|
<span class="insight-detail">{{ t('insightPeakDecadeBooks', { count: insights.peakDecadeCount }) }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="insight-item decades">
|
<div class="insight-item golden-era">
|
||||||
<span class="insight-label">{{ t('insightDecadesCovered') }}</span>
|
<span class="insight-label">{{ t('insightGoldenEra') }}</span>
|
||||||
<span class="insight-value">{{ insights.decadesCovered }}</span>
|
<span class="insight-value">{{ insights.goldenEra.start }}-{{ insights.goldenEra.end }}</span>
|
||||||
<span class="insight-detail">{{ t('insightDifferentEras') }}</span>
|
<span class="insight-detail">{{ t('insightGoldenEraRange', { count: insights.goldenEra.count }) }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="insight-item rarity">
|
||||||
|
<span class="insight-label">{{ t('insightRarityScore') }}</span>
|
||||||
|
<span class="insight-value">{{ insights.rarityScore }}%</span>
|
||||||
|
<span class="insight-detail">{{ t('insightRarePicks') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+26
-9
@@ -33,15 +33,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.insights-row {
|
.insights-row {
|
||||||
display: flex;
|
display: grid;
|
||||||
justify-content: space-between;
|
grid-template-columns: repeat(4, 1fr);
|
||||||
gap: 1rem;
|
gap: 0.75rem;
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.insight-item {
|
.insight-item {
|
||||||
flex: 1;
|
|
||||||
min-width: 120px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -105,14 +102,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.decades {
|
&.golden-era {
|
||||||
.insight-value {
|
.insight-value {
|
||||||
color: #fb923c;
|
color: #fb923c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.common-year {
|
||||||
|
.insight-value {
|
||||||
|
color: #34d399;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.rarity {
|
||||||
|
.insight-value {
|
||||||
|
color: #f87171;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.insights-row.secondary {
|
.insights-row + .insights-row {
|
||||||
margin-top: 0.75rem;
|
margin-top: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +134,11 @@
|
|||||||
gap: 0.75rem;
|
gap: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.insights-row {
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.insight-item {
|
.insight-item {
|
||||||
padding: 0.6rem;
|
padding: 0.6rem;
|
||||||
|
|
||||||
@@ -148,8 +162,11 @@
|
|||||||
padding: 0.3rem 0.75rem;
|
padding: 0.3rem 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.insights-row {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
.insight-item {
|
.insight-item {
|
||||||
min-width: 90px;
|
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
|
|
||||||
.insight-value {
|
.insight-value {
|
||||||
|
|||||||
+39
-3
@@ -27,7 +27,9 @@ interface TimelineInsights {
|
|||||||
peakDecade: string;
|
peakDecade: string;
|
||||||
peakDecadeCount: number;
|
peakDecadeCount: number;
|
||||||
centuryBreakdown: { c21: number; c20: number; older: number };
|
centuryBreakdown: { c21: number; c20: number; older: number };
|
||||||
decadesCovered: number;
|
goldenEra: { start: number; end: number; count: number };
|
||||||
|
mostCommonYear: { year: number; count: number };
|
||||||
|
rarityScore: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type TimelineChartData = ChartData<'bar', number[], string>;
|
type TimelineChartData = ChartData<'bar', number[], string>;
|
||||||
@@ -338,13 +340,45 @@ export class PublicationTimelineChartComponent implements OnInit, OnDestroy {
|
|||||||
let peakDecadeCount = 0;
|
let peakDecadeCount = 0;
|
||||||
for (const [decade, count] of decadeCounts) {
|
for (const [decade, count] of decadeCounts) {
|
||||||
if (count > peakDecadeCount) {
|
if (count > peakDecadeCount) {
|
||||||
peakDecade = decade === 'pre1900' ? 'Pre-1900' : decade.toUpperCase();
|
peakDecade = decade === 'pre1900' ? 'Pre-1900' : decade;
|
||||||
peakDecadeCount = count;
|
peakDecadeCount = count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeSpan = oldest && newest ? newest.year - oldest.year : 0;
|
const timeSpan = oldest && newest ? newest.year - oldest.year : 0;
|
||||||
|
|
||||||
|
// Golden Era: best 20-year window
|
||||||
|
let goldenEra = {start: 0, end: 0, count: 0};
|
||||||
|
if (years.length > 0) {
|
||||||
|
for (let i = 0; i < years.length; i++) {
|
||||||
|
const windowStart = years[i];
|
||||||
|
const windowEnd = windowStart + 19;
|
||||||
|
const windowCount = years.filter(y => y >= windowStart && y <= windowEnd).length;
|
||||||
|
if (windowCount > goldenEra.count) {
|
||||||
|
goldenEra = {start: windowStart, end: windowEnd, count: windowCount};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Most Common Year
|
||||||
|
const yearCounts = new Map<number, number>();
|
||||||
|
for (const y of years) {
|
||||||
|
yearCounts.set(y, (yearCounts.get(y) || 0) + 1);
|
||||||
|
}
|
||||||
|
let mostCommonYear = {year: 0, count: 0};
|
||||||
|
for (const [y, c] of yearCounts) {
|
||||||
|
if (c > mostCommonYear.count) {
|
||||||
|
mostCommonYear = {year: y, count: c};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rarity Score: % of books in decades with fewer than 3 books
|
||||||
|
let rareBooks = 0;
|
||||||
|
for (const [_, count] of decadeCounts) {
|
||||||
|
if (count < 3) rareBooks += count;
|
||||||
|
}
|
||||||
|
const rarityScore = years.length > 0 ? Math.round((rareBooks / years.length) * 100) : 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
oldestBook: oldest,
|
oldestBook: oldest,
|
||||||
newestBook: newest,
|
newestBook: newest,
|
||||||
@@ -355,7 +389,9 @@ export class PublicationTimelineChartComponent implements OnInit, OnDestroy {
|
|||||||
peakDecade,
|
peakDecade,
|
||||||
peakDecadeCount,
|
peakDecadeCount,
|
||||||
centuryBreakdown: {c21, c20, older},
|
centuryBreakdown: {c21, c20, older},
|
||||||
decadesCovered: decadeCounts.size
|
goldenEra,
|
||||||
|
mostCommonYear,
|
||||||
|
rarityScore
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -57,13 +57,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.insight-value {
|
.insight-value {
|
||||||
font-size: 1.4rem;
|
font-size: 1.5rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--text-color, #ffffff);
|
color: var(--text-color, #ffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
.insight-detail {
|
.insight-detail {
|
||||||
font-size: 0.7rem;
|
font-size: 0.75rem;
|
||||||
color: var(--text-secondary-color);
|
color: var(--text-secondary-color);
|
||||||
margin-top: 0.25rem;
|
margin-top: 0.25rem;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|||||||
@@ -87,8 +87,12 @@
|
|||||||
"insightYearsOfLiterature": "years of literature",
|
"insightYearsOfLiterature": "years of literature",
|
||||||
"insightPeakDecade": "Peak Decade",
|
"insightPeakDecade": "Peak Decade",
|
||||||
"insightPeakDecadeBooks": "{{ count }} books",
|
"insightPeakDecadeBooks": "{{ count }} books",
|
||||||
"insightDecadesCovered": "Decades Covered",
|
"insightGoldenEra": "Golden Era",
|
||||||
"insightDifferentEras": "different eras"
|
"insightGoldenEraRange": "{{ count }} books",
|
||||||
|
"insightMostCommonYear": "Most Common Year",
|
||||||
|
"insightMostCommonYearBooks": "{{ count }} books",
|
||||||
|
"insightRarityScore": "Rarity Score",
|
||||||
|
"insightRarePicks": "rare picks"
|
||||||
},
|
},
|
||||||
"publicationTrend": {
|
"publicationTrend": {
|
||||||
"title": "Publication Trend",
|
"title": "Publication Trend",
|
||||||
|
|||||||
@@ -87,8 +87,12 @@
|
|||||||
"insightYearsOfLiterature": "anos de literatura",
|
"insightYearsOfLiterature": "anos de literatura",
|
||||||
"insightPeakDecade": "Decada pico",
|
"insightPeakDecade": "Decada pico",
|
||||||
"insightPeakDecadeBooks": "{{ count }} libros",
|
"insightPeakDecadeBooks": "{{ count }} libros",
|
||||||
"insightDecadesCovered": "Decadas cubiertas",
|
"insightGoldenEra": "Epoca dorada",
|
||||||
"insightDifferentEras": "diferentes epocas"
|
"insightGoldenEraRange": "{{ count }} libros",
|
||||||
|
"insightMostCommonYear": "Ano mas comun",
|
||||||
|
"insightMostCommonYearBooks": "{{ count }} libros",
|
||||||
|
"insightRarityScore": "Puntuacion de rareza",
|
||||||
|
"insightRarePicks": "selecciones raras"
|
||||||
},
|
},
|
||||||
"publicationTrend": {
|
"publicationTrend": {
|
||||||
"title": "Tendencia de publicacion",
|
"title": "Tendencia de publicacion",
|
||||||
|
|||||||
Reference in New Issue
Block a user