2009年5月23日

輕鬆使用MS Chart Control - 樣式設定篇

這次來簡單的說明一下 Chart Control 的一些樣式設定吧

首先,先把焦點放到 Chart 屬性的 Appearance 分類
要修改Chart上的資料顯示顏色,可直接修改 Palette 屬性,下拉會有預設的多種樣式
若是想要自己設定顏色,就到 PaletteCustomColors 裡設定

不過坎尼這邊一直有個疑問,在 PaletteCustomColors 的說明裡

提到這個屬性比上面的 Palette 的屬性值還要優先
但為何兩個屬性同時設定時,出現的顏色卻是以 Palette 優先呢? (如下圖)

坎尼開了 vs2010 的 Chart Control 出來看,也是一樣
所以說明是一回事,顯示出來又是另一回事....
Anyway,大家有空再自行測試看看 (說不定是坎尼搞錯了?)

另外還有一種方法可以改變資料顯示的顏色
就是直接到 Series 裡修改,且目前實驗發現,這邊修改的 Style 優先權最高
下面可以看到坎尼加了個 Series2,並將顏色改為漸層

顏色為自訂的漸層色

最後來補充一下,上面的圖都有出現的外框
先打開 Chart 屬性裡的 BorderSkin
首先要選定 SkinStyle,接著再調整要展示的樣式

前幾張實際畫面的 Border Style 如下
(這裡為了展示,所以幾乎所有樣式都選了)


最後是 範例檔下載
範例展示畫面


其實這篇所講的樣式還只是冰山一角
未來有機會會再介紹其他樣式設定

2009年5月21日

輕鬆使用MS Chart Control - 資料繫結篇

之前坎尼有寫一篇 Chart Control 製作學生成績表
現在就來教一下如何使用 Chart Control 吧!
(安裝部分就跳過不講了,請自行參照上面的連結)

I.利用 SqlDataSource 控制項
首先,在頁面上拉進一個 Chart SqlDataSource

將 Chart1 的 DataSourceID 屬性指定為剛剛拉進來的 SqlDataSource

接著選擇 Chart1 屬性裡的 Series 集合

