PlugInChartF.cpp 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "ITS_OPLibF.h"
  7. #include "ITSLangTransF.h"
  8. #pragma hdrstop
  9. #include "PlugInChartF.h"
  10. #include "PlugInSetChartF.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "Chart"
  14. #pragma link "DBChart"
  15. #pragma link "Series"
  16. #pragma link "TeEngine"
  17. #pragma link "TeeProcs"
  18. #pragma link "cxButtons"
  19. #pragma link "cxCheckBox"
  20. #pragma link "cxContainer"
  21. #pragma link "cxControls"
  22. #pragma link "cxDropDownEdit"
  23. #pragma link "cxEdit"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxImageComboBox"
  26. #pragma link "cxLabel"
  27. #pragma link "cxLookAndFeelPainters"
  28. #pragma link "cxLookAndFeels"
  29. #pragma link "cxMaskEdit"
  30. #pragma link "cxSplitter"
  31. #pragma link "cxTextEdit"
  32. #pragma link "dxSkinBlack"
  33. #pragma link "dxSkinBlue"
  34. #pragma link "dxSkinsCore"
  35. #pragma link "dxSkinMcSkin"
  36. #pragma resource "*.dfm"
  37. //TPlugInChart *PlugInChart = NULL;
  38. //---------------------------------------------------------------------------
  39. __fastcall TPlugInChart::TPlugInChart(TComponent* Owner)
  40. : TForm(Owner)
  41. {
  42. LangTrans->Translate(this, ITSDb_GetConnection());
  43. ITSSkin_Load(this);
  44. }
  45. //---------------------------------------------------------------------------
  46. /*
  47. * form을 보여줄때 호출되는 event 메서드이다.
  48. * arguments
  49. * Sender : event handler 객체
  50. * return
  51. * void
  52. */
  53. void __fastcall TPlugInChart::FormShow(TObject *Sender)
  54. {
  55. // form 초기화
  56. FormInit();
  57. DbChart->SetFocus();
  58. DbChart->Title->Visible = false;
  59. //DbChart->Title->Text->Strings[0] = "";
  60. DbChart->Title->Caption = "";
  61. //Caption = m_sCaption;
  62. }
  63. //---------------------------------------------------------------------------
  64. /*
  65. * form 초기화
  66. * arguments
  67. *
  68. * return
  69. * void
  70. */
  71. void __fastcall TPlugInChart::FormInit()
  72. {
  73. CbChartKind->ItemIndex = 0;
  74. //LstLegend->Style = Stdctrls::lbOwnerDrawFixed;
  75. DbChart->View3D = false;
  76. //ClearChart();
  77. //LstLegend->Refresh();
  78. }
  79. //---------------------------------------------------------------------------
  80. /*
  81. * Form을 닫을때 호출되는 event 메서드
  82. * arguments
  83. * Sender : event handler 객체
  84. * Action : TCloseAction 객체
  85. * return
  86. * void
  87. */
  88. void __fastcall TPlugInChart::FormClose(TObject *Sender, TCloseAction &Action)
  89. {
  90. //상속한 PlugIn 폼에서는 CommClose() 함수를 override 하여 사용하자.
  91. CommClose();
  92. Action = caFree;
  93. }
  94. //---------------------------------------------------------------------------
  95. /*
  96. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  97. * Form과 DataModule class를 delete시킨다.
  98. * arguments
  99. *
  100. * return
  101. * void
  102. */
  103. void __fastcall TPlugInChart::CommClose()
  104. {
  105. try
  106. {
  107. Clear();
  108. }
  109. catch(...)
  110. {
  111. }
  112. }
  113. //---------------------------------------------------------------------------
  114. /*
  115. * 공통으로 처리되지 않는 스킨을 변경한다.
  116. * arguments
  117. *
  118. * return
  119. * void
  120. */
  121. void __fastcall TPlugInChart::LoadLocalSkin()
  122. {
  123. /*
  124. * 스킨 변경
  125. */
  126. //FrmResource->LoadSkinTitle(this, NULL, NULL, NULL);
  127. //FrmResource->LoadSkinButton(BtnChkAll, BtnReverse, BtnProperty, NULL, NULL, NULL, NULL, NULL);
  128. #if 0
  129. switch (SkinType)
  130. {
  131. case 1:
  132. Splitter->Color = (TColor)0x00FDE8D7;
  133. break;
  134. case 2:
  135. Splitter->Color = (TColor)0x003B69F0;
  136. break;
  137. case 3:
  138. Splitter->Color = (TColor)0x00BAA181;
  139. break;
  140. case 4:
  141. Splitter->Color = (TColor)0x00F8C6A4;
  142. break;
  143. case 5:
  144. Splitter->Color = (TColor)0x00A3D8C9;
  145. break;
  146. case 6:
  147. Splitter->Color = (TColor)0x004A189C;
  148. break;
  149. default:
  150. Splitter->Color = (TColor)0x003B69F0;//0x00F5F5F5;
  151. break;
  152. }
  153. #endif
  154. }
  155. //---------------------------------------------------------------------------
  156. /*
  157. * Legend check all button click event
  158. * arguments
  159. *
  160. * return
  161. * void
  162. */
  163. void __fastcall TPlugInChart::BtnChkAllClick(TObject *Sender)
  164. {
  165. // Check all
  166. LstLegend->Items->BeginUpdate();
  167. for (int ii = 0; ii < LstLegend->Count; ii++)
  168. {
  169. LstLegend->Checked[ii] = true;
  170. }
  171. LstLegend->Items->EndUpdate();
  172. BtnApplyClick(NULL);
  173. }
  174. //---------------------------------------------------------------------------
  175. /*
  176. * Legend Reverse button click event
  177. * arguments
  178. *
  179. * return
  180. * void
  181. */
  182. void __fastcall TPlugInChart::BtnReverseClick(TObject *Sender)
  183. {
  184. // Reverse check
  185. LstLegend->Items->BeginUpdate();
  186. for (int ii = 0; ii < LstLegend->Count; ii++)
  187. {
  188. LstLegend->Checked[ii] = !LstLegend->Checked[ii];
  189. }
  190. LstLegend->Items->EndUpdate();
  191. BtnApplyClick(NULL);
  192. }
  193. //---------------------------------------------------------------------------
  194. /*
  195. * Legend Property button click event
  196. * arguments
  197. *
  198. * return
  199. * void
  200. */
  201. void __fastcall TPlugInChart::BtnPropertyClick(TObject *Sender)
  202. {
  203. // Legend property setting
  204. LstLegendDblClick(NULL);
  205. }
  206. //---------------------------------------------------------------------------
  207. /*
  208. * Chart property apply
  209. * arguments
  210. *
  211. * return
  212. * void
  213. */
  214. void __fastcall TPlugInChart::BtnApplyClick(TObject *Sender)
  215. {
  216. // Apply
  217. int nRes = 0;
  218. LstLegend->Items->BeginUpdate();
  219. for (int ii = 0; ii < LstLegend->Count; ii++)
  220. {
  221. nRes += SetActive(ii);
  222. }
  223. if (nRes)
  224. {
  225. DbChart->LeftAxis->Maximum = GetActiveMaxY();
  226. }
  227. LstLegend->Items->EndUpdate();
  228. }
  229. //---------------------------------------------------------------------------
  230. /*
  231. * Chart 3d on/off
  232. * arguments
  233. *
  234. * return
  235. * void
  236. */
  237. void __fastcall TPlugInChart::Chk3DClick(TObject *Sender)
  238. {
  239. DbChart->Locked = true;
  240. try
  241. {
  242. // DbChart->Aspect->Orthogonal = false;
  243. DbChart->View3D = Chk3D->Checked;
  244. }
  245. __finally
  246. {
  247. DbChart->Locked = false;
  248. DbChart->Update();
  249. }
  250. BtnApplyClick(NULL);
  251. }
  252. //---------------------------------------------------------------------------
  253. /*
  254. * Chart Label value display on/off
  255. * arguments
  256. *
  257. * return
  258. * void
  259. */
  260. void __fastcall TPlugInChart::ChkDispValueClick(TObject *Sender)
  261. {
  262. try
  263. {
  264. DbChart->Locked = true;
  265. int nSeries = DbChart->SeriesCount();
  266. for (int ii = 0; ii < nSeries; ii++)
  267. {
  268. DbChart->Series[ii]->Marks->Style = smsValue;
  269. DbChart->Series[ii]->Marks->Visible = !DbChart->Series[ii]->Marks->Visible;
  270. }
  271. }
  272. __finally
  273. {
  274. DbChart->Locked = false;
  275. }
  276. #if 0
  277. // Label value display on/off
  278. SeriesItem* pSrsItem;
  279. TChartSeries *pSeries;
  280. //DbChart->Series->BeginUpdate();
  281. for (int ii = 0; ii < LstLegend->Count; ii++)
  282. {
  283. pSrsItem = (SeriesItem*)LstLegend->Items->Objects[ii];
  284. if (pSrsItem == NULL) continue;
  285. pSeries = (TChartSeries*)pSrsItem->ChartSeries;
  286. if (pSeries == NULL) continue;
  287. pSeries->Marks->Style = smsValue;
  288. pSeries->Marks->Visible = ChkDispValue->Checked;
  289. }
  290. //DbChart->Series->EndUpdate();
  291. #endif
  292. }
  293. //---------------------------------------------------------------------------
  294. /*
  295. * Chart kind select
  296. * arguments
  297. *
  298. * return
  299. * void
  300. */
  301. void __fastcall TPlugInChart::CbChartKindPropertiesEditValueChanged(TObject *Sender)
  302. {
  303. //ChangeSeries(DbChart, (SeriesType)CbChartKind->ItemIndex, DbChart->SeriesCount());
  304. SeriesItem *pSrsItem;
  305. TChartSeries *pSeries;
  306. SeriesType SrsTypeNew;
  307. SrsTypeNew = (SeriesType)CbChartKind->ItemIndex;
  308. try
  309. {
  310. DbChart->Locked = true;
  311. LstLegend->Items->BeginUpdate();
  312. for (int ii = 0; ii < LstLegend->Count; ii++)
  313. {
  314. pSrsItem = (SeriesItem*)LstLegend->Items->Objects[ii];
  315. if (pSrsItem == NULL) continue;
  316. pSeries = (TChartSeries*)pSrsItem->ChartSeries;
  317. if (pSeries == NULL) continue;
  318. ChangeSeriesItem(ii, SrsTypeNew);
  319. }
  320. }
  321. __finally
  322. {
  323. LstLegend->Items->EndUpdate();
  324. DbChart->Locked = false;
  325. }
  326. }
  327. //---------------------------------------------------------------------------
  328. /*
  329. * DBChart 의 모양을 변경한다.
  330. * arguments
  331. * pDBChart - DBChart 컴포넌트
  332. * pSeriesIndex - 챠트유형 콤보에서 선택한 유형 index
  333. * return
  334. * void
  335. */
  336. void __fastcall TPlugInChart::ChangeSeriesItem(int nIdx, SeriesType ToSrsType)
  337. {
  338. SeriesItem* pSrsItem;
  339. TChartSeries *pSeries;
  340. TMetaClass* NewType;
  341. pSrsItem = (SeriesItem*)LstLegend->Items->Objects[nIdx];
  342. if (pSrsItem == NULL) return;
  343. if (pSrsItem->SrsType == ToSrsType) return;
  344. pSeries = (TChartSeries*)pSrsItem->ChartSeries;
  345. switch (ToSrsType)
  346. {
  347. case ctpLine: NewType = __classid(TLineSeries); break;
  348. case ctpBar: NewType = __classid(TBarSeries); break;
  349. case ctpHorizontal_Bar: NewType = __classid(THorizBarSeries); break;
  350. case ctpArea: NewType = __classid(TAreaSeries); break;
  351. case ctpPoint: NewType = __classid(TPointSeries); break;
  352. case ctpPie: NewType = __classid(TPieSeries); break;
  353. case ctpFast_Line: NewType = __classid(TFastLineSeries); break;
  354. case ctpHorizontal_Line: NewType = __classid(THorizLineSeries); break;
  355. case ctpHorizontal_Area: NewType = __classid(THorizAreaSeries); break;
  356. case ctpShape: NewType = __classid(TChartShape); break;
  357. case ctpGantt: NewType = __classid(TGanttSeries); break;
  358. case ctpArrow: NewType = __classid(TArrowSeries); break;
  359. case ctpBubble: NewType = __classid(TBubbleSeries); break;
  360. default : return;
  361. }
  362. ChangeSeriesType(pSeries, NewType);
  363. pSrsItem->ChartSeries = (void*)pSeries;
  364. pSrsItem->SrsType = ToSrsType;
  365. if (ToSrsType == ctpLine)
  366. {
  367. ((TLineSeries*)pSeries)->Pointer->Style = psRectangle;
  368. ((TLineSeries*)pSeries)->Pointer->VertSize = 4;
  369. ((TLineSeries*)pSeries)->Pointer->Visible = true;
  370. }
  371. else if(ToSrsType == ctpPie)
  372. {
  373. ((TPieSeries*)pSeries)->Marks->Style = smsValue;
  374. ((TPieSeries*)pSeries)->Circled = true;
  375. //((TPieSeries*)pSeries)->Marks->Visible = ChkDispValue->Checked;
  376. }
  377. pSeries->Marks->Style = smsValue;
  378. pSeries->Marks->Visible = ChkDispValue->Checked;
  379. }
  380. //---------------------------------------------------------------------------
  381. void __fastcall TPlugInChart::ChangeSeries(TDBChart *pDBChart, SeriesType nSeriesTp, int nSeriesCount)
  382. {
  383. TChartSeries *pChartSeries;
  384. if (pDBChart == NULL) return;
  385. for (int ii = 0; ii < nSeriesCount; ii++)
  386. {
  387. try
  388. {
  389. pChartSeries = pDBChart->Series[ii];
  390. switch(nSeriesTp)
  391. {
  392. case ctpLine: ChangeSeriesType(pChartSeries, __classid(TLineSeries)); break;
  393. case ctpBar: ChangeSeriesType(pChartSeries, __classid(TBarSeries)); break;
  394. case ctpHorizontal_Bar: ChangeSeriesType(pChartSeries, __classid(THorizBarSeries)); break;
  395. case ctpArea: ChangeSeriesType(pChartSeries, __classid(TAreaSeries)); break;
  396. case ctpPoint: ChangeSeriesType(pChartSeries, __classid(TPointSeries)); break;
  397. case ctpPie: ChangeSeriesType(pChartSeries, __classid(TPieSeries)); break;
  398. case ctpFast_Line: ChangeSeriesType(pChartSeries, __classid(TFastLineSeries)); break;
  399. case ctpHorizontal_Line: ChangeSeriesType(pChartSeries, __classid(THorizLineSeries)); break;
  400. case ctpHorizontal_Area: ChangeSeriesType(pChartSeries, __classid(THorizAreaSeries)); break;
  401. case ctpShape: ChangeSeriesType(pChartSeries, __classid(TChartShape)); break;
  402. case ctpGantt: ChangeSeriesType(pChartSeries, __classid(TGanttSeries)); break;
  403. case ctpArrow: ChangeSeriesType(pChartSeries, __classid(TArrowSeries)); break;
  404. case ctpBubble: ChangeSeriesType(pChartSeries, __classid(TBubbleSeries)); break;
  405. }
  406. }
  407. catch(...)
  408. {
  409. }
  410. }
  411. }
  412. //---------------------------------------------------------------------------
  413. /*
  414. * 조회 전 챠트를 Clear 한다.
  415. *
  416. * arguments
  417. * return
  418. * void
  419. */
  420. void __fastcall TPlugInChart::ClearChart()
  421. {
  422. try
  423. {
  424. for (int ii = 0; ii < DbChart->SeriesCount(); ii++)
  425. {
  426. DbChart->Series[ii]->Clear();
  427. }
  428. }
  429. catch(...)
  430. {
  431. }
  432. }
  433. //---------------------------------------------------------------------------
  434. /*
  435. * Check on/off legend
  436. *
  437. * arguments
  438. * return
  439. * void
  440. */
  441. void __fastcall TPlugInChart::LstLegendClickCheck(TObject *Sender)
  442. {
  443. // Check on/off legend
  444. int nIdx = LstLegend->ItemIndex;
  445. LstLegend->Items->BeginUpdate();
  446. if (SetActive(nIdx))
  447. {
  448. DbChart->LeftAxis->Maximum = GetActiveMaxY();
  449. }
  450. LstLegend->Items->EndUpdate();
  451. }
  452. //---------------------------------------------------------------------------
  453. /*
  454. * double legend list
  455. *
  456. * arguments
  457. * return
  458. * void
  459. */
  460. void __fastcall TPlugInChart::LstLegendDblClick(TObject *Sender)
  461. {
  462. // double legend list
  463. SeriesItem *pSrsItem;
  464. TChartSeries *pSeries;
  465. SeriesType SrsTypeNew;
  466. int idx;
  467. String sMsgTitle, sMsgString;
  468. idx = LstLegend->ItemIndex;
  469. if(idx < 0)
  470. {
  471. sMsgString = lblSel->Caption;//"아이템을 선택하세요.";
  472. MessageDlg(sMsgString.c_str(), mtInformation, TMsgDlgButtons() << mbOK, NULL);
  473. return;
  474. }
  475. pSrsItem = (SeriesItem *)LstLegend->Items->Objects[idx];
  476. pSeries = (TChartSeries*)pSrsItem->ChartSeries;
  477. try
  478. {
  479. TPlugInSetChart *PlugInSetChart = new TPlugInSetChart(Parent);
  480. PlugInSetChart->EdtItemNm->Text = pSeries->Title;
  481. PlugInSetChart->ChkVisible->Checked = pSeries->Active;
  482. PlugInSetChart->PnlItemColor->Color = pSeries->SeriesColor;
  483. PlugInSetChart->m_nSrsType = pSrsItem->SrsType;
  484. if (PlugInSetChart->ShowModal() == mrOk)
  485. {
  486. Application->ProcessMessages();
  487. pSeries->Active = PlugInSetChart->ChkVisible->Checked;
  488. LstLegend->Checked[idx] = pSeries->Active;
  489. pSeries->SeriesColor = PlugInSetChart->PnlItemColor->Color;
  490. SrsTypeNew = (SeriesType)PlugInSetChart->m_nSrsType;
  491. if (pSrsItem->SrsType != SrsTypeNew)
  492. {
  493. ChangeSeriesItem(idx, SrsTypeNew);
  494. pSeries = (TChartSeries*)pSrsItem->ChartSeries;
  495. }
  496. LstLegend->Repaint();
  497. }
  498. delete PlugInSetChart;
  499. PlugInSetChart = NULL;
  500. }
  501. catch(...)
  502. {
  503. }
  504. #if 0
  505. pSrsItem = (SeriesItem*)lstItems->Items->Objects[idx];
  506. FrmSTC_Grph_Prop->lblSrsTitle->Caption = pSeries->Title;
  507. FrmSTC_Grph_Prop->chxSrsActive->Checked = pSeries->Active;
  508. FrmSTC_Grph_Prop->lblSrsColor->Color = pSeries->SeriesColor;
  509. FrmSTC_Grph_Prop->SetSrsTypeBtn(pSrsItem->SrsType);
  510. if(FrmSTC_Grph_Prop->ShowModal() == mrOk)
  511. {
  512. Application->ProcessMessages();
  513. pSeries->Active = FrmSTC_Grph_Prop->chxSrsActive->Checked;
  514. lstItems->Checked[idx] = pSeries->Active;
  515. pSeries->SeriesColor = FrmSTC_Grph_Prop->lblSrsColor->Color;
  516. SrsTypeNew = FrmSTC_Grph_Prop->FSrsType;
  517. if(pSrsItem->SrsType != SrsTypeNew)
  518. {
  519. ChangeSeriesItem(idx, SrsTypeNew);
  520. pSeries = (TChartSeries*)pSrsItem->ChartSeries;
  521. }
  522. lstItems->Repaint();
  523. }
  524. delete FrmSTC_Grph_Prop;
  525. FrmSTC_Grph_Prop = NULL;
  526. #endif
  527. }
  528. //---------------------------------------------------------------------------
  529. /*
  530. * Draw legend items
  531. *
  532. * arguments
  533. * return
  534. * void
  535. */
  536. void __fastcall TPlugInChart::LstLegendDrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State)
  537. {
  538. TCanvas* pCvs = LstLegend->Canvas;
  539. int Offset = 2, iBarWidth = 12;
  540. TColor brColor;
  541. TRect rct;
  542. SeriesType SrsType;
  543. brColor = pCvs->Brush->Color;
  544. pCvs->Pen->Color = brColor;
  545. pCvs->Rectangle(Rect);
  546. // Chart Type Rect
  547. pCvs->Brush->Color = clWhite;
  548. rct = Rect;
  549. rct.Top = Rect.Top + 1;
  550. rct.Right = Rect.Left + iBarWidth;
  551. rct.Bottom = Rect.Bottom - 1;
  552. pCvs->Rectangle(rct);
  553. DrawSeriesType(GetSeriesType(Index), pCvs, rct);
  554. // Chart Color Rect
  555. Rect.Left += iBarWidth + Offset;
  556. pCvs->Pen->Color = TColor(0x00646464);
  557. pCvs->Brush->Color = GetSeriesColor(Index);
  558. pCvs->Rectangle(Rect.Left, Rect.Top + 1,
  559. Rect.Left + iBarWidth, Rect.Bottom - 1);
  560. // Chart Label
  561. pCvs->Brush->Color = brColor;
  562. Rect.Left += iBarWidth + Offset;
  563. pCvs->TextOut(Rect.Left, Rect.Top, LstLegend->Items->Strings[Index]);
  564. }
  565. //---------------------------------------------------------------------------
  566. /*
  567. * Get Chart type
  568. *
  569. * arguments
  570. * return
  571. * void
  572. */
  573. SeriesType __fastcall TPlugInChart::GetSeriesType(int nIdx)
  574. {
  575. SeriesItem* pSrsItem;
  576. pSrsItem = (SeriesItem*)LstLegend->Items->Objects[nIdx];
  577. return pSrsItem->SrsType;
  578. }
  579. //---------------------------------------------------------------------------
  580. /*
  581. * Get Chart serice color
  582. *
  583. * arguments
  584. * return
  585. * void
  586. */
  587. TColor __fastcall TPlugInChart::GetSeriesColor(int nIdx)
  588. {
  589. SeriesItem *pSrsItem;
  590. TChartSeries *pSeries;
  591. pSrsItem = (SeriesItem*)LstLegend->Items->Objects[nIdx];
  592. pSeries = (TChartSeries*)pSrsItem->ChartSeries;
  593. return pSeries->SeriesColor;
  594. }
  595. //---------------------------------------------------------------------------
  596. /*
  597. * Draw chart type on legend list
  598. *
  599. * arguments
  600. * return
  601. * void
  602. */
  603. void __fastcall TPlugInChart::DrawSeriesType(SeriesType SrsType, TCanvas* pCvs, TRect Rct)
  604. {
  605. int x, y;
  606. x = Rct.Left, y = Rct.Bottom;
  607. pCvs->Pen->Color = clBlack;
  608. switch(SrsType)
  609. {
  610. /*
  611. ctpLine = 0,
  612. ctpBar,
  613. ctpHorizontal_Bar,
  614. ctpArea,
  615. ctpPoint,
  616. ctpFastLine,
  617. */
  618. case ctpLine : y -= (Rct.Bottom - Rct.Top) / 3;
  619. pCvs->MoveTo(x, y);
  620. x += (Rct.Right - Rct.Left) / 3;
  621. y -= (Rct.Bottom - Rct.Top) / 2;
  622. pCvs->LineTo(x, y);
  623. x += (Rct.Right - Rct.Left) / 4;
  624. y += (Rct.Bottom - Rct.Top) / 2;
  625. pCvs->LineTo(x, y);
  626. x = Rct.Right;
  627. y -= (Rct.Bottom - Rct.Top) / 2;
  628. pCvs->LineTo(x, y);
  629. break;
  630. case ctpBar : Rct.Top += 8;
  631. Rct.Left += 3; Rct.Right = Rct.Left + 1;
  632. pCvs->Rectangle(Rct);
  633. Rct.Top -= 2;
  634. Rct.Left = Rct.Right + 2; Rct.Right = Rct.Left + 1;
  635. pCvs->Rectangle(Rct);
  636. Rct.Top -= 4;
  637. Rct.Left = Rct.Right + 2; Rct.Right = Rct.Left + 1;
  638. pCvs->Rectangle(Rct);
  639. break;
  640. case ctpArea : Rct.Top += 1; Rct.Bottom -= 1;
  641. pCvs->Ellipse(Rct);
  642. pCvs->Pie(Rct.Left, Rct.Top, Rct.Right, Rct.Bottom,
  643. Rct.Left, Rct.Top, Rct.Right, Rct.Top + 3);
  644. pCvs->Pie(Rct.Left, Rct.Top, Rct.Right, Rct.Bottom,
  645. Rct.Left, Rct.Top, Rct.Left + 4, Rct.Bottom);
  646. break;
  647. case ctpPoint: Rct.Top += 8;
  648. Rct.Left += 3; Rct.Right = Rct.Left + 2;
  649. pCvs->Rectangle(Rct);
  650. //Rct.Top -= 5;
  651. Rct.Left = Rct.Right + 2; Rct.Right = Rct.Left + 2;
  652. pCvs->Rectangle(Rct);
  653. break;
  654. default : break;
  655. }
  656. }
  657. //---------------------------------------------------------------------------
  658. /*
  659. * Active show/hide legend
  660. *
  661. * arguments
  662. * return
  663. * void
  664. */
  665. bool __fastcall TPlugInChart::SetActive(int nIdx)
  666. {
  667. SeriesItem* pSrsItem;
  668. TChartSeries *pSeries;
  669. pSrsItem = (SeriesItem*)LstLegend->Items->Objects[nIdx];
  670. if (pSrsItem == NULL) return false;
  671. pSeries = (TChartSeries*)pSrsItem->ChartSeries;
  672. if (pSeries == NULL) return false;
  673. if (pSeries->Active != LstLegend->Checked[nIdx])
  674. {
  675. pSeries->Active = LstLegend->Checked[nIdx];
  676. return true;
  677. }
  678. return false;
  679. }
  680. //---------------------------------------------------------------------------
  681. /*
  682. * Get active chart Y axis value
  683. *
  684. * arguments
  685. * return
  686. * void
  687. */
  688. double __fastcall TPlugInChart::GetActiveMaxY(void)
  689. {
  690. SeriesItem *pSrsItem;
  691. TChartSeries *pSeries;
  692. double dMaxY = 0.0;
  693. for (int ii = 0; ii < LstLegend->Count; ii++)
  694. {
  695. pSrsItem = (SeriesItem*)LstLegend->Items->Objects[ii];
  696. if (pSrsItem == NULL) continue;
  697. pSeries = (TChartSeries*)pSrsItem->ChartSeries;
  698. if (pSeries == NULL) continue;
  699. if (pSeries->Active == false) continue;
  700. if(dMaxY < pSeries->YValues->MaxValue)
  701. dMaxY = pSeries->YValues->MaxValue;
  702. }
  703. double calMaxY = dMaxY + (dMaxY / 20.);
  704. return calMaxY;// > DbChart->LeftAxis->Minimum ? calMaxY : DbChart->LeftAxis->Minimum;
  705. }
  706. //---------------------------------------------------------------------------
  707. /*
  708. * 차트 정보 설정
  709. *
  710. * arguments
  711. * return
  712. * void
  713. */
  714. void __fastcall TPlugInChart::SetChartInfo(String sTitle, String sAxisX, String sAxisY)
  715. {
  716. DbChart->Title->Visible = false;
  717. DbChart->BottomAxis->Title->Visible = false;
  718. DbChart->LeftAxis->Title->Visible = false;
  719. if (sTitle != "")
  720. {
  721. DbChart->Title->Caption = sTitle;
  722. DbChart->Title->Visible = true;
  723. }
  724. if (sAxisY != "")
  725. {
  726. DbChart->BottomAxis->Title->Caption = sAxisX;
  727. DbChart->BottomAxis->LabelStyle = talText;
  728. DbChart->BottomAxis->LabelsAngle = 0;
  729. DbChart->BottomAxis->Title->Visible = true;
  730. }
  731. if (sAxisX != "")
  732. {
  733. DbChart->LeftAxis->Title->Caption = sAxisY;
  734. DbChart->LeftAxis->Title->Visible = true;
  735. }
  736. }
  737. //---------------------------------------------------------------------------
  738. /*
  739. * 차트 그리기전에 반드시 호출
  740. *
  741. * arguments
  742. * return
  743. * void
  744. */
  745. void __fastcall TPlugInChart::BeginDraw(String sTitle/*=""*/, String sAxisX/*=""*/, String sAxisY/*=""*/)
  746. {
  747. ClearData();
  748. SetChartInfo(sTitle, sAxisX, sAxisY);
  749. }
  750. //---------------------------------------------------------------------------
  751. /*
  752. * 메모리를 해제한다.
  753. *
  754. * arguments
  755. * return
  756. * void
  757. */
  758. void __fastcall TPlugInChart::Clear()
  759. {
  760. ClearData();
  761. }
  762. //---------------------------------------------------------------------------
  763. /*
  764. * 메모리를 해제한다.
  765. *
  766. * arguments
  767. * return
  768. * void
  769. */
  770. void __fastcall TPlugInChart::ClearData()
  771. {
  772. try
  773. {
  774. LstLegend->Items->BeginUpdate();
  775. try
  776. {
  777. for (int ii = 0; ii < LstLegend->Count; ii++)
  778. {
  779. SeriesItem *pSrsItem = (SeriesItem *)LstLegend->Items->Objects[ii];
  780. if (pSrsItem == NULL) continue;
  781. delete pSrsItem;
  782. }
  783. LstLegend->Items->Clear();
  784. ClearChart();
  785. DbChart->FreeAllSeries();
  786. }
  787. catch(...)
  788. {
  789. }
  790. }
  791. __finally
  792. {
  793. LstLegend->Items->EndUpdate();
  794. }
  795. }
  796. //---------------------------------------------------------------------------
  797. /*
  798. * 해당되지 않는 컬럼을 클리어한다.
  799. * arguments
  800. *
  801. * return
  802. * void
  803. */
  804. void __fastcall TPlugInChart::DrawChart1(TcxGridDBTableView *TvList, int nAxisY, int nStColIdx, int nTotColIdx/*=-1*/)
  805. {
  806. int ii, jj, kk;
  807. SeriesType SrsType;
  808. TColor clSrsColor;
  809. TChartSeries *pSeries;
  810. TClientDataSet *pCDS = NULL;
  811. TCursor cOldCursor= Screen->Cursor;
  812. try
  813. {
  814. Screen->Cursor = crHourGlass;
  815. LstLegend->Items->BeginUpdate();
  816. TvList->BeginUpdate();
  817. pCDS = (TClientDataSet *)TvList->DataController->DataSource->DataSet;
  818. if (pCDS)
  819. {
  820. pCDS->DisableControls();
  821. }
  822. int nCols = TvList->ColumnCount;
  823. int nRows = TvList->ViewData->RecordCount;
  824. SrsType = GetChartType();
  825. /*
  826. * 합계 표출
  827. */
  828. kk = 0;
  829. if (nTotColIdx >= 0)
  830. {
  831. clSrsColor = GetDefaultColor(kk++);
  832. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  833. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  834. pSeries = AddSeriesItem(lblSoge->Caption/*"소계"*/, SrsType, clSrsColor, true);
  835. if (pSeries)
  836. {
  837. for (jj = nStColIdx; jj < nCols; jj++)
  838. {
  839. if (!TvList->Columns[jj]->Visible)
  840. {
  841. break;
  842. }
  843. String sAxisX = TvList->Columns[jj]->Caption;
  844. nTotColIdx = TvList->DataController->Summary->FooterSummaryItems->IndexOfItemLink(TvList->Columns[jj]);
  845. if (!VarIsNull(TvList->DataController->Summary->FooterSummaryValues[nTotColIdx]))
  846. {
  847. double dValX = 0;
  848. try {
  849. dValX = (double)TvList->DataController->Summary->FooterSummaryValues[nTotColIdx];
  850. } catch(...) { dValX = 0; }
  851. pSeries->AddY(dValX, sAxisX);
  852. }
  853. }
  854. }
  855. }
  856. for (ii = 0; ii < nRows; ii++, kk++)
  857. {
  858. try
  859. {
  860. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  861. clSrsColor = GetDefaultColor(kk);
  862. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  863. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  864. String sTitle = "";
  865. if (!VarIsNull(sTitle = ARow->Values[nAxisY]))
  866. {
  867. sTitle = ARow->Values[nAxisY];
  868. }
  869. pSeries = AddSeriesItem(sTitle, SrsType, clSrsColor, true);
  870. if (pSeries)
  871. {
  872. for (jj = nStColIdx; jj < nCols; jj++)
  873. {
  874. if (!TvList->Columns[jj]->Visible)
  875. {
  876. break;
  877. }
  878. String sAxisX = TvList->Columns[jj]->Caption;
  879. double dValX = 0;
  880. if (!VarIsNull(ARow->Values[jj]))
  881. try { dValX = (double)ARow->Values[jj]; } catch(...) {dValX=0;}
  882. pSeries->AddY(dValX, sAxisX);
  883. }
  884. }
  885. }
  886. catch(...)
  887. {
  888. }
  889. }
  890. DbChart->LeftAxis->Minimum = 0;
  891. DbChart->LeftAxis->Maximum = GetActiveMaxY(); // 그래프 생성
  892. if (DbChart->LeftAxis->Minimum >= DbChart->LeftAxis->Maximum)
  893. {
  894. DbChart->LeftAxis->Maximum = DbChart->LeftAxis->Minimum + 1; // 그래프 그리기
  895. }
  896. }
  897. __finally
  898. {
  899. if (pCDS)
  900. {
  901. pCDS->EnableControls();
  902. }
  903. TvList->EndUpdate();
  904. DbChart->Refresh();
  905. LstLegend->Items->EndUpdate(); //챠트 생성
  906. Screen->Cursor = cOldCursor;
  907. }
  908. }
  909. //---------------------------------------------------------------------------
  910. /*
  911. * 해당되지 않는 컬럼을 클리어한다.
  912. * arguments
  913. *
  914. * return
  915. * void
  916. */
  917. void __fastcall TPlugInChart::DrawChart4(TcxGridDBTableView *TvList, int nAxisY1, int nAxisY2, int nStColIdx, int nTotColIdx/*=-1*/)
  918. {
  919. int ii, jj, kk;
  920. SeriesType SrsType;
  921. TColor clSrsColor;
  922. TChartSeries *pSeries;
  923. TClientDataSet *pCDS = NULL;
  924. TCursor cOldCursor= Screen->Cursor;
  925. try
  926. {
  927. Screen->Cursor = crHourGlass;
  928. LstLegend->Items->BeginUpdate();
  929. TvList->BeginUpdate();
  930. pCDS = (TClientDataSet *)TvList->DataController->DataSource->DataSet;
  931. if (pCDS)
  932. {
  933. pCDS->DisableControls();
  934. }
  935. int nCols = TvList->ColumnCount;
  936. int nRows = TvList->ViewData->RecordCount;
  937. SrsType = GetChartType();
  938. /*
  939. * 합계 표출
  940. */
  941. kk = 0;
  942. if (nTotColIdx >= 0)
  943. {
  944. clSrsColor = GetDefaultColor(kk++);
  945. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  946. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  947. pSeries = AddSeriesItem(lblSoge->Caption/*"소계"*/, SrsType, clSrsColor, true);
  948. if (pSeries)
  949. {
  950. for (jj = nStColIdx; jj < nCols; jj++)
  951. {
  952. if (!TvList->Columns[jj]->Visible)
  953. {
  954. break;
  955. }
  956. String sAxisX = TvList->Columns[jj]->Caption;
  957. nTotColIdx = TvList->DataController->Summary->FooterSummaryItems->IndexOfItemLink(TvList->Columns[jj]);
  958. if (!VarIsNull(TvList->DataController->Summary->FooterSummaryValues[nTotColIdx]))
  959. {
  960. double dValX = 0;
  961. try {
  962. dValX = (double)TvList->DataController->Summary->FooterSummaryValues[nTotColIdx];
  963. } catch(...) { dValX = 0; }
  964. pSeries->AddY(dValX, sAxisX);
  965. }
  966. }
  967. }
  968. }
  969. for (ii = 0; ii < nRows; ii++, kk++)
  970. {
  971. try
  972. {
  973. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  974. clSrsColor = GetDefaultColor(kk);
  975. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  976. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  977. String sTitle = "";
  978. if (!VarIsNull(ARow->Values[nAxisY1]))
  979. {
  980. sTitle = ARow->Values[nAxisY1];
  981. }
  982. if (!VarIsNull(ARow->Values[nAxisY2]))
  983. {
  984. sTitle += ":";
  985. sTitle += ARow->Values[nAxisY2];
  986. }
  987. pSeries = AddSeriesItem(sTitle, SrsType, clSrsColor, true);
  988. if (pSeries)
  989. {
  990. for (jj = nStColIdx; jj < nCols; jj++)
  991. {
  992. if (!TvList->Columns[jj]->Visible)
  993. {
  994. break;
  995. }
  996. String sAxisX = TvList->Columns[jj]->Caption;
  997. double dValX = 0;
  998. String sVal = ARow->Values[jj];
  999. if (!VarIsNull(ARow->Values[jj]))
  1000. try { dValX = (double)ARow->Values[jj]; } catch(...) {dValX=0;}
  1001. pSeries->AddY(dValX, sAxisX);
  1002. }
  1003. }
  1004. }
  1005. catch(...)
  1006. {
  1007. }
  1008. }
  1009. DbChart->LeftAxis->Minimum = 0;
  1010. DbChart->LeftAxis->Maximum = GetActiveMaxY();
  1011. if (DbChart->LeftAxis->Minimum >= DbChart->LeftAxis->Maximum)
  1012. {
  1013. DbChart->LeftAxis->Maximum = DbChart->LeftAxis->Minimum + 1;
  1014. }
  1015. }
  1016. __finally
  1017. {
  1018. if (pCDS)
  1019. {
  1020. pCDS->EnableControls();
  1021. }
  1022. TvList->EndUpdate();
  1023. DbChart->Refresh();
  1024. LstLegend->Items->EndUpdate();
  1025. Screen->Cursor = cOldCursor;
  1026. }
  1027. }
  1028. //---------------------------------------------------------------------------
  1029. void __fastcall TPlugInChart::DrawChart5(TcxGridDBTableView *TvList, int nAxisY1, int nAxisY2, int nAxisY3, int nStColIdx, int nEdColIdx/*=-1*/,int nTotColIdx/*=-1*/)
  1030. {
  1031. int ii, jj, kk;
  1032. SeriesType SrsType;
  1033. TColor clSrsColor;
  1034. TChartSeries *pSeries;
  1035. TClientDataSet *pCDS = NULL;
  1036. TCursor cOldCursor= Screen->Cursor;
  1037. try
  1038. {
  1039. Screen->Cursor = crHourGlass;
  1040. LstLegend->Items->BeginUpdate();
  1041. TvList->BeginUpdate();
  1042. pCDS = (TClientDataSet *)TvList->DataController->DataSource->DataSet;
  1043. if (pCDS)
  1044. {
  1045. pCDS->DisableControls();
  1046. }
  1047. int nCols = TvList->ColumnCount;
  1048. int nRows = TvList->ViewData->RecordCount;
  1049. if (nEdColIdx != -1)
  1050. {
  1051. nCols = nCols > nEdColIdx ? nEdColIdx+1 : nCols;
  1052. }
  1053. SrsType = GetChartType();
  1054. /*
  1055. * 합계 표출
  1056. */
  1057. kk = 0;
  1058. if (nTotColIdx >= 0)
  1059. {
  1060. clSrsColor = GetDefaultColor(kk++);
  1061. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  1062. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  1063. pSeries = AddSeriesItem(lblSoge->Caption/*"소계"*/, SrsType, clSrsColor, true);
  1064. if (pSeries)
  1065. {
  1066. for (jj = nStColIdx; jj < nCols; jj++)
  1067. {
  1068. if (!TvList->Columns[jj]->Visible)
  1069. {
  1070. break;
  1071. }
  1072. String sAxisX = TvList->Columns[jj]->Caption;
  1073. nTotColIdx = TvList->DataController->Summary->FooterSummaryItems->IndexOfItemLink(TvList->Columns[jj]);
  1074. if (!VarIsNull(TvList->DataController->Summary->FooterSummaryValues[nTotColIdx]))
  1075. {
  1076. double dValX = 0;
  1077. try {
  1078. dValX = (double)TvList->DataController->Summary->FooterSummaryValues[nTotColIdx];
  1079. } catch(...) { dValX = 0;}
  1080. pSeries->AddY(dValX, sAxisX);
  1081. }
  1082. }
  1083. }
  1084. }
  1085. for (ii = 0; ii < nRows; ii++, kk++)
  1086. {
  1087. try
  1088. {
  1089. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  1090. clSrsColor = GetDefaultColor(kk);
  1091. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  1092. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  1093. String sTitle = "";
  1094. if (TvList->Columns[nAxisY1]->Visible && !VarIsNull(ARow->Values[nAxisY1]))
  1095. {
  1096. sTitle = ARow->Values[nAxisY1];
  1097. }
  1098. if (TvList->Columns[nAxisY2]->Visible && !VarIsNull(ARow->Values[nAxisY2]))
  1099. {
  1100. sTitle += ":";
  1101. sTitle += ARow->Values[nAxisY2];
  1102. }
  1103. if (TvList->Columns[nAxisY3]->Visible && !VarIsNull(ARow->Values[nAxisY3]))
  1104. {
  1105. sTitle += ":";
  1106. sTitle += ARow->Values[nAxisY3];
  1107. }
  1108. pSeries = AddSeriesItem(sTitle, SrsType, clSrsColor, true);
  1109. if (pSeries)
  1110. {
  1111. for (jj = nStColIdx; jj < nCols; jj++)
  1112. {
  1113. if (!TvList->Columns[jj]->Visible)
  1114. {
  1115. break;
  1116. }
  1117. String sAxisX = TvList->Columns[jj]->Caption;
  1118. double dValX = 0;
  1119. if (!VarIsNull(ARow->Values[jj]))
  1120. {
  1121. String sVal = VarToStr(ARow->Values[jj]);
  1122. try {
  1123. //dValX = (double)ARow->Values[jj];
  1124. dValX = (double)sVal.ToIntDef(0);
  1125. } catch(...) {
  1126. dValX=0;
  1127. }
  1128. }
  1129. pSeries->AddY(dValX, sAxisX);
  1130. }
  1131. }
  1132. }
  1133. catch(...)
  1134. {
  1135. }
  1136. }
  1137. DbChart->LeftAxis->Minimum = 0;
  1138. DbChart->LeftAxis->Maximum = GetActiveMaxY();
  1139. if (DbChart->LeftAxis->Minimum >= DbChart->LeftAxis->Maximum)
  1140. {
  1141. DbChart->LeftAxis->Maximum = DbChart->LeftAxis->Minimum + 1;
  1142. }
  1143. }
  1144. __finally
  1145. {
  1146. if (pCDS)
  1147. {
  1148. pCDS->EnableControls();
  1149. }
  1150. TvList->EndUpdate();
  1151. DbChart->Refresh();
  1152. LstLegend->Items->EndUpdate();
  1153. Screen->Cursor = cOldCursor;
  1154. }
  1155. }
  1156. //---------------------------------------------------------------------------
  1157. void __fastcall TPlugInChart::DrawChart5_1(TcxGridTableView *TvList, int nAxisY1, int nAxisY2, int nStColIdx, int nEdColIdx/*=-1*/,int nTotColIdx/*=-1*/)
  1158. {
  1159. int ii, jj, kk;
  1160. SeriesType SrsType;
  1161. TColor clSrsColor;
  1162. TChartSeries *pSeries;
  1163. TCursor cOldCursor= Screen->Cursor;
  1164. try
  1165. {
  1166. Screen->Cursor = crHourGlass;
  1167. LstLegend->Items->BeginUpdate();
  1168. TvList->BeginUpdate();
  1169. int nCols = TvList->ColumnCount;
  1170. int nRows = TvList->ViewData->RecordCount;
  1171. if (nEdColIdx != -1)
  1172. {
  1173. nCols = nCols > nEdColIdx ? nEdColIdx+1 : nCols;
  1174. }
  1175. SrsType = GetChartType();
  1176. /*
  1177. * 합계 표출
  1178. */
  1179. kk = 0;
  1180. if (nTotColIdx >= 0)
  1181. {
  1182. clSrsColor = GetDefaultColor(kk++);
  1183. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  1184. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  1185. pSeries = AddSeriesItem(lblSoge->Caption/*"소계"*/, SrsType, clSrsColor, true);
  1186. if (pSeries)
  1187. {
  1188. for (jj = nStColIdx; jj < nCols; jj++)
  1189. {
  1190. if (!TvList->Columns[jj]->Visible)
  1191. {
  1192. break;
  1193. }
  1194. String sAxisX = TvList->Columns[jj]->Caption;
  1195. nTotColIdx = TvList->DataController->Summary->FooterSummaryItems->IndexOfItemLink(TvList->Columns[jj]);
  1196. if (!VarIsNull(TvList->DataController->Summary->FooterSummaryValues[nTotColIdx]))
  1197. {
  1198. double dValX = 0;
  1199. try {
  1200. dValX = (double)TvList->DataController->Summary->FooterSummaryValues[nTotColIdx];
  1201. } catch(...) { dValX = 0;}
  1202. pSeries->AddY(dValX, sAxisX);
  1203. }
  1204. }
  1205. }
  1206. }
  1207. for (ii = 0; ii < nRows; ii++, kk++)
  1208. {
  1209. try
  1210. {
  1211. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  1212. clSrsColor = GetDefaultColor(kk);
  1213. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  1214. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  1215. String sTitle = "";
  1216. if (TvList->Columns[nAxisY1]->Visible && !VarIsNull(ARow->Values[nAxisY1]))
  1217. {
  1218. sTitle = ARow->Values[nAxisY1];
  1219. }
  1220. if (TvList->Columns[nAxisY2]->Visible && !VarIsNull(ARow->Values[nAxisY2]))
  1221. {
  1222. sTitle += ":";
  1223. sTitle += ARow->Values[nAxisY2];
  1224. }
  1225. pSeries = AddSeriesItem(sTitle, SrsType, clSrsColor, true);
  1226. if (pSeries)
  1227. {
  1228. for (jj = nStColIdx; jj < nCols; jj++)
  1229. {
  1230. if (!TvList->Columns[jj]->Visible)
  1231. {
  1232. break;
  1233. }
  1234. String sAxisX = TvList->Columns[jj]->Caption;
  1235. double dValX = 0;
  1236. if (!VarIsNull(ARow->Values[jj]))
  1237. {
  1238. String sVal = VarToStr(ARow->Values[jj]);
  1239. try {
  1240. //dValX = (double)ARow->Values[jj];
  1241. dValX = (double)sVal.ToIntDef(0);
  1242. } catch(...) {
  1243. dValX=0;
  1244. }
  1245. }
  1246. pSeries->AddY(dValX, sAxisX);
  1247. }
  1248. }
  1249. }
  1250. catch(...)
  1251. {
  1252. }
  1253. }
  1254. DbChart->LeftAxis->Minimum = 0;
  1255. DbChart->LeftAxis->Maximum = GetActiveMaxY();
  1256. if (DbChart->LeftAxis->Minimum >= DbChart->LeftAxis->Maximum)
  1257. {
  1258. DbChart->LeftAxis->Maximum = DbChart->LeftAxis->Minimum + 1;
  1259. }
  1260. }
  1261. __finally
  1262. {
  1263. TvList->EndUpdate();
  1264. DbChart->Refresh();
  1265. LstLegend->Items->EndUpdate();
  1266. Screen->Cursor = cOldCursor;
  1267. }
  1268. }
  1269. //---------------------------------------------------------------------------
  1270. void __fastcall TPlugInChart::DrawChart6(TcxGridDBTableView *TvList, int nAxisY1, int nAxisY2, int nAxisY3, int nStColIdx, int nEdColIdx/*=-1*/,int nTotColIdx/*=-1*/)
  1271. {
  1272. int ii, jj, kk;
  1273. SeriesType SrsType;
  1274. TColor clSrsColor;
  1275. TChartSeries *pSeries;
  1276. TClientDataSet *pCDS = NULL;
  1277. TCursor cOldCursor= Screen->Cursor;
  1278. try
  1279. {
  1280. Screen->Cursor = crHourGlass;
  1281. LstLegend->Items->BeginUpdate();
  1282. TvList->BeginUpdate();
  1283. pCDS = (TClientDataSet *)TvList->DataController->DataSource->DataSet;
  1284. if (pCDS)
  1285. {
  1286. pCDS->DisableControls();
  1287. }
  1288. int nCols = TvList->ColumnCount;
  1289. int nRows = TvList->ViewData->RecordCount;
  1290. if (nEdColIdx != -1)
  1291. {
  1292. nCols = nCols > nEdColIdx ? nEdColIdx+1 : nCols;
  1293. }
  1294. SrsType = GetChartType();
  1295. /*
  1296. * 합계 표출
  1297. */
  1298. kk = 0;
  1299. if (nTotColIdx >= 0)
  1300. {
  1301. clSrsColor = GetDefaultColor(kk++);
  1302. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  1303. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  1304. pSeries = AddSeriesItem(lblSoge->Caption/*"소계"*/, SrsType, clSrsColor, true);
  1305. if (pSeries)
  1306. {
  1307. for (jj = nStColIdx; jj < nCols; jj++)
  1308. {
  1309. if (!TvList->Columns[jj]->Visible)
  1310. {
  1311. break;
  1312. }
  1313. String sAxisX = TvList->Columns[jj]->Caption;
  1314. nTotColIdx = TvList->DataController->Summary->FooterSummaryItems->IndexOfItemLink(TvList->Columns[jj]);
  1315. if (!VarIsNull(TvList->DataController->Summary->FooterSummaryValues[nTotColIdx]))
  1316. {
  1317. double dValX = 0;
  1318. try {
  1319. dValX = (double)TvList->DataController->Summary->FooterSummaryValues[nTotColIdx];
  1320. } catch(...) { dValX = 0;}
  1321. pSeries->AddY(dValX, sAxisX);
  1322. }
  1323. }
  1324. }
  1325. }
  1326. for (ii = 0; ii < nRows; ii++, kk++)
  1327. {
  1328. try
  1329. {
  1330. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  1331. String sTitle1, sTitle2;
  1332. if (TvList->Columns[nAxisY1]->Visible && !VarIsNull(ARow->Values[nAxisY1]))
  1333. {
  1334. sTitle1 = ARow->Values[nAxisY1];
  1335. }
  1336. if (TvList->Columns[nAxisY2]->Visible && !VarIsNull(ARow->Values[nAxisY2]))
  1337. {
  1338. sTitle2 = ARow->Values[nAxisY2];
  1339. }
  1340. if (sTitle1 == sTitle2)
  1341. {
  1342. //그룹핑했을 경우 그룹핑한 컬럼 제외
  1343. //continue;
  1344. }
  1345. if (!ARow->IsData) continue;
  1346. clSrsColor = GetDefaultColor(kk);
  1347. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  1348. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  1349. String sTitle = sTitle1 + ":" + sTitle2;
  1350. #if 0
  1351. if (TvList->Columns[nAxisY3]->Visible && !VarIsNull(ARow->Values[nAxisY3]))
  1352. {
  1353. sTitle += ":";
  1354. sTitle += ARow->Values[nAxisY3];
  1355. }
  1356. #endif
  1357. pSeries = AddSeriesItem(sTitle, SrsType, clSrsColor, true);
  1358. if (pSeries)
  1359. {
  1360. for (jj = nStColIdx; jj < nCols; jj++)
  1361. {
  1362. if (!TvList->Columns[jj]->Visible)
  1363. {
  1364. break;
  1365. }
  1366. String sAxisX = TvList->Columns[jj]->Caption;
  1367. double dValX = 0;
  1368. if (!VarIsNull(ARow->Values[jj]))
  1369. {
  1370. String sVal = VarToStr(ARow->Values[jj]);
  1371. try {
  1372. //dValX = (double)ARow->Values[jj];
  1373. dValX = (double)sVal.ToIntDef(0);
  1374. } catch(...) {
  1375. dValX=0;
  1376. }
  1377. }
  1378. pSeries->AddY(dValX, sAxisX);
  1379. }
  1380. }
  1381. }
  1382. catch(...)
  1383. {
  1384. }
  1385. }
  1386. DbChart->LeftAxis->Minimum = 0;
  1387. DbChart->LeftAxis->Maximum = GetActiveMaxY();
  1388. if (DbChart->LeftAxis->Minimum >= DbChart->LeftAxis->Maximum)
  1389. {
  1390. DbChart->LeftAxis->Maximum = DbChart->LeftAxis->Minimum + 1;
  1391. }
  1392. }
  1393. __finally
  1394. {
  1395. if (pCDS)
  1396. {
  1397. pCDS->EnableControls();
  1398. }
  1399. TvList->EndUpdate();
  1400. DbChart->Refresh();
  1401. LstLegend->Items->EndUpdate();
  1402. Screen->Cursor = cOldCursor;
  1403. }
  1404. }
  1405. //---------------------------------------------------------------------------
  1406. /*
  1407. * 해당되지 않는 컬럼을 클리어한다.
  1408. * arguments
  1409. *
  1410. * return
  1411. * void
  1412. */
  1413. void __fastcall TPlugInChart::DrawChart3(TcxGridDBTableView *TvList, int nAxisY1, int nAxisY2, int nStColIdx, int nTotColIdx/*=-1*/)
  1414. {
  1415. int ii, jj, kk;
  1416. SeriesType SrsType;
  1417. TColor clSrsColor;
  1418. TChartSeries *pSeries;
  1419. TClientDataSet *pCDS = NULL;
  1420. TCursor cOldCursor= Screen->Cursor;
  1421. try
  1422. {
  1423. Screen->Cursor = crHourGlass;
  1424. LstLegend->Items->BeginUpdate();
  1425. TvList->BeginUpdate();
  1426. pCDS = (TClientDataSet *)TvList->DataController->DataSource->DataSet;
  1427. if (pCDS)
  1428. {
  1429. pCDS->DisableControls();
  1430. }
  1431. int nCols = TvList->ColumnCount;
  1432. int nRows = TvList->ViewData->RecordCount;
  1433. SrsType = GetChartType();
  1434. /*
  1435. * 합계 표출
  1436. */
  1437. kk = 0;
  1438. if (nTotColIdx >= 0)
  1439. {
  1440. clSrsColor = GetDefaultColor(kk++);
  1441. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  1442. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  1443. pSeries = AddSeriesItem(lblSoge->Caption/*"소계"*/, SrsType, clSrsColor, true);
  1444. if (pSeries)
  1445. {
  1446. for (jj = nStColIdx; jj < nCols; jj++)
  1447. {
  1448. if (!TvList->Columns[jj]->Visible)
  1449. {
  1450. break;
  1451. }
  1452. String sAxisX = TvList->Columns[jj]->Caption;
  1453. nTotColIdx = TvList->DataController->Summary->FooterSummaryItems->IndexOfItemLink(TvList->Columns[jj]);
  1454. if (!VarIsNull(TvList->DataController->Summary->FooterSummaryValues[nTotColIdx]))
  1455. {
  1456. double dValX = 0;
  1457. try {
  1458. dValX = (double)TvList->DataController->Summary->FooterSummaryValues[nTotColIdx];
  1459. } catch(...) { dValX = 0; }
  1460. pSeries->AddY(dValX, sAxisX);
  1461. }
  1462. }
  1463. }
  1464. }
  1465. for (ii = 0; ii < nRows; ii++, kk++)
  1466. {
  1467. try
  1468. {
  1469. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  1470. String sTitle, sTitle1, sTitle2;
  1471. sTitle = "";
  1472. sTitle1 = "";
  1473. sTitle2 = "";
  1474. if (!VarIsNull(ARow->Values[nAxisY1]))
  1475. sTitle1 = ARow->Values[nAxisY1];
  1476. if (!VarIsNull(ARow->Values[nAxisY2]))
  1477. sTitle2 = ARow->Values[nAxisY2];
  1478. if (sTitle2 == FrmLang->lblChartSoge->Caption)//"소계")
  1479. continue;
  1480. if (sTitle2 == "")
  1481. {
  1482. sTitle = sTitle1;
  1483. }
  1484. else
  1485. {
  1486. sTitle = sTitle1 + ":" + sTitle2;
  1487. }
  1488. clSrsColor = GetDefaultColor(kk);
  1489. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  1490. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  1491. pSeries = AddSeriesItem(sTitle, SrsType, clSrsColor, true);
  1492. if (pSeries)
  1493. {
  1494. for (jj = nStColIdx; jj < nCols; jj++)
  1495. {
  1496. if (!TvList->Columns[jj]->Visible)
  1497. {
  1498. break;
  1499. }
  1500. String sAxisX = TvList->Columns[jj]->Caption;
  1501. double dValX = 0;
  1502. if (!VarIsNull(ARow->Values[jj]))
  1503. try { dValX = (double)ARow->Values[jj]; } catch(...) {dValX=0;}
  1504. pSeries->AddY(dValX, sAxisX);
  1505. }
  1506. }
  1507. }
  1508. catch(...)
  1509. {
  1510. }
  1511. }
  1512. DbChart->LeftAxis->Minimum = 0;
  1513. DbChart->LeftAxis->Maximum = GetActiveMaxY();
  1514. if (DbChart->LeftAxis->Minimum >= DbChart->LeftAxis->Maximum)
  1515. {
  1516. DbChart->LeftAxis->Maximum = DbChart->LeftAxis->Minimum + 1;
  1517. }
  1518. }
  1519. __finally
  1520. {
  1521. if (pCDS)
  1522. {
  1523. pCDS->EnableControls();
  1524. }
  1525. TvList->EndUpdate();
  1526. DbChart->Refresh();
  1527. LstLegend->Items->EndUpdate();
  1528. Screen->Cursor = cOldCursor;
  1529. }
  1530. }
  1531. //---------------------------------------------------------------------------
  1532. /*
  1533. * 해당되지 않는 컬럼을 클리어한다.
  1534. * arguments
  1535. *
  1536. * return
  1537. * void
  1538. */
  1539. void __fastcall TPlugInChart::DrawChart2(TcxGridDBBandedTableView *TvList,
  1540. int nAxisY, int nStColIdx,
  1541. int nTotColIdx/*=-1*/,
  1542. bool bBarSeries/*=true*/,
  1543. bool bBandText/*=true*/,
  1544. int nEdColIdx/*=-1*/)
  1545. {
  1546. int ii, jj, kk;
  1547. SeriesType SrsType;
  1548. TColor clSrsColor;
  1549. TChartSeries *pSeries;
  1550. TClientDataSet *pCDS = NULL;
  1551. TcxGridBand *pBand;
  1552. TcxGridDBBandedColumn *pCol;
  1553. TCursor cOldCursor= Screen->Cursor;
  1554. try
  1555. {
  1556. Screen->Cursor = crHourGlass;
  1557. LstLegend->Items->BeginUpdate();
  1558. TvList->BeginUpdate();
  1559. pCDS = (TClientDataSet *)TvList->DataController->DataSource->DataSet;
  1560. if (pCDS)
  1561. {
  1562. pCDS->DisableControls();
  1563. }
  1564. int nCols;
  1565. if (nEdColIdx >= 0)
  1566. nCols = nEdColIdx+1;
  1567. else
  1568. nCols = TvList->ColumnCount;
  1569. int nRows = TvList->ViewData->RecordCount;
  1570. SrsType = GetChartType();
  1571. for (ii = nStColIdx; ii < nCols; ii++, kk++)
  1572. {
  1573. pCol = TvList->Columns[ii];
  1574. if (!pCol)
  1575. {
  1576. continue;
  1577. }
  1578. if (!pCol->Visible)
  1579. continue;
  1580. pBand = TvList->Bands->Items[pCol->Position->BandIndex];
  1581. clSrsColor = GetDefaultColor(kk);
  1582. if (clSrsColor == clWhite) clSrsColor = GetDefaultColor(++kk);
  1583. if (clSrsColor == clYellow) clSrsColor = GetDefaultColor(++kk);
  1584. String sTitle;
  1585. if (bBandText)
  1586. {
  1587. sTitle = "[" + pBand->Caption + "]" + pCol->Caption;
  1588. }
  1589. else
  1590. {
  1591. sTitle = pCol->Caption;
  1592. }
  1593. if (ii == nTotColIdx)
  1594. sTitle = pCol->Caption;
  1595. if (ii == nTotColIdx && bBarSeries)
  1596. {
  1597. pSeries = AddSeriesItem(sTitle, ctpBar, clSrsColor, true);
  1598. }
  1599. else
  1600. {
  1601. pSeries = AddSeriesItem(sTitle, SrsType, clSrsColor, true);
  1602. }
  1603. for (jj = 0; jj < nRows; jj++)
  1604. {
  1605. TcxCustomGridRow* ARow = TvList->ViewData->Rows[jj];
  1606. String sX = "";
  1607. if (!VarIsNull(ARow->Values[nAxisY]))
  1608. try { sX = ARow->Values[nAxisY]; } catch(...) {}
  1609. double nY = 0;
  1610. if (!VarIsNull(ARow->Values[ii]))
  1611. try { nY = (double)ARow->Values[ii]; } catch(...){nY=0;};
  1612. pSeries->AddY(nY, sX);
  1613. }
  1614. }
  1615. DbChart->LeftAxis->Minimum = 0;
  1616. DbChart->LeftAxis->Maximum = GetActiveMaxY();
  1617. if (DbChart->LeftAxis->Minimum >= DbChart->LeftAxis->Maximum)
  1618. {
  1619. DbChart->LeftAxis->Maximum = DbChart->LeftAxis->Minimum + 1;
  1620. }
  1621. }
  1622. __finally
  1623. {
  1624. if (pCDS)
  1625. {
  1626. pCDS->EnableControls();
  1627. }
  1628. TvList->EndUpdate();
  1629. DbChart->Refresh();
  1630. LstLegend->Items->EndUpdate();
  1631. Screen->Cursor = cOldCursor;
  1632. }
  1633. }
  1634. //---------------------------------------------------------------------------
  1635. /*
  1636. * 차트 그린후 호출(Optional)
  1637. *
  1638. * arguments
  1639. * return
  1640. * void
  1641. */
  1642. void __fastcall TPlugInChart::EndDraw()
  1643. {
  1644. BtnChkAllClick(NULL);
  1645. }
  1646. //---------------------------------------------------------------------------
  1647. SeriesType __fastcall TPlugInChart::GetChartType()
  1648. {
  1649. return (SeriesType)CbChartKind->ItemIndex;
  1650. }
  1651. //---------------------------------------------------------------------------
  1652. /*
  1653. * 차트에 차트시리즈를 추가한다.
  1654. *
  1655. * arguments
  1656. * return
  1657. * void
  1658. */
  1659. TChartSeries* __fastcall TPlugInChart::AddSeriesItem(String sTitle,
  1660. SeriesType SrsType,
  1661. TColor clSrsColor,
  1662. bool bActive/*=true*/
  1663. )
  1664. {
  1665. SeriesItem *pSrsItem;
  1666. TChartSeries *pSeries = NULL;
  1667. try
  1668. {
  1669. pSrsItem = new SeriesItem;
  1670. pSrsItem->SrsType = SrsType;
  1671. pSeries = MakeChartSeries(SrsType);
  1672. pSeries->Title = sTitle;
  1673. pSrsItem->ChartSeries = (void*)pSeries;
  1674. pSeries->Active = bActive;
  1675. pSeries->SeriesColor = clSrsColor;
  1676. LstLegend->Items->AddObject(sTitle, (TObject*)pSrsItem);
  1677. LstLegend->Checked[LstLegend->Count-1] = bActive;
  1678. pSeries->ParentChart = DbChart;
  1679. }
  1680. catch(...)
  1681. {
  1682. }
  1683. return pSeries;
  1684. }
  1685. //---------------------------------------------------------------------------
  1686. /*
  1687. * 차트시리즈를 생성한다.
  1688. *
  1689. * arguments
  1690. * return
  1691. * void
  1692. */
  1693. TChartSeries* __fastcall TPlugInChart::MakeChartSeries(SeriesType nSeriesTp)
  1694. {
  1695. TChartSeries *pSeries = NULL;
  1696. try
  1697. {
  1698. switch(nSeriesTp)
  1699. {
  1700. case ctpLine:
  1701. {
  1702. TLineSeries *pChart = new TLineSeries(this);
  1703. pChart->Pointer->Style = psRectangle;
  1704. pChart->Pointer->Visible = true;
  1705. pChart->Pointer->VertSize = 4;
  1706. //pChart->Marks->Style = smsValue;
  1707. //pChart->Marks->Visible = false;
  1708. pSeries = (TChartSeries *)pChart;
  1709. }
  1710. break;
  1711. case ctpBar:
  1712. {
  1713. TBarSeries *pChart = new TBarSeries(this);
  1714. pChart->Marks->Visible = true;
  1715. pSeries = (TChartSeries *)pChart;
  1716. }
  1717. break;
  1718. case ctpHorizontal_Bar:
  1719. {
  1720. THorizBarSeries *pChart = new THorizBarSeries(this);
  1721. pSeries = (TChartSeries *)pChart;
  1722. }
  1723. break;
  1724. case ctpArea:
  1725. {
  1726. TAreaSeries *pChart = new TAreaSeries(this);
  1727. pSeries = (TChartSeries *)pChart;
  1728. }
  1729. break;
  1730. case ctpPoint:
  1731. {
  1732. TPointSeries *pChart = new TPointSeries(this);
  1733. pSeries = (TChartSeries *)pChart;
  1734. }
  1735. break;
  1736. case ctpPie:
  1737. {
  1738. TPieSeries *pChart = new TPieSeries(this);
  1739. pSeries = (TChartSeries *)pChart;
  1740. }
  1741. break;
  1742. case ctpFast_Line:
  1743. {
  1744. TFastLineSeries *pChart = new TFastLineSeries(this);
  1745. pSeries = (TChartSeries *)pChart;
  1746. }
  1747. break;
  1748. case ctpHorizontal_Line:
  1749. {
  1750. THorizLineSeries *pChart = new THorizLineSeries(this);
  1751. pSeries = (TChartSeries *)pChart;
  1752. }
  1753. break;
  1754. case ctpHorizontal_Area:
  1755. {
  1756. THorizAreaSeries *pChart = new THorizAreaSeries(this);
  1757. pSeries = (TChartSeries *)pChart;
  1758. }
  1759. break;
  1760. case ctpShape:
  1761. {
  1762. TChartShape *pChart = new TChartShape(this);
  1763. pSeries = (TChartSeries *)pChart;
  1764. }
  1765. break;
  1766. case ctpGantt:
  1767. {
  1768. TGanttSeries *pChart = new TGanttSeries(this);
  1769. pSeries = (TChartSeries *)pChart;
  1770. }
  1771. break;
  1772. case ctpArrow:
  1773. {
  1774. TArrowSeries *pChart = new TArrowSeries(this);
  1775. pSeries = (TChartSeries *)pChart;
  1776. }
  1777. break;
  1778. case ctpBubble:
  1779. {
  1780. TBubbleSeries *pChart = new TBubbleSeries(this);
  1781. pSeries = (TChartSeries *)pChart;
  1782. }
  1783. break;
  1784. }
  1785. pSeries->Marks->Style = smsValue;
  1786. pSeries->Marks->Visible = ChkDispValue->Checked;
  1787. }
  1788. catch(...)
  1789. {
  1790. }
  1791. return pSeries;
  1792. }
  1793. //---------------------------------------------------------------------------
  1794. /*
  1795. * Bar 차트시리즈를 생성한다.
  1796. *
  1797. * arguments
  1798. * return
  1799. * void
  1800. */
  1801. void __fastcall TPlugInChart::ShowBarChart()
  1802. {
  1803. #if 0
  1804. chart.RemoveAllSeries();
  1805. if (ds.rowcount == 0) return;
  1806. var i = 0, serindex = 0;
  1807. var oldvalue = "", newvalue = "";
  1808. while (i < ds.rowcount)
  1809. {
  1810. newvalue = ds.GetColumn(i,"D1");
  1811. if (oldvalue != newvalue) {
  1812. //시리즈 추가
  1813. chart.addSeries (1); //scBar
  1814. chart.Series(serindex).Clear();
  1815. chart.Series(serindex).title = newvalue;
  1816. chart.Series(serindex).Name = newvalue;
  1817. chart.Series(serindex).Marks.Style = 0; //smsValue;
  1818. chart.Series(serindex).Marks.Visible = false;
  1819. chart.Series(serindex).color = arrseror[serindex % arrseror.length];
  1820. serindex++;
  1821. oldvalue = newvalue;
  1822. }
  1823. var xname = ds.GetColumn(i,"D2"); //X축 명칭
  1824. var xvalue = ds.GetColumn(i,"D3"); //X축 값
  1825. chart.Series(serindex-1).Add (toNumber(xvalue), xname, chart.Series(serindex-1).color);
  1826. chart.Series(serindex-1).Marks.Style = 0; //smsValue //마크에 표시될 내용
  1827. chart.Series(serindex-1).Marks.Frame.Color = TCH_MARK_BORDERCOLOR; //마크 테두리 색상
  1828. i++;
  1829. }
  1830. #endif
  1831. }
  1832. //---------------------------------------------------------------------------
  1833. void __fastcall TPlugInChart::DbChartClickSeries(TCustomChart *Sender, TChartSeries *Series, int ValueIndex, TMouseButton Button, TShiftState Shift,
  1834. int X, int Y)
  1835. {
  1836. #if 0
  1837. try
  1838. {
  1839. double vx, vy;
  1840. AnsiString s;
  1841. Sender->GetCursorValues(vx, vy);
  1842. int nValue = Sender->GetMarkValue(floor(vx+0.50)-1);
  1843. acDragPanel1->Color = Sender->Tag;
  1844. AnsiString sTP = (AnsiString)tvList->Columns[2+ValueIndex]->Caption;
  1845. s = sTP + "\n" + Sender->Title + "\n" + IntToStr(nValue) + lblEA->Caption;//"건";
  1846. LblDet->Caption = s;
  1847. LblDet->Left = 6;
  1848. LblDet->Top = 6;
  1849. acDragPanel1->Width = LblDet->Left+LblDet->Width+8;
  1850. acDragPanel1->Height = LblDet->Left+LblDet->Height+8;
  1851. acDragPanel1->Left = X + 5;
  1852. if((Sender->ParentChart->Height - Y) <= acDragPanel1->Height)
  1853. acDragPanel1->Top = Y - acDragPanel1->Height;
  1854. else
  1855. acDragPanel1->Top = Y;
  1856. acDragPanel1->Visible = true;
  1857. }
  1858. catch(...)
  1859. {
  1860. }
  1861. #endif
  1862. if (Button != mbLeft)
  1863. {
  1864. return;
  1865. }
  1866. String sMsg;
  1867. //double vx, vy;
  1868. //Series->GetCursorValues(vx, vy);
  1869. //int nValue = Series->GetMarkValue(floor(vx+0.50)-1);
  1870. //ShowMessage(String(ValueIndex));
  1871. //Series->Labels->
  1872. sMsg = Series->Title + "\r\n";
  1873. //sMsg += Series->Labels[ValueIndex].ToString() + "\r\n";
  1874. // sMsg+= String(Series->XValues->Value[ValueIndex]) + " " + DbChart->BottomAxis->Title->Caption + "\r\n";
  1875. sMsg+= DbChart->LeftAxis->Title->Caption + ": " + String(Series->YValues->Value[ValueIndex]);
  1876. ShowMessage(sMsg);
  1877. }
  1878. //---------------------------------------------------------------------------
  1879. void __fastcall TPlugInChart::DbChartMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
  1880. {
  1881. #if 0
  1882. int idx=Series1->GetCursorValueIndex();
  1883. if(idx>=0)
  1884. {
  1885. double dX,dY;
  1886. Series1->GetCursorValues(dX,dY);
  1887. Chart1->Hint="( "+IntToStr((int)dX)+" , "+IntToStr((int)dY)+ " )";
  1888. }
  1889. else
  1890. {
  1891. Chart1->Hint="";
  1892. }
  1893. #endif
  1894. }
  1895. //---------------------------------------------------------------------------