最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#畫圖之餅圖折線圖的實(shí)現(xiàn)方法

 更新時(shí)間:2014年09月20日 11:09:02   投稿:shichen2014  
這篇文章主要介紹了C#畫圖之餅圖折線圖的實(shí)現(xiàn)方法,以實(shí)例形式講述了C#畫圖的完整實(shí)現(xiàn)過程,是非常實(shí)用的技巧,有不錯(cuò)的借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了C#畫圖之餅圖折線圖的實(shí)現(xiàn)方法,是C#程序設(shè)計(jì)中非常實(shí)用的技巧。分享給大家供大家參考。具體方法分析如下:

顯示圖像的控件定義如下:

public PlaceHolder PlaceHolder1;

各個(gè)圖像的類別名稱如下:

PictureType    圖形種類    5    chChartTypeBarClustered    簇狀條形圖    0    NULL

PictureType    圖形種類    7    chChartTypeBarClustered3D    三維簇狀條形圖    0    NULL

PictureType    圖形種類    6    chChartTypeBarStacked    堆積條形圖    0    NULL

PictureType    圖形種類    8    chChartTypeBarStacked3D    三維堆積條形圖    0    NULL

PictureType    圖形種類    1    chChartTypeColumnClustered    簇狀柱形圖    0    NULL

PictureType    圖形種類    3    chChartTypeColumnClustered3D    三維簇狀柱形圖    0    NULL

PictureType    圖形種類    2    chChartTypeColumnStacked    堆積柱狀圖    1    NULL

PictureType    圖形種類    4    chChartTypeColumnStacked3D    三維堆積柱形圖    0    NULL

PictureType    圖形種類    13    chChartTypeLine    折線圖    0    NULL

PictureType    圖形種類    15    chChartTypeLineMarkers    數(shù)據(jù)點(diǎn)折線圖    0    NULL

PictureType    圖形種類    14    chChartTypeLineStacked    堆積折線圖    0    NULL

PictureType    圖形種類    16    chChartTypeLineStackedMarkers    堆積數(shù)據(jù)點(diǎn)折線圖    0    NULL

PictureType    圖形種類    17    chChartTypePie    餅圖    1    NULL

PictureType    圖形種類    19    chChartTypePie3D    三維餅圖    0    NULL

PictureType    圖形種類    18    chChartTypePieExploded    分離型餅圖    0    NULL

PictureType    圖形種類    20    chChartTypePieExploded3D    分離型三維餅圖    0    NULL

PictureType    圖形種類    9    chChartTypeSmoothLine    平滑線圖    0    NULL

PictureType    圖形種類    10    chChartTypeSmoothLineMarkers    數(shù)據(jù)點(diǎn)平滑線圖    0    NULL

PictureType    圖形種類    11    chChartTypeSmoothLineStacked    堆積平滑線圖    0    NULL

PictureType    圖形種類    12    chChartTypeSmoothLineStackedMarkers    堆積數(shù)據(jù)平滑線圖    0    NULL

取圖像的方法如下:

