diff --git a/webapp/src/app/api/api/ranking.service.ts b/webapp/src/app/api/api/ranking.service.ts index 444051ba..872b7f22 100644 --- a/webapp/src/app/api/api/ranking.service.ts +++ b/webapp/src/app/api/api/ranking.service.ts @@ -34,6 +34,8 @@ import { AuthorYearlyWorks } from '../model/authorYearlyWorks'; import { AuthorCorrespondingCount } from '../model/authorCorrespondingCount'; // @ts-ignore import { AuthorImpactStats } from '../model/authorImpactStats'; +// @ts-ignore +import { AuthorTopicStats } from '../model/authorTopicStats'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -517,4 +519,120 @@ export class RankingService extends BaseService { }, ); } + + /** + * Section 1: combined stats over each selected author\'s topic-filtered works. + * @endpoint post /api/rank/topic-stats + * @param rankSelectedAuthorRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public topicStats( + rankSelectedAuthorRequest: RankSelectedAuthorRequest, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public topicStats( + rankSelectedAuthorRequest: RankSelectedAuthorRequest, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>>; + public topicStats( + rankSelectedAuthorRequest: RankSelectedAuthorRequest, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>>; + public topicStats( + rankSelectedAuthorRequest: RankSelectedAuthorRequest, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if ( + rankSelectedAuthorRequest === null || + rankSelectedAuthorRequest === undefined + ) { + throw new Error( + 'Required parameter rankSelectedAuthorRequest was null or undefined when calling topicStats.', + ); + } + + let localVarHeaders = this.defaultHeaders; + + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); + } + + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + const consumes: string[] = ['application/json']; + const httpContentTypeSelected: string | undefined = + this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Content-Type', + httpContentTypeSelected, + ); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/rank/topic-stats`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request>( + 'post', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: rankSelectedAuthorRequest, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } } diff --git a/webapp/src/app/api/model/authorTopicStats.ts b/webapp/src/app/api/model/authorTopicStats.ts new file mode 100644 index 00000000..c66fc0ad --- /dev/null +++ b/webapp/src/app/api/model/authorTopicStats.ts @@ -0,0 +1,40 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +export interface AuthorTopicStats { + /** + * The OpenAlex ID of the author. + */ + author_id: string; + /** + * The name of the author. + */ + display_name: string; + /** + * Number of the author\'s works matching the topic filter. + */ + works_total: number; + /** + * Number of the author\'s topic works where they are the corresponding author. + */ + corresponding_count: number; + /** + * Average field-normalized citation percentile (0-1) over the author\'s topic works. + */ + avg_percentile: number; + /** + * Number of the author\'s topic works in the top 1% most-cited. + */ + top1_count: number; + /** + * Number of the author\'s topic works in the top 10% most-cited. + */ + top10_count: number; +} diff --git a/webapp/src/app/api/model/models.ts b/webapp/src/app/api/model/models.ts index 32961a18..cf57b180 100644 --- a/webapp/src/app/api/model/models.ts +++ b/webapp/src/app/api/model/models.ts @@ -223,3 +223,4 @@ export * from './rankSelectedAuthorRequest'; export * from './authorYearlyWorks'; export * from './authorCorrespondingCount'; export * from './authorImpactStats'; +export * from './authorTopicStats'; diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index 3c444350..21412585 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -36,9 +36,9 @@ } @else if (!hasData()) {

