HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function() {
2
3
anychart.theme({defaultFontSettings: {fontColor: "#000"}});
4
5
// set stage
6
var stage = anychart.graphics.create("container");
7
8
// create table
9
var table = anychart.standalones.table();
10
11
// set table content
12
table.contents([
13
[
14
"Method",
15
"Samples"
16
],[
17
"textDirection()",
18
"This text has Left to Right direction.", // table.getCell(1,1).content().textDirection( anychart.graphics.vector.Text.Direction.LTR );
19
"This text has Right to Left direction." // table.getCell(1,2).content().textDirection( anychart.graphics.vector.Text.Direction.RTL );
20
],[
21
"fontDecoration()",
22
"This text was decorated with the line above", // table.getCell(2,1).content().fontDecoration( anychart.graphics.vector.Text.Decoration.OVERLINE );
23
"This text was decorated with the line below the text" // table.getCell(2,2).content().fontDecoration( anychart.graphics.vector.Text.Decoration.UNDERLINE );
24
],[
25
"fontVariant()",
26
"Text with default fontVariant", // table.getCell(3,1).content().fontVariant( anychart.graphics.vector.Text.FontVariant.NORMAL );
27
"This font is small cup" // table.getCell(3,2).content().fontVariant( anychart.graphics.vector.Text.FontVariant.SMALL_CAP );
28
],[
29
"fontWeight()",
30
"this text has 700 fontWeight", // table.getCell(4,1).content().fontWeight(700);
31
"this text has \'bold\' fontWeight value" // table.getCell(4,2).content().fontWeight("bold");
32
],[
33
"hAlign()",
34
"this text align to the center", // table.getCell(5,1).content().hAlign("center");
35
"this text align to the right" // table.getCell(5,2).content().hAlign("right");
36
],[
37
"height()",
38
anychart.standalones.label() // create custom title
39
.text("This title has default height.") // set text for the title
40
.padding(0) // disable padding
41
.fontWeight(400) // set font weight
42
.background({fill: null, stroke: "#ccc"}), // set border color
43
anychart.standalones.label() // create custom title
44
.height(25) // set custom height for the title
45
.text("This title has 25px height.") // set title text
46
.padding(0) // disable padding
47
.fontWeight(400) // set font weight
48
.vAlign("center") // position text at the middle of the title
49
.background({fill: null, stroke: "#ccc"}) // set border color
50
],[
51
"letterSpacing()",
52
"This text has 3px letter spacing", // table.getCell(7,1).content().letterSpacing(3);
53
"This text has 5px letter\nspacing" // table.getCell(7,2).content().letterSpacing(5);
54
],[
55
"lineHeight()",
56
"This text has 20px line height.\nEach line is bigger"
57
+" now", // table.getCell(8,1).content().lineHeight(1.7);
58
"This text has default line height.\nNo extra space "
59
+"between lines" // table.getCell(8,2).content().lineHeight(1);
60
],[
61
"fontOpacity()",
62
"This text has no transparency.", // table.getCell(9,1).content().fontOpacity(1);
63
"This text is transparent. You can\nsee the background "+
64
"through letters" // table.getCell(9,2).content().fontOpacity(0.4);
65
],[
66
"rotation()",
67
anychart.standalones.title() // create custom title
68
.rotation(5) // set rotation of the title
69
.text("This title is rotated by 5") // set text for the title
70
.padding(0) // disable padding
71
.margin(0) // disable margin
72
.fontWeight(400), // set font weight
73
anychart.standalones.title() // create custom title
74
.rotation(-7) // set title rotation
75
.text("This title is rotated by -7") // set text for the title
76
.padding(0) // disable padding
77
.margin(0) // disable margin
78
.fontWeight(400) // set font weight
79
],[
80
"selectable()",
81
anychart.standalones.label() // create custom title
82
.selectable(true) // make text selectable
83
.text("This text is selectable.\nIt is the only "
84
+"selectable text in this table.") // set text for the title
85
.fontWeight(400) // set font weight
86
.padding(0), // disable padding
87
anychart.standalones.label() // create custom title
88
.selectable(false) // disable text selection
89
.text("This text can\'t be selected.") // set title text
90
.padding(0) // disable padding
91
.fontWeight(400) // set font weight
92
],[
93
"textIndent()",
94
"Text indent is a space before the first line in the "
95
+"text. If the text consist of multiple paragraphs, "
96
+"each of them will have a space at the beginning first "
97
+"line", // table.getCell(12,1).content().textIndent(30);
98
"This text has no indent. All lines sticked to the left" //
99
+" and there is no margin for any of the lines." // table.getCell(12,2).content().textIndent(0);
100
],[
101
"textOverflow()",
102
"The overflowing text clips by the limits of the cell. "
103
+"You can see the text reaching cell border and clips "
104
+"by the cell border, if there isn\'t enough space for "
105
+"another line", // table.getCell(13,1).content().textOverflow(anychart.graphics.vector.Text.TextOverflow.CLIP);
106
"This text has \'Ellipsis\' value for textOverflow()."
107
+"Overflowing text replaced with Ellipsis just before it"
108
+" reaches the cell border and there is no space for "
109
+"another line." // table.getCell(14,2).content().textWrap(anychart.graphics.vector.Text.TextWrap.BY_LETTER);
110
],[
111
"textWrap()",
112
"This text has no wrapping. The whole text has no line "
113
+"breaking." , // table.getCell(14,1).content().textWrap(anychart.graphics.vector.Text.TextWrap.NO_WRAP);
114
"This text is wrapped by letters. The line breaks the "
115
+"moment it reaches the cell border" // table.getCell(14,2).content().textWrap(anychart.graphics.vector.Text.TextWrap.BY_LETTER);
116
],[
117
"vAlign()",
118
"This text align to the center", // table.getCell(15,1).content().vAlign("center");
119
"This text align to the bottom" // table.getCell(15,2).content().vAlign("bottom");
120
],[
121
"width()",
122
anychart.standalones.label() // create custom title
123
.text("This title has default width.") // set title text
124
.padding(0) // disable padding
125
.fontWeight(400) // set font weight
126
.background({fill: null, stroke: "#ccc"}), // set title border
127
anychart.standalones.label() // create custom title
128
.width(175) // set title width
129
.text("This title has 175px width.") // set title text
130
.padding(0) // disable padding
131
.fontWeight(400) // set font weight
132
.background({fill: null, stroke: "#ccc"}) // set title border
133
]
134
]);
135
136
// table settings
137
table.fontSize(10);
138
table.getRow(0).height(30);
139
table.getRow(8).height(40);
140
table.getRow(9).height(45);
141
table.getRow(12).height(45);
142
table.getCol(0).width(100);
143
table.cellBorder("#B8B8B8");
144
table.getCell(0,0).hAlign("center").vAlign("center").fill("#f0f0f0").fontWeight(900);
145
table.getCell(0,1).colSpan(2).hAlign("center").vAlign("center").fill("#f0f0f0").fontWeight(900);
146
147
table.getCell(1,1).textDirection(anychart.graphics.vector.Text.Direction.LTR);
148
table.getCell(1,2).textDirection(anychart.graphics.vector.Text.Direction.RTL);
149
table.getCell(2,1).fontDecoration(anychart.graphics.vector.Text.Decoration.OVERLINE);
150
table.getCell(2,2).fontDecoration(anychart.graphics.vector.Text.Decoration.UNDERLINE);
151
table.getCell(3,1).fontVariant(anychart.graphics.vector.Text.FontVariant.NORMAL);
152
table.getCell(3,2).fontVariant(anychart.graphics.vector.Text.FontVariant.SMALL_CAP);
153
table.getCell(4,1).fontWeight(700);
154
table.getCell(4,2).fontWeight("bold");
155
table.getCell(5,1).hAlign("center");
156
table.getCell(5,2).hAlign("right");
157
table.getCell(7,1).letterSpacing(3);
158
table.getCell(7,2).letterSpacing(5);
159
table.getCell(8,1).lineHeight(1.7);
160
table.getCell(8,2).lineHeight(1);
161
table.getCell(9,1).fill({
162
keys: [".1 red", ".5 yellow", ".9 green"],
163
angle: 90
164
}).fontWeight(900).fontSize(15).fontOpacity(1);
165
table.getCell(9,2).fill({
166
keys: [".1 red", ".5 yellow", ".9 green"],
167
angle: 90
168
}).fontWeight(900).fontSize(15).fontOpacity(0.4);
169
170
table.getCell(12,1).textIndent(30);
171
table.getCell(12,2).textIndent(0);
172
table.getCell(13,1).textOverflow(anychart.graphics.vector.Text.TextOverflow.CLIP);
173
table.getCell(13,2).textOverflow(anychart.graphics.vector.Text.TextOverflow.ELLIPSIS);
174
table.getCell(14,1).textWrap(anychart.graphics.vector.Text.TextWrap.NO_WRAP);
175
table.getCell(14,2).textWrap(anychart.graphics.vector.Text.TextWrap.BY_LETTER);
176
table.getCell(15,1).vAlign("center");
177
table.getCell(15,2).vAlign("bottom");
178
179
stage.height(680);
180
stage.width(690);
181
182
// set table container and initiate draw
183
table.container(stage).draw();
184
});