PlugInChartF.cpp 61 KB

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