官术网_书友最值得收藏!

Creating dummy data

The first thing it does is that it creates some dummy data. This is the data that determines how many rectangles to render, and how large the rectangles will be:

var rectangleWidth = 100, 
data = [],
numberOfRectangles = Math.ceil(Math.random() * 7);

for (var i = 0 ; i < numberOfRectangles ; i++) {
data.push((Math.random() * rectangleWidth / 2)
+ rectangleWidth / 2);
}

This is just plain JavaScript, and this will result in the data array being filled with one to seven numeric values ranging from 50 to 100. It could look something like this:

[52.653238934888726, 88.52709144102309, 81.70794256804369, 58.10611357491862]
主站蜘蛛池模板: 宜宾市| 西青区| 玛曲县| 海晏县| 沁源县| 芜湖市| 孝感市| 高要市| 筠连县| 平定县| 岫岩| 沾化县| 禹州市| 芮城县| 威信县| 桐乡市| 合作市| 内乡县| 浦东新区| 平邑县| 铅山县| 普宁市| 临沧市| 司法| 凉山| 桦川县| 南丹县| 沙坪坝区| 陵水| 红桥区| 巴楚县| 林芝县| 龙州县| 竹山县| 兴隆县| 安多县| 珠海市| 井冈山市| 淮阳县| 遵化市| 皋兰县|