File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,16 @@ <h3>Statistics</h3>
257257 const valueDisplay = document . getElementById ( valueId ) ;
258258 slider . addEventListener ( 'input' , ( e ) => {
259259 valueDisplay . textContent = e . target . value ;
260+
261+ if ( sliderId === 'top-words' && app . currentResults ) {
262+ const viewMode = document . getElementById ( 'view-mode' ) . value ;
263+ if ( viewMode === 'overview' ) {
264+ app . visualizer . renderOverview ( app . currentResults ) ;
265+ } else if ( viewMode === 'intertopic' ) {
266+ const topicIdx = parseInt ( document . getElementById ( 'selected-topic' ) . value ) || 0 ;
267+ app . visualizer . showTopicWordBars ( topicIdx === 'all' ? 0 : topicIdx , app . currentResults ) ;
268+ }
269+ }
260270 } ) ;
261271 }
262272
Original file line number Diff line number Diff line change @@ -51,16 +51,14 @@ export class TopicVisualizer {
5151 } ) ;
5252 }
5353
54- /**
55- * Create a topic card element
56- */
5754 createTopicCard ( topic , topicIdx , results ) {
5855 const card = document . createElement ( 'div' ) ;
5956 card . className = 'topic-card' ;
6057 card . style . borderLeftColor = this . colors [ topicIdx % this . colors . length ] ;
6158 card . style . borderLeftWidth = '4px' ;
6259
63- const topWords = topic . slice ( 0 , 10 ) ;
60+ const topWordsCount = parseInt ( document . getElementById ( 'top-words' ) ?. value || 10 ) ;
61+ const topWords = topic . slice ( 0 , topWordsCount ) ;
6462
6563 // Count documents where this is the dominant topic
6664 let dominantCount = 0 ;
@@ -396,11 +394,9 @@ export class TopicVisualizer {
396394 return coords ;
397395 }
398396
399- /**
400- * Show top words for a topic as horizontal bars
401- */
402397 showTopicWordBars ( topicIdx , results ) {
403- const topic = results . topics [ topicIdx ] . slice ( 0 , 15 ) ;
398+ const topWordsCount = parseInt ( document . getElementById ( 'top-words' ) ?. value || 10 ) ;
399+ const topic = results . topics [ topicIdx ] . slice ( 0 , topWordsCount ) ;
404400
405401 const trace = {
406402 y : topic . map ( w => w . word ) . reverse ( ) ,
You can’t perform that action at this time.
0 commit comments