選 Series1後,設定 XValueMember YValueMembers
這邊由於有設定 SqlDataSource,所以兩個屬性都可以由下拉的方式選擇
(注意:X軸為類別,Y軸為數值

接著就是放到網頁上預覽啦


II.利用 ObjectDataSource 控制項
首先,在後端建立一個取得資料的方法,如下圖的 GetMyTable()
這邊坎尼先用人工的方式建立資料,並可回傳給 ObjectDataSource 使用

前端加入一個 ObjectDataSource
並將 ID 指定給 Chart1 的 DataSourceID 屬性
XValueMember 及 YValueMembers 的設定方式和前面相同

OK!!!大功告成!! (最後會有畫面

III.利用程式控制
其實這個方法已經在上次講的 範例 裡有提到過了
  • 先取得資料
  • 把資料設定給 Chart1.DataSource
  • Chart1.DataBind(); //打完收功

這邊要注意的是 ValueMember 已在前端設定,所以可以直接 DataBind()
否則要加入下圖的設定


範例檔下載 (只有 ObjectDataSource 及 程式控制部分,SqlDataSource請自行練習)

範例檔的執行畫面 (就長度來看,工程師的薪水似乎比較高?)


資料繫結給 Chart 控制項
最主要的就是 X 及 Y 的繫結欄位,且Y一定要數值型
另外目前都還只用一個 Series,或許未來會用多個 Series 來示範?

下次的主題是樣式設定,敬請期待 :D

2009年5月19日

visual studio 2010 beta 快照

距離上次提出 vs2010 CTP 版本至今大約也過了半年
總算是在本星期三可下載beta版本 下載點 (聽說星期三才有用)
這邊坎尼抓了幾張圖和大家分享一下

安裝畫面可以參考祭司的 VS 2010安裝畫面預覽
安裝完就是漂亮的 vs2010 start page
這次將整個 visual studio 利用 WPF 重新改寫
畫面真是愈來愈亮麗啦 (這裡很抱歉沒抓圖 Orz

首先是 new project 的畫面

上面一樣有 multi-target 選項,當然支援到 .NET Framework 4.0 beta
另外還有 2.0、3.0、3.5 可供使用者選擇
左方的專案樣版也提供了 SharePoint Silverlight 開發樣版
但 MVC 這次則不包含在vs2010 beta 版本裡,而且聽說裝了還會出問題
(若還是想裝MVC的人可以參考這篇

另外這次在UI上方多了個 Sort 下拉選項,可以將專案樣版依名稱做排序

接著坎尼開了個 Web Application 想比較一下差異性
下圖左方為 vs 2010 的預設 Toolbox,右方則為 vs 2008
以全部收合的大類來看是完全一樣的 (坎尼另外加進來的 item 不算

standard 一打開坎尼就發現多了 DynamicHyperLink 的 Control

Data工具箱打開則是多了 MS Chart Control
但由於坎尼早就裝了,所以這裡的工具都一樣

就在坎尼逐一對照之下,發現其他工具箱裡的控制項完全一樣 (除了版本號改為4.0
所以此次在控制項方面的改變不大
這次外功目前看來尚無強力新招,但內力據坎尼看到的倒是增加了不少
如加強 Ajax Library、Session State 改善等 (詳情請參照 這裡

最後提一個坎尼從CTP就十分尬意的功能:code snippets of javascript
下圖是在打完 function 後,按下 tab 鍵跳出的畫面

當然,for迴圈等基本語法也有支援

以後寫程式的速度又可加快不少

有興趣的人別忘了星期三 (應該是美國時間) 上網下載 vs 2010 beta1喔 :)

2009年5月9日

New World Community Grid Project – Influenza Antiviral Drug Search

距離上次 World Community Grid 啟動的新專案 – Help Fight Childhood Cancer 不久,前幾天收到 World Community Grid 寄來的信,最近開始了一個新的 Research Project
- Influenza Antiviral Drug Search,顧名思義,就是要研發對抗流感的藥物,主要針對那些已經對一般藥物產生抗藥性的強大流感病毒。

如果你不想讓你的 CPU 繼續吃閒飯,那麼可以藉由這個機會加入這個人類對抗病毒的大戰!!

Mail 的內容如下:

Title: World Community Grid - You Can Help Fight Influenza!
World Community Grid has started a new research project that will use your donated computer time to find new drugs that can stop the spread of an influenza infection in an individual. The research will specifically address the influenza strains that have become drug resistant, as well as new strains that are appearing. Your computer will help identify the chemical compounds that are the best candidates. This will accelerate the efforts to develop treatments that would be useful in managing seasonal influenza outbreaks and future influenza epidemics.
If you are currently contributing and want to check to see if you are contributing to this project, click here. If you are no longer contributing but would like to contribute to this project, please click here.

For more information about the Influenza Antiviral Drug Search project or other projects running on World Community Grid, please click here.

Influenza Antiviral Drug Search 計畫首頁的說明如下:

Project Status and Findings: 
If you have comments or questions about this project, please visit the Influenza Antiviral Drug Search forum. For specific questions about the project, please go to the Influenza Antiviral Drug Search FAQs.

Mission
The mission of the Influenza Antiviral Drug Search project is to find new drugs that can stop the spread of an influenza infection in the body. The research will specifically address the influenza strains that have become drug resistant as well as new strains that are appearing. Identifying the chemical compounds that are the best candidates will accelerate the efforts to develop treatments that would be useful in managing seasonal influenza outbreaks, and future influenza epidemics and even pandemics.

Significance
Hundreds of thousands of people around the world die each year as a result of influenza infections. If a particularly virulent strain emerges that is readily transmitted among humans, a pandemic can potentially kill millions of people. The influenza virus mutates rapidly and therefore new varieties of influenza appear each year. Influenza vaccines are designed to anticipate the strains likely to be prevalent for the next flu season but can often miss newly evolved varieties. While drugs such as oseltamivir (commercial name Tamiflu) and zanamivir (commercial name Relenza) help keep influenza from spreading in the body, they do not work for all types of influenza and new drug resistant forms of influenza evolve and cannot be treated with these drugs. When drug resistant strains emerge, manufacturers designing vaccines may not be able to respond quickly enough to prevent a large outbreak of the disease. This project will search for promising new drug leads that stop the replication of the influenza viruses within the body, potentially helping patients who are not immune to a particular form of influenza. The discovery of both broad-spectrum and specific antiviral drugs is expected to significantly improve global health.

Approach
One promising approach to combat these viruses and prevent them from causing disease is to develop new drugs that inhibit neuraminidase (N1, N2, etc), NS1 protein, hemagglutinin, and possibly other targets that influenza needs to spread in the body. Using the known chemical structures of these target molecules, the project will perform virtual chemistry experiments and determine which of millions of known compounds attach to these target molecules in a manner that can disable or inhibit them, thus potentially keeping the influenza virus from spreading in the body. These experiments are performed using a program called AutoDock, from the Scripps Research Institute. This software is used for several other projects on World Community Grid. These include FightAIDS@Home, Discovering Dengue Drugs - Together, and Help Fight Childhood Cancer projects. Once drug candidates are identified using World Community Grid, then additional laboratory work, testing and ultimately drug trials will be required. This will likely not lead to any immediate treatments for influenza during the current H1N1 outbreak. However, influenza viruses cause recurrent seasonal disease outbreaks and have the potential for evolving into dangerous forms. Thus, proceeding on this project at this time will give us a better chance to be prepared for more serious outbreaks in the future.
In an effort to spread the words about WCG, I will include a link to my last post about WCG – here it is: Help Fight Childhood Cancer

Google Spreadsheet 裡用規則運算式

最近因為工作關係,遇到要用 Google Form 及 Google Sheet 所以研究了 Google Sheet 裡的一些 function 怎麼用 首先,分享一下如何在 Google Sheet 裡用規則運算 :D