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
var color1 = "#FF0000";
4
5
// Variable for controlling color darkness
6
var colorIndex = 0;
7
8
// color darken function
9
function colorizer(){
10
var mixColor1 = anychart.color.darken(color1, colorIndex);
11
colorIndex = colorIndex + 0.2;
12
return mixColor1;
13
}
14
15
// data and fill color settings
16
var data = anychart.data.set([
17
{x: "P1", value: 10000, fill: (colorizer())},
18
{x: "P2", value: 12000, fill: (colorizer())},
19
{x: "P3", value: 18000, fill: (colorizer())},
20
{x: "P4", value: 13000, fill: (colorizer())},
21
{x: "P5", value: 9000, fill: (colorizer())},
22
]);
23
24
// chart type
25
var chart = anychart.column();
26
27
chart.title("Darken Colors Sample");
28
29
30
// set data and set additional information in tooltip
31
var series = chart.column(data);
32
series.stroke(null);
33
var tooltip = series.tooltip();
34
tooltip.format(function(){
35
var mixColor2 = anychart.color.darken(color1, (this.index * 0.2));
36
return "Input Color: " + color1 +
37
"\nDarken Ratio: " + this.index * 2 / 10 +
38
"\nResult: " + mixColor2;
39
});
40
41
// draw
42
chart.container("container");
43
chart.draw();
44
});