DEVChart_ParticlesComposition.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. using DevExpress.Charts.Model;
  2. using DevExpress.Utils;
  3. using DevExpress.XtraCharts;
  4. using DevExpress.XtraReports.UI;
  5. using NPOI.Util;
  6. using OTSIncAReportApp._1_UI.Control_DEVCharts;
  7. using OTSIncAReportApp.DataOperation.DataAccess;
  8. using OTSIncAReportApp.OTSRstMgrFunction;
  9. using OTSIncAReportApp.OTSSampleReportInfo;
  10. using OTSIncAReportApp.SysMgrTools;
  11. using OTSIncAReportGrids;
  12. using System;
  13. using System.Collections;
  14. using System.Collections.Generic;
  15. using System.Data;
  16. using System.Drawing;
  17. using System.Linq;
  18. using System.Windows.Forms;
  19. using System.Xml;
  20. using static System.Net.WebRequestMethods;
  21. namespace OTSIncAReportApp.Control_ECharts
  22. {
  23. /// <summary>
  24. /// 各图char相关模块
  25. /// </summary>
  26. public partial class DEVChart_ParticlesComposition : UserControl
  27. {
  28. Hashtable table;
  29. #region 图表相关变量
  30. //y轴名称
  31. public string m_str_AxisY { get; set; }
  32. //数据图类型:常用夹杂物分类CommonlyUsedClassify ,颗粒成分PComponent,元素成分EComponent,颗粒尺寸分布PSize
  33. string ComSel { get; set; }
  34. public bool Report { get; set; }
  35. frmReportApp m_ReportApp;
  36. private frmReportConditionChoose m_conditionChoose;
  37. private ResultDataMgr m_DataMgr;
  38. private List<DataTable> prListData = new List<DataTable>();
  39. private List<string> prListString = new List<string>();
  40. #endregion
  41. #region 窗体加载及构造函数
  42. public DEVChart_ParticlesComposition(frmReportApp ReportApp, string comsel)
  43. {
  44. ComSel = comsel;
  45. m_ReportApp = ReportApp;
  46. m_conditionChoose = ReportApp.m_conditionChoose;
  47. m_DataMgr = ReportApp.m_rstDataMgr;
  48. InitializeComponent();
  49. //国际化
  50. Language lan = new Language();
  51. table = lan.GetNameTable("CompositionDistributionGrid");
  52. comboBox1.SelectedIndex = 0;
  53. }
  54. private void EChart_ParticlesComposition_Load(object sender, EventArgs e)
  55. {
  56. string sou = "";
  57. int sel = 0;//选择颗粒范围(0为全部颗粒1为选择颗粒)
  58. if (Report)
  59. {
  60. sou = m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].anotherFileName.ToString();
  61. sel = 0;
  62. }
  63. else
  64. {
  65. sou = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
  66. sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  67. }
  68. Report = false;
  69. if (m_ReportApp.more)
  70. {
  71. m_ReportApp.trans = false;
  72. }
  73. else
  74. {
  75. m_ReportApp.trans = true;
  76. }
  77. m_ReportApp.more = true;
  78. List<DataTable> list_dt = GetListJsonStr();
  79. bool bl = false;
  80. for (int i=0;i< list_dt.Count;i++)
  81. {
  82. if (list_dt[i].Rows.Count>0)
  83. {
  84. bl = true;
  85. }
  86. }
  87. List<DataTable> listDt = new List<DataTable>();
  88. for (int i=0;i< list_dt.Count;i++)
  89. {
  90. DataTable dt = list_dt[i].Clone();
  91. for (int a=0;a< list_dt[i].Rows.Count;a++)
  92. {
  93. if (list_dt[i].Rows[a]["name"].ToString() != "")
  94. {
  95. dt.Rows.Add(list_dt[i].Rows[a].ItemArray);
  96. }
  97. }
  98. listDt.Add(dt);
  99. }
  100. prListData = listDt.Copy();
  101. prListString.Clear();
  102. for (int i = 0; i < list_dt.Count; i++)
  103. {
  104. ResultFile resultFile = m_DataMgr.ResultFilesList.Find(s => s.anotherFileName == sou.Split('+')[i]);
  105. string str = resultFile.anotherFileName;
  106. prListString.Add(str);
  107. }
  108. panel1.Dock = DockStyle.Fill;
  109. chartControl1.Dock = DockStyle.Fill;
  110. int sel_pro = m_conditionChoose.m_conditionData.ProItemProIndex();
  111. if (sel_pro == 2)
  112. {
  113. comboBox1.Visible = false;
  114. Graphics_Stacking(list_dt[0]);
  115. }
  116. else
  117. {
  118. comboBox1.Visible = true;
  119. Graphics();
  120. }
  121. }
  122. #endregion
  123. #region 获取单数据源
  124. private DataTable ClassificationIntegration(string path, int sel)
  125. {
  126. //------------------加载模块,获取数据-------------------------------------------------
  127. ResultGrid ls_resultgrid = new ResultGrid(m_ReportApp);
  128. Dictionary<string, string> keyValues_ResultGrid = ls_resultgrid.GetData_ResultGrid_Report();
  129. //------------------加载模块,获取数据结束----------------------------------------------
  130. Dictionary<string, string>.Enumerator en = keyValues_ResultGrid.GetEnumerator();
  131. string str_SCZS = "";
  132. keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col5"].ToString(), out str_SCZS);//视场总数
  133. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  134. DataTable data = new DataTable();
  135. data = particledata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
  136. if (data.Rows.Count == 0)
  137. {
  138. return data;
  139. }
  140. DataTable AreaInformationOfAllElements = ConSolidateInvalid(data);
  141. DataTable AllAnalysisDetails = new DataTable();
  142. AllAnalysisDetails.Columns.Add("Name");
  143. AllAnalysisDetails.Columns.Add("TypeId");
  144. AllAnalysisDetails.Columns.Add("Area", typeof(double));
  145. AllAnalysisDetails.Columns.Add("Class");
  146. AllAnalysisDetails.Columns.Add("Cunt", typeof(double));
  147. for (int i = 0; i < AreaInformationOfAllElements.Rows.Count; i++)
  148. {
  149. DataRow dr2 = AllAnalysisDetails.NewRow();
  150. dr2["Name"] = AreaInformationOfAllElements.Rows[i]["TypeName"].ToString();
  151. dr2["Area"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["ar"]);
  152. dr2["TypeId"] = AreaInformationOfAllElements.Rows[i]["TypeId"].ToString();
  153. dr2["Cunt"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["con"]);
  154. dr2["Class"] = AreaInformationOfAllElements.Rows[i]["GroupName"].ToString();
  155. AllAnalysisDetails.Rows.Add(dr2);
  156. }
  157. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  158. List<string> ClassName = new List<string>();
  159. DataTable getClass_dt = particledata.GetAllClass();
  160. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  161. {
  162. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  163. }
  164. DataTable AreaRatio = new DataTable();
  165. AreaRatio.TableName = "InclusionAreaRatio";
  166. AreaRatio.Columns.Add("e1");
  167. AreaRatio.Columns.Add("e2");
  168. AreaRatio.Columns.Add("e3", typeof(double));
  169. AreaRatio.Columns.Add("e4");
  170. AreaRatio.Columns.Add("e5");
  171. AreaRatio.Columns.Add("Cunt", typeof(int));
  172. //获取夹杂物的总面积用于计算夹杂物类别的占比(gridview最后一个固定是未识别颗粒,要排除未识别颗粒所以for循环至grid view长度减一)
  173. double totalInclusionArea = 0;
  174. totalInclusionArea = Convert.ToDouble(decimal.Parse(AllAnalysisDetails.Compute("sum(Area)", "").ToString()));
  175. for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
  176. {
  177. DataRow dr2 = AreaRatio.NewRow();
  178. dr2["e1"] = AllAnalysisDetails.Rows[i]["Class"].ToString();
  179. dr2["e2"] = AllAnalysisDetails.Rows[i]["Name"].ToString();
  180. dr2["e3"] = Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]);
  181. dr2["e4"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / totalInclusionArea) * 100, 2);
  182. dr2["e5"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / Convert.ToDouble(str_SCZS)) * 100, 4);
  183. dr2["Cunt"] = AllAnalysisDetails.Rows[i]["Cunt"].ToString();
  184. AreaRatio.Rows.Add(dr2);
  185. }
  186. DataTable AreaRatio_dt = AreaRatio.Copy();
  187. AreaRatio_dt.Clear();
  188. for (int i = 0; i < ClassName.Count(); i++)
  189. {
  190. DataTable dt = AreaRatio.Copy();
  191. dt.Clear();
  192. for (int a = 0; a < AreaRatio.Rows.Count; a++)
  193. {
  194. if (AreaRatio.Rows[a]["e1"].ToString() == ClassName[i].ToString())
  195. {
  196. dt.Rows.Add(AreaRatio.Rows[a].ItemArray);
  197. }
  198. }
  199. DataView dv = dt.DefaultView;
  200. dv.Sort = "e3 DESC";
  201. DataTable dt_Element = dv.ToTable();
  202. for (int a = 0; a < dt_Element.Rows.Count; a++)
  203. {
  204. AreaRatio_dt.Rows.Add(dt_Element.Rows[a].ItemArray);
  205. }
  206. }
  207. DataTable AllAnalysisDetails1 = AreaRatio_dt.Copy();
  208. AllAnalysisDetails1.Clear();
  209. for (int i = 0; i < ClassName.Count; i++)
  210. {
  211. DataTable dt = AreaRatio_dt.Copy();
  212. dt.Clear();
  213. for (int a = 0; a < AreaRatio_dt.Rows.Count; a++)
  214. {
  215. if (AreaRatio_dt.Rows[a]["e1"].ToString() == ClassName[i].ToString())
  216. {
  217. dt.Rows.Add(AreaRatio_dt.Rows[a].ItemArray);
  218. }
  219. }
  220. if (dt.Rows.Count > 0)
  221. {
  222. double totalInclusionArea2 = Convert.ToDouble(decimal.Parse(AreaRatio_dt.Compute("sum(e3)", "").ToString()));
  223. double Area = Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
  224. int cunt = Convert.ToInt32(decimal.Parse(dt.Compute("sum(Cunt)", "").ToString()));
  225. DataRow dr3 = AllAnalysisDetails1.NewRow();
  226. dr3["e1"] = ClassName[i].ToString();
  227. dr3["e3"] = Math.Round(Area, 2);
  228. dr3["e4"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / totalInclusionArea2) * 100, 2);
  229. dr3["e5"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / Convert.ToDouble(str_SCZS)) * 100, 4);
  230. dr3["Cunt"] = cunt;
  231. AllAnalysisDetails1.Rows.Add(dr3);
  232. }
  233. }
  234. return AllAnalysisDetails1;
  235. }
  236. private DataTable ConSolidateInvalid(DataTable dt)
  237. {
  238. DataTable dt_invalid = dt.Clone();
  239. DataTable dt_no_invalid = dt.Clone();
  240. for (int i = 0; i < dt.Rows.Count; i++)
  241. {
  242. if (dt.Rows[i]["TypeName"].ToString() == "Invalid")
  243. {
  244. dt_invalid.Rows.Add(dt.Rows[i].ItemArray);
  245. }
  246. else
  247. {
  248. dt_no_invalid.Rows.Add(dt.Rows[i].ItemArray);
  249. }
  250. }
  251. return dt_no_invalid;
  252. }
  253. private string getWhere(string max, string min, string col)
  254. {
  255. if (col == "Area")
  256. {
  257. return col + ">=" + ((Convert.ToDouble(min) / 2) * (Convert.ToDouble(min) / 2) * Math.PI).ToString() + " and " + col + "<" + ((Convert.ToDouble(max) / 2) * (Convert.ToDouble(max) / 2) * Math.PI).ToString();
  258. }
  259. else
  260. {
  261. return col + ">=" + min + " and " + col + "<" + max;
  262. }
  263. }
  264. #endregion
  265. #region echarts
  266. /// <summary>
  267. /// 按照颗粒类别重新显示chart图
  268. /// </summary>
  269. public void DisplayTheChartAgainByParticleCategory(ReportCondition sourceGridData)
  270. {
  271. string stdId = "";
  272. int stdIdIndex = 0;
  273. //find the stdId condition
  274. var STDIdItm = sourceGridData.ConditionItemList.Find(s => s.iItemId == OTS_REPORT_PROP_GRID_ITEMS.STD_ID);
  275. if (STDIdItm != null)
  276. {
  277. stdId = STDIdItm.itemDisplayVal.ToString();
  278. stdIdIndex = STDIdItm.comboDownList.IndexOf(stdId);
  279. }
  280. string sou = "";
  281. int sel = 0;//选择颗粒范围(0为全部颗粒1为选择颗粒)
  282. if (Report)
  283. {
  284. sou = m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].anotherFileName.ToString();
  285. sel = 0;
  286. }
  287. else
  288. {
  289. sou = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
  290. sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  291. }
  292. Report = false;
  293. if (m_ReportApp.more)
  294. {
  295. m_ReportApp.trans = false;
  296. }
  297. else
  298. {
  299. m_ReportApp.trans = true;
  300. }
  301. m_ReportApp.more = true;
  302. List<DataTable> list_dt = GetListJsonStr();
  303. bool bl = false;
  304. for (int i = 0; i < list_dt.Count; i++)
  305. {
  306. if (list_dt[i].Rows.Count > 0)
  307. {
  308. bl = true;
  309. }
  310. }
  311. List<DataTable> listDt = new List<DataTable>();
  312. for (int i = 0; i < list_dt.Count; i++)
  313. {
  314. DataTable dt = list_dt[i].Clone();
  315. for (int a = 0; a < list_dt[i].Rows.Count; a++)
  316. {
  317. if (list_dt[i].Rows[a]["name"].ToString() != "")
  318. {
  319. dt.Rows.Add(list_dt[i].Rows[a].ItemArray);
  320. }
  321. }
  322. listDt.Add(dt);
  323. }
  324. prListData = listDt.Copy();
  325. prListString.Clear();
  326. for (int i = 0; i < list_dt.Count; i++)
  327. {
  328. ResultFile resultFile = m_DataMgr.ResultFilesList.Find(s => s.anotherFileName == sou.Split('+')[i]);
  329. string str = resultFile.anotherFileName;
  330. prListString.Add(str);
  331. }
  332. panel1.Dock = DockStyle.Fill;
  333. chartControl1.Dock = DockStyle.Fill;
  334. //int sel_pro = m_conditionChoose.m_conditionData.ProItemProIndex();
  335. //if (sel_pro == 2)
  336. //{
  337. comboBox1.Visible = false;
  338. Graphics_Stacking(list_dt[0],stdId);
  339. //}
  340. //else
  341. //{
  342. // comboBox1.Visible = true;
  343. // Graphics();
  344. //}
  345. }
  346. /// <summary>
  347. /// 通过m_list_chartstruct,组合json数据格式
  348. /// </summary>
  349. /// <returns></returns>
  350. private List<DataTable> GetListJsonStr()
  351. {
  352. int sel = m_conditionChoose.m_conditionData.ProItemProIndex();
  353. string filedAndParticl = "";
  354. DataOperation.DataAccess.ParticleData particledata = null;
  355. DataTable dt = new DataTable();
  356. List<DataTable> ListData = new List<DataTable>();
  357. string sou = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
  358. for (int i = 0; i < sou.Split('+').Length; i++)
  359. {
  360. ResultFile resultFile = m_DataMgr.ResultFilesList.Find(s => s.anotherFileName == sou.Split('+')[i]);
  361. if (resultFile == null)
  362. {
  363. continue;
  364. }
  365. particledata = new DataOperation.DataAccess.ParticleData(resultFile.FilePath);
  366. switch (ComSel)
  367. {
  368. case "InclusionareaRatio":
  369. dt = particledata.GetAreaByAllIncA("");
  370. DataTable dtInclusionareaRatio = new DataTable();
  371. dtInclusionareaRatio.Columns.Add("name");
  372. dtInclusionareaRatio.Columns.Add("Cunt");
  373. for (int k = 0; k < dt.Rows.Count; k++)
  374. {
  375. string str = dt.Rows[k]["ar"].ToString();
  376. string name = dt.Rows[k]["TypeName"].ToString();
  377. if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
  378. {
  379. continue;
  380. }
  381. DataRow dr = dtInclusionareaRatio.NewRow();
  382. dr["name"] = name;
  383. dr["Cunt"] = decimal.Round(decimal.Parse(dt.Rows[k]["ar"].ToString()), 2).ToString();
  384. dtInclusionareaRatio.Rows.Add(dr);
  385. }
  386. ListData.Add(dtInclusionareaRatio);
  387. break;
  388. case "CommonlyUsedClassify":
  389. //计算分类整个表的数据
  390. dt = ClassificationIntegration(resultFile.FilePath, sel);
  391. DataTable data = new DataTable();
  392. data.Columns.Add("name");
  393. data.Columns.Add("Cunt");
  394. for (int a = 0; a < dt.Rows.Count; a++)
  395. {
  396. DataRow dr = data.NewRow();
  397. dr["name"] = dt.Rows[a]["e1"].ToString();
  398. dr["Cunt"] = dt.Rows[a]["Cunt"].ToString();
  399. data.Rows.Add(dr);
  400. }
  401. ListData.Add(data);
  402. break;
  403. case "PComponent":
  404. //创建新的图形数据源
  405. dt = particledata.GetParticleListByIncA("area");
  406. DataTable dtPComponent = new DataTable();
  407. dtPComponent.Columns.Add("name");
  408. dtPComponent.Columns.Add("Cunt");
  409. for (int a = 0; a < dt.Rows.Count; a++)
  410. {
  411. if (Convert.ToInt32(dt.Rows[a]["TypeId"]) < 100)
  412. {
  413. continue;
  414. }
  415. DataRow dr = dtPComponent.NewRow();
  416. dr["name"] = dt.Rows[a]["TypeName"].ToString();
  417. dr["Cunt"] = dt.Rows[a]["con"].ToString();
  418. dtPComponent.Rows.Add(dr);
  419. }
  420. ListData.Add(dtPComponent);
  421. break;
  422. case "EComponent":
  423. //创建新的图形数据源
  424. dt = particledata.GetElementForArea(filedAndParticl);
  425. DataTable dtEComponent = new DataTable();
  426. dtEComponent.Columns.Add("name");
  427. dtEComponent.Columns.Add("Cunt");
  428. for (int k = 0; k < dt.Rows.Count; k++)
  429. {
  430. string str = dt.Rows[k]["earea"].ToString();
  431. try
  432. {
  433. DataRow dr = dtEComponent.NewRow();
  434. dr["name"] = dt.Rows[k]["name"].ToString();
  435. dr["Cunt"] = decimal.Round(decimal.Parse(str), 2).ToString();
  436. dtEComponent.Rows.Add(dr);
  437. }
  438. catch
  439. {
  440. DataRow dr = dtEComponent.NewRow();
  441. dr["name"] = dt.Rows[k]["name"].ToString();
  442. dr["Cunt"] = str;
  443. dtEComponent.Rows.Add(dr);
  444. }
  445. }
  446. ListData.Add(dtEComponent);
  447. break;
  448. case "PSize":
  449. //获取粒级表
  450. string pathe = m_DataMgr.m_RptConfigFile.PartSizeFileFolder + m_DataMgr.m_RptConfigFile.PartSizeFile;
  451. DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
  452. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  453. List<string> temp = new List<string>();
  454. for (int j = 0; j < sizestr.Split(',').Length - 1; j++)
  455. {
  456. if (sizestr.Split(',')[j].Length > 0)
  457. {
  458. double d1 = Convert.ToDouble(sizestr.Split(',')[j]);
  459. double d2 = Convert.ToDouble(sizestr.Split(',')[j + 1]);
  460. string name = d1.ToString() + "~" + d2.ToString();
  461. temp.Add(name);
  462. }
  463. }
  464. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  465. string name1 = d.ToString() + "~MAX";
  466. temp.Add(name1);
  467. string con = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
  468. string po = "";
  469. switch (con)
  470. {
  471. case "DMAX":
  472. po = "DMAX";
  473. break;
  474. case "DMIN":
  475. po = "DMIN";
  476. break;
  477. case "ECD":
  478. po = "Area";
  479. break;
  480. case "FERET":
  481. po = "DFERET";
  482. break;
  483. }
  484. var dpd= DataProcessing(particledata,po, temp);
  485. ListData.Add(dpd);
  486. break;
  487. }
  488. }
  489. return ListData;
  490. }
  491. private DataTable DataProcessing(ParticleData particledata,string po, List<string> temp)
  492. {
  493. DataTable pos_dt = particledata.GetParticleListForParticlSize("area", "");
  494. DataTable pos_AreaInformationOfAllElements = particledata.GetAreaByAllIncA("");
  495. DataTable pos_dtp = particledata.GetParticleAll("");
  496. List<string> colid = new List<string>() { "name", "ar", "TypeId", "Largest", "Class", "GroupId", "con" };
  497. DataTable m_bt_DBData = new DataTable();
  498. for (int i = 0; i < temp.Count; i++)
  499. {
  500. colid.Add(temp[i].ToString());
  501. }
  502. for (int i = 0; i < colid.Count; i++)
  503. {
  504. m_bt_DBData.Columns.Add(colid[i].ToString());
  505. }
  506. for (int i = 0; i < pos_dt.Rows.Count; i++)
  507. {
  508. DataRow dr = m_bt_DBData.NewRow();
  509. dr["name"] = pos_dt.Rows[i]["TypeName"].ToString();
  510. dr["TypeId"] = pos_dt.Rows[i]["TypeId"].ToString();
  511. dr["con"] = pos_dt.Rows[i]["con"].ToString();
  512. dr["GroupId"] = pos_dt.Rows[i]["GroupId"].ToString();
  513. if (pos_dt.Rows[i]["GroupName"].ToString() == "")
  514. dr["Class"] = "Default";
  515. else
  516. dr["Class"] = pos_dt.Rows[i]["GroupName"].ToString();
  517. //continue;
  518. dr["Largest"] = Math.Round(Convert.ToDouble(pos_dt.Rows[i]["max"]), 2);
  519. for (int a = 7; a < colid.Count; a++)
  520. {
  521. string d1 = colid[a].Split('~')[0];
  522. string d2 = colid[a].Split('~')[1];
  523. if (d2 == "MAX")
  524. {
  525. d2 = "999";
  526. }
  527. DataRow[] datas = pos_dtp.Select(getWhere(d2, d1, po, pos_dt.Rows[i]["TypeId"].ToString()));
  528. dr[colid[a]] = datas.Count();
  529. }
  530. for (int a = 0; a < pos_AreaInformationOfAllElements.Rows.Count; a++)
  531. {
  532. if (pos_dt.Rows[i]["TypeId"].ToString() == pos_AreaInformationOfAllElements.Rows[a]["TypeId"].ToString())
  533. {
  534. dr["ar"] = pos_AreaInformationOfAllElements.Rows[a]["ar"];
  535. }
  536. }
  537. m_bt_DBData.Rows.Add(dr);
  538. }
  539. return m_bt_DBData;
  540. }
  541. private string getWhere(string max, string min, string col, string partic)
  542. {
  543. if (col == "Area")
  544. {
  545. return col + ">=" + ((Convert.ToDouble(min) / 2) * (Convert.ToDouble(min) / 2) * Math.PI).ToString() + " and " + col + "<" + ((Convert.ToDouble(max) / 2) * (Convert.ToDouble(max) / 2) * Math.PI).ToString() + " and TypeId=" + partic;
  546. }
  547. else
  548. {
  549. return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
  550. }
  551. }
  552. #endregion
  553. private void Graphics_Stacking(DataTable dt,string stdId)
  554. {
  555. chartControl1.Series.Clear();
  556. DataTable dataTable = new DataTable();
  557. dataTable.Columns.Add("name");
  558. dataTable.Columns.Add("size");
  559. if (stdId != "All")
  560. {
  561. for (int i = 0; i < dt.Rows.Count; i++)
  562. {
  563. if (dt.Rows[i]["name"].ToString() == stdId)
  564. {
  565. for (int a = 7; a < dt.Columns.Count; a++)
  566. {
  567. DataRow dr = dataTable.NewRow();
  568. dr["name"] = dt.Columns[a].ColumnName;
  569. dr["size"] = Convert.ToInt16(dt.Rows[i][a]);
  570. dataTable.Rows.Add(dr);
  571. }
  572. }
  573. }
  574. }
  575. if (stdId == "All")
  576. {
  577. List<Series> seriesList = new List<Series>();
  578. DataTable data = new DataTable();
  579. data.Columns.Add("name");
  580. data.Columns.Add("range");
  581. data.Columns.Add("num");
  582. for (int i = 0; i < dt.Rows.Count; i++)
  583. {
  584. for (int a = 7; a < dt.Columns.Count; a++)
  585. {
  586. DataRow dr = data.NewRow();
  587. dr["name"] = dt.Rows[i]["name"].ToString();
  588. dr["range"] = dt.Columns[a].ColumnName;
  589. dr["num"] = dt.Rows[i][a].ToString();
  590. data.Rows.Add(dr);
  591. }
  592. }
  593. foreach (DataRow dr in data.DefaultView.ToTable(true, "name").Rows)
  594. {
  595. Series s = new Series(dr["name"].ToString(), ViewType.StackedBar)
  596. {
  597. LegendTextPattern = dr["name"].ToString(),
  598. ArgumentScaleType = ScaleType.Qualitative,
  599. };
  600. foreach (DataRow drl in data.Select("name='" + dr["name"].ToString() + "'"))
  601. s.Points.Add(new SeriesPoint(drl["range"].ToString(), int.Parse(drl["num"].ToString())));
  602. s.LabelsVisibility = DefaultBoolean.False;
  603. seriesList.Add(s);
  604. }
  605. foreach (DataRow dr in data.DefaultView.ToTable(true, "name").Rows)
  606. {
  607. Series s = new Series(dr["name"].ToString(), ViewType.StackedBar)
  608. {
  609. LegendTextPattern = dr["name"].ToString(),
  610. ArgumentScaleType = ScaleType.Qualitative,
  611. };
  612. foreach (DataRow drl in data.Select("name='" + dr["name"].ToString() + "'"))
  613. s.Points.Add(new SeriesPoint(drl["range"].ToString(), int.Parse(drl["num"].ToString())));
  614. s.LabelsVisibility = DefaultBoolean.False;
  615. seriesList.Add(s);
  616. }
  617. foreach (Series sr in seriesList.ToArray())
  618. chartControl1.Series.Add(sr);
  619. }
  620. else
  621. {
  622. // 假设你已经有一个 ChartControl 实例,并且已经添加了一个饼图 Series
  623. Series series = new Series(stdId, ViewType.Bar);
  624. for (int a = 0; a < dataTable.Rows.Count; a++)
  625. {
  626. string name = dataTable.Rows[a]["name"].ToString();
  627. double Cunt = Convert.ToDouble(dataTable.Rows[a]["size"]);
  628. series.Points.Add(new SeriesPoint(name, Cunt));
  629. }
  630. series.LabelsVisibility = DefaultBoolean.True;
  631. chartControl1.Series.Add(series);
  632. }
  633. ((XYDiagram)chartControl1.Diagram).AxisY.Title.Text = "";
  634. ((XYDiagram)chartControl1.Diagram).AxisX.Title.Text = "";
  635. ((XYDiagram)chartControl1.Diagram).AxisY.Title.Visibility = DefaultBoolean.True;
  636. ((XYDiagram)chartControl1.Diagram).AxisX.Title.Visibility = DefaultBoolean.True;
  637. ((XYDiagram)chartControl1.Diagram).AxisY.Title.Font = new Font("Tahoma", 9);
  638. ((XYDiagram)chartControl1.Diagram).AxisX.Title.Font = new Font("Tahoma", 9);
  639. ((XYDiagram)chartControl1.Diagram).AxisY.Title.Alignment = System.Drawing.StringAlignment.Far;
  640. ((XYDiagram)chartControl1.Diagram).AxisX.Title.Alignment = System.Drawing.StringAlignment.Far;
  641. //图例的位置定义
  642. chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.Top;
  643. chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside;
  644. chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
  645. chartControl1.Legend.Direction = LegendDirection.TopToBottom;
  646. //十字准线光标
  647. chartControl1.CrosshairEnabled = DefaultBoolean.True;
  648. chartControl1.CrosshairOptions.ShowValueLine = true;
  649. chartControl1.CrosshairOptions.ShowArgumentLabels = true;
  650. }
  651. private void Graphics_Stacking(DataTable dt)
  652. {
  653. chartControl1.Series.Clear();
  654. List<Series> seriesList = new List<Series>();
  655. DataTable data = new DataTable();
  656. data.Columns.Add("name");
  657. data.Columns.Add("range");
  658. data.Columns.Add("num");
  659. for (int i = 0; i < dt.Rows.Count; i++)
  660. {
  661. for (int a = 7; a < dt.Columns.Count; a++)
  662. {
  663. DataRow dr = data.NewRow();
  664. dr["name"] = dt.Rows[i]["name"].ToString();
  665. dr["range"] = dt.Columns[a].ColumnName;
  666. dr["num"] = dt.Rows[i][a].ToString();
  667. data.Rows.Add(dr);
  668. }
  669. }
  670. foreach (DataRow dr in data.DefaultView.ToTable(true, "name").Rows)
  671. {
  672. Series s = new Series(dr["name"].ToString(), ViewType.StackedBar)
  673. {
  674. LegendTextPattern = dr["name"].ToString(),
  675. ArgumentScaleType = ScaleType.Qualitative,
  676. };
  677. foreach (DataRow drl in data.Select("name='" + dr["name"].ToString() + "'"))
  678. s.Points.Add(new SeriesPoint(drl["range"].ToString(), int.Parse(drl["num"].ToString())));
  679. s.LabelsVisibility = DefaultBoolean.False;
  680. seriesList.Add(s);
  681. }
  682. foreach (DataRow dr in data.DefaultView.ToTable(true, "name").Rows)
  683. {
  684. Series s = new Series(dr["name"].ToString(), ViewType.StackedBar)
  685. {
  686. LegendTextPattern = dr["name"].ToString(),
  687. ArgumentScaleType = ScaleType.Qualitative,
  688. };
  689. foreach (DataRow drl in data.Select("name='" + dr["name"].ToString() + "'"))
  690. s.Points.Add(new SeriesPoint(drl["range"].ToString(), int.Parse(drl["num"].ToString())));
  691. s.LabelsVisibility = DefaultBoolean.False;
  692. seriesList.Add(s);
  693. }
  694. foreach (Series sr in seriesList.ToArray())
  695. chartControl1.Series.Add(sr);
  696. ((XYDiagram)chartControl1.Diagram).AxisY.Title.Text = "";
  697. ((XYDiagram)chartControl1.Diagram).AxisX.Title.Text = "";
  698. ((XYDiagram)chartControl1.Diagram).AxisY.Title.Visibility = DefaultBoolean.True;
  699. ((XYDiagram)chartControl1.Diagram).AxisX.Title.Visibility = DefaultBoolean.True;
  700. ((XYDiagram)chartControl1.Diagram).AxisY.Title.Font = new Font("Tahoma", 9);
  701. ((XYDiagram)chartControl1.Diagram).AxisX.Title.Font = new Font("Tahoma", 9);
  702. ((XYDiagram)chartControl1.Diagram).AxisY.Title.Alignment = System.Drawing.StringAlignment.Far;
  703. ((XYDiagram)chartControl1.Diagram).AxisX.Title.Alignment = System.Drawing.StringAlignment.Far;
  704. //图例的位置定义
  705. chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.Top;
  706. chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside;
  707. chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
  708. chartControl1.Legend.Direction = LegendDirection.TopToBottom;
  709. //十字准线光标
  710. chartControl1.CrosshairEnabled = DefaultBoolean.True;
  711. chartControl1.CrosshairOptions.ShowValueLine = true;
  712. chartControl1.CrosshairOptions.ShowArgumentLabels = true;
  713. }
  714. private void Graphics()
  715. {
  716. chartControl1.Series.Clear();
  717. for (int i = 0; i < prListData.Count; i++)
  718. {
  719. string str = prListString[i];
  720. // 假设你已经有一个 ChartControl 实例,并且已经添加了一个饼图 Series
  721. Series series = new Series(str, ViewType.Bar);
  722. for (int a = 0; a < prListData[i].Rows.Count; a++)
  723. {
  724. string name = prListData[i].Rows[a]["name"].ToString();
  725. double Cunt = Convert.ToDouble(prListData[i].Rows[a]["Cunt"]);
  726. series.Points.Add(new SeriesPoint(name, Cunt));
  727. }
  728. series.LabelsVisibility = DefaultBoolean.True;
  729. chartControl1.Series.Add(series);
  730. }
  731. //图例的位置定义
  732. chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.Top;
  733. chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside;
  734. chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
  735. chartControl1.Legend.Direction = LegendDirection.TopToBottom;
  736. //十字准线光标
  737. chartControl1.CrosshairEnabled = DefaultBoolean.True;
  738. chartControl1.CrosshairOptions.ShowValueLine = true;
  739. chartControl1.CrosshairOptions.ShowArgumentLabels = true;
  740. DevFunctions.ChangeView2(chartControl1, comboBox1.Text);
  741. }
  742. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  743. {
  744. Graphics();
  745. }
  746. }
  747. }