下载地址
http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c
微软今天发布了Net Framework 3.5下的 Chart 控件,弥补了.Net平台下缺乏一个十分强力的图表控件。
该图表控件支持多种图表,如饼图,柱状图,曲线图,散点图,雷达图,面积图,股票图等,同时支持Winform和Asp.net。
目前该控件只能用在.Net Framework 3.5上,没有查找到For .Net Framework 2.0的信息。
补:根据stu_acer的反馈,原来该款控件来自dundas.com, For .Net Framework 2.0也有,只是需要付费。
下载信息:
-
-
-
-
-
WinForm 和 Asp.net的例子(Samples Environment for Microsoft Chart Controls) –
这个只有英文的,没找到英文的。
如何设置X或者Y轴Label间隔数(默认为自动分配,有时候12个X,只会显示6个的lable)
chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 1;
设置为每隔1个就显示一个Lable。
MSChartTest
在UpdatePanel中使用Charts Controls
Code
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers> http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/b6d90e08-d0e9-4bdd-953c-02de8c938e48
通过webservice来传送图片
Code
[WebMethod]
public byte[] GetChart()
{
Chart chart1 = new Chart();
//Set chart properties
//and dind it to data
//Save chart to memory stream
using (MemoryStream s= new MemoryStream())
{
chart1.Save(s, ChartImageFormat.Png);
return s.ToArray();
}
}
GridView中使用
The most simple way to achieve master detail in grid view is to insert a data source and chart ( and other detail output if you need) in a template field. Use data grid RowDataBound event to sync the data sources. The sample bellow shows territory name in the first column and a pie chart in the second column, data bind to sales.
Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<script runat="server">
void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
SqlDataSource source = (SqlDataSource)e.Row.FindControl("SqlDataSource3");
source.SelectParameters["SalesTeritory"].DefaultValue = ((System.Data.DataRowView)e.Row.DataItem)["Name"] as string;
}
}
</script>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorks2008ConnectionString %>"
SelectCommand="SELECT Sales.SalesTerritory.* FROM Sales.SalesTerritory"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="TerritoryID"
DataSourceID="SqlDataSource2" Style="margin-right: 0px" Width="713px" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Territory" SortExpression="Name">
<HeaderStyle Width="30%" />
</asp:BoundField>
<asp:TemplateField HeaderText="Sales">
<ItemTemplate>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorks2008ConnectionString %>"
SelectCommand="SELECT SalesPersonID, FullName, JobTitle, SalesTerritory, [2002], [2003], [2004] FROM Sales.vSalesPersonSalesByFiscalYears WHERE (SalesTerritory = @SalesTeritory)">
<SelectParameters>
<asp:Parameter DbType="String" Name="SalesTeritory" />
</SelectParameters>
</asp:SqlDataSource>
<asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource3" Height="149px"
Width="328px">
<Series>
<asp:Series Name="Series1" ChartType="Pie" XValueMember="FullName" YValueMembers="2004">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/bb0548cc-90f7-4622-8ced-61ded9a63b3d