<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blue955 &#187; 圖表</title>
	<atom:link href="http://m955.com/wp/archives/tag/%e5%9c%96%e8%a1%a8/feed" rel="self" type="application/rss+xml" />
	<link>http://m955.com/wp</link>
	<description>追風箏的小孩</description>
	<lastBuildDate>Thu, 01 Jul 2010 09:49:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>使用 ZedGraph 製作統計圖</title>
		<link>http://m955.com/wp/archives/237</link>
		<comments>http://m955.com/wp/archives/237#comments</comments>
		<pubDate>Wed, 22 Jul 2009 08:23:30 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[圖表]]></category>

		<guid isPermaLink="false">http://m955.com/wp/archives/237</guid>
		<description><![CDATA[這幾天研究了 ZedGraph，發現它是一套很好用的畫圖表工具，練習做了一個統計圖，大家參考看看！

PLAIN TEXT
C#:




//記得要加入參考


using ZedGraph;


&#160;


//資料來源&#160; &#160; &#160; &#160; 


privat... ]]></description>
			<content:encoded><![CDATA[<p>這幾天研究了 ZedGraph，發現它是一套很好用的畫圖表工具，練習做了一個統計圖，大家參考看看！</p>
<p><a href="http://farm4.static.flickr.com/3529/3744942595_3e8b5a6bcb_o.png" target="_blank" rel="lightbox"><img src="http://farm4.static.flickr.com/3529/3744942595_226b42dbe7.jpg"></a></p>
<div class="igBar"><span id="lcsharp-2"><a href="#" onclick="javascript:showPlainTxt('csharp-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-2">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//記得要加入參考</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">using</span> ZedGraph;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//資料來源&nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">private</span> DataTable getDT<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; DataTable dt = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> DataTable<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"學號"</span>, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"System.String"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"姓名"</span>, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"System.String"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"國文"</span>, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"System.Int32"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"英文"</span>, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"System.Int32"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"數學"</span>, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"System.Int32"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510001"</span>, <span style="color: #808080;">"崔昱翰"</span>, <span style="color: #FF0000;color:#800000;">85</span>, <span style="color: #FF0000;color:#800000;">66</span>, <span style="color: #FF0000;color:#800000;">71</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510002"</span>, <span style="color: #808080;">"王詩光"</span>, <span style="color: #FF0000;color:#800000;">65</span>, <span style="color: #FF0000;color:#800000;">92</span>, <span style="color: #FF0000;color:#800000;">88</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510003"</span>, <span style="color: #808080;">"劉育白"</span>, <span style="color: #FF0000;color:#800000;">52</span>, <span style="color: #FF0000;color:#800000;">66</span>, <span style="color: #FF0000;color:#800000;">63</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510004"</span>, <span style="color: #808080;">"許威宇"</span>, <span style="color: #FF0000;color:#800000;">98</span>, <span style="color: #FF0000;color:#800000;">70</span>, <span style="color: #FF0000;color:#800000;">61</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510005"</span>, <span style="color: #808080;">"李佩珊"</span>, <span style="color: #FF0000;color:#800000;">81</span>, <span style="color: #FF0000;color:#800000;">63</span>, <span style="color: #FF0000;color:#800000;">76</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510006"</span>, <span style="color: #808080;">"潘紹興"</span>, <span style="color: #FF0000;color:#800000;">91</span>, <span style="color: #FF0000;color:#800000;">77</span>, <span style="color: #FF0000;color:#800000;">76</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">return</span> dt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//學生成績</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> StudentChart1<span style="color: #000000;">&#40;</span>ZedGraphControl zgc<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Google網域搜尋：Fill site:http://zedgraph.sourceforge.net/documentation</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; GraphPane myPane = zgc.<span style="color: #0000FF;">GraphPane</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; DataTable dt = getDT<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Set the title and axis labels</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">Title</span>.<span style="color: #0000FF;">Text</span> = <span style="color: #808080;">"學生成績量化表"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">XAxis</span>.<span style="color: #0000FF;">Title</span>.<span style="color: #0000FF;">Text</span> = <span style="color: #808080;">"學生姓名"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">YAxis</span>.<span style="color: #0000FF;">Title</span>.<span style="color: #0000FF;">Text</span> = <span style="color: #808080;">"分數"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; PointPairList list1 = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> PointPairList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; PointPairList list2 = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> PointPairList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; PointPairList list3 = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> PointPairList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Random rand = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> Random<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Generate random data for three curves</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i = <span style="color: #FF0000;color:#800000;">0</span>; i &lt;dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Count</span>; i++<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">double</span> x = <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">double</span><span style="color: #000000;">&#41;</span>i;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">double</span> y1_chian = Convert.<span style="color: #0000FF;">ToDouble</span><span style="color: #000000;">&#40;</span>dt.<span style="color: #0000FF;">Rows</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"國文"</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">double</span> y2_eng = Convert.<span style="color: #0000FF;">ToDouble</span><span style="color: #000000;">&#40;</span>dt.<span style="color: #0000FF;">Rows</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"英文"</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">double</span> y3_math = Convert.<span style="color: #0000FF;">ToDouble</span><span style="color: #000000;">&#40;</span>dt.<span style="color: #0000FF;">Rows</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"數學"</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; list1.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>x, y1_chian<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; list2.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>x, y2_eng<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; list3.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>x, y3_math<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// create the curves</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// BarItem.Bar.Fill(Color) 填入單一顏色</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// BarItem.Bar.Fill(Color, Color, Color, 90) 填入漸層顏色，第4參數是旋轉角度</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; BarItem myCurve1 = myPane.<span style="color: #0000FF;">AddBar</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"國文"</span>, list1, Color.<span style="color: #0000FF;">Red</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myCurve1.<span style="color: #0000FF;">Bar</span>.<span style="color: #0000FF;">Fill</span> = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> Fill<span style="color: #000000;">&#40;</span>Color.<span style="color: #0000FF;">FromArgb</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">255</span>, <span style="color: #FF0000;color:#800000;">238</span>, <span style="color: #FF0000;color:#800000;">221</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; BarItem myCurve2 = myPane.<span style="color: #0000FF;">AddBar</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"英文"</span>, list2, Color.<span style="color: #0000FF;">Blue</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myCurve2.<span style="color: #0000FF;">Bar</span>.<span style="color: #0000FF;">Fill</span> = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> Fill<span style="color: #000000;">&#40;</span>Color.<span style="color: #0000FF;">FromArgb</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">221</span>, <span style="color: #FF0000;color:#800000;">255</span>, <span style="color: #FF0000;color:#800000;">238</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; BarItem myCurve3 = myPane.<span style="color: #0000FF;">AddBar</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"數學"</span>, list3, Color.<span style="color: #0000FF;">Green</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myCurve3.<span style="color: #0000FF;">Bar</span>.<span style="color: #0000FF;">Fill</span> = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> Fill<span style="color: #000000;">&#40;</span>Color.<span style="color: #0000FF;">FromArgb</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">238</span>, <span style="color: #FF0000;color:#800000;">221</span>, <span style="color: #FF0000;color:#800000;">255</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Fill the axis background with a color gradient</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// 背景色</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F);</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">XAxis</span>.<span style="color: #0000FF;">MajorTic</span>.<span style="color: #0000FF;">IsBetweenLabels</span> = <span style="color: #0600FF;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//加入X LabelText</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> labels = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;color:#800000;">6</span><span style="color: #000000;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i = <span style="color: #FF0000;color:#800000;">0</span>; i &lt;dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Count</span>; i++<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; labels<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = Convert.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span>dt.<span style="color: #0000FF;">Rows</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"姓名"</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">XAxis</span>.<span style="color: #0000FF;">Scale</span>.<span style="color: #0000FF;">TextLabels</span> = labels; <span style="color: #008080; font-style: italic;">//X軸的說明文字</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">XAxis</span>.<span style="color: #0000FF;">Type</span> = AxisType.<span style="color: #0000FF;">Text</span>;&nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//X軸類型</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//重新計算目前數據範圍</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; zgc.<span style="color: #0000FF;">AxisChange</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// expand the range of the Y axis slightly to accommodate the labels</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// YAxis最大值</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">YAxis</span>.<span style="color: #0000FF;">Scale</span>.<span style="color: #0000FF;">Max</span> = <span style="color: #FF0000;color:#800000;">110</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Create TextObj's to provide labels for each bar</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// 在bar上顯示數值</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; BarItem.<span style="color: #0000FF;">CreateBarLabels</span><span style="color: #000000;">&#40;</span>myPane, <span style="color: #0600FF;">false</span>, <span style="color: #808080;">"f0"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//顯示格點</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">YAxis</span>.<span style="color: #0000FF;">MajorGrid</span>.<span style="color: #0000FF;">IsVisible</span> = <span style="color: #0600FF;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">XAxis</span>.<span style="color: #0000FF;">MajorGrid</span>.<span style="color: #0000FF;">IsVisible</span> = <span style="color: #0600FF;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/237/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.Net 第三方繪圖控件 dotnetCharting 和 ZedGraph 比較，</title>
		<link>http://m955.com/wp/archives/235</link>
		<comments>http://m955.com/wp/archives/235#comments</comments>
		<pubDate>Tue, 21 Jul 2009 09:10:50 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[圖表]]></category>

		<guid isPermaLink="false">http://m955.com/wp/archives/235</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160;&#160;&#160; 最近參考了幾個統計圖表控件包，OpenSource 的有 ZedGraph，Nplot 等，但是相比之下還是 ZedGraph 強大，方便一些，其他的感覺還是半成品。

&#160;&#160;&#160;&#160;&#160;&#... ]]></description>
			<content:encoded><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 最近參考了幾個統計圖表控件包，OpenSource 的有 <a href="http://zedgraph.org/" target="_blank">ZedGraph</a>，<a href="http://netcontrols.org/nplot/" target="_blank">Nplot</a> 等，但是相比之下還是 ZedGraph 強大，方便一些，其他的感覺還是半成品。
<p><img src="http://farm3.static.flickr.com/2630/3742414956_6a73bc31b8_o.png">
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 收費的套件就多了，只要是商業的報表開發工具都有統計圖表的功能，水晶報表，ActiveReport，Reporting Service，不過要方便，功能單一的還是 <a href="http://www.dotnetcharting.com/" target="_blank">dotnetCharting</a>。下面主要從 winform 使用上說說 ZedGraph 和 dotnetCharting。
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 從效果上說 dotnetCharting 確實沒的說，水晶式效果很是炫目，這應該是其最大的賣點。為了便於開發者學習，帶了各種效果的示例代碼。DotnetCharting 在產生統計圖的時候需要設置一個臨時目錄，用來保存產生的統計圖的圖片，dotnetCharting 的圖表效果好，很大程度上是因為它生成了圖片，然後將其顯示在界面上。當然，作為代價，它犧牲了性能。同時，它不支持縮放，雖然你可以通過更改坐標軸的刻度來實現這個功能，但是性能上就差了很多。
<p>如果你對性能要求不高，<a href="http://www.dotnetcharting.com/" target="_blank">dotnetCharting</a> 是非常好的選擇。
<p><img src="http://farm3.static.flickr.com/2601/3742415058_e51fc0c355.jpg">
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ZedGraph 最大的賣點在哪裡？應該是OpenSource，你可以修改代碼以適應自己的需求，例如：ZedGraph 在畫線型圖的時候，線條沒有使用抗鋸齒，你只要修改 Line類的 Default 結構中的預設設置就可以了。和 dotnetCharting 相比，ZedGraph 的效果要差一些，不過，要是自己調整的好，也還不錯，但是 ZedGraph 的優勢不在這裡。
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 由於 ZedGraph 是使用 GDI+ 直接在 Canvas 上進行描畫，所以，性能得到了保證，如果你改變坐標軸的刻度，和 dotnetCharing 相比，ZedGraph 的反應速度是很快的。基於此，ZedGraph 提供了很重要的縮放和拖動功能，你可以通過鼠標滾輪進行方法，縮小圖表，可以通過鼠標中鍵來拖動，非常方便。
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 對於類似股市的實時走勢，CPU 使用率等實時變化的數據，使用 ZedGraph 也可以很方便地作到。ZedGraph 在基於 PointPairList 作畫，所以你只要在 PointPairList 這個集合中添加新的數據，然後進行重畫就可以實現了，對於性能，上面說了，由於是直接使用 GDI+，性能是比較好的，我測過 400 個點是沒問題的。所以，ZedGraph 對於實時要求比較強的需求也是可以應對的。
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 總結的來說，dotnetCHARTING 產出的圖表效果好，但是性能方面較差，對實時要求強的需求不適應。ZedGraph 開放原始碼，效果比起 dotnetCHARTING 差，但是性能好，能適應有實時要求的數據。
<p>本文章轉貼於：<a title="http://blog.csai.cn/user1/17072/archives/2009/37706.html" href="http://blog.csai.cn/user1/17072/archives/2009/37706.html" target="_blank">http://blog.csai.cn/user1/17072/archives/2009/37706.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/235/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
