731e7e4691784e16bc51def50ceae690028a5cf4.svn-base 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. $(function() {
  2. BWA.ChartOptions = BWA.ChartOptions || {};
  3. var C = BWA.ChartOptions.LocEnergyConsumption = BWA.ChartOptions.LocEnergyConsumption || {};
  4. var valueAxises = [
  5. {
  6. pane: 'topPane',
  7. title: {
  8. text: '전력 사용량 (kwh)',
  9. }
  10. },
  11. /*
  12. {
  13. //visible:false,
  14. pane: 'topPane',
  15. name: 'Temperature',
  16. position: 'right',
  17. //valueMarginsEnabled: true,
  18. //minValueMargin: 0,
  19. //maxValueMargin: 0,
  20. min: -20,
  21. max: 40,
  22. title: {
  23. text: $G('outdoorTemperatureWithUnit')
  24. }
  25. }, {
  26. pane: 'topPane',
  27. name: 'humidity',
  28. min: 0,
  29. max: 100,
  30. position: 'right',
  31. grid: {
  32. visible: true
  33. },
  34. label: {
  35. visible: true,
  36. format: 'largeNumber'
  37. },
  38. title: {
  39. text: $G('outdoorHumidityWithUnit')
  40. },
  41. }*/
  42. ];
  43. var argumentAxisS = [
  44. {
  45. argumentType: 'datetime',
  46. title: $G('hour'),
  47. label: {
  48. alignment: 'center',
  49. format: 'HH'
  50. },
  51. tickInterval: { hours: 1 },
  52. },
  53. {
  54. argumentType: 'datetime',
  55. title: $G('hour'),
  56. label: {
  57. alignment: 'center',
  58. format: 'HH'
  59. },
  60. tickInterval: { hours: 1 },
  61. },
  62. {
  63. argumentType: 'datetime',
  64. title: $G('day'),
  65. label: {
  66. alignment: 'center',
  67. format: 'MM-dd'
  68. },
  69. tickInterval: { days: 1 },
  70. },
  71. {
  72. argumentType: 'datetime',
  73. title: $G('month'),
  74. label: {
  75. alignment: 'center',
  76. format: 'MM'
  77. },
  78. tickInterval: { months: 1 },
  79. }]
  80. var fuelTypeValueAxises = [{
  81. pane: 'topPane',
  82. title: {
  83. text: $G('electricityConsumptionUsageWithUnit')
  84. }
  85. },
  86. /*{
  87. pane: 'topPane',
  88. title: {
  89. text: $G('gasUsageWithUnit')
  90. }
  91. }, {
  92. pane: 'topPane',
  93. title: {
  94. text: $G('waterUsageWithUnit')
  95. }
  96. }*/];
  97. var series = [{
  98. type: 'line',
  99. pane: 'topPane',
  100. axis: 'Temperature',
  101. valueField: 'Temperature',
  102. visible: true, // 시리즈만 안보이게 할수 있다. 대신 그렇게 할려면 시작은 false로 해야 한다 hcLee 2015 04 25
  103. point: { size: 8 },
  104. name: $G('outdoorTemperature'),
  105. label: {
  106. visible: false,
  107. customizeText: function() {
  108. return this.valueText + ' °C';
  109. }
  110. }
  111. }, {
  112. type: 'line',
  113. pane: 'topPane',
  114. axis: 'humidity',
  115. valueField: 'Humidity',
  116. point: { size: 8 },
  117. name: $G('outdoorHumidity'),
  118. label: {
  119. visible: false,
  120. customizeText: function() {
  121. return this.valueText + ' %';
  122. }
  123. }
  124. }];
  125. var fuelTypeSeries = [{
  126. type: 'bar',
  127. pane: 'topPane',
  128. valueField: 'Value',
  129. name: '전력 사용량',
  130. label: {
  131. horizontalAlignment: 'left',
  132. visible: false,
  133. customizeText: function() {
  134. return this.valueText + 'kWh';
  135. }
  136. }
  137. }/*, {
  138. type: 'bar',
  139. pane: 'topPane',
  140. valueField: 'Value',
  141. name: '가스',
  142. label: {
  143. visible: false,
  144. customizeText: function() {
  145. return this.valueText + 'm3';
  146. }
  147. }
  148. }, {
  149. type: 'bar',
  150. pane: 'topPane',
  151. valueField: 'Value',
  152. name: '수도',
  153. label: {
  154. visible: false,
  155. customizeText: function() {
  156. return this.valueText + 'm3';
  157. }
  158. }
  159. }*/];
  160. //C.getSeriesOptions = function(fuelTypeId, goalUpperBound) {
  161. C.getSeriesOptions = function (codeTimeType, goalUpperBound) {
  162. return {
  163. legend: {
  164. visible: true,
  165. verticalAlignment: 'top',
  166. horizontalAlignment: 'center'
  167. },
  168. /*
  169. valueAxis: [$.extend({}, fuelTypeValueAxises[fuelTypeId - 1],
  170. {
  171. constantLines: [{
  172. label: {
  173. text: $G('goalUpperBound')
  174. },
  175. width: 2,
  176. value: goalUpperBound,
  177. color: '#ff4500',
  178. dashStyle: 'dash'
  179. }],
  180. showZero: true,
  181. //})].concat(valueAxises[0]),
  182. })].concat(valueAxises), */
  183. panes: [{
  184. name: 'topPane',
  185. border: {
  186. visible: false,
  187. left: false,
  188. right: false,
  189. top: false,
  190. color: 'gray'
  191. }
  192. }, ],
  193. defaultPane: "topPane",
  194. commonSeriesSettings: {
  195. argumentField: "DateTime",
  196. selectionStyle: {
  197. hatching: {
  198. direction: "left"
  199. }
  200. }
  201. },
  202. //argumentAxis: BWA.Chart.getTimeLineArgumentAxis(moment(), codeTimeType),
  203. argumentAxis: BWA.Chart.getTimeLineArgumentAxis(null, codeTimeType),
  204. //argumentAxis: argumentAxisS[codeTimeType-1],
  205. valueAxis: valueAxises,
  206. //series: [fuelTypeSeries[fuelTypeId - 1]].concat(series[0]),
  207. series:
  208. {
  209. type: 'bar',
  210. pane: 'topPane',
  211. valueField: 'Value',
  212. name: '전력 사용량',
  213. label: {
  214. horizontalAlignment: 'left',
  215. visible: false,
  216. customizeText: function() {
  217. return this.valueText + 'kWh';
  218. }
  219. }
  220. }
  221. };
  222. };
  223. //사용안함
  224. C.getChartOptions = function(codeTimeType, goalUpperBound) {
  225. return {
  226. legend: {
  227. visible: true,
  228. verticalAlignment: 'top',
  229. horizontalAlignment: 'center'
  230. },
  231. legendClick: function (clickedItem) {
  232. var chart = $('#chart').dxChart('instance');
  233. var series = chart.getSeriesByName(clickedItem.name);
  234. var chartOptions = chart.option();
  235. if (series.isVisible()) {
  236. var valueAxis = [];
  237. valueAxis.push(chartOptions.valueAxis[0]);
  238. valueAxis.push(valueAxises[1]);
  239. chart.option('valueAxis', valueAxis);
  240. var seriesNew = [];
  241. seriesNew.push(chartOptions.series[0]);
  242. seriesNew.push(series[1]);
  243. chart.option('series', seriesNew);
  244. }
  245. else {
  246. var valueAxis = [];
  247. valueAxis.push(chartOptions.valueAxis[0]);
  248. valueAxis.push(valueAxises[0]);
  249. valueAxis.push(valueAxises[1]);
  250. chart.option('valueAxis', valueAxis);
  251. }
  252. },
  253. argumentAxis: BWA.Chart.getTimeLineArgumentAxis(moment(), codeTimeType),
  254. commonSeriesSettings: {
  255. argumentField: "DateTime",
  256. selectionStyle: {
  257. hatching: {
  258. direction: "left"
  259. }
  260. }
  261. },
  262. panes: [{
  263. name: 'topPane',
  264. border: {
  265. visible: false,
  266. left: false,
  267. right: false,
  268. top: false,
  269. color: 'gray'
  270. }
  271. },],
  272. defaultPane: "topPane",
  273. customizePoint: function() {
  274. if (this.value > goalUpperBound()) {
  275. return { color: '#ff4500', hoverStyle: { color: '#ff4500' } };
  276. }
  277. },
  278. tooltip: {
  279. enabled: true,
  280. shared: true
  281. // format: "millions",
  282. //customizeText: function() {
  283. // return this.argumentText + "<br/>" + this.valueText;
  284. //}
  285. },
  286. };
  287. };
  288. });