import React from 'react'; import NumberRangeSelector from 'wdk-client/Components/InputControls/NumberRangeSelector'; import RadioList from 'wdk-client/Components/InputControls/RadioList'; import { makeClassNameHelper, pure } from 'wdk-client/Utils/ComponentUtils'; import { Seq } from 'wdk-client/Utils/IterableUtils'; import { RankRange, Sort, } from 'wdk-client/Actions/WordCloudAnalysisActions'; import 'wdk-client/Views/AttributeAnalysis/WordCloudAnalysis/WordCloudAnalysis.scss'; export interface Tag { word: string; count: number; }; const cx = makeClassNameHelper('WordCloudAnalysis'); const sortItems = [ { name: 'sort', value: 'rank', display: 'Rank' }, { name: 'sort', value: 'alpha', display: 'A-Z' } ]; type WordCloudProps = { tags: Tag[]; rankRange: RankRange; sort: Sort; onRankRangeChange: (range: RankRange) => void; onSortChange: (sort: string) => void; } export const WordCloud = pure(({ tags, rankRange, sort, onRankRangeChange, onSortChange }: WordCloudProps) => { const tagSubset = Seq.from(tags) .take(rankRange.max) .drop(rankRange.min - 1) .orderBy(tag => sort === 'alpha' ? tag.word : tag.count, sort !== 'alpha'); const subsetMax = Math.max(...tagSubset.map(tag => tag.count)); return (