Search Results for '차트'


1 POSTS

  1. 2010/03/07 Chart by jincaesar

Chart

VS2010에.. Chart가 추가되었다..

그러나.. 그전에 이미 Chart는 있었다는것..

사용법은 거의 비슷하다..

Microsoft Chart Controls for Microsoft .NET Framework 3.5

MSChart.exe를 다운받은 후 설치

설치가 완료된 후 Visual Studio 2008을 실행하면 도구상자에 그림과 같은 Data 탭이 추가된 것을 확인할 수 있다.

차트 도구상자 
Chart를 aspx 페이지에 올려놓으면.. 아래와 같은 코드가 생긴다..


    
        
        
    
    
        
        
    

cs 단은 아래처럼 대충 구성했다..

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

#region #Add Reference,
using System.Transactions;
using System.Data.SqlClient;
using System.Text;
using System.Web.UI.DataVisualization.Charting;
#endregion

public partial class SampleCode_ChartSample : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            InitControls();
            GetData();
        }
    }

   
    private void InitControls()
    {
        Chart1.Width = Unit.Pixel(800);
        Chart1.Height = Unit.Pixel(600);
        
        Chart1.DataSource = null;
        Chart1.Legends.Add("★");
        Chart1.Series["Series1"].ChartType = SeriesChartType.Column;
        Chart1.Series["Series1"].BackGradientStyle = GradientStyle.Center;
        Chart1.Series["Series1"].BackHatchStyle = ChartHatchStyle.Divot;
        Chart1.Series["Series1"].XValueMember = "FirstName";
        Chart1.Series["Series1"].YValueMembers = "Cnt";
        Chart1.RenderType = RenderType.ImageTag;
        Chart1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
        Chart1.Titles.Add(":: First Name Test ::");
        Chart1.ToolTip = ":: First Name Test ::";
        
       
        
        Chart1.ChartAreas.Add("");
    }

    private void GetData()
    {
        StringBuilder qry = new StringBuilder();

        qry.AppendFormat(@"
SELECT	DISTINCT top 15 A.FirstName
,		COUNT(Cnt) AS Cnt
FROM	(
		SELECT	SUBSTRING(FirstName, 1, 1) AS FirstName
		,		1 AS Cnt
		FROM	dbo.DANCET01
		) AS A 
GROUP BY A.FirstName
ORDER BY A.FirstName ASC
");

        using (TransactionScope tScope = new TransactionScope())
        {
            using (SqlConnection con = DBHandler.ConnectionDatabase())
            {
                SqlCommand cmd = DBHandler.TextCmd(con, qry.ToString());

                DataSet ds = DBHandler.ExecuteDataSet(cmd);

                Chart1.DataSource = ds;
                Chart1.DataBind();
            }
        }
    }
}

어쨌거나.. 나오긴 하는데... =_=;; 생각만큼 잘 안된다.. 일단.. 해당 메서드 관련해서.. 좀더 찾아봐야겠다..

크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by jincaesar

2010/03/07 05:42 2010/03/07 05:42
, ,
Response
No Trackback , No Comment
RSS :
http://jincaesar.maru.net/tc/rss/response/8