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 settings

  1. fontFamily: Defines the font family. Its default value is sans-serif.
  2. fontWeight: Defines the font weight. Its default value is normal.
  3. sizeRange: Defines the size range depending on main metric. Its default value is [10, 40].
  4. color: By default each word is colored with a random color of the theme palette. You can also specify a metric to drive color in the same way as in other standard charts. Please refer to the Color Documentation for more information.
  5. verticalWords: If false, the words are displayed only horizontally. If true, the words are displayed in vertical and horizontal orientation. Its defalt value is true. The example below shows how to set the verticalWords settings to false.
1
.set("verticalWords", false) // to display the words only horizontally