orderedWordCloud = (theWidth, data, termColor, exent, id) => {
const innerWidth = theWidth - (2 * config.padding);
const svg = d3.create("svg")
.attr('height', config.height)
.attr('width', theWidth)
.attr('id', id || 'ordered-word-cloud')
.attr('class', 'word-cloud');
let y = config.height;
let wordNodes;
const wordListHeight = config.height - (2 * config.padding);
const wordWrapper = svg.append('g')
.attr('transform', `translate(${2 * config.padding},0)`);
const sizeRange = { min: config.minFontSize, max: config.maxFontSize };
const fullExtent = exent || d3.extent(data, d => d.tfnorm)
while ((y >= wordListHeight) && (sizeRange.max > sizeRange.min)) {
wordNodes = wordWrapper.selectAll('text')
.data(data, d => d.term)
.enter()
.append('text')
.attr('class', '')
.attr('fill', termColor)
.attr('font-family', 'Lato, Helvetica, sans')
.classed('word', true)
.classed('hide', d => d.display === false)
.classed('show', d => d.display !== false)
.classed('selected', d => d.term === config.selectedTerm)
.attr('font-size', d => fontSizeComputer(d, fullExtent, sizeRange))
.text(d => d.term)
.attr('font-weight', 'bold')
.on('mouseover', (d) => {
const { event } = d3;
d3.select(event.target).attr('fill', config.linkColor)
.attr('cursor', 'pointer');
})
.on('mouseout', () => {
const { event } = d3;
d3.select(event.target).attr('fill', config.textColor)
.attr('cursor', 'arrow');
});
y = 0;
const leftHeight = listCloudLayout(wordNodes, innerWidth, fullExtent, sizeRange);
y = Math.max(y, leftHeight);
sizeRange.max -= 1;
}
return svg.node();
}