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
// data set
4
var data = anychart.data.set([
5
["P1", 16, 20],
6
["P2", 12, 18],
7
["P3", 9, 14]
8
]);
9
10
// map data for series
11
var seriesData_1 = data.mapAs({x: [0], value: [1]});
12
var seriesData_2 = data.mapAs({x: [0], value: [2]});
13
14
// set stage
15
var stage = anychart.graphics.create("container");
16
17
// setting main title
18
var title = anychart.standalones.title();
19
title.parentBounds(0, 0, stage.width(), stage.height()*0.1);
20
title.text("Background Stroke Types");
21
title.container(stage);
22
title.draw();
23
24
25
// Chart with red solid stroke
26
var solidStrokeSeries = anychart.column();
27
28
// setting title
29
solidStrokeSeries.title("Solid Stroke");
30
31
// setting stroke for chart contaoner. It has solid type by default
32
var solidBackground = solidStrokeSeries.background();
33
solidBackground.stroke("5 red");
34
35
// setting position and bounds
36
solidStrokeSeries.bounds(0, "10%", "45%", "40%");
37
38
// disabling titles, labels and all ticks for Axes
39
solidStrokeSeries.yAxis(false);
40
solidStrokeSeries.xAxis(false);
41
42
// setting data series
43
solidStrokeSeries.column(seriesData_1);
44
solidStrokeSeries.column(seriesData_2);
45
46
// set container and draw
47
solidStrokeSeries.container(stage);
48
solidStrokeSeries.draw();
49
50
51
// chart with gradient stroke
52
var gradientStrokeChart = anychart.column();
53
gradientStrokeChart.title("Gradient Stroke");
54
gradientStrokeChart.bounds("55%", "10%", "45%", "40%");
55
56
// adjust stroke type and set color keys
57
var gradientBackground = gradientStrokeChart.background();
58
gradientBackground.stroke({
59
// set colors position
60
keys: [".1 red", ".5 yellow", ".9 blue"],
61
// set angle of colors drawing
62
angle: 45,
63
// set stroke thickness
64
thickness: 5
65
});
66
67
// disabling titles, labels and all ticks for Axes
68
gradientStrokeChart.yAxis(false);
69
gradientStrokeChart.xAxis(false);
70
71
// set series data
72
gradientStrokeChart.column(seriesData_1);
73
gradientStrokeChart.column(seriesData_2);
74
75
// set container and draw
76
gradientStrokeChart.container(stage);
77
gradientStrokeChart.draw();
78
79
80
// chart with dashed stroke
81
var dashedStrokeChart = anychart.column();
82
dashedStrokeChart.title("Dashed Stroke");
83
dashedStrokeChart.bounds(0, "60%", "45%", "40%");
84
85
// adjust stroke type and dash settings
86
var dashedBackground = dashedStrokeChart.background();
87
dashedBackground.stroke({color: "red", dash: "5 2 5", thickness: 5});
88
89
// disable axes
90
dashedStrokeChart.xAxis(false);
91
dashedStrokeChart.yAxis(false);
92
93
dashedStrokeChart.column(seriesData_1);
94
dashedStrokeChart.column(seriesData_2);
95
96
dashedStrokeChart.container(stage);
97
dashedStrokeChart.draw();
98
99
100
// chat with disabled stroke
101
var disabledStrokeSeries = anychart.column();
102
103
disabledStrokeSeries.title("Disabled Stroke");
104
disabledStrokeSeries.bounds("55%", "60%", "45%", "40%");
105
var disabledBackground = disabledStrokeSeries.background();
106
disabledBackground.stroke(null);
107
108
disabledStrokeSeries.xAxis(false);
109
disabledStrokeSeries.yAxis(false);
110
111
disabledStrokeSeries.column(seriesData_1);
112
disabledStrokeSeries.column(seriesData_2);
113
114
disabledStrokeSeries.container(stage);
115
disabledStrokeSeries.draw();
116
});