Keine Daten für die ausgewählten Autoren.

} @else { - +
-

Kennzahlen im Vergleich

+

Kennzahlen zu den Keywords

Bester Wert je Zeile ist hervorgehoben. „–“ bedeutet, dass der Wert für diese:n Autor:in nicht vorliegt. @@ -85,54 +85,5 @@

- - -
-

Werke pro Jahr

-
-
- - -
-
-

Werke gesamt (Thema)

-
-
- -
-

Corresponding-Author-Werke

-
-
- -
-

Ø Impact-Perzentil (0–1)

-
-
- -
-

Hoch zitierte Werke

-
-
-
} diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.scss b/webapp/src/app/modules/compare-authors/compare-authors.component.scss index e7f077f7..99bfcadf 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.scss +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.scss @@ -176,28 +176,8 @@ color: var(--sg-text-soft, #8a95b3); } -/* ---- charts ---- */ -.chart-container { - height: 420px; - width: 100%; -} - -.chart-container--sm { - height: 300px; -} - -.chart-grid { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 18px; -} - @media (max-width: 900px) { .compare-layout { padding: 20px 16px 32px; } - - .chart-grid { - grid-template-columns: 1fr; - } } diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.ts b/webapp/src/app/modules/compare-authors/compare-authors.component.ts index b7d2984e..5dcc88ac 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.ts +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.ts @@ -2,36 +2,11 @@ import { Component, OnInit, computed, inject, signal } from '@angular/core'; import { DecimalPipe } from '@angular/common'; import { ActivatedRoute } from '@angular/router'; import { MatIconModule } from '@angular/material/icon'; -import { EChartsOption } from 'echarts'; -import { NgxEchartsDirective } from 'ngx-echarts'; -import { - AuthorCorrespondingCount, - AuthorImpactStats, - AuthorYearlyWorks, - RankingService, -} from '../../api'; +import { AuthorTopicStats, RankingService } from '../../api'; const AUTHOR_COLORS = ['#1565c0', '#e6550d', '#2ca02c', '#9467bd']; -const AXIS_LABEL = { color: '#4b5563', fontFamily: 'Open Sans' }; -const AXIS_LINE = { lineStyle: { color: '#e5e7eb' } }; -const SPLIT_LINE = { lineStyle: { color: '#f3f4f6' } }; -const TOOLTIP = { - backgroundColor: 'rgba(255,255,255,0.98)', - borderColor: '#e5e7eb', - borderWidth: 1, - textStyle: { color: '#374151', fontFamily: 'Open Sans' }, - extraCssText: 'border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,0.15);', -}; -const BAR_LABEL = { - show: true, - position: 'top' as const, - color: '#374151', - fontFamily: 'Open Sans', - fontWeight: 600, -}; - interface AuthorSummary { authorId: string; name: string; @@ -58,7 +33,7 @@ interface MetricRow { @Component({ selector: 'app-compare-authors', standalone: true, - imports: [DecimalPipe, MatIconModule, NgxEchartsDirective], + imports: [DecimalPipe, MatIconModule], templateUrl: './compare-authors.component.html', styleUrl: './compare-authors.component.scss', }) @@ -71,37 +46,27 @@ export class CompareAuthorsComponent implements OnInit { // full OpenAlex ids in the requested order — the source of truth for colour + order readonly authorIds = signal([]); - readonly data = signal([]); - readonly corresponding = signal([]); - readonly impact = signal([]); + // section 1: combined topic stats, one entry per author + readonly topic = signal([]); readonly loading = signal(false); - // merges the three endpoints into one row per author, in the requested order + // maps the topic stats onto one row per author, in the requested order readonly summary = computed(() => { - const yearly = new Map(this.data().map((a) => [a.author_id, a])); - const corr = new Map(this.corresponding().map((a) => [a.author_id, a])); - const imp = new Map(this.impact().map((a) => [a.author_id, a])); + const stats = new Map(this.topic().map((a) => [a.author_id, a])); return this.authorIds().map((id, index) => { - const y = yearly.get(id); - const c = corr.get(id); - const im = imp.get(id); - const name = - y?.display_name ?? - c?.display_name ?? - im?.display_name ?? - id.split('/').pop() ?? - id; + const s = stats.get(id); + const name = s?.display_name ?? id.split('/').pop() ?? id; return { authorId: id, name, color: AUTHOR_COLORS[index % AUTHOR_COLORS.length], - totalWorks: y ? y.years.reduce((sum, e) => sum + e.count, 0) : 0, - corresponding: c ? c.value : null, - avgPercentile: im ? im.avg_percentile : null, - top10: im ? im.top10_count : null, - top1: im ? im.top1_count : null, + totalWorks: s ? s.works_total : 0, + corresponding: s ? s.corresponding_count : null, + avgPercentile: s ? s.avg_percentile : null, + top10: s ? s.top10_count : null, + top1: s ? s.top1_count : null, }; }); }); @@ -158,162 +123,11 @@ export class CompareAuthorsComponent implements OnInit { ]; }); - // line chart: works per year, one line per author - readonly chartOption = computed(() => { - const authors = this.summary(); - const yearly = new Map(this.data().map((a) => [a.author_id, a])); - if (authors.length === 0) { - return {}; - } - - const yearSet = new Set(); - for (const author of this.data()) { - for (const entry of author.years) { - yearSet.add(entry.year); - } - } - const years = Array.from(yearSet).sort((a, b) => a - b); - - const series = authors.map((author) => { - const source = yearly.get(author.authorId); - const countByYear = new Map(); - for (const entry of source?.years ?? []) { - countByYear.set(entry.year, entry.count); - } - return { - name: author.name, - type: 'line', - smooth: true, - symbolSize: 8, - emphasis: { focus: 'series' }, - lineStyle: { color: author.color, width: 2.5 }, - itemStyle: { color: author.color }, - data: years.map((year) => countByYear.get(year) ?? 0), - }; - }); - - return { - color: authors.map((a) => a.color), - tooltip: { trigger: 'axis', ...TOOLTIP }, - grid: { left: '3%', right: '4%', top: 16, bottom: 8, containLabel: true }, - xAxis: { - type: 'category', - boundaryGap: false, - data: years.map(String), - axisLabel: AXIS_LABEL, - axisLine: AXIS_LINE, - axisTick: { show: false }, - }, - yAxis: { - type: 'value', - name: 'Werke', - nameTextStyle: AXIS_LABEL, - axisLabel: AXIS_LABEL, - splitLine: SPLIT_LINE, - }, - series: series as unknown as EChartsOption['series'], - }; - }); - - readonly totalWorksOption = computed(() => - this.singleMetricBar((a) => a.totalWorks), - ); - readonly correspondingOption = computed(() => - this.singleMetricBar((a) => a.corresponding), - ); - readonly percentileOption = computed(() => - this.singleMetricBar((a) => a.avgPercentile, { max: 1, decimals: true }), - ); - - // grouped bars: top-10% vs top-1% works, one coloured bar per author in each group - readonly topCitedOption = computed(() => { - const authors = this.summary(); - if (authors.length === 0) { - return {}; - } - - const series = authors.map((author) => ({ - name: author.name, - type: 'bar', - itemStyle: { color: author.color, borderRadius: [4, 4, 0, 0] }, - label: BAR_LABEL, - data: [author.top10 ?? 0, author.top1 ?? 0], - })); - - return { - color: authors.map((a) => a.color), - tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, ...TOOLTIP }, - grid: { left: '3%', right: '4%', top: 24, bottom: 8, containLabel: true }, - xAxis: { - type: 'category', - data: ['Top 10%', 'Top 1%'], - axisLabel: AXIS_LABEL, - axisLine: AXIS_LINE, - axisTick: { show: false }, - }, - yAxis: { - type: 'value', - axisLabel: AXIS_LABEL, - splitLine: SPLIT_LINE, - }, - series: series as unknown as EChartsOption['series'], - }; - }); - - private singleMetricBar( - select: (a: AuthorSummary) => number | null, - opts: { max?: number; decimals?: boolean } = {}, - ): EChartsOption { - const authors = this.summary(); - if (authors.length === 0) { - return {}; - } - - const bars = authors.map((author) => ({ - value: select(author) ?? 0, - itemStyle: { color: author.color, borderRadius: [4, 4, 0, 0] }, - })); - - return { - tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, ...TOOLTIP }, - grid: { left: '3%', right: '4%', top: 24, bottom: 8, containLabel: true }, - xAxis: { - type: 'category', - data: authors.map((a) => this.truncate(a.name)), - axisLabel: { ...AXIS_LABEL, interval: 0, hideOverlap: true }, - axisLine: AXIS_LINE, - axisTick: { show: false }, - }, - yAxis: { - type: 'value', - max: opts.max, - axisLabel: AXIS_LABEL, - splitLine: SPLIT_LINE, - }, - series: [ - { - type: 'bar', - barMaxWidth: 72, - data: bars, - label: { - ...BAR_LABEL, - formatter: opts.decimals - ? (p: { value: number }) => p.value.toFixed(2) - : undefined, - }, - }, - ] as unknown as EChartsOption['series'], - }; - } - - private truncate(name: string): string { - return name.length > 18 ? `${name.slice(0, 17)}…` : name; - } - ngOnInit(): void { // everything is read from the URL so a shared link lands on the same view const rawAuthors = this.route.snapshot.queryParamMap.get('authors') ?? ''; const rawKeywords = this.route.snapshot.queryParamMap.get('keywords') ?? ''; + const rawOperator = this.route.snapshot.queryParamMap.get('operator'); const rawPubType = this.route.snapshot.queryParamMap.get('pubType'); const rawTFrom = this.route.snapshot.queryParamMap.get('tFrom'); const rawTTo = this.route.snapshot.queryParamMap.get('tTo'); @@ -326,6 +140,7 @@ export class CompareAuthorsComponent implements OnInit { return; } + const operator = rawOperator === 'or' ? 'or' : 'and'; const publication_types = rawPubType ? this.parseList(rawPubType) : undefined; @@ -340,42 +155,23 @@ export class CompareAuthorsComponent implements OnInit { const requestPayload = { author_ids: fullIds, keywords: keywords, + operator: operator, publication_types: publication_types, timespan: timespan, }; this.loading.set(true); - this.rankingService.rankSelectedAuthor(requestPayload).subscribe({ + this.rankingService.topicStats(requestPayload).subscribe({ next: (results) => { - this.data.set(results); + this.topic.set(results); this.loading.set(false); }, error: (error) => { console.error(error); - this.data.set([]); + this.topic.set([]); this.loading.set(false); }, }); - - this.rankingService.correspondingAuthors(requestPayload).subscribe({ - next: (results) => { - this.corresponding.set(results); - }, - error: (error) => { - console.error(error); - this.corresponding.set([]); - }, - }); - - this.rankingService.impactStats(requestPayload).subscribe({ - next: (results) => { - this.impact.set(results); - }, - error: (error) => { - console.error(error); - this.impact.set([]); - }, - }); } private parseList(raw: string): string[] { diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts index 4fa91fc8..f827ba08 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts @@ -423,6 +423,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { queryParams: { authors: this.selectedIds().join(','), keywords: this.state.keywords().join(','), + operator: this.keywordOperator() === 'or' ? 'or' : null, pubType: this.selectedPubTypes().length > 0 ? this.selectedPubTypes().join(',')