tchartHelper.js.soonsu 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. function createTChart(tChartID, leftPx, topPx, widthPx, heightPx, parentObj) {
  2. if( parentObj == null )
  3. parentObj = body;
  4. var tChartObj = parentObj.createChild("xforms:object", "id:" + tChartID + "; clsid:{fab9b41c-87d6-474d-ab7e-f07d78f2422e}; left:" + leftPx + "px; top:" + topPx + "px; width:" + widthPx + "px; height:" + heightPx + "px; ")
  5. return tChartObj;
  6. }
  7. function createTChart8(tChartID, leftPx, topPx, widthPx, heightPx, parentObj) {
  8. if( parentObj == null )
  9. parentObj = body;
  10. var tChartObj = parentObj.createChild("xforms:object", "id:" + tChartID + "; clsid:{BDEB0088-66F9-4A55-ABD2-0BF8DEEC1196}; left:" + leftPx + "px; top:" + topPx + "px; width:" + widthPx + "px; height:" + heightPx + "px; ")
  11. return tChartObj;
  12. }
  13. function clearTChart(tChartObj) {
  14. tChartObj.RemoveAllSeries();
  15. tChartObj.Tools.clear()
  16. }
  17. function drawBar(tChartObj, gridObj ,yColRef , title, pivot) {
  18. clearTChart(tChartObj);
  19. tChartObj.Header.Text(0) = title;
  20. tChartObj.Aspect.View3D = 0;
  21. if( pivot )
  22. pivot = 2;
  23. else
  24. pivot = 1;
  25. tChartObj.AddSeries(pivot);
  26. tChartObj.Legend.setVisible(false);
  27. tChartObj.Series(0).marks.setVisible(false);
  28. var Rnd1, Rnd2, Rnd3;
  29. var cColor;
  30. var i;
  31. var x, y;
  32. var yCol = gridObj.colRef(yColRef);
  33. for (i = gridObj.fixedRows; i < gridObj.rows; i++ ) {
  34. Rnd1 = Math.random();
  35. Rnd2 = Math.random();
  36. Rnd3 = Math.random();
  37. cColor = window.rgb( (255 - 1) * Rnd1 + 1, (255 - 1) * Rnd2 + 1 , (255 - 1) * Rnd3 + 1);
  38. x = gridObj.valueMatrix(i, 0);
  39. y = gridObj.valueMatrix(i, yCol);
  40. tChartObj.Series(0).Add (y, x, cColor);
  41. }
  42. }
  43. function drawSelectBar(chart, grid, title, rows, cols, legend, pivot, type) {
  44. clearTChart(chart);
  45. chart.Header.Text(0) = title;
  46. chart.Aspect.View3D = 0;
  47. if( pivot ) {
  48. pivot = 2;
  49. } else {
  50. pivot = 1;
  51. }
  52. if (legend) {
  53. chart.Legend.setVisible(true);
  54. } else {
  55. chart.Legend.setVisible(false);
  56. }
  57. if (type == "row") {
  58. var r, g, b, color;
  59. var x, y;
  60. for (var i = 0; i < cols.length; i++ ) {
  61. chart.AddSeries(pivot);
  62. var idx = chart.SeriesCount -1;
  63. chart.Series(idx).title = grid.valueMatrix(0, cols[i]);
  64. chart.Series(i).marks.setVisible(false);
  65. r = Math.random();
  66. g = Math.random();
  67. b = Math.random();
  68. color = window.rgb( (255 - 1) * r + 1, (255 - 1) * g + 1 , (255 - 1) * b + 1);
  69. for (var j = 0; j < rows.length; j++) {
  70. x = grid.valueMatrix(rows[j], 0);
  71. y = grid.valueMatrix(rows[j], cols[i]);
  72. chart.Series(i).Add (y, x, chart.Series(idx).Color);
  73. chart.Series(i).LegendItemColor(color)
  74. }
  75. }
  76. } else if (type == "col") {
  77. var r, g, b, color;
  78. var x, y;
  79. for (var i = 0; i < rows.length; i++ ) {
  80. chart.AddSeries(pivot);
  81. var idx = chart.SeriesCount -1;
  82. chart.Series(idx).title = grid.valueMatrix(rows[i], 0);
  83. chart.Series(i).marks.setVisible(false);
  84. r = Math.random();
  85. g = Math.random();
  86. b = Math.random();
  87. color = window.rgb( (255 - 1) * r + 1, (255 - 1) * g + 1 , (255 - 1) * b + 1);
  88. for (var j = 0; j < cols.length; j++) {
  89. x = grid.valueMatrix(0, cols[j]);
  90. y = grid.valueMatrix(rows[i], cols[j]);
  91. chart.Series(i).Add (y, x, chart.Series(idx).Color);
  92. chart.Series(i).LegendItemColor(color)
  93. }
  94. }
  95. }
  96. }
  97. function drawLine(tChartObj, gridObj, row, title, refresh) {
  98. if( refresh ) {
  99. clearTChart(tChartObj);
  100. }
  101. if( title != null || title == "" ) {
  102. tChartObj.Header.Text(0) = title;
  103. }
  104. tChartObj.Aspect.View3D = 0;
  105. tChartObj.Legend.CheckBoxes = true;
  106. tChartObj.Legend.Alignment = 0;
  107. var Rnd1, Rnd2, Rnd3;
  108. var cColor;
  109. var i;
  110. var x, y;
  111. tChartObj.AddSeries(0);
  112. var seriesIndex = tChartObj.SeriesCount - 1;
  113. var trgRow = row;
  114. tChartObj.Series(seriesIndex).asLine.Pointer.Visible = true;
  115. tChartObj.Series(seriesIndex).asLine.Pointer.Style = 1;
  116. tChartObj.Series(seriesIndex).Title = gridObj.valueMatrix(trgRow, 0);
  117. Rnd1 = Math.random();
  118. Rnd2 = Math.random();
  119. Rnd3 = Math.random();
  120. cColor = window.rgb( (255 - 1) * Rnd1 + 1, (255 - 1) * Rnd2 + 1 , (255 - 1) * Rnd3 + 1);
  121. for( i = gridObj.fixedCols; i < gridObj.cols; i++ ){
  122. x = gridObj.valueMatrix(0, i);
  123. y = gridObj.valueMatrix(trgRow, i);
  124. tChartObj.Series(seriesIndex).Add (y, x, tChartObj.Series(seriesIndex).Color);
  125. tChartObj.Series(seriesIndex).LegendItemColor(cColor);
  126. }
  127. }
  128. function drawOneTChart(tChartObj, gridObj, row, title, refresh) {
  129. drawLine(tChartObj, gridObj, row, title, refresh);
  130. }
  131. function drawLineAll(tChartObj, gridObj, title) {
  132. for( var i = gridObj.fixedRows; i < gridObj.rows; i ++)
  133. drawOneTChart(tChartObj, gridObj, i, title, false);
  134. }
  135. function drawAllTChart(tChartObj, gridObj, title) {
  136. drawLineAll(tChartObj, gridObj, title);
  137. }
  138. function setBackImageLoad(tChartObj, imgCd){
  139. tChartObj.Panel.BackImageLoad(getTChartBackgroundImage(imgCd));
  140. }
  141. function getTChartBackgroundImage(imgcd){
  142. return "C:\\Program Files\\himed\\components\\ClipSoft\\teechart7\\images\\"+imgcd+".gif";
  143. }