/// </summary>
/// <param name="dbDtViewWrk">傳遞的數(shù)據(jù)</param>
/// <param name="strAbsolutePath">絕對(duì)路徑</param>
/// <param name="strRelativePath">相對(duì)路徑</param>
/// <param name="ChartType">要畫的圖格式(餅圖或者折線圖等)</param>
/// <param name="strTitle">統(tǒng)計(jì)名稱</param>
public void PaintToImage(DataTable dbDtViewWrk, string strAbsolutePath, string strRelativePath, ChartChartTypeEnum ChartType, string strTitle)
{
  string strSeriesName = "圖例";
  //存放項(xiàng)目
  string[] ItemsName = new string[dbDtViewWrk.Rows.Count];
  //存放數(shù)據(jù)
  string[] ItemsCount = new string[dbDtViewWrk.Rows.Count];
  //刻度單位
  int iUnit = 1;
  //最大值
  int iMaxValue = 0;
  string strXdata = String.Empty;
  string strYdata = String.Empty;
  
 //為數(shù)組賦值
 for (int i = 0; i < dbDtViewWrk.Rows.Count; i++)
 {
   ItemsName[i] = dbDtViewWrk.Rows[i][0].ToString(); //要統(tǒng)計(jì)的字段名字
   ItemsCount[i] = dbDtViewWrk.Rows[i][5].ToString();//要統(tǒng)計(jì)的字段數(shù)據(jù)
 }
  //為x軸指定特定字符串,以便顯示數(shù)據(jù)
  // string strXdata = String.Empty;
  foreach (string strData in ItemsName)
  {
 strXdata += strData + "\t";
  }
  // string strYdata = String.Empty;
  //為y軸指定特定的字符串,以便與x軸相對(duì)應(yīng)
  foreach (string strValue in ItemsCount)
  {
 strYdata += strValue + "\t";
 if (int.Parse(strValue) > iMaxValue)
 {
   iMaxValue = int.Parse(strValue);
 }
  }
  if (iMaxValue > 20)
  {
 iUnit = iMaxValue / 10;
  }
  //創(chuàng)建ChartSpace對(duì)象來放置圖表
  ChartSpace laySpace = new ChartSpaceClass();
  
  //在ChartSpace對(duì)象中添加圖表
  ChChart InsertChart = laySpace.Charts.Add(0);
  
  //底座顏色
  InsertChart.PlotArea.Interior.Color = "white";

  //指定繪制圖表的類型。類型可以通過OWC.ChartChartTypeEnum枚舉值得到
  InsertChart.Type = ChartType;//柱形圖


  //指定圖表是否需要圖例標(biāo)注
  InsertChart.HasLegend = true;
  InsertChart.BarWidth = 0;
  InsertChart.Legend.Position = ChartLegendPositionEnum.chLegendPositionBottom;

  InsertChart.HasTitle = true;//為圖表添加標(biāo)題
  InsertChart.Title.Caption = strTitle;//標(biāo)題名稱

  //為x,y軸添加圖示說明
  if (ChartType.ToString().IndexOf("ChartTypePie") == -1)
  {
 InsertChart.Axes[0].Font.Size = 11; //X軸

 InsertChart.Axes[1].Font.Size = 11; //Y軸
 InsertChart.Legend.Font.Size = 11;
 InsertChart.Axes[0].HasTitle = true;
 InsertChart.Axes[0].Title.Caption = "";//月份
 InsertChart.Axes[1].HasTitle = true;
 //InsertChart.Axes[1].Scaling.SplitMinimum = 200;
 InsertChart.Axes[1].Title.Caption = "數(shù)量";
 InsertChart.Axes[1].MajorUnit = iUnit; //刻度單位設(shè)置
 InsertChart.Axes[1].Scaling.Minimum = 0;//最小刻度=0
  }

  //添加一個(gè)series系列
  InsertChart.SeriesCollection.Add(0);
  
  //給定series系列的名字
  InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName);

  //給定分類
  strXdata = strXdata.Substring(0, strXdata.Length - 1);
  InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strXdata);

  //給定值
  strYdata = strYdata.Substring(0, strYdata.Length - 1);
  InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strYdata);

  //添加標(biāo)簽
  ChDataLabels dls = InsertChart.SeriesCollection[0].DataLabelsCollection.Add();
  if (ChartType.ToString().IndexOf("ChartTypePie") != -1)
  {
 dls.Position = ChartDataLabelPositionEnum.chLabelPositionCenter;
 dls.HasPercentage = false;
 //dls.HasValue = false;
 dls.HasCategoryName = false;
 //指定圖表是否需要圖例標(biāo)注
 InsertChart.HasLegend = true;
 InsertChart.Legend.Position = ChartLegendPositionEnum.chLegendPositionBottom;
  }

  //輸出文件.
  int iImageLength = 0;
  int iImageWidth = 0;

  //從Config文件取得設(shè)置
  //iImageLength = int.Parse(WebConfigurationManager.AppSettings["ShowImageLength"]);
  //iImageWidth = int.Parse(WebConfigurationManager.AppSettings["ShowImageWidth"]);
  iImageLength = 450;
  iImageWidth = 300;

  string strImageName = ChartType.ToString() + "_" + Guid.NewGuid().ToString("N") + ".png";
  laySpace.ExportPicture(strAbsolutePath + strImageName, "PNG", 450, 300);

  //把圖片添加到placeholder中,并在頁面上顯示
  string strImageTag = "<IMG WIDTH='450' SRC='" + strRelativePath + strImageName + "'/>";
  
  this.PlaceHolder1.Controls.Add(new LiteralControl(strImageTag));
  // return strImageTag;
}

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 輕松學(xué)習(xí)C#的哈希表

    輕松學(xué)習(xí)C#的哈希表

    輕松學(xué)習(xí)C#的哈希表,對(duì)C#的哈希表感興趣的朋友可以參考本篇文章,幫助大家更靈活的運(yùn)用C#的哈希表
    2015-11-11
  • c# winform多線程死循環(huán)踩坑

    c# winform多線程死循環(huán)踩坑

    本文主要介紹了c# winform多線程死循環(huán)踩坑,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-12-12
  • 使用C#實(shí)現(xiàn)一個(gè)PPT遙控器

    使用C#實(shí)現(xiàn)一個(gè)PPT遙控器

    由于本人需要參加的討論會(huì)比較多,每次都會(huì)涉及到PPT,有時(shí)候坐在電腦旁講會(huì)比較不生動(dòng),前人就發(fā)明了PPT遙控器,今天就給大家介紹下基于C#實(shí)現(xiàn)ppt遙控器,感興趣的朋友一起看看吧
    2021-05-05
  • 淺析c#范型中的特殊關(guān)鍵字where & default

    淺析c#范型中的特殊關(guān)鍵字where & default

    以下是對(duì)c#范型中的特殊關(guān)鍵字where和default進(jìn)行了詳細(xì)的介紹,需要的朋友可以過來參考下
    2013-09-09
  • 基于C#實(shí)現(xiàn)簡(jiǎn)單離線注冊(cè)碼生成與驗(yàn)證

    基于C#實(shí)現(xiàn)簡(jiǎn)單離線注冊(cè)碼生成與驗(yàn)證

    本文使用RSA非對(duì)稱加密和Base64簡(jiǎn)單地實(shí)現(xiàn)離線注冊(cè)碼的生成與驗(yàn)證功能。感興趣的朋友跟著小編一起學(xué)習(xí)吧
    2015-09-09
  • 解析C#中的ref和out參數(shù)

    解析C#中的ref和out參數(shù)

    本文將通過實(shí)例和說明,給大家詳細(xì)講解C#中的ref和out參數(shù)
    2013-11-11
  • C#動(dòng)態(tài)執(zhí)行字符串(動(dòng)態(tài)創(chuàng)建代碼)的實(shí)例代碼

    C#動(dòng)態(tài)執(zhí)行字符串(動(dòng)態(tài)創(chuàng)建代碼)的實(shí)例代碼

    在編寫C#程序的時(shí)候,有時(shí)我們需要?jiǎng)討B(tài)生成一些代碼并執(zhí)行。然而C#不像JavaScript有一個(gè)Eval函數(shù),可以動(dòng)態(tài)的執(zhí)行代碼。所有這些功能都要我們自己去完成
    2013-03-03
  • C#實(shí)現(xiàn)對(duì)象序列化的3種方案小結(jié)

    C#實(shí)現(xiàn)對(duì)象序列化的3種方案小結(jié)

    在上位機(jī)開發(fā)過程中,我們可能經(jīng)常要實(shí)現(xiàn)一個(gè)數(shù)據(jù)對(duì)象的持久化,本文主要介紹了C#實(shí)現(xiàn)對(duì)象序列化的3種方案,具有一定的參考價(jià)值,感興趣的可以了解一下
    2025-01-01
  • Unity實(shí)現(xiàn)音頻播放管理器

    Unity實(shí)現(xiàn)音頻播放管理器

    這篇文章主要為大家詳細(xì)介紹了Unity實(shí)現(xiàn)音頻播放管理器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-09-09
  • C#操作windows系統(tǒng)進(jìn)程的方法

    C#操作windows系統(tǒng)進(jìn)程的方法

    這篇文章介紹了C#操作windows系統(tǒng)進(jìn)程的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-05-05

最新評(píng)論

河源市| 祥云县| 阿拉善左旗| 白朗县| 佛山市| 平陆县| 龙陵县| 尼玛县| 京山县| 法库县| 英超| 揭阳市| 岱山县| 兴仁县| 海安县| 汉寿县| 玉龙| 资源县| 邢台市| 长岛县| 扶沟县| 金川县| 台江县| 凤冈县| 昔阳县| 德清县| 阿城市| 蓬溪县| 奎屯市| 博野县| 周口市| 兰坪| 洪洞县| 和林格尔县| 灵璧县| 当涂县| 乌拉特中旗| 温泉县| 建宁县| 类乌齐县| 峨眉山市|