In this tutorial, the most important steps for using TRAViz are explained:
1. Include FilesTRAViz requires the JavaScript libraries jQuery, Raphaël and qTip. All TRAViz sources and these libraries are combined and minified in one TRAViz source file. In the Source Code section, you can download the bundle version that you extract into your client folder. Then, include the TRAViz sources into the head environment of the HTML-page with:
<head> ... <link rel="stylesheet" href="traviz_directory/traviz.css" type="text/css"/> <script src="traviz_directory/traviz-min.js"/> ... </head>
As a container for TRAViz, you need to place a DIV with an arbitrary ID into the body of your document:
var traviz = new TRAViz("TRAVizContainerDiv",yourConfiguration);
traviz.align(yourData);
traviz.visualize();
The first line initializes TRAViz. The JSON object "yourConfiguration" is optional and holds desired configuration changes.
An overview of the default configurations that can be overwritten is given in: TRAViz Configuration.The given data must be an array with a JSON entry for each text edition.
[ ... edition_i, edition_j, edition_k, ... ]Each entry of the array contains an edition ID and the corresponding text snippet. It looks like:
{
edition: 'Some Edition ID',
text: 'Some cool and fancy edition text that will be aligned to the other texts and visualized'
}
For the Genesis 1:1 example the array looks like:
[{
edition: "American Standard Version",
text: "In the beginning God created the heavens and the earth."
},{
edition: "Bible in Basic English",
text: "At the first God made the heaven and the earth."
},{
edition: "Darby Bible",
text: "In the beginning God created the heavens and the earth."
},{
edition: "King James Version",
text: "In the beginning God created the heaven and the earth."
},{
edition: "World English Bible",
text: "In the beginning God created the heavens and the earth."
},{
edition: "Young's Literal Translation",
text: "In the beginning of God`s preparing the heavens and the earth --"
},{
edition: "New Life Version",
text: "In the beginning God made from nothing the heavens and the earth."
}]
Below, you can find the standard configuration of TRAViz:
/* General */
colors: [ "red", "blue", "green", "rgb(230,230,0)", "orange", "#996600",
"purple", "#FF00FF", "#66FFFF", "#339999" ], // colors used to identify the various edition paths
normalize: true, // if the sentences shall be normalized or not (remove special characters)
lineBreaks: true, // if line breaks are allowed or not (if true, only the width of the given div is used)
rtl: false, // if labels should be drawn from right to left (for arabic, hebrew)
/* Text Vertices */
baseColor: '#3E576F', // color used for text and joined connections
vertexBackground: '#F2F2F2', // false or a CSS color for the text backgrounds
font: 'Georgia', // text font
startAndEnd: true, // if start and end vertex are shown and linked to all paths
collapseLabels: 0, // text labels are only shown for vertices with more than the given value
interpolateFontSize: false, // if true, the font size of the vertices is interpolated
// between 'fontSizeMin' and 'fontSizeMax', otherwise the font size
// grows by 4px with each edition
fontSizeMin: 10, // minimum font size
fontSizeMax: 50, // maximum font size
fontSizeIncrease: 4, // the number of pixels the labels grow by edition if interpolateFontSize = false
/* Connections */
edgeGap: 5, // minimum gap between two connections; required when adjusting the connections horizontally and vertically
curveRadius: 10, // radius of the curves
connectionType: 'all' // how the connections shall be displayed:
// 'all' for displaying each individual stream,
// 'joined' to merge all parallel connections, or
// 'majority' to merge only if more than half of the edges are routed between the same vertices
/* General Settings */
majorityPercentage: 0.5, // an edge becomes a majority edge when the given percentage of editions passes it
editDistance: false, // false (or 0) if only exact matches between two words shall be merged or edit distance dependent on the word lengths computed with the formula 2*editDistance/(|word1|+|word2|)
/* Interaction */
splitAndMerge: true, // if the user is allowed to interactively split vertices or merge via drag&drop
transpositions: true // if (potential) transpositions shall be determined and visualized on mouseover
To overwrite the defaults, e.g. the values for 'interpolateFontSize' and 'fontSizeMax', you just need to initialize TRAViz like:
var traviz = new TRAViz("someDivName",{
interpolateFontSize: true,
fontSizeMax: 72
});
Below, we show the resultant visualizations for some of the configuration settings.
| connectionType: 'all' (default) | ![]() |
| connectionType: 'joined' | ![]() |
| connectionType: 'majority' | ![]() |
| curveRadius: 10 (default) | ![]() |
| curveRadius: 5 | ![]() |
| startAndEnd: true | ![]() |
| startAndEnd: false | ![]() |
| baseColor: '#3E576F' vertexBackground: '#F2F2F2' font: 'Georgia' (default) | ![]() |
| baseColor: 'black' vertexBackground: false font: 'Sawasdee' | ![]() |
| normalize: true (default) | ![]() |
| normalize: false | ![]() |
RED(A,B) = 2*Levenshtein_distance(A,B)/(|A|+|B|).
RED(A,B) = 0 is an exact match, RED(A,B) = 0.1-0.2 allows smaller variations (e.g. "beginnings" and "beginning"), and RED(A,B) = 0.3-0.5 allows stronger ones (e.g. "beginnings" and "bigynnyng"). RED(A,B) = 1 is possible, but does not make any sense :-)
"NEQ· QUIB· S̄P̄S̄ DS̄ ETIA ̄"TRAViz computes the following layout:
vizcovery.org