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

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]
主站蜘蛛池模板: 五家渠市| 万年县| 北辰区| 湛江市| 宁乡县| 宣汉县| 陆良县| 西林县| 正安县| 阜新| 巧家县| 阿勒泰市| 龙里县| 咸阳市| 阳信县| 阜南县| 西贡区| 郓城县| 绵竹市| 红安县| 景宁| 灵丘县| 武川县| 皮山县| 曲阳县| 璧山县| 平远县| 潮安县| 台州市| 清水县| 潞城市| 临高县| 辉南县| 重庆市| 枣阳市| 木里| 灵丘县| 英山县| 渝北区| 绥滨县| 南雄市|