fix/wordcloud-legend-highlight #283
+5
@@ -23,6 +23,7 @@ import {
|
||||
getTopicLegendFieldId,
|
||||
getTopicLegendSubfieldId,
|
||||
TopicLegendGroup,
|
||||
TopicLegendSelectionState,
|
||||
TopicLegendSubfieldSelection,
|
||||
TopicLegendTopic,
|
||||
toggleTopicLegendFieldSelection,
|
||||
@@ -130,6 +131,8 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
@Output() loadEarlierYears = new EventEmitter<void>();
|
||||
@Output() subfieldLegendVisibleChange = new EventEmitter<boolean>();
|
||||
@Output() subfieldLegendExpandedChange = new EventEmitter<boolean>();
|
||||
@Output() legendSelectionChange =
|
||||
new EventEmitter<TopicLegendSelectionState>();
|
||||
|
||||
timelineViewMode: TimelineViewMode = 'years';
|
||||
|
||||
@@ -412,6 +415,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
|
||||
this.activeLegendFieldIds = selection.fieldIds;
|
||||
this.activeLegendSubfieldIds = selection.subfieldIds;
|
||||
this.legendSelectionChange.emit(selection);
|
||||
}
|
||||
|
||||
onLegendSubfieldToggle(selection: TopicLegendSubfieldSelection): void {
|
||||
@@ -423,6 +427,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
|
||||
this.activeLegendFieldIds = nextSelection.fieldIds;
|
||||
this.activeLegendSubfieldIds = nextSelection.subfieldIds;
|
||||
this.legendSelectionChange.emit(nextSelection);
|
||||
}
|
||||
|
||||
isTopicActiveByLegend(topic: TopicTimelineTopic): boolean {
|
||||
|
||||
+1
@@ -10,6 +10,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="word-cloud-word"
|
||||
[class.word-cloud-word-active]="isWordActiveByLegend(word)"
|
||||
[style.color]="word.color"
|
||||
[style.fontSize.px]="word.fontSize"
|
||||
[style.fontWeight]="word.fontWeight"
|
||||
|
||||
+11
-2
@@ -20,12 +20,16 @@
|
||||
appearance: none;
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 0;
|
||||
padding: 0.1em 0.3em;
|
||||
margin: 0;
|
||||
border-radius: 6px;
|
||||
font-family: 'Open Sans', Arial, sans-serif;
|
||||
line-height: 1.1;
|
||||
cursor: pointer;
|
||||
transition: transform 0.15s ease;
|
||||
transition:
|
||||
transform 0.15s ease,
|
||||
background-color 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
|
||||
&:hover:not(:disabled),
|
||||
&:focus-visible {
|
||||
@@ -38,6 +42,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
.word-cloud-word-active {
|
||||
background: color-mix(in srgb, currentColor 14%, transparent);
|
||||
box-shadow: inset 0 0 0 1.5px currentColor;
|
||||
}
|
||||
|
||||
.word-cloud-state {
|
||||
margin: 0;
|
||||
min-height: 420px;
|
||||
|
||||
+21
-1
@@ -3,7 +3,11 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { ComponentTooltipDirective } from '../../../../directives/component-tooltip.directive';
|
||||
import { AppTopicTooltipComponent } from '../../../../shared/ui/app-topic-tooltip/app-topic-tooltip.component';
|
||||
import { topicHierarchyColor } from '../../../../resolvers/utils/topic-colors';
|
||||
import { TopicLegendTopic } from '../../../../resolvers/utils/topic-legend';
|
||||
import {
|
||||
getTopicLegendFieldId,
|
||||
getTopicLegendSubfieldId,
|
||||
TopicLegendTopic,
|
||||
} from '../../../../resolvers/utils/topic-legend';
|
||||
|
||||
export interface WordCloudTopicOccurrence {
|
||||
name: string;
|
||||
@@ -21,6 +25,8 @@ export interface WordCloudWord {
|
||||
name: string;
|
||||
topicId: string;
|
||||
rawTopicId: string;
|
||||
fieldLegendId: string;
|
||||
subfieldLegendId: string;
|
||||
color: string;
|
||||
fontSize: number;
|
||||
fontWeight: number;
|
||||
@@ -92,6 +98,10 @@ export function buildResearchWordcloud(
|
||||
name,
|
||||
topicId: legendTopic?.id ?? '',
|
||||
rawTopicId: stripOpenAlexId(legendTopic?.id),
|
||||
fieldLegendId: legendTopic ? getTopicLegendFieldId(legendTopic) : '',
|
||||
subfieldLegendId: legendTopic
|
||||
? getTopicLegendSubfieldId(legendTopic)
|
||||
: '',
|
||||
color: topicHierarchyColor(legendTopic),
|
||||
fontSize: Math.round(
|
||||
minimumFontSize + scale * (maximumFontSize - minimumFontSize),
|
||||
@@ -151,6 +161,8 @@ export class ResearchWordcloudComponent {
|
||||
@Input() words: WordCloudWord[] = [];
|
||||
@Input() loading = false;
|
||||
@Input() loadFailed = false;
|
||||
@Input() activeFieldIds: ReadonlySet<string> = new Set();
|
||||
@Input() activeSubfieldIds: ReadonlySet<string> = new Set();
|
||||
|
||||
@Output() wordSelect = new EventEmitter<WordCloudWord>();
|
||||
|
||||
@@ -161,4 +173,12 @@ export class ResearchWordcloudComponent {
|
||||
|
||||
this.wordSelect.emit(word);
|
||||
}
|
||||
|
||||
isWordActiveByLegend(word: WordCloudWord): boolean {
|
||||
return (
|
||||
this.activeFieldIds.has(word.fieldLegendId) ||
|
||||
(word.subfieldLegendId.length > 0 &&
|
||||
this.activeSubfieldIds.has(word.subfieldLegendId))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,15 @@
|
||||
(subfieldLegendExpandedChange)="onTimelineLegendExpandedChange($event)"
|
||||
(topicSelect)="onTimelineTopicSelect($event)"
|
||||
(yearSelect)="onTimelineYearSelect($event)"
|
||||
(loadEarlierYears)="onTimelineLoadEarlierYears()">
|
||||
(loadEarlierYears)="onTimelineLoadEarlierYears()"
|
||||
(legendSelectionChange)="onLegendSelectionChange($event)">
|
||||
<app-research-wordcloud
|
||||
timeline-wordcloud-content
|
||||
[words]="wordCloudWords"
|
||||
[loading]="loadingWordCloud"
|
||||
[loadFailed]="wordCloudLoadFailed"
|
||||
[activeFieldIds]="activeLegendFieldIds"
|
||||
[activeSubfieldIds]="activeLegendSubfieldIds"
|
||||
(wordSelect)="onWordClick($event)" />
|
||||
</app-research-timeline>
|
||||
</section>
|
||||
|
||||
@@ -19,7 +19,10 @@ import {
|
||||
WordCloudWord,
|
||||
} from './components/research-wordcloud/research-wordcloud.component';
|
||||
import { workQueryParamKeys } from '../../resolvers/work-page.resolver';
|
||||
import { TopicLegendTopic } from '../../resolvers/utils/topic-legend';
|
||||
import {
|
||||
TopicLegendSelectionState,
|
||||
TopicLegendTopic,
|
||||
} from '../../resolvers/utils/topic-legend';
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-overview',
|
||||
@@ -64,6 +67,8 @@ export class PersonOverviewComponent implements OnInit {
|
||||
wordCloudLegendTopics: TopicLegendTopic[] = [];
|
||||
loadingWordCloud = false;
|
||||
wordCloudLoadFailed = false;
|
||||
activeLegendFieldIds: ReadonlySet<string> = new Set();
|
||||
activeLegendSubfieldIds: ReadonlySet<string> = new Set();
|
||||
|
||||
private rawTopicOccurrences: WordCloudTopicOccurrence[] = [];
|
||||
|
||||
@@ -210,6 +215,11 @@ export class PersonOverviewComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onLegendSelectionChange(selection: TopicLegendSelectionState): void {
|
||||
this.activeLegendFieldIds = selection.fieldIds;
|
||||
this.activeLegendSubfieldIds = selection.subfieldIds;
|
||||
}
|
||||
|
||||
private findAuthorId(paramMaps: readonly ParamMap[]): string {
|
||||
return (
|
||||
paramMaps
|
||||
|
||||
Reference in New Issue
Block a user