|
1)我使用的DotNet.Highcharts,使用nuget添加引用,或者去https://dotnethighcharts.codeplex.com/下载
2) 相应的页面引入js文件,jquery和highcharts,注意文件的目录。
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="../res/js/jquery-1.9.0.min.js" type="text/javascript"></script>
<script src="../Scripts/Highcharts-4.0.1/js/highcharts.js" type="text/javascript"></script>
<title></title>
</head>
3)放置组件,放到ContentPanel里,里面的div是控制图表大小的。
<f:ContentPanel ID="ContentPanel1" runat="server" Width="1000px" BodyPadding="5px"
ShowBorder="true" ShowHeader="true" Title="内容面板">
<div id="container" style="width:900px;height:400px">
<aspiteral ID="Literal1" runat="server"></aspiteral>
</div>
</f:ContentPanel>
4)
DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
.SetXAxis(new XAxis
{
Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
})
.SetSeries(new Series
{
Data = new Data(new object[] { 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4 })
})
.SetCredits(new Credits{Enabled=false}) ;
Literal1.Text = chart.ToHtmlString();
|
|