0a2030b969c8e5b16749b99491a3bb5bae785341.svn-base 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. BemsWebApplication.IceStoreAirAnalysis = function(params, viewInfo) {
  2. "use strict";
  3. var initialized = false,
  4. shouldReload = false,
  5. datagrid = null,
  6. currentTabIndex = ko.observable(0),
  7. facilityViewModel = new BWA.CmFacilityViewModel(),
  8. dataSource;
  9. var m_Facility;
  10. var multiViewItems = [{
  11. template: 'mainCharts'
  12. }, {
  13. template: 'subCharts'
  14. }
  15. ];
  16. var facilityDataSource = BWA.db.createDataSource('CmFacility'),
  17. facilitiesForSearch = ko.observableArray(),
  18. facilityCodeForSearch = ko.observable(0),
  19. deferredForSearch = new $.Deferred();
  20. var visiblePopup = ko.observable(false);
  21. var dataCalorie = ko.observableArray(),
  22. dataAtfw = ko.observableArray(),
  23. dataTemperatureCalorie = ko.observableArray(),
  24. dataTemperatureElectricity = ko.observableArray()
  25. ;
  26. var formulaGet = new BWA.Chart.FormulaGet(BWA.UserInfo.SiteId());
  27. //var timeBoxForSearch = BWA.SearchView.createDateTimeBox();
  28. // cyim 2016.08.22 : 성능분석 그래프의 경우 시간 데이타만 표시되어야 한다
  29. var timeBoxForSearch = BWA.SearchView.createDateTimeBox($G.TimeTypesForHourOnly, null, false);
  30. var chartCOP = BWA.Chart.Instance('chartCOPISA', 'dxChart'),
  31. chartCOPout = BWA.Chart.Instance('chartCOPoutISA', 'dxChart'),
  32. chartStoreLoad = BWA.Chart.Instance('chartStoreLoadISA', 'dxChart'),
  33. chartCOPLoad = BWA.Chart.Instance('chartCOPLoadISA', 'dxChart');
  34. /*
  35. chartColdCOP = BWA.Chart.Instance('chartColdCOPISA', 'dxChart'),
  36. chartKCAL = BWA.Chart.Instance('chartKCALISA', 'dxChart'),
  37. chartEffi = BWA.Chart.Instance('chartEffiISA', 'dxChart'),
  38. chartApproch = BWA.Chart.Instance('chartApprochISA', 'dxChart'); */
  39. var chartLayout = new BWA.ChartLayout({
  40. divs: [[{
  41. id: 'IceStoreAirDetail'
  42. }, {
  43. id: 'COP',
  44. chartId: 'chartCOPISA'
  45. }, {
  46. id: 'COPout',
  47. chartId: 'chartCOPoutISA'
  48. }, {
  49. id: 'StoreLoad',
  50. chartId: 'chartStoreLoadISA'
  51. }, {
  52. id: 'COPLoad',
  53. chartId: 'chartCOPLoadISA'
  54. }, {
  55. id: 'ColdCOP',
  56. chartId: 'chartColdCOPISA'
  57. }, {
  58. id: 'KCAL',
  59. chartId: 'chartKCALISA'
  60. }, {
  61. id: 'Effi',
  62. chartId: 'chartEffiISA'
  63. }, {
  64. id: 'Approch',
  65. chartId: 'chartApprochISA'
  66. }
  67. ]
  68. ],
  69. multiViewOptions: {
  70. viewIndex: currentTabIndex,
  71. //viewCount: 2 원래는2개,
  72. viewCount: 1
  73. }
  74. });
  75. var m = moment();
  76. dataCalorie([
  77. { DateTime: new Date(m.year(), m.month(), 1), Value: 50 },
  78. { DateTime: new Date(m.year(), m.month(), 2), Value: 50 },
  79. { DateTime: new Date(m.year(), m.month(), 3), Value: 60 },
  80. { DateTime: new Date(m.year(), m.month(), 4), Value: 80 },
  81. { DateTime: new Date(m.year(), m.month(), 5), Value: 100 },
  82. { DateTime: new Date(m.year(), m.month(), 6), Value: 40, },
  83. { DateTime: new Date(m.year(), m.month(), 7), Value: 120 },
  84. { DateTime: new Date(m.year(), m.month(), 31), Value: 120 }
  85. ]);
  86. // 추가 2015 04 20 hcLee ->
  87. var CODE = $Code,
  88. FuelType = CODE.FuelType,
  89. FT = CODE.FacilityType,
  90. FC = CODE.FacilityCode,
  91. F = CODE.Formula,
  92. TIT = CODE.TimeIntervalType;
  93. // 추가 2015 04 20 hcLee <-
  94. //dataMonthForBar(dataDayForBar());
  95. //dataDayForPie([
  96. // { FuelTypeName: '전기', Value: 320 },
  97. // { FuelTypeName: '가스', Value: 350 },
  98. // { FuelTypeName: '수도', Value: 360 },
  99. //]);
  100. //dataMonthForPie(dataDayForPie());
  101. function handleViewShown() {
  102. if (initialized === false) {
  103. var chartOption = BWA.ChartOptions.IceStoreAirAnalysis;
  104. chartCOP = chartCOP(chartOption.getChartCOPOptions($Code.TimeType.HOUR));
  105. chartCOPout = chartCOPout(chartOption.getChartCOPoutOptions($Code.TimeType.HOUR));
  106. chartStoreLoad = chartStoreLoad(chartOption.getChartStoreLoadOptions($Code.TimeType.HOUR));
  107. chartCOPLoad = chartCOPLoad(chartOption.getChartCOPOptions2($Code.TimeType.HOUR));
  108. /*
  109. chartColdCOP = chartColdCOP(chartOption.getChartColdCOPOptions($Code.TimeType.HOUR));
  110. chartKCAL = chartKCAL(chartOption.getChartKCALOptions($Code.TimeType.HOUR));
  111. chartEffi = chartEffi(chartOption.getChartEffiOptions($Code.TimeType.HOUR));
  112. chartApproch = chartApproch(chartOption.getChartApprochOptions($Code.TimeType.HOUR));*/
  113. initialized = true;
  114. }
  115. //hcLee 2016 07 12
  116. timeBoxForSearch.setDefaultDate();
  117. var eq = BWA.DataUtil.constructEqualFilter;
  118. facilityDataSource.filter([
  119. eq('SiteId', BWA.UserInfo.SiteId()),
  120. 'and',
  121. eq('FacilityTypeId', $Code.FacilityType.ICESTOREAIR)
  122. ]);
  123. facilityDataSource.load().done(function(facilities) {
  124. facilitiesForSearch(facilities);
  125. if (_.isEmpty(facilities) === false) {
  126. var f = facilities[0];
  127. handleSelectedFacilityInSearchView(f);
  128. handleSearchInSearchView();
  129. var datagrid = $('#IceStoreAirDataGridViewInSearchView').dxDataGrid('instance');
  130. if (_.has(datagrid, 'selectRows')) {
  131. datagrid.selectRows(f);
  132. }
  133. }
  134. });
  135. }
  136. if (shouldReload) {
  137. //shouldReload = false;
  138. //dataSource.pageIndex(0);
  139. //dataSource.load();
  140. }
  141. function handleViewHidden() {
  142. //hideOverlay();
  143. // var dataGrid = $('#gridContainer').dxDataGrid('instance');
  144. // dataGrid.clearSelection();
  145. var paging = BWA.ChartLayout.Paging;
  146. paging.sideOverlayVisible(false);
  147. //paging.hideNextButton(true);
  148. //paging.hidePrevButton(true);
  149. $SearchView.visibleObservable(false); // hcLee 2015 03 23
  150. visiblePopup(false);
  151. }
  152. function handleViewShowing() {
  153. }
  154. function refreshList() {
  155. //dataSource.pageIndex(0);
  156. //dataSource.load();
  157. }
  158. var searchViewOptions = {
  159. searchViewItems: [
  160. { id: 'FacilityCode', ignoreValue: 0, defaultValue: 0, value: facilityCodeForSearch, dataSource: facilitiesForSearch },
  161. ],
  162. promiseDataInSearchView: deferredForSearch.promise()
  163. };
  164. function handleSelectedFacilityInSearchView(facility) {
  165. m_Facility = facility;
  166. return;
  167. }
  168. function handleSearchInSearchView(filter, searchViewItems) {
  169. //console.log(filter);
  170. //console.log(searchViewItems);
  171. if (m_Facility == null) return;
  172. visiblePopup(true);
  173. var f = m_Facility.toJS();
  174. facilityViewModel.fromJS(f);
  175. //var timeIntervalType = $Code.TimeIntervalType.QUARTERMIN;
  176. var timeIntervalType = timeBoxForSearch.type();
  177. var formula = $Code.Formula[$Code.FacilityType.ICESTOREAIR];
  178. var formulaIds = _.values(formula);
  179. var date = timeBoxForSearch.getDate();
  180. // var startDate = moment().
  181. var promises = [];
  182. _.each(formulaIds, function (formulaId) {
  183. var p = formulaGet.apiGet({
  184. FacilityTypeId: f.FacilityTypeId,
  185. FacilityCode: f.FacilityCode,
  186. FormulaId: formulaId,
  187. TimeIntervalType: timeIntervalType,
  188. StartDate: date.startDate,
  189. EndDate: date.endDate
  190. });
  191. promises.push(p);
  192. });
  193. // 외기 온도와 습도를 위해 추가 hcLee 2015 04 20 ->
  194. var commonParameters = {
  195. //TimeIntervalType: $Code.TimeIntervalType.QUARTERMIN,
  196. TimeIntervalType: timeIntervalType,
  197. StartDate: date.startDate,
  198. EndDate: date.endDate
  199. };
  200. var temperatureParameters = {
  201. FacilityTypeId: FT.OUTDOOR,
  202. FacilityCode: FC.OUTDOOR,
  203. FormulaId: F[FT.OUTDOOR].TEMPERATURE,
  204. };
  205. var humidityParameters = _.extend({}, temperatureParameters, {
  206. FormulaId: F[FT.OUTDOOR].HUMIDITY,
  207. });
  208. promises.push(formulaGet.apiGet(_.extend(temperatureParameters, commonParameters)));
  209. promises.push(formulaGet.apiGet(_.extend(humidityParameters, commonParameters)));
  210. $.when.apply(this, promises)
  211. .done(function (cold_av, effi, load, cold_kcal, vline_kcal, elec, sw, COP, input_temp, out_temp, h_temp, approch, kcal,
  212. // 2016 02 29 추가
  213. cop1, cop2, load1, load2,
  214. OUTtemperatures, humidities) { // done의 리턴 파라메터는 정해져 있다 2015 04 20, 끝에 2개 (OUTtemperatures, humidities)추가
  215. cold_av = cold_av[0];
  216. effi = effi[0];
  217. load = load[0];
  218. cold_kcal = cold_kcal[0];
  219. vline_kcal = vline_kcal[0];
  220. elec = elec[0];
  221. sw = sw[0];
  222. COP = COP[0];
  223. input_temp = input_temp[0];
  224. out_temp = out_temp[0];
  225. h_temp = h_temp[0];
  226. approch = approch[0];
  227. kcal = kcal[0];
  228. cop1 = cop1[0];
  229. cop2 = cop2[0];
  230. load1 = load1[0];
  231. load2 = load2[0];
  232. // chart 1
  233. var COPDataArray = [];
  234. _.each(COP, function (x) {
  235. COPDataArray.push({
  236. //DateTime: moment(x.DateTime).toDate(),
  237. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  238. cop: x.Value
  239. });
  240. });
  241. /*
  242. _.each(cold_av, function (x) {
  243. COPDataArray.push({
  244. //DateTime: moment(x.DateTime).toDate(),
  245. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  246. cold_av: x.Value
  247. });
  248. });*/ //2016 02 29 대구은행현장제외
  249. _.each(elec, function (x) {
  250. COPDataArray.push({
  251. //DateTime: moment(x.DateTime).toDate(),
  252. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  253. elec: x.Value
  254. });
  255. });
  256. //chartCOP().option('dataSource', COPDataArray);
  257. var options = BWA.ChartOptions.IceStoreAirAnalysis.getChartCOPOptions(timeBoxForSearch.type());
  258. //chartCOP().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  259. options.dataSource = COPDataArray;
  260. chartCOP().option(options);
  261. //chart2
  262. var COPoutDataArray = [];
  263. var maxValue = 0;
  264. /*
  265. _.each(COP, function (x) { 2016 02 29 대구은행현장은 축열량으로 변경
  266. COPoutDataArray.push({
  267. //DateTime: moment(x.DateTime).toDate(),
  268. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  269. cop: x.Value
  270. });
  271. if (maxValue < x.Value) maxValue = x.Value;
  272. }); */
  273. // 2016 02 29 대구은행현장은 축열량으로 변경
  274. _.each(kcal, function (x) {
  275. COPoutDataArray.push({
  276. //DateTime: moment(x.DateTime).toDate(),
  277. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  278. kcal: x.Value
  279. });
  280. if (maxValue < x.Value) maxValue = x.Value;
  281. });
  282. //_.each(OUTtemperatures[0], function (x) {
  283. // COPoutDataArray.push({
  284. // //DateTime: moment(x.DateTime).toDate(),
  285. // DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  286. // temp: x.Value
  287. // });
  288. //});
  289. //_.each(humidities[0], function (x) {
  290. // COPoutDataArray.push({
  291. // //DateTime: moment(x.DateTime).toDate(),
  292. // DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  293. // hum: x.Value
  294. // });
  295. //});
  296. // 2016 02 29 대구은행현장은 축열량으로 변경
  297. //options = BWA.ChartOptions.IceStoreAirAnalysis.getChartCOPoutOptions(timeBoxForSearch.type());
  298. options = BWA.ChartOptions.IceStoreAirAnalysis.getChartKCALoutOptions(timeBoxForSearch.type());
  299. //chartCOPout().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  300. //options.valueAxis[0].tickInterval = Math.round(maxValue / 5) + 1;
  301. options.dataSource = COPoutDataArray;
  302. chartCOPout().option(options);
  303. //chart3
  304. /*
  305. var dataArray = BWA.Chart.getRelationDataArrayOnDateTime(
  306. kcal, load, 'kcal', 'load');
  307. options = BWA.ChartOptions.IceStoreAirAnalysis.getChartStoreLoadOptions(timeBoxForSearch.type());
  308. options.dataSource = dataArray;
  309. chartStoreLoad().option(options); 2016 02 29 대구은행현장 */
  310. var dataArray = BWA.Chart.getRelationDataArrayOnDateTime(
  311. kcal, load1, 'kcal', 'load1');
  312. var dataArray2 = BWA.Chart.getRelationDataArrayOnDateTime(
  313. kcal, load2, 'kcal', 'load2');
  314. _.each(dataArray2, function (x) {
  315. dataArray.push(x);
  316. });
  317. options = BWA.ChartOptions.IceStoreAirAnalysis.getChartStoreLoadOptions(timeBoxForSearch.type());
  318. options.dataSource = dataArray;
  319. chartStoreLoad().option(options);
  320. //chart 4
  321. /*
  322. dataArray = BWA.Chart.getRelationDataArrayOnDateTime(
  323. COP, load, 'cop', 'load');
  324. options = BWA.ChartOptions.IceStoreAirAnalysis.getChartCOPLoadOptions(timeBoxForSearch.type());
  325. options.dataSource = dataArray;
  326. chartCOPLoad().option(options); 2016 02 29 대구은행현장*/
  327. dataArray = [];
  328. _.each(cop1, function (x) {
  329. dataArray.push({
  330. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  331. cop1: x.Value
  332. });
  333. });
  334. _.each(cop2, function (x) {
  335. dataArray.push({
  336. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  337. cop2: x.Value
  338. });
  339. });
  340. _.each(kcal, function (x) {
  341. dataArray.push({
  342. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  343. kcal : x.Value
  344. });
  345. });
  346. var options = BWA.ChartOptions.IceStoreAirAnalysis.getChartCOPOptions2(timeBoxForSearch.type());
  347. options.dataSource = dataArray;
  348. chartCOPLoad().option(options);
  349. //2016 02 29
  350. //
  351. visiblePopup(false);
  352. return;
  353. //chart5
  354. var ColdCOPDataArray = [];
  355. _.each(input_temp, function (x) {
  356. ColdCOPDataArray.push({
  357. //DateTime: moment(x.DateTime).toDate(),
  358. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  359. temp: x.Value
  360. });
  361. });
  362. _.each(COP, function (x) {
  363. ColdCOPDataArray.push({
  364. //DateTime: moment(x.DateTime).toDate(),
  365. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  366. cop: x.Value
  367. });
  368. });
  369. _.each(load, function (x) {
  370. ColdCOPDataArray.push({
  371. //DateTime: moment(x.DateTime).toDate(),
  372. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  373. load: x.Value
  374. });
  375. });
  376. //chartColdCOP().option('dataSource', ColdCOPDataArray);
  377. options = BWA.ChartOptions.IceStoreAirAnalysis.getChartColdCOPOptions(timeBoxForSearch.type());
  378. //chartColdCOP().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  379. options.dataSource = ColdCOPDataArray;
  380. chartColdCOP().option(options);
  381. //chart6
  382. var KCALDataArray = [];
  383. _.each(cold_kcal, function (x) {
  384. KCALDataArray.push({
  385. //DateTime: moment(x.DateTime).toDate(),
  386. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  387. cold_kcal: x.Value
  388. });
  389. });
  390. _.each(vline_kcal, function (x) {
  391. KCALDataArray.push({
  392. //DateTime: moment(x.DateTime).toDate(),
  393. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  394. vline_kcal: x.Value
  395. });
  396. });
  397. //chartKCAL().option('dataSource', KCALDataArray);
  398. options = BWA.ChartOptions.IceStoreAirAnalysis.getChartKCALOptions(timeBoxForSearch.type());
  399. //chartKCAL().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  400. options.dataSource = KCALDataArray;
  401. chartKCAL().option(options);
  402. //chart7
  403. var EffiDataArray = [];
  404. _.each(effi, function (x) {
  405. EffiDataArray.push({
  406. //DateTime: moment(x.DateTime).toDate(),
  407. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  408. effi: x.Value
  409. });
  410. });
  411. _.each(sw, function (x) {
  412. EffiDataArray.push({
  413. //DateTime: moment(x.DateTime).toDate(),
  414. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  415. sw: x.Value
  416. });
  417. });
  418. //chartEffi().option('dataSource', EffiDataArray);
  419. options = BWA.ChartOptions.IceStoreAirAnalysis.getChartEffiOptions(timeBoxForSearch.type());
  420. //chartEffi().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  421. options.dataSource = EffiDataArray;
  422. chartEffi().option(options);
  423. //chart8
  424. var ApproDataArray = [];
  425. _.each(approch, function (x) {
  426. ApproDataArray.push({
  427. //DateTime: moment(x.DateTime).toDate(),
  428. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  429. approch: x.Value
  430. });
  431. });
  432. _.each(h_temp, function (x) {
  433. ApproDataArray.push({
  434. //DateTime: moment(x.DateTime).toDate(),
  435. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  436. h_temp: x.Value
  437. });
  438. });
  439. _.each(input_temp, function (x) {
  440. ApproDataArray.push({
  441. //DateTime: moment(x.DateTime).toDate(),
  442. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  443. in_temp: x.Value
  444. });
  445. });
  446. _.each(out_temp, function (x) {
  447. ApproDataArray.push({
  448. //DateTime: moment(x.DateTime).toDate(),
  449. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  450. out_temp: x.Value
  451. });
  452. });
  453. //chartApproch().option('dataSource', ApproDataArray);
  454. options = BWA.ChartOptions.IceStoreAirAnalysis.getChartApprochOptions(timeBoxForSearch.type());
  455. //chartApproch().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  456. options.dataSource = ApproDataArray;
  457. chartApproch().option(options);
  458. /*
  459. //chart3
  460. var COPDataArray = [];
  461. _.each(COP, function (x) {
  462. COPDataArray.push({
  463. DateTime: moment(x.DateTime).toDate(),
  464. COP: x.Value
  465. });
  466. });
  467. _.each(elecuse, function (x) {
  468. COPDataArray.push({
  469. DateTime: moment(x.DateTime).toDate(),
  470. elecuse: x.Value
  471. });
  472. });
  473. _.each(fueluse, function (x) {
  474. COPDataArray.push({
  475. DateTime: moment(x.DateTime).toDate(),
  476. m3: x.Value
  477. });
  478. });
  479. chartCOP().option('dataSource', COPDataArray);
  480. //chart4
  481. var FIREDataArray = [];
  482. _.each(fire, function (x) {
  483. FIREDataArray.push({
  484. DateTime: moment(x.DateTime).toDate(),
  485. fire: x.Value
  486. });
  487. });
  488. _.each(elecuse, function (x) {
  489. FIREDataArray.push({
  490. DateTime: moment(x.DateTime).toDate(),
  491. elecuse: x.Value
  492. });
  493. });
  494. _.each(fueluse, function (x) {
  495. FIREDataArray.push({
  496. DateTime: moment(x.DateTime).toDate(),
  497. m3: x.Value
  498. });
  499. });
  500. chartFIRE().option('dataSource', FIREDataArray);
  501. */
  502. visiblePopup(false);
  503. /* msgbox.
  504. $("#large-indicator").dxLoadIndicator({
  505. height: 60,
  506. width: 60
  507. });*/
  508. //chartTemperatureCalorie().option('dataSource', calories.concat(OUTtemperatures));
  509. //chartTemperatureElectricity2().option('dataSource', electricityDataArray.concat(OUTtemperatures));
  510. })
  511. .fail(function (error) {
  512. //alert(error);
  513. visiblePopup(false);
  514. });
  515. }
  516. var viewModel = $.extend(BWA.CommonView.create(
  517. params, viewInfo, searchViewOptions, ko.observable(null),
  518. handleViewShown, null, handleSearchInSearchView, undefined,
  519. chartLayout), {
  520. // facility: facilityViewModel,
  521. refreshList: refreshList,
  522. viewHidden: handleViewHidden, // hcLee 2015 06 03
  523. viewShowing: handleViewShowing,
  524. scrolling: { mode: 'infinite' },
  525. IceStoreAirDataGridOptions: {
  526. dataSource: facilitiesForSearch,
  527. columns: [
  528. { dataField: 'Name', caption: $G('facilityName'), width: '100%', alignment: 'left' }
  529. ],
  530. filterRow: {
  531. visible: true,
  532. showOperationChooser: false
  533. },
  534. selection: {
  535. mode: 'single'
  536. },
  537. rowClick: function(clickRow) {
  538. handleSelectedFacilityInSearchView(clickRow.data);
  539. }
  540. },
  541. contentReadyAction: function(e) {
  542. datagrid = e.component;
  543. }
  544. });
  545. viewModel.timeBoxForSearch = timeBoxForSearch;
  546. viewModel.currentTabIndex = currentTabIndex;
  547. viewModel.multiViewItems = [{
  548. facility: facilityViewModel,
  549. template: 'mainCharts'
  550. }, {
  551. template: 'subCharts'
  552. }
  553. ];
  554. $HourGlassPopup(viewModel, visiblePopup);
  555. return viewModel;
  556. };