StatExplorer.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. MWF.require("MWF.widget.Mask", null, false);
  2. MWF.xDesktop.requireApp("process.Application", "ViewExplorer", null, false);
  3. MWF.xApplication.process.Application.StatExplorer = new Class({
  4. Extends: MWF.xApplication.process.Application.ViewExplorer,
  5. Implements: [Options, Events],
  6. initialize: function(node, actions, options){
  7. this.setOptions(options);
  8. this.setTooltip();
  9. this.path = "/x_component_process_Application/$WorkExplorer/";
  10. this.cssPath = "/x_component_process_Application/$WorkExplorer/"+this.options.style+"/css.wcss";
  11. this._loadCss();
  12. this.actions = actions;
  13. this.node = $(node);
  14. this.items=[];
  15. },
  16. loadContentNode: function(){
  17. this.filterNode.setStyles(this.css.statListNode);
  18. this.elementContentNode = new Element("div", {
  19. "styles": this.css.elementContentNode
  20. }).inject(this.node);
  21. this.elementContentListNode = new Element("div", {
  22. "styles": this.css.elementContentListNode
  23. }).inject(this.elementContentNode);
  24. this.createWorkListHead();
  25. this.setContentSize();
  26. this.app.addEvent("resize", function(){this.setContentSize();}.bind(this));
  27. },
  28. setContentSize: function(){
  29. var toolbarSize = this.toolbarNode.getSize();
  30. var nodeSize = this.node.getSize();
  31. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  32. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  33. var filterSize = this.filterNode.getSize();
  34. var height = nodeSize.y-toolbarSize.y-pt-pb-filterSize.y;
  35. this.elementContentNode.setStyle("height", ""+height+"px");
  36. this.pageCount = (height/40).toInt()+5;
  37. },
  38. showMask: function(){
  39. if (!this.mask){
  40. this.mask = new MWF.widget.Mask({"style": "desktop"});
  41. this.mask.loadNode(this.node);
  42. }
  43. },
  44. hideMask: function(){
  45. if (this.mask){
  46. this.mask.hide();
  47. this.mask = null;
  48. }
  49. },
  50. loadViewList: function(){
  51. this.actions.listStat(this.app.options.id, function(json){
  52. if (json.data.length){
  53. json.data.each(function(process){
  54. this.loadViewListNode(process);
  55. }.bind(this));
  56. this.hideMask();
  57. if (this.currentView){
  58. this.currentView.click();
  59. }else{
  60. this.items[0].click();
  61. }
  62. }else{
  63. this.filterNode.destroy();
  64. var noElementNode = new Element("div", {
  65. "styles": this.css.noElementNode,
  66. "text": this.app.lp.noStat
  67. }).inject(this.elementContentListNode);
  68. this.hideMask();
  69. }
  70. }.bind(this));
  71. },
  72. _getLnkPar: function(view){
  73. return {
  74. "icon": this.path+this.options.style+"/statIcon/lnk.png",
  75. "title": view.name,
  76. "par": "process.Application#{\"navi\": 3, \"id\": \""+this.app.options.id+"\", \"viewName\": \""+view.name+"\", \"hideMenu\": true}"
  77. };
  78. },
  79. loadViewData: function(node){
  80. this.showMask();
  81. this.items.each(function(item){
  82. item.setStyles(this.css.filterViewNode);
  83. }.bind(this));
  84. node.setStyles(this.css.filterViewNode_current);
  85. this.elementContentListNode.empty();
  86. if (this.stat){
  87. this.stat.destroy();
  88. this.stat = null;
  89. }
  90. var view = node.retrieve("view");
  91. this.actions.loadStat(function(json){
  92. if (json.data.calculate.isGroup){
  93. this.stat = new MWF.xApplication.process.Application.StatExplorer.GroupStat(this, json.data);
  94. }else{
  95. this.stat = new MWF.xApplication.process.Application.StatExplorer.Stat(this, json.data);
  96. }
  97. //this.showViewData(json.data);
  98. this.hideMask();
  99. }.bind(this), null, view.id, this.app.options.id);
  100. },
  101. destroy: function(){
  102. if (this.stat){
  103. this.stat.destroy();
  104. }
  105. this.node.destroy();
  106. MWF.release(this);
  107. }
  108. });
  109. MWF.xApplication.process.Application.StatExplorer.Stat = new Class({
  110. initialize: function(explorer, data){
  111. this.explorer = explorer;
  112. this.data = data;
  113. this.css = this.explorer.css;
  114. this.lp = this.explorer.app.lp;
  115. this.node = this.explorer.elementContentListNode;
  116. this.load();
  117. },
  118. load: function(){
  119. this.chartAreaNode = new Element("div", {"styles": this.css.statChartAreaNode}).inject(this.node);
  120. this.tableAreaNode = new Element("div", {"styles": this.css.statTableAreaNode}).inject(this.node);
  121. this.createTable();
  122. this.createChart();
  123. },
  124. createChart: function(){
  125. //this.chartFlagNode = new Element("div", {"styles": this.css.statChartFlagAreaNode}).inject(this.chartAreaNode);
  126. this.chartNode = new Element("div", {"styles": this.css.statChartNode}).inject(this.chartAreaNode);
  127. this.loadChart();
  128. this.resizeChartFun = this.resizeChart.bind(this);
  129. this.explorer.app.addEvent("resizeCompleted", this.resizeChartFun);
  130. this.explorer.app.addEvent("postMaxSize", this.resizeChartFun);
  131. this.explorer.app.addEvent("postRestoreSize", this.resizeChartFun);
  132. },
  133. resizeChart: function(){
  134. if (this.bar) this.bar.destroy();
  135. this.bar = null;
  136. this.chartNode.empty();
  137. this.loadChart();
  138. },
  139. loadChart: function(){
  140. MWF.require("MWF.widget.chart.Bar", function(){
  141. this.bar = new MWF.widget.chart.Bar(this.chartNode, this.data.calculateGrid, "displayName", {"delay": 0, "style": "monthly"});
  142. this.bar.addBar("value");
  143. //bar.addBar("value");
  144. this.bar.addEvents({
  145. "mouseover": function(rects, texts, d, i){
  146. texts.filter(function(data, idx){return (idx==i);}).attr("display", "block");
  147. var rect = rects.filter(function(data, idx){return (idx==i);});
  148. var color = rect.attr("fill");
  149. rect.node().store("color", color);
  150. rect.attr("fill", "brown");
  151. }.bind(this),
  152. "mouseout": function(rects, texts, d, i){
  153. texts.filter(function(data, idx){return (idx==i);}).attr("display", "none");
  154. var rect = rects.filter(function(data, idx){return (idx==i);});
  155. var color = rect.node().retrieve("color");
  156. rect.attr("fill", color);
  157. }.bind(this)
  158. });
  159. this.bar.load();
  160. }.bind(this));
  161. },
  162. createTable: function(){
  163. this.createTableHead();
  164. this.createTableData();
  165. },
  166. createTableHead: function(){
  167. this.table = new Element("table", {
  168. "styles": this.css.statTableNode,
  169. "width": "100%",
  170. "border": "0",
  171. "cellPadding": "0",
  172. "cellSpacing": "0"
  173. }).inject(this.node);
  174. this.headTr = new Element("tr").inject(this.table);
  175. this.data.calculate.calculateEntryList.each(function(title){
  176. var th = new Element("th", {
  177. "styles": this.css.statHeadTh,
  178. "text": title.displayName
  179. }).inject(this.headTr);
  180. }.bind(this));
  181. },
  182. createTableData: function(){
  183. if (this.data.calculateGrid.length){
  184. var tr = new Element("tr").inject(this.table);
  185. this.data.calculateGrid.each(function(d){
  186. var td = new Element("td", {"styles": this.css.statContentTdNode}).inject(tr);
  187. td.set("text", d.value);
  188. }.bind(this));
  189. }
  190. },
  191. destroy: function(){
  192. if (this.bar) this.bar.destroy();
  193. if (this.resizeChartFun){
  194. this.explorer.app.removeEvent("resizeCompleted", this.resizeChartFun);
  195. this.explorer.app.removeEvent("postMaxSize", this.resizeChartFun);
  196. this.explorer.app.removeEvent("postRestoreSize", this.resizeChartFun);
  197. }
  198. MWF.release(this);
  199. }
  200. });
  201. MWF.xApplication.process.Application.StatExplorer.GroupStat = new Class({
  202. Extends: MWF.xApplication.process.Application.StatExplorer.Stat,
  203. createChart: function(){
  204. this.chartFlagNode = new Element("div", {"styles": this.css.statChartFlagAreaNode}).inject(this.chartAreaNode);
  205. this.chartNode = new Element("div", {"styles": this.css.statChartNode}).inject(this.chartAreaNode);
  206. this.loadChart();
  207. this.resizeChartFun = this.resizeChart.bind(this);
  208. this.explorer.app.addEvent("resizeCompleted", this.resizeChartFun);
  209. this.explorer.app.addEvent("postMaxSize", this.resizeChartFun);
  210. this.explorer.app.addEvent("postRestoreSize", this.resizeChartFun);
  211. },
  212. resizeChart: function(){
  213. if (this.bar) this.bar.destroy();
  214. this.bar = null;
  215. this.chartFlagNode.empty();
  216. this.chartNode.empty();
  217. this.loadChart();
  218. },
  219. loadChart: function(){
  220. if (!this.selectedData) this.selectedData = this.data.calculateGrid;
  221. if (!this.selectedData.length) this.selectedData = this.data.calculateGrid;
  222. MWF.require("MWF.widget.chart.Bar", function(){
  223. this.flag = [];
  224. this.bar = new MWF.widget.chart.Bar(this.chartNode, this.selectedData, "group", {"delay": 0, "style": "monthly"});
  225. if (this.selectedData.length){
  226. this.selectedData[0].list.each(function(d, i){
  227. this.flag.push({"name":d.displayName, "color": this.bar.colors[i]});
  228. this.bar.addBar(function(v){return v.list[i].value});
  229. }.bind(this));
  230. }
  231. this.bar.addEvents({
  232. "mouseover": function(rects, texts, d, i){
  233. texts.filter(function(data, idx){return (idx==i);}).attr("display", "block");
  234. var rect = rects.filter(function(data, idx){return (idx==i);});
  235. var color = rect.attr("fill");
  236. rect.node().store("color", color);
  237. rect.attr("fill", "brown");
  238. }.bind(this),
  239. "mouseout": function(rects, texts, d, i){
  240. texts.filter(function(data, idx){return (idx==i);}).attr("display", "none");
  241. var rect = rects.filter(function(data, idx){return (idx==i);});
  242. var color = rect.node().retrieve("color");
  243. rect.attr("fill", color);
  244. }.bind(this)
  245. });
  246. this.bar.load();
  247. this.loadFlags();
  248. }.bind(this));
  249. },
  250. loadFlags: function(){
  251. this.flag.each(function(f, i){
  252. this.loadFlag(f, i);
  253. }.bind(this));
  254. },
  255. loadFlag: function(f, i){
  256. var flagNode = new Element("div", {"styles": this.css.ststChartFlagNode}).inject(this.chartFlagNode);
  257. var flagColorNode = new Element("div", {"styles": this.css.ststChartFlagColorNode}).inject(flagNode);
  258. flagColorNode.setStyle("background-color", f.color);
  259. var flagNameNode = new Element("div", {"styles": this.css.ststChartFlagNameNode}).inject(flagNode);
  260. flagNameNode.set("text", f.name);
  261. flagNameNode.set("title", f.name);
  262. flagNode.store("idx", i);
  263. flagNode.store("barColor", f.color);
  264. var _self = this;
  265. flagNode.addEvents({
  266. "mouseover": function(){
  267. this.getFirst().setStyles(_self.css.ststChartFlagColorNode_over);
  268. var idx = this.retrieve("idx");
  269. _self.highlightBar(idx);
  270. },
  271. "mouseout": function(){
  272. this.getFirst().setStyles(_self.css.ststChartFlagColorNode);
  273. var idx = this.retrieve("idx");
  274. var barColor = this.retrieve("barColor");
  275. _self.unHighlightBar(idx, barColor);
  276. }
  277. });
  278. },
  279. createDefs: function(node, data){
  280. var svgNode = node.append(data.tag);
  281. Object.each(data.attrs, function(v,k){svgNode.attr(k,v);});
  282. if (data.subs) {
  283. data.subs.each(function(v){
  284. this.createDefs(svgNode, v);
  285. }.bind(this));
  286. }
  287. },
  288. createHighlightDefs: function(id){
  289. //this.defssvg = this.bar.createDefs;
  290. var node = this.bar.svg.append("defs");
  291. var data = this.bar.css["rect_over_defs"];
  292. this.createDefs(node, data);
  293. node.select(function(){ return this.getFirst(); }).attr("id", id);
  294. node.attr("id", "defs_"+id);
  295. },
  296. unHighlightBar: function(i, barColor){
  297. var id = "rect_over_defs"+i;
  298. var def = d3.select("#defs_"+id);
  299. def.remove();
  300. var rects = this.bar.rectCluster[i];
  301. rects.attr(this.bar.css["rect_over_defs"].urlAttr, null);
  302. var texts = this.bar.textCluster[i];
  303. texts.attr("display", "none");
  304. texts.attr("font-weight", "normal");
  305. },
  306. highlightBar: function(i){
  307. this.bar.rectCluster[i].remove();
  308. var rects = this.recreateBars(i);
  309. var id = "rect_over_defs"+i;
  310. this.createHighlightDefs(id);
  311. rects.attr(this.bar.css["rect_over_defs"].urlAttr, "url(#"+id+")");
  312. var texts = this.bar.textCluster[i];
  313. texts.attr("display", "block");
  314. texts.attr("font-weight", "bold");
  315. },
  316. recreateBars: function(i){
  317. var data = this.data.calculateGrid.map(function(d, idx) {
  318. return {"name": d["group"], "data": d.list[i].value};
  319. }.bind(this));
  320. this.bar.rectClass = Math.round(Math.random()*100);
  321. var barWidth = this.bar.xScale.bandwidth()/this.bar.barsData.length;
  322. var rects = this.bar.group.selectAll(".MWFBar_"+this.bar.rectClass+"_"+i)
  323. .data(data)
  324. .enter().append("rect")
  325. .attr("class", ".MWFBar_"+this.bar.rectClass+"_"+i)
  326. .attr("x", function(d) { return this.xScale(d.name)+(i*barWidth); }.bind(this.bar))
  327. .attr("width", barWidth)
  328. .attr("height", function(d) { return this.size.y - this.yScale(d.data); }.bind(this.bar))
  329. .attr("y", function(d) { return this.yScale(d.data); }.bind(this.bar))
  330. .attr("fill", this.bar.colors[i]);
  331. this.bar.rectCluster[i] = rects;
  332. this.bar.setEvents();
  333. return rects;
  334. },
  335. createTableHead: function(){
  336. this.selectedCols = [];
  337. this.selectedRows = [];
  338. this.table = new Element("table", {
  339. "styles": this.css.statTableNode,
  340. "width": "100%",
  341. "border": "0",
  342. "cellPadding": "0",
  343. "cellSpacing": "0"
  344. }).inject(this.node);
  345. _self = this;
  346. this.headTr = this.table.insertRow();
  347. this.selectAllTd = this.headTr.insertCell().setStyles(this.css.statAllSelectTd).set("title", this.explorer.app.lp.selecteAll);
  348. this.selectAllTd.addEvent("click", function(){
  349. _self.selectAll(this);
  350. });
  351. this.selectEntryTd = this.headTr.insertCell().setStyles(this.css.statAllColSelectTd).set("title", this.explorer.app.lp.selecteAllCol);
  352. this.selectEntryTd.addEvent("click", function(){
  353. _self.selectAllCol(this);
  354. });
  355. this.data.calculate.calculateEntryList.each(function(title){
  356. selectTd = this.headTr.insertCell().setStyles(this.css.statColSelectTd);
  357. selectTd.addEvent("click", function(){
  358. _self.selectCol(this);
  359. });
  360. }.bind(this));
  361. this.titleTr = this.table.insertRow();
  362. this.selectGroupTd = this.titleTr.insertCell().setStyles(this.css.statAllRowSelectTd).set("title", this.explorer.app.lp.selecteAllRow);
  363. this.categoryTitleTd = new Element("th", {
  364. "styles": this.css.statHeadTh,
  365. "text": this.data.calculate.title || this.explorer.app.lp.category
  366. }).inject(this.titleTr);
  367. this.categoryTitleTd.setStyle("width", "160px");
  368. this.data.calculate.calculateEntryList.each(function(title){
  369. var th = new Element("th", {
  370. "styles": this.css.statHeadTh,
  371. "text": title.displayName
  372. }).inject(this.titleTr);
  373. }.bind(this));
  374. },
  375. createTableData: function(){
  376. if (this.data.calculateGrid.length){
  377. var _self = this;
  378. this.data.calculateGrid.each(function(d){
  379. var tr = this.table.insertRow();
  380. var selectTd = tr.insertCell().setStyles(this.css.statRowSelectTd);
  381. selectTd.addEvent("click", function(){
  382. _self.selectRow(this);
  383. });
  384. var categoryTh = new Element("th", {"styles": this.css.statHeadTh, "text": d.group}).inject(tr);
  385. d.list.each(function(l){
  386. var td = new Element("td", {"styles": this.css.statContentTdNode}).inject(tr);
  387. td.set("text", l.value);
  388. this.setDragEvent(td);
  389. }.bind(this));
  390. }.bind(this));
  391. }
  392. },
  393. setDragEvent: function(td){
  394. new Drag(td, {
  395. "onStart": function(dragged, e){
  396. this.cellDragStart(dragged, e);
  397. }.bind(this),
  398. "onDrag": function(dragged, e){
  399. this.cellDrag(dragged, e);
  400. }.bind(this),
  401. "onComplete": function(dragged, e){
  402. this.completeDrag(dragged, e);
  403. }.bind(this)
  404. });
  405. var _self = this;
  406. td.addEvent("click", function(){
  407. var cellIndex = td.cellIndex-2;
  408. var rowIndex = td.getParent("tr").rowIndex-2;
  409. if (_self.checkIsSelected(cellIndex, rowIndex)){
  410. }else{
  411. debugger;
  412. if (_self.selectedCols.length || _self.selectedRows.length){
  413. _self.selectAll();
  414. }
  415. }
  416. });
  417. },
  418. cellDragStart: function(td, e){
  419. //if (_self.selectedCols.length || _self.selectedRows.length){
  420. // _self.selectAll();
  421. //}
  422. var p = td.getPosition();
  423. var size = td.getSize();
  424. td.store("start", {"x": p.x, "y": p.y});
  425. td.store("start2", {"x": p.x+size.x, "y": p.y+size.y});
  426. },
  427. getSelectedCells: function(td, start, e){
  428. var ox = e.page.x-start.x;
  429. var oy = e.page.y-start.y;
  430. var tdSize = td.getSize();
  431. var cols = (ox/tdSize.x).toInt();
  432. var rows = (oy/tdSize.y).toInt();
  433. return {"cols": cols, "rows": rows};
  434. },
  435. cellDrag: function(td, e){
  436. this.selectedRows = [];
  437. this.selectedCols = [];
  438. this.selectedData = [];
  439. var start = td.retrieve("start");
  440. var start2 = td.retrieve("start2");
  441. var c1 = this.getSelectedCells(td, start, e);
  442. var c2 = this.getSelectedCells(td, start2, e);
  443. var cols = (Math.abs(c1.cols)>Math.abs(c2.cols)) ? c1.cols : c2.cols;
  444. var rows = (Math.abs(c1.rows)>Math.abs(c2.rows)) ? c1.rows : c2.rows;
  445. var cellIndex = td.cellIndex-2;
  446. var rowIndex = td.getParent("tr").rowIndex-2;
  447. if (!cellIndex || cellIndex<0) cellIndex = 0;
  448. if (!rowIndex || rowIndex<0) rowIndex = 0;
  449. var toCellIndex = cellIndex+cols;
  450. var toRowIndex = rowIndex+rows;
  451. if (toRowIndex>rowIndex){
  452. for (var i=rowIndex; i<=toRowIndex; i++) this.selectedRows.push(i);
  453. }else{
  454. for (var i=toRowIndex; i<=rowIndex; i++) this.selectedRows.push(i);
  455. }
  456. if (toCellIndex>cellIndex){
  457. for (var i=cellIndex; i<=toCellIndex; i++) this.selectedCols.push(i);
  458. }else{
  459. for (var i=toCellIndex; i<=cellIndex; i++) this.selectedCols.push(i);
  460. }
  461. this.checkSelectedCells();
  462. },
  463. completeDrag: function(td, e){
  464. var trs = this.table.getElements("tr");
  465. var tds = trs[0].getElements("td");
  466. this.selectedCols.each(function(i){
  467. tds[i+2].setStyles(this.css.statTableSelectedTd);
  468. }.bind(this));
  469. this.selectedRows.each(function(i){
  470. trs[i+2].getElement("td").setStyles(this.css.statTableSelectedTd);
  471. }.bind(this));
  472. this.reloadChart();
  473. },
  474. selectCol: function(td){
  475. var i = td.cellIndex;
  476. var dataIndex = i-2;
  477. if (this.selectedCols.indexOf(dataIndex)!=-1){
  478. td.setStyles(this.css.statTableSelectTd);
  479. this.selectedCols.erase(dataIndex);
  480. }else{
  481. td.setStyles(this.css.statTableSelectedTd);
  482. this.selectedCols.push(dataIndex);
  483. }
  484. this.checkSelectedCells();
  485. this.reloadChart();
  486. },
  487. selectRow: function(td){
  488. var tr = td.getParent("tr");
  489. var i = tr.rowIndex;
  490. var dataIndex = i-2;
  491. if (this.selectedRows.indexOf(dataIndex)!=-1){
  492. td.setStyles(this.css.statTableSelectTd);
  493. this.selectedRows.erase(dataIndex);
  494. }else{
  495. td.setStyles(this.css.statTableSelectedTd);
  496. this.selectedRows.push(dataIndex);
  497. }
  498. this.checkSelectedCells();
  499. this.reloadChart();
  500. },
  501. selectAllCol: function(){
  502. if (this.selectedCols.length){
  503. this.selectedCols = [];
  504. var trs = this.table.getElements("tr");
  505. var tds = trs[0].getElements("td");
  506. for (var i=2; i<tds.length; i++){
  507. tds[i].setStyles(this.css.statTableSelectTd);
  508. }
  509. //for (var n=2; n<trs.length; n++){
  510. // trs[n].getElement("td").setStyles(this.css.statTableSelectTd);
  511. //}
  512. }else{
  513. var seltrs = this.table.getElements("tr");
  514. var seltds = seltrs[0].getElements("td");
  515. for (var n=2; n<seltds.length; n++){
  516. this.selectedCols.push(n-2);
  517. seltds[n].setStyles(this.css.statTableSelectedTd);
  518. }
  519. }
  520. this.checkSelectedCells();
  521. this.reloadChart();
  522. },
  523. selectAll: function(){
  524. if (this.selectedRows.length || this.selectedCols.length){
  525. this.selectedRows = [];
  526. this.selectedCols = [];
  527. var trs = this.table.getElements("tr");
  528. var tds = trs[0].getElements("td");
  529. for (var i=2; i<tds.length; i++){
  530. tds[i].setStyles(this.css.statTableSelectTd);
  531. }
  532. for (var n=2; n<trs.length; n++){
  533. trs[n].getElement("td").setStyles(this.css.statTableSelectTd);
  534. }
  535. }else{
  536. var seltrs = this.table.getElements("tr");
  537. var seltds = seltrs[0].getElements("td");
  538. for (var seli=2; seli<seltds.length; seli++){
  539. this.selectedCols.push(seli-2);
  540. seltds[seli].setStyles(this.css.statTableSelectedTd);
  541. }
  542. for (var seln=2; seln<seltrs.length; seln++){
  543. this.selectedRows.push(seln-2);
  544. seltrs[seln].getElement("td").setStyles(this.css.statTableSelectedTd);
  545. }
  546. }
  547. this.checkSelectedCells();
  548. this.reloadChart();
  549. },
  550. checkIsSelected: function(ci, ri){
  551. if (!this.selectedCols.length && !this.selectedRows.length) return false;
  552. var colSelect = (!this.selectedCols.length) || this.selectedCols.indexOf(ci)!=-1;
  553. var rowSelect = (!this.selectedRows.length) || this.selectedRows.indexOf(ri)!=-1;
  554. return (colSelect && rowSelect);
  555. },
  556. checkSelectedCells: function(){
  557. this.selectedData = [];
  558. var rows = this.table.getElements("tr");
  559. for (var rowIdx = 2; rowIdx<rows.length; rowIdx++){
  560. var o = {
  561. "group": this.data.calculateGrid[rowIdx-2].group,
  562. "list": []
  563. };
  564. var cols = rows[rowIdx].getElements("td");
  565. for (var colIdx = 1; colIdx<cols.length; colIdx++){
  566. if (this.checkIsSelected(colIdx-1, rowIdx-2)){
  567. cols[colIdx].setStyles(this.css.statContentTdNode_selected);
  568. o.list.push({
  569. "column": this.data.calculateGrid[rowIdx-2].list[colIdx-1].column,
  570. "displayName": this.data.calculateGrid[rowIdx-2].list[colIdx-1].displayName,
  571. "value": this.data.calculateGrid[rowIdx-2].list[colIdx-1].value,
  572. });
  573. }else{
  574. cols[colIdx].setStyles(this.css.statContentTdNode);
  575. }
  576. }
  577. if (o.list.length) this.selectedData.push(o);
  578. }
  579. },
  580. reloadChart: function(){
  581. if (this.bar) this.bar.destroy();
  582. this.bar = null;
  583. this.chartFlagNode.empty();
  584. this.chartNode.empty();
  585. this.loadChart();
  586. }
  587. });
  588. MWF.xApplication.process.Application.StatExplorer.GroupStat.Select = new Class({
  589. //Extends: MWF.xApplication.process.Application.StatExplorer.Stat
  590. });