MS Chart Control 學習手記(二) - 圓餅圖
using System.Web.UI.DataVisualization.Charting; |
02 |
using System.Drawing; |
03 |
04 |
namespace Chart.AJAX |
05 |
{ |
06 |
public partial class Export_AJAX : System.Web.UI.Page |
07 |
{ |
08 |
void CreateChart() |
09 |
{ |
10 |
string [] xValues = { "0-20" , "20-30" , "30-40" , "40-50" , "50-60" , "> 60" , "unknow" }; |
11 |
int [] yValues = {5, 18, 45, 17, 2, 1, 162 }; |
12 |
13 |
//ChartAreas,Series,Legends 基本設定------------------------------------------------- |
14 |
Chart Chart1 = new Chart(); |
15 |
Chart1.ChartAreas.Add( "ChartArea1" ); //圖表區域集合 |
16 |
Chart1.Legends.Add( "Legends1" ); //圖例集合說明 |
17 |
Chart1.Series.Add( "Series1" ); //數據序列集合 |
18 |
19 |
//設定 Chart------------------------------------------------------------------------- |
20 |
Chart1.Width = 770; |
21 |
Chart1.Height = 400; |
22 |
Title title = new Title(); |
23 |
title.Text = titleStr; |
24 |
title.Alignment = ContentAlignment.MiddleCenter; |
25 |
title.Font = new System.Drawing.Font( "Trebuchet MS" , 14F, FontStyle.Bold); |
26 |
Chart1.Titles.Add(title); |
27 |
28 |
//設定 ChartArea1-------------------------------------------------------------------- |
29 |
Chart1.ChartAreas[ "ChartArea1" ].Area3DStyle.Enable3D = is3D; |
30 |
Chart1.ChartAreas[0].AxisX.Interval = 1; |
31 |
32 |
//設定 Legends------------------------------------------------------------------------- |
33 |
//Chart1.Legends["Legends1"].DockedToChartArea = "ChartArea1"; //顯示在圖表內 |
34 |
//Chart1.Legends["Legends1"].Docking = Docking.Bottom; //自訂顯示位置 |
35 |
//背景色 |
36 |
Chart1.Legends[ "Legends1" ].BackColor = Color.FromArgb(235, 235, 235); |
37 |
//斜線背景 |
38 |
Chart1.Legends[ "Legends1" ].BackHatchStyle = ChartHatchStyle.DarkDownwardDiagonal; |
39 |
Chart1.Legends[ "Legends1" ].BorderWidth = 1; |
40 |
Chart1.Legends[ "Legends1" ].BorderColor = Color.FromArgb(200, 200, 200); |
41 |
42 |
//設定 Series1----------------------------------------------------------------------- |
43 |
Chart1.Series[ "Series1" ].ChartType = SeriesChartType.Pie; |
44 |
//Chart1.Series["Series1"].ChartType = SeriesChartType.Doughnut; |
45 |
Chart1.Series[ "Series1" ].Points.DataBindXY(xValues, yValues); |
46 |
Chart1.Series[ "Series1" ].LegendText = "#VALX: [ #PERCENT{P1} ]" ; //X軸 + 百分比 |
47 |
Chart1.Series[ "Series1" ].Label = "#VALX\n#PERCENT{P1}" ; //X軸 + 百分比 |
48 |
//Chart1.Series["Series1"].LabelForeColor = Color.FromArgb(0, 90, 255); //字體顏色 |
49 |
//字體設定 |
50 |
Chart1.Series[ "Series1" ].Font = new System.Drawing.Font( "Trebuchet MS" , 10, System.Drawing.FontStyle.Bold); |
51 |
Chart1.Series[ "Series1" ].Points.FindMaxByValue().LabelForeColor = Color.Red; |
52 |
//Chart1.Series["Series1"].Points.FindMaxByValue().Color = Color.Red; |
53 |
//Chart1.Series["Series1"].Points.FindMaxByValue()["Exploded"] = "true"; |
54 |
Chart1.Series[ "Series1" ].BorderColor = Color.FromArgb(255, 101, 101, 101); |
55 |
|
56 |
//Chart1.Series["Series1"]["DoughnutRadius"] = "80"; // ChartType為Doughnut時,Set Doughnut hole size |
57 |
//Chart1.Series["Series1"]["PieLabelStyle"] = "Inside"; //數值顯示在圓餅內 |
58 |
Chart1.Series[ "Series1" ][ "PieLabelStyle" ] = "Outside" ; //數值顯示在圓餅外 |
59 |
//Chart1.Series["Series1"]["PieLabelStyle"] = "Disabled"; //不顯示數值 |
60 |
//設定圓餅效果,除 Default 外其他效果3D不適用 |
61 |
Chart1.Series[ "Series1" ][ "PieDrawingStyle" ] = "Default" ; |
62 |
//Chart1.Series["Series1"]["PieDrawingStyle"] = "SoftEdge"; |
63 |
//Chart1.Series["Series1"]["PieDrawingStyle"] = "Concave"; |
64 |
65 |
//Random rnd = new Random(); //亂數產生區塊顏色 |
66 |
//foreach (DataPoint point in Chart1.Series["Series1"].Points) |
67 |
//{ |
68 |
// //pie 顏色 |
69 |
// point.Color = Color.FromArgb(150, rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)); |
70 |
//} |
71 |
Page.Controls.Add(Chart1); |
72 |
} |
73 |
} |
74 |
} |

MS Chart Control 學習手記(二) - 圓餅圖的更多相关文章
- [Python學習筆記] 使用xlwings 插入註解 (forked 版本)
到今天為止 xlwings 還沒有插入註解的功能 去原始開發者的 Github Pull Requests 他說之前有人有建議要加入這個功能 但他還沒更新~ 如果需要使用 Python 來插入註解的話 ...
- Java學習筆記(基本語法)
本文件是以學習筆記的概念為基礎,用於自我的複習紀錄,不過也開放各位的概念指證.畢竟學習過程中難免會出現觀念錯誤的問題.也感謝各位的觀念指證. 安裝JDK 在Oracle網站中找自己系統的JDK下載位置 ...
- FPGA學習筆記(肆)--- Star Test Bench Template Writer
上一篇testbench我自己也沒怎麽搞懂,再來一篇學習特權同學的方法. 課程:Lesson 7 BJ EPM240学习板实验1——分频计数实验 鏈接:https://www.youtube.com/ ...
- [DDD]學習筆記 第15章 精煉(Distillation)
核心領域(Core-Domain) 為了使領域模型成為企業真正的資產, 模型中的關鍵核心部份需要足夠靈活和充分利用來創建應用程序的功能; 簡而言之, 核心領域是系統中最有價值的部份. 濃縮模型, 將最 ...
- [Python學習筆記] 利用 Python在Excel 插入註解
用Python 來處理excel 檔 用過了 openpyxl 還有 pyexcel目前覺得除了讀寫如果還要使用另外的功能 (像是讀取格子裡的公式)可以用 xlwings 他的首頁標題 " ...
- C# partial 學習筆記
局部類的講解參考:http://blog.csdn.net/susan19890313/article/details/7575204 感謝作者~
- ORACLE 學習筆記
proc 里的 commit等于提交就是你做了insert或者update后,commit后才是真正修改或者插入了数据库中 如果不提交的话,那么这个表就被锁了 CURSOR MYCURSOR is ...
- FPGA學習筆記(貳)--- 流水燈
平臺:FPGA黑金开发板 AX301 開發環境:Quartus Prime Version 17.0.0 Build 595 04/25/2017 Standard Edition 引脚配置:鼠標托拉 ...
- [Python學習筆記] 使用 selenium 抓取網頁並且雙擊滑鼠 (double click)
一開始使用的時候 看官方文件 以為使用 double_click()即可 但後來出現錯誤 AttributeError: 'WebElement' object has no attribute 'd ...
随机推荐
- Android——Fragment 真正的完全解析(下)(转)
原文地址:http://blog.csdn.net/lmj623565791/article/details/37992017 上篇博客中已经介绍了Fragment产生原因,以及一些基本的用法和各种A ...
- 【html】优酷视频去广告代码
相信大家都有这样的感受,看个视频有个30秒的广告,让人非常的不爽.同样对于我们前端童鞋来说,为了吸引用户,把制作好的视频嵌入到网页中,结果因为视频有30秒的广告不但没有吸引到多少用户,反而可能会流失一 ...
- SpringMVC深度探险(三) —— DispatcherServlet与初始化主线
在上一篇文章中,我们给出了构成SpringMVC应用程序的三要素以及三要素的设计过程.让我们来归纳一下整个设计过程中的一些要点: SpringMVC将Http处理流程抽象为一个又一个处理单元 Spri ...
- ASP.NET MVC5使用AjaxHelp
默认情况下,Visual Studio 2013新建ASP.NET MVC5项目,不包含jquery.unobtrusive-ajax.js,需要手工添加. 点击Visual Studio 2013中 ...
- MapReduce 图解流程超详细解答(1)-【map阶段】
转自:http://www.open-open.com/lib/view/open1453097241308.html 在MapReduce中,一个YARN 应用被称作一个job, MapReduc ...
- JDBC结果集
SQL语句执行后从数据库查询读取数据,返回的数据放在结果集中. SELECT语句用于从数据库中选择行并在结果集中查看它们的标准方法. java.sql.ResultSet接口表示数据库查询的结果集. ...
- Windows 2008安装Oracle10g提示操作系统版本检查未通过
原文链接:http://www.cnblogs.com/emanlee/archive/2012/12/18/2824147.html 因开发环境需要,在Windows Server 2008 R2 ...
- mothur summary.seqs 统计fasta文件中每条序列的长度
在介绍summary.seqs的用法之前,我们首先需要搞清楚两个概念: 1)ambiguous bases 中文叫做模糊碱基,对于DNA序列来说,只有ATCG 4种碱基,在IUPAC定义的碱基标准中, ...
- Linux 下 CPU 使用率与机器负载的关系与区别
原文链接: http://blog.chinaunix.net/uid-28541347-id-4926054.html 当我们使用top命令查看系统的资源使用情况时会看到load average, ...
- JavaScript中String和JSON互换
最简答的方式是: JSON.parse(obj) 将json对象解析为json字符串 JSON.stringify(str) 将json字符串转为json对象. 需要注意的是早期的IE浏览器是没有JS ...