问题描述
现在我正在将数据硬编码到JQuery中我希望数据通过C传递#
我尝试过:
控制器
公共ActionResult GetPiechartData()
{
返回查看();
}
查看
< html>
< head>
< script>
$(document).ready(function(){
var m1 =新Morris.Line({
元素:'折线图',
数据:[
{ y:'2006',a:30,b:20},
{y:'2007',a:75,b:65},
{y: '2008',a:50,b:40},
{y:'2009',a:75,b:65},
{y:'2010 ',a:50,b:40},
{y:'2011',a:75,b:65},
{y:'2012',a:100,b:90}
],
xkey:'y',
ykeys:[ 'a','b'],
标签:['系列A','系列B'],
lineColors:['#D9534F','#428BCA '],
lineWidth:'2px',
hideHover:true
});
});
< / script>
< / head>
< body>
< div id =line-chartclass =body-chart>
< / div>
< / body>
< / html>
Right Now i am hard coding data into JQuery i want data to be passed via C#
What I have tried:
controller
public ActionResult GetPiechartData()
{
return View();
}
View
<html>
<head>
<script>
$(document).ready(function () {
var m1 = new Morris.Line({
element: 'line-chart',
data: [
{ y: '2006', a: 30, b: 20 },
{ y: '2007', a: 75, b: 65 },
{ y: '2008', a: 50, b: 40 },
{ y: '2009', a: 75, b: 65 },
{ y: '2010', a: 50, b: 40 },
{ y: '2011', a: 75, b: 65 },
{ y: '2012', a: 100, b: 90 }
],
xkey: 'y',
ykeys: ['a', 'b'],
labels: ['Series A', 'Series B'],
lineColors: ['#D9534F', '#428BCA'],
lineWidth: '2px',
hideHover: true
});
});
</script>
</head>
<body>
< div id="line-chart" class="body-chart">
</div>
</body>
</html>
推荐答案
<script>
这篇关于将硬编码数据从c#传递到morris图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!