Skip to content

Commit 27af0f7

Browse files
committed
Select segment
1 parent d0b753a commit 27af0f7

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

app/scripts/components/wordpicture/word-picture-column.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ angular.module("korpApp").component("wordPictureColumn", {
6565
const $ctrl = this as WordPictureColumnController
6666

6767
$ctrl.$onChanges = (changes) => {
68-
if (changes.limit?.currentValue || changes.items?.currentValue) {
68+
if (changes.limit?.currentValue || changes.items?.currentValue || changes.segment?.currentValue) {
6969
$ctrl.rows = $ctrl.items.filter((item) => item.stats[$ctrl.segment]).slice(0, Number($ctrl.limit))
7070
}
7171
}

app/scripts/components/wordpicture/word-picture.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,32 @@ type WordPictureScope = IScope & {
1616
fromLemgram: (word: string) => string
1717
isLemgram: (word: string) => boolean
1818
lemgramToHtml: (word: string) => string
19+
segmentIndex: number
1920
}
2021

2122
angular.module("korpApp").component("wordPicture", {
2223
template: html`
24+
<div ng-show="$ctrl.data.segments.length > 1" class="my-2">
25+
{{'word_pic_segment' | loc:$root.lang}}: {{$ctrl.data.segments[segmentIndex]}}
26+
27+
<div class="w-full max-w-screen-sm">
28+
<input
29+
type="range"
30+
max="{{$ctrl.data.segments.length - 1}}"
31+
list="wordpic-trend-markers"
32+
ng-model="segmentIndex"
33+
class="w-full"
34+
/>
35+
<datalist id="wordpic-trend-markers">
36+
<option
37+
ng-repeat="segment in $ctrl.data.segments"
38+
value="{{$index}}"
39+
label="{{ segment }}"
40+
></option>
41+
</datalist>
42+
</div>
43+
</div>
44+
2345
<div class="content_target flex flex-wrap gap-4 items-start">
2446
<section class="radialBkg p-2 border border-gray-400" ng-repeat="section in $ctrl.data.getData()">
2547
<h2 class="text-xl mb-4">
@@ -47,7 +69,7 @@ angular.module("korpApp").component("wordPicture", {
4769
css-class="column.config.css_class"
4870
items="column.rows"
4971
limit="$ctrl.limit"
50-
segment="$ctrl.data.segments[0]"
72+
segment="$ctrl.data.segments[segmentIndex]"
5173
show-word-class="$ctrl.showWordClass"
5274
sort="$ctrl.sort"
5375
></word-picture-column>
@@ -66,6 +88,13 @@ angular.module("korpApp").component("wordPicture", {
6688
function ($scope: WordPictureScope) {
6789
const $ctrl = this as WordPictureController
6890

91+
$ctrl.$onChanges = (changes) => {
92+
if (changes.data?.currentValue) {
93+
// Set to most last segment (most recent timespan)
94+
$scope.segmentIndex = $ctrl.data.segments.length - 1
95+
}
96+
}
97+
6998
$scope.fromLemgram = (word) => Lemgram.parse(word)?.form || word
7099
$scope.isLemgram = (id) => !!Lemgram.parse(id)
71100
$scope.lemgramToHtml = (id) => Lemgram.parse(id)!.toHtml()

app/translations/locale-eng.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"word_pic_description": "The Word picture shows words that tend to co-occur in syntactic relations with the search word.",
105105
"word_pic_result_description": "The part of speech of the search word determines what relations to show. Each list collects words that occur in the selected corpora and in the given relation to the search word.",
106106
"word_pic_split": "Show trends",
107+
"word_pic_segment": "Segment",
107108
"word_pic_show_all": "Show all hits",
108109
"word_pic_show_some": "Show up to",
109110
"word_pic_hits": "hits",

app/translations/locale-swe.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"word_pic_description": "I ordbilden visas vilka ord som tenderar att förekomma i syntaktiska relationer med sökordet.",
9797
"word_pic_result_description": "Vilka relationer som visas beror på sökordets ordklass. Varje lista innehåller ord som i det valda korpusmaterialet står i den givna relationen med sökordet.",
9898
"word_pic_split": "Visa trender",
99+
"word_pic_segment": "Segment",
99100
"word_pic_show_all": "Visa alla träffar",
100101
"word_pic_show_some": "Visa upp till",
101102
"word_pic_hits": "träffar",

0 commit comments

Comments
 (0)