рони,
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.pr {
float: left;
width: 100%;
height: 100%;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/adapters/standalone-framework.js"></script>
<script type="text/javascript" src="http://www.highcharts.com/media/com_demo/highslide-full.min.js"></script>
<script type="text/javascript">
var Q, D, T, AIR, AF, AW;
var AR = new Array(8);
function myFunctionCPT(q,d) {
D=d;
Q=q;
var arr = [];
for (T = -800; T < 1601; T += 400) {
AIR = [0.238785488, -0.00900857881, 0.0193221258, 0.132711466, -0.190166916, 0.10379398, -0.0258490883, 0.00245365952];
AF = [0.367102859, 0.384334584, 0.190633867, -0.361766882, 0.263417998, -0.112618047, 0.0257271586, -0.00237417234];
AW = [0.4700077, -0.3206047, 1.196138, 1.728544, 1.55052, -0.8291961, 0.237057, -0.02773743];
for (var i=0; i<8; i++) {
AR[i]=(AIR[i]+Q*AF[i]+D*AW[i])/(1+Q+D);
}
R=T/1000;
CPTA=94*Q/(1+Q+D);
B=R*(AR[0]+R*(AR[1]/2+R*(AR[2]/3+R*(AR[3]/4+R*(AR[4]/5+R*(AR[5]/6+R*(AR[6]/7+R*AR[7]/8)))))));
CPT=CPTA+B*1000;
arr.push(CPT);
}
return {
data: arr,
name: 'q=' + Q + '; d=' + D,
color: RandColor(),
type: 'spline',
}
}
var series = [];
function plotGraph(form) {
var q = +form.q.value, d = +form.d.value;
form.q.value = '';
form.d.value = '';
series.push(myFunctionCPT(q,d));
$('#CPT-T').highcharts({
title: {
text: 'Graph CPT-T',
x: -20 //center
},
xAxis: {
title: {
text: 'Enthalpy'
},
categories: ['-800', '-400', '0', '400', '800', '1200', '1600'],
},
yAxis: {
title: {
text: 'Temperature (K)',
}
},
series: series
});
return false;
}
function RandColor() {
var r=Math.floor(Math.random() * (256));
var g=Math.floor(Math.random() * (256));
var b=Math.floor(Math.random() * (256));
var rgb='#' + r.toString(16) + g.toString(16) + b.toString(16);
return rgb;
}
</script>
</head>
<body>
<form action="http://" onsubmit="return plotGraph(this)">
<label>Input <b>q</b> value <input name="q"></label>
<label>Input <b>d</b> value <input name="d"></label>
<input type="submit" value="ok" />
</form>
<div id="CPT-T" class="pr"></div>
</body>
</html>
какой-то баг, иногда, вместо сплайнов строятся просто точки, в чем причина?