Skip to content

Word Cloud


Required Components

Adding a word cloud requires the following components:

  • wDef = []
    • A list that establishes the chart's title, words, frequencies, and sentiments, based on the underlying dataframe or data node.
  • wOptions = []
    • A list of format options that changes the visual appearance of the chart.
  • dash.add_wordcloud()
    • The function that places the chart on a designated pane. The structure and formatting lists are passed into this function.

Note that the definition and options lists are simply Python lists and that their variable names can change.


Components Syntax

wDef

wDef = [ ["TITLE", "WORDS", "FREQUENCIES", "SENTIMENTS" ] ]

The wDef ("word definition") list establishes the chart's overall structure by defining the series' name, words list, word frequencies, and sentiment values.

  • "TITLE"
    • A string value that gives a name to the series.
  • "WORDS"
    • A cell or list reference that determines the words on the word cloud.
    • Example: "=DF1!B:B"
  • "FREQUENCIES"
    • A cell or list reference that determines the word frequencies on the word cloud. The higher the frequency, the larger the word appears.
    • Example: "=DF1!E:E"
  • "SENTIMENTS"
    • A cell or list reference that determines the sentiment for each word in the cloud.
    • Example: "=DF1!F:F"
    • Sentiment values should range from -1 to 1.


wOptions

wOptions = [
    ["Details", "ColorTheme",[0xaf4425,0x662e1c,0xc9a66b,0xebdcb2]],
    ["Details", "Layout", "ChartFill","Color",0x222222], # background to dark grey
    ["Format", "PreferHorizontal", .53],
    ["Format", "WordDensity", 1.5],
    ...
]

The wOptions list is a list of formatting options that changes the appearance of the chart. Each formatting item is enclosed in brackets [ ... ] and separated by commas. A full list of formatting options is available in the Word Cloud Format Options section.


dash.add_wordcloud()

dash.add_wordcloud("wcloud1", "TopPane", wDef, wOptions)

The dash.add_wordcloud() function adds the word cloud to a designated dashboard pane. This function takes the chart's name, the destination pane's name, and the definition and formatting lists as arguments.

  • "CHART_NAME"
    • The name you want to give the chart.
  • "PANE_NAME"
    • The name of a pane from the pane list (pList) that the chart should be placed on. The name provided for this argument should match a pane name from the pane list.
  • wDef
    • The definition list, which defines the chart's title, words, frequencies, and sentiments
  • wOptions
    • The options list, which defines the chart's visual appearance and formatting.


Code Example

# Module import
from row64tools.dash64 import dash64

# Dashboard save location
dash = dash64("/var/www/dashboards/temp/wordcloud.dash")

# Establish dashboard panes
pList = [
    ["Dashboard",       "",             "1600",     "900",  "y"],
    ["TopPane",         "Dashboard",    "*",        "*",    ""],    
    ["BottomPane",      "Dashboard",    "*",        "20%",  ""]
]
dash.Layout.set_panes(pList)

# Add and format a dataframe
dash.add_ramdb("/var/www/ramdb/live/RAMDB.Row64/Examples/City_Locations.ramdb","DF1")
dash.add_df("DF1", "BottomPane")
cWidths = dash.Sheets.Items[ dash.Sheets.get_sheet_ind("DF1") ].ColumnWidths
cWidths[0] = 250 # set the paragraph text columns to be wider
cWidths[1] = 300
paneDef = [ 
    ["Layout","Zoom",1.18], # set the dataframe pane to zoom in
    ["Layout","ShowTitle",False] # set the dataframe pane to hide the title
]
dash.set_pane_def("BottomPane",paneDef)

# Word cloud definition list
wDef = [ ["", "=DF1!B:B", "=DF1!E:E", "" ] ] # Title, Words, Frequencies, Sentiments

# Word cloud formatting list
wOptions = [
    ["Details", "ColorTheme",[0xaf4425,0x662e1c,0xc9a66b,0xebdcb2]],
    ["Details", "Layout", "ChartFill","Color",0x222222], # background to dark grey
    ["Format", "PreferHorizontal", .53],
    ["Format", "WordDensity", 1.5],
]

# Add the word cloud to the dashboard
dash.add_wordcloud("wcloud1", "TopPane", wDef, wOptions) 

# Save the dashboard
dash.save()


Word Cloud Format Options

The following tables list the available formatting options for word clouds. To format word clouds, include formatting items in the wOptions list. Each formatting item should be encapsulated in brackets [ ], and formatting items should be separated by commas. For an example of a wOptions list with multiple formatting items, please see the Code Example above.

General Formatting

Parameter Keys Value Type Example Description
"Format","Color"int - hex color["Format","Color",0x000000]Background Color of the Pane
"Format","CrossLinking"bool["Format","CrossLinking",False]False = Disable Cross filtering for this Pane
"Format","Pad"float["Format","Pad",.15]Percentage of Total Height/Width Padding on Pane
"Format","MaxSize"float["Format","MaxSize",1000]Max Number of Words to Display
"Format","PreferHorizontal"float["Format","PreferHorizontal", 0.55]Ratio or Words that WordCloud Will First Try To Place Horizontal: Between 0 - 1
"Format","WordDensity"float["Format","WordDensity", 0.55]Density of Words, Higher Is Denser. User Interface range is 0 - 3 but can go higher.


Series Data

(Index must be 0: a word cloud contains a single series).

Parameter Keys Value Type Example Description
"Series",0,"Words"string["Series",0,"Name","Enter Series Name"]Words List or Cell Reference
"Series",0,"Freqs"string["Series",0,"Labels","=DF1!B:B"]Frequencies List or Cell Reference
"Series",0,"Sents"string["Series",0,"Sents","=DF1!A:A"]Sentiment Values List or Cell Reference - between -1 to 1


Details

Parameter Keys Value Type Example Description
"Details","ColorTheme"[float,float,float,float]["Details", "ColorTheme",[0xaf4425,0x662e1c,0xc9a66b,0xebdcb2]]Color Theme For WordCloud
"Details","ShowTitle"bool["Details","ShowTitle",True]Show Chart Title
"Details","Title"string["Details","Title","Enter Chart Title"]String of Chart Title
"Details","TitleFont","Size"float["Details","TitleFont","Size",25]Font size of Title (if ShowTitle is True)
"Details","TitleFont","Color"int - hex color["Details","TitleFont","Color",0xFF000]Font Color of Title (if ShowTitle is True)
"Details","TitleFont","Bold"bool["Details","TitleFont","Bold",True]Font Bold of Title (if ShowTitle is True)
"Details","TitleFont","Italic"bool["Details","TitleFont","Italic",True]Font Italic of Title (if ShowTitle is True)
"Details","TitleFont","Underline"bool["Details","TitleFont","Underline",True]Font Underline of Title (if ShowTitle is True)
"Details","TitleFont","Alpha"float["Details","TitleFont","Alpha",.5]Font Transparency of Title (if ShowTitle is True)
"Details","TitlePos"[float,float]["Details","TitlePos",[.5,.05]]Chart Title x,y as a percentage of Pane Height/Width
"Details","Layout","RPadding"float["Details","Layout","RPadding",10.0]Chart Right Padding Inset In Addition To Pane Padding
"Details","Layout","LPadding"float["Details","Layout","LPadding",10.0]Chart Left Padding Inset In Addition To Pane Padding
"Details","Layout","TPadding"float["Details","Layout","TPadding",10.0]Chart Top Padding Inset In Addition To Pane Padding
"Details","Layout","BPadding"float["Details","Layout","BPadding",10.0]Chart Bottom Padding Inset In Addition To Pane Padding
"Details","Layout","HasChartBorder"bool["Details","Layout","HasChartBorder",True]Chart Border Around Chart Area (Does Not Include Label Area)
"Details","Layout","ChartBorder","Color"int - hex color["Details","Layout","ChartBorder","Color",0xFF000]Line color of Chart Border
"Details","Layout","ChartBorder","Size"float["Details","Layout","ChartBorder","Size",2.1]Line size / thickness of Chart Border
"Details","Layout","ChartBorder","Alpha"float["Details","Layout","ChartBorder","Alpha",.5]Line transparency of Chart Border
"Details","Layout","HasChartFill"bool["Details","Layout","HasChartFill",True]Fill Inner Chart Area (Does Not Include Label Area)
"Details","Layout","ChartFill","Color"int - hex color["Details","Layout","ChartFill","Color",0xFF000]Fill Color Of Inner Chart Area
"Details","Layout","ChartFill","Alpha"float["Details","Layout","ChartFill","Alpha",.5]Transparency Of Inner Chart Area Fill
"Details","Layout","HasBkgdFill"bool["Details","Layout","HasBkgdFill",True]Fill Chart Area (Drawn Overtop Of Any Pane Color)
"Details","Layout","BkgdFill","Color"int - hex color["Details","Layout","BkgdFill","Color",0xFF000]Fill Color Of Chart Area (Drawn Overtop Of Any Pane Color)
"Details","Layout","BkgdFill","Alpha"float["Details","Layout","BkgdFill","Alpha",.5]Transparency Of Chart Area Fill (Drawn Overtop Of Any Pane Color)