我想使用Highcharts显示折线图。当我运行我的代码时,它可以工作并显示我想要的内容。但有时它会消失。有什么建议吗? PS:我正在使用ASP.NET MVC4
这是我的观点代码
<body>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<script>
$(function () {
$('#container').highcharts({
title: {
text: 'Evolution graphique d\'option théorique',
x: -20 //center
},
subtitle: {
text: 'Evolution graphique d\'option théorique',
x: -20
},
xAxis: {
categories: (function () {
var data = [];
@foreach(var z in Model.temps)
{
@:data.push('@z');
}
return data;
}())
},
yAxis: {
title: {
text: 'Evolution graphique d\'option théorique'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueDecimals: 4
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
name: 'call théorique',
data: (function () {
var data = [];
@foreach(var x in Model.prix_option_call)
{
@:t = parseFloat('@x'.replace(',', '.'));
@:data.push(t);
}
return data;
}())
},
{
name: 'put théorique',
data: (function () {
var data = [];
@foreach(var y in Model.prix_option_put)
{
@:m = parseFloat('@y'.replace(',', '.'));
@:data.push(m);
}
return data;
}())
}]
});
});
</script>