html图表实现,用 Flotr2 实现的 HTML5 图表

1.[图片] 未命名.jpg

b2cf6188de3c20ae1cc3ffa17caf88df.png

e5050075270cfc1af67c1ac042e73e81.png

​2. [代码][HTML]代码

用 Flotr2 实现的 HTML5 图表

/* page layout styles */

*{

margin:0;

padding:0;

}

header a.stuts,a.stuts:visited{

border:none;

text-decoration:none;

color:#fcfcfc;

font-size:14px;

left:50%;

line-height:31px;

margin:23px 0 0 110px;

position:absolute;

top:0;

}

header .stuts span {

font-size:22px;

font-weight:bold;

margin-left:5px;

}

.container {

color: #000;

margin: 20px auto;

overflow: hidden;

position: relative;

width: 600px;

height: 400px;

}

.controls {

border: 1px dashed gray;

color: #000;

margin: 20px auto;

padding: 25px;

position: relative;

width: 550px;

}

.controls p {

margin-bottom: 10px;

}

.controls input {

margin-left: 10px;

}

使用Flotr2实现的HTML5图表效果

源码地址:http://www.script-tutorials.com/html5-charts-and-graphs/

函数:

sin

sin(1/x)

视觉模式:

#1

#2

#3

3. [代码][JavaScript]代码

var container = document.getElementById('container');

var start = (new Date).getTime();

var data, graph, offset, i;

var mode = 1;

var fmode = 1; // 1- basic sin, 2 - sin(1/x)

// toggle mode

function toggleMode(i) {

mode = i;

}

// toggle func

function toggleFunc(i) {

fmode = i;

}

// Draw a sine curve at time t

function animateSine (t) {

data = [];

data2 = [];

// little offset between steps

offset = 2 * Math.PI * (t - start) / 10000;

http://www.enterdesk.com/special/meitu/​

if (fmode == 2 && offset > 15) {

start = t;

美图

}

for (i = 0; i < 4 * Math.PI; i += 0.2) {

if (fmode == 1) {

data.push([i, Math.sin(i - offset)]);

data2.push([i, Math.sin(i*2 - offset)]);

} else if (fmode == 2) {

data.push([i, Math.sin(1/(i-offset))]);

// data2.push([i, Math.sin(1/(i*2-offset))]);

}

}

// prepare properties

var properties;

switch (mode) {

case 1:

properties = {

yaxis : {

max : 2,

min : -2

}

};

break;

case 2:

properties = {

yaxis : {

max : 2,

min : -2

},

bars: {

show: true,

horizontal: false,

shadowSize: 0,

barWidth: 0.5

}

};

break;

case 3:

properties = {

yaxis : {

max : 2,

min : -2

},

radar: {

show: true

},

grid: {

circular: true,

minorHorizontalLines: true

}

};

break;

case 4:

properties = {

yaxis : {

max : 2,

min : -2

},

bubbles: {

show: true,

baseRadius: 5

},

};

break;

}

// draw graph

if (fmode == 1) {

graph = Flotr.draw(container, [ data, data2 ], properties);

} else if (fmode == 2) {

graph = Flotr.draw(container, [ data ], properties);

}

// main loop

setTimeout(function () {

animateSine((new Date).getTime());

}, 50);

}

animateSine(start);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值