tchartHelper.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /************************************************************************************************
  2. DATE : 2007-07-06
  3. WRITER : Comsquare
  4. DEFINITION : TrustForm4.0 TChart 관련 공통 JavaScript ( CMC )
  5. *************************************************************************************************/
  6. /************************************************************************************************
  7. 함수명 : createTChart ()
  8. 인자 :
  9. String objID - 생성될 TChart Object ID
  10. Integer leftPx - Left
  11. Integer topPx - Top
  12. Integer widthPx - Width
  13. Integer heightPx - Height
  14. [Object parentObj] - 생성될 타겟(부모 객체)
  15. 결과값 : Object TChart
  16. 함수설명 : TChart Control 생성
  17. ************************************************************************************************
  18. 작 성 자 : 김 기용
  19. 작 성 일 : 2007. 07. 06
  20. ************************************************************************************************/
  21. function createTChart(objID, leftPx, topPx, widthPx, heightPx, parentObj) {
  22. if( parentObj == null )
  23. parentObj = body;
  24. var tChartObj = parentObj.createChild("xforms:object", "id:" + objID + "; clsid:{fab9b41c-87d6-474d-ab7e-f07d78f2422e}; left:" + leftPx + "px; top:" + topPx + "px; width:" + widthPx + "px; height:" + heightPx + "px; ")
  25. return tChartObj;
  26. }
  27. /************************************************************************************************
  28. 함수명 : drawOneTChart ()
  29. 인자 :
  30. Object tChartObj - Target TChart
  31. Object gridObj - Source DataGrid
  32. Integer row - Datagrid Source row
  33. [String title] - TChart Title
  34. [Boolean refresh] - 초기화 여부
  35. 결과값 :
  36. 함수설명 : Datagrid의 해당 로우 data를 반영하여 TChart에(Point Type) 그려 줌.
  37. ************************************************************************************************
  38. 작 성 자 : 김 기용
  39. 작 성 일 : 2007. 07. 06
  40. ************************************************************************************************/
  41. function drawOneTChart(tChartObj, gridObj, row, title, refresh) {
  42. if( refresh )
  43. tChartObj.RemoveAllSeries(); // Series 초기화
  44. if( title != null || title == "" ) {
  45. tChartObj.Header.Text(0) = title; // Title 설정
  46. }
  47. tChartObj.Aspect.View3D = 0; // 3D 설정
  48. tChartObj.Legend.CheckBoxes = true;
  49. // tChartObj.Legend.Alignment = 0; // Legend 위치 설정 :: 0 - left | 1 - right | 2 - top| 3 - bottom
  50. var Rnd1, Rnd2, Rnd3;
  51. var cColor;
  52. var i;
  53. var x, y;
  54. tChartObj.AddSeries(0);
  55. var seriesIndex = tChartObj.SeriesCount - 1;
  56. var trgRow = row;
  57. tChartObj.Series(seriesIndex).asLine.Pointer.Visible = true;
  58. tChartObj.Series(seriesIndex).asLine.Pointer.Style = 1; //PointStyle 설정 :: 0 - 8
  59. tChartObj.Series(seriesIndex).Title = datagrid1.valueMatrix(trgRow, 0);
  60. //tChartObj.Series(cline - 2).Marks.Style = 0;
  61. Rnd1 = Math.random();
  62. Rnd2 = Math.random();
  63. Rnd3 = Math.random();
  64. cColor = window.rgb( (255 - 1) * Rnd1 + 1, (255 - 1) * Rnd2 + 1 , (255 - 1) * Rnd3 + 1);
  65. for( i = gridObj.fixedCols; i < gridObj.cols; i++ ){
  66. x = gridObj.valueMatrix(0, i);
  67. y = gridObj.valueMatrix(trgRow, i);
  68. tChartObj.Series(seriesIndex).Add (y, x, tChartObj.Series(seriesIndex).Color);
  69. // tChartObj.Series(seriesIndex).LegendItemColor(cColor);
  70. }
  71. }
  72. /************************************************************************************************
  73. 함수명 : drawAllTChart ()
  74. 인자 :
  75. Object tChartObj - Target TChart
  76. Object gridObj - Source DataGrid
  77. String title - TChart Title
  78. 결과값 :
  79. 함수설명 : Datagrid data를 반영하여 TChart에(Point Type) 그려 줌.
  80. ************************************************************************************************
  81. 작 성 자 : 김 기용
  82. 작 성 일 : 2007. 07. 06
  83. ************************************************************************************************/
  84. function drawAllTChart(tChartObj, gridObj, title) {
  85. tChartObj.RemoveAllSeries(); // Series 초기화
  86. for( var i = gridObj.fixedRows; i < gridObj.rows; i ++)
  87. drawOneTChart(tChartObj, gridObj, i, title, false);
  88. }