Skip to content

Word Cloud

The word cloud is a useful visualization to see the weight of certain terms (words) in a given data set. To visualize a simple word cloud you can write the following code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
// Define the metrics to be used
let metrics = [];
let metric = cf.Metric('value', 'avg');
// const countMetric = cf.Metric('count');

// define attribute to group by
let groups = [];
let group = cf.Attribute('node')
                .limit(50)
                .sort('asc', 'node');

metrics.push(metric);
groups.push(group);

let myChart = cf.provider('Elasticsearch')
                .source('family')
                .groupby(...groups)
                .metrics(...metrics)
                .graph('Word Cloud')
                .element('chart')
                .execute();

Previous code will render a Word Cloud like follow:

WC

Custom configurations

  1. fontFamily: to define the font family. By default 'sans-serif'
  2. fontWeight: to define the font weight. By default 'normal'
  3. sizeRange: to define the size range depending on main metric. By default: [10, 40]
  4. color: By default each word is colored with a random color of the theme palette but could be specified a custom metric color in the same way that in other charts. Ej. Color Documentation