• Edit
  • Download
    1. <!doctype html>
    2. <html class="zc-html">
    3.  
    4. <head>
    5. <meta charset="utf-8">
    6. <title>ZingSoft Demo</title>
    7. <script nonce="undefined" src="https://cdn.zingchart.com/zingchart.min.js"></script>
    8. <style>
    9. .zc-body {
    10. background: #fff;
    11. }
    12.  
    13. .chart--container {
    14. height: 100%;
    15. width: 100%;
    16. min-height: 530px;
    17. }
    18.  
    19. .zc-ref {
    20. display: none;
    21. }
    22. </style>
    23. </head>
    24.  
    25. <body class="zc-body">
    26. <div id="myChart" class="chart--container">
    27. <a href="https://www.zingchart.com/" rel="noopener" class="zc-ref">Powered by ZingChart</a>
    28. </div>
    29.  
    30. <script>
    31. ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];
    32. let chartConfig = {
    33. globals: {
    34. color: '#666',
    35. },
    36. backgroundColor: '#fff',
    37. graphset: [{
    38. type: 'gauge',
    39. width: '31.5%',
    40. height: '50%',
    41. x: '0px',
    42. y: '0px',
    43. title: {
    44. text: 'Energy Output',
    45. mediaRules: [{
    46. maxWidth: '650px',
    47. visible: false,
    48. }, ],
    49. },
    50. plot: {
    51. csize: '3%',
    52. size: '100%',
    53. },
    54. plotarea: {
    55. marginTop: '35%',
    56. },
    57. scale: {
    58. sizeFactor: 1.2,
    59. mediaRules: [{
    60. maxWidth: '650px',
    61. sizeFactor: 1.6,
    62. }, ],
    63. },
    64. scaleR: {
    65. values: '0:40:10',
    66. aperture: 130,
    67. center: {
    68. borderColor: '#23211E',
    69. borderWidth: '2px',
    70. mediaRules: [{
    71. maxWidth: '650px',
    72. size: '10px',
    73. }, ],
    74. size: '20px',
    75. },
    76. guide: {
    77. alpha: 1,
    78. backgroundColor: '#E3DEDA',
    79. },
    80. item: {
    81. offsetR: 0,
    82. },
    83. markers: [{
    84. type: 'area',
    85. alpha: 0.95,
    86. backgroundColor: '#00AE4D',
    87. range: [0, 35],
    88. }, ],
    89. ring: {
    90. backgroundColor: '#E3DEDA',
    91. mediaRules: [{
    92. maxWidth: '650px',
    93. visible: false,
    94. }, ],
    95. },
    96. tick: {
    97. visible: false,
    98. },
    99. },
    100. tooltip: {
    101. visible: false,
    102. },
    103. mediaRules: [{
    104. maxWidth: '650px',
    105. width: '100%',
    106. height: '20%',
    107. x: '0px',
    108. y: '2%',
    109. },
    110. {
    111. minWidth: '651px',
    112. width: '31.5%',
    113. height: '50%',
    114. x: '0px',
    115. y: '0px',
    116. },
    117. ],
    118. series: [{
    119. values: [35],
    120. valueBox: {
    121. text: '%v',
    122. fontColor: '#00AE4D',
    123. fontSize: '14px',
    124. mediaRules: [{
    125. fontSize: '10px',
    126. maxWidth: '650px',
    127. }, ],
    128. placement: 'center',
    129. },
    130. backgroundColor: '#23211E',
    131. }, ],
    132. },
    133. {
    134. type: 'gauge',
    135. width: '31.5%',
    136. height: '50%',
    137. x: '34.5%',
    138. y: '0px',
    139. title: {
    140. text: 'Energy Recycled',
    141. mediaRules: [{
    142. maxWidth: '650px',
    143. visible: false,
    144. }, ],
    145. },
    146. plot: {
    147. csize: '3%',
    148. size: '100%',
    149. },
    150. plotarea: {
    151. marginTop: '35%',
    152. },
    153. scale: {
    154. sizeFactor: 1.2,
    155. mediaRules: [{
    156. maxWidth: '650px',
    157. sizeFactor: 1.6,
    158. }, ],
    159. },
    160. scaleR: {
    161. values: '0:20:5',
    162. aperture: 130,
    163. center: {
    164. borderColor: '#23211E',
    165. borderWidth: '2px',
    166. mediaRules: [{
    167. maxWidth: '650px',
    168. size: '10px',
    169. }, ],
    170. size: '20px',
    171. },
    172. guide: {
    173. alpha: 1,
    174. backgroundColor: '#E3DEDA',
    175. },
    176. item: {
    177. offsetR: 0,
    178. },
    179. markers: [{
    180. type: 'area',
    181. alpha: 0.95,
    182. backgroundColor: '#E2D51A',
    183. range: [0, 11],
    184. }, ],
    185. ring: {
    186. backgroundColor: '#E3DEDA',
    187. mediaRules: [{
    188. maxWidth: '650px',
    189. visible: false,
    190. }, ],
    191. },
    192. tick: {
    193. visible: false,
    194. },
    195. },
    196. tooltip: {
    197. visible: false,
    198. },
    199. mediaRules: [{
    200. maxWidth: '650px',
    201. width: '100%',
    202. height: '20%',
    203. x: '0px',
    204. y: '20%',
    205. },
    206. {
    207. minWidth: '651px',
    208. width: '31.5%',
    209. height: '50%',
    210. x: '34.5%',
    211. y: '0px',
    212. },
    213. ],
    214. series: [{
    215. values: [11],
    216. valueBox: {
    217. text: '%v',
    218. fontColor: '#E2D51A',
    219. fontSize: '14px',
    220. mediaRules: [{
    221. fontSize: '10px',
    222. maxWidth: '650px',
    223. }, ],
    224. placement: 'center',
    225. },
    226. backgroundColor: '#23211E',
    227. }, ],
    228. },
    229. {
    230. type: 'gauge',
    231. width: '31.5%',
    232. height: '50%',
    233. x: '69%',
    234. y: '0px',
    235. title: {
    236. text: 'Energy Consumed',
    237. mediaRules: [{
    238. maxWidth: '650px',
    239. visible: false,
    240. }, ],
    241. },
    242. plot: {
    243. csize: '3%',
    244. size: '100%',
    245. },
    246. plotarea: {
    247. marginTop: '35%',
    248. },
    249. scale: {
    250. sizeFactor: 1.2,
    251. mediaRules: [{
    252. maxWidth: '650px',
    253. sizeFactor: 1.6,
    254. }, ],
    255. },
    256. scaleR: {
    257. values: '0:100:25',
    258. aperture: 130,
    259. center: {
    260. borderColor: '#23211E',
    261. borderWidth: '2px',
    262. mediaRules: [{
    263. maxWidth: '650px',
    264. size: '10px',
    265. }, ],
    266. size: '20px',
    267. },
    268. guide: {
    269. alpha: 1,
    270. backgroundColor: '#E3DEDA',
    271. },
    272. item: {
    273. offsetR: 0,
    274. },
    275. markers: [{
    276. type: 'area',
    277. alpha: 0.95,
    278. backgroundColor: '#FB301E',
    279. range: [0, 28],
    280. }, ],
    281. ring: {
    282. backgroundColor: '#E3DEDA',
    283. mediaRules: [{
    284. maxWidth: '650px',
    285. visible: false,
    286. }, ],
    287. },
    288. tick: {
    289. visible: false,
    290. },
    291. },
    292. tooltip: {
    293. visible: false,
    294. },
    295. mediaRules: [{
    296. maxWidth: '650px',
    297. width: '100%',
    298. height: '20%',
    299. x: '0px',
    300. y: '40%',
    301. },
    302. {
    303. minWidth: '651px',
    304. width: '31.5%',
    305. height: '50%',
    306. x: '69%',
    307. y: '0px',
    308. },
    309. ],
    310. series: [{
    311. values: [28],
    312. valueBox: {
    313. text: '%v',
    314. fontColor: '#FB301E',
    315. fontSize: '14px',
    316. mediaRules: [{
    317. fontSize: '10px',
    318. maxWidth: '650px',
    319. }, ],
    320. placement: 'center',
    321. },
    322. backgroundColor: '#23211E',
    323. }, ],
    324. },
    325. {
    326. type: 'line',
    327. width: '100%',
    328. height: '55%',
    329. x: '0px',
    330. y: '45%',
    331. title: {
    332. text: 'Meter History',
    333. adjustLayout: true,
    334. mediaRules: [{
    335. fontSize: '14px',
    336. maxWidth: '650px',
    337. }, ],
    338. },
    339. plot: {
    340. tooltip: {
    341. visible: false,
    342. },
    343. },
    344. plotarea: {
    345. margin: 'dynamic',
    346. marginRight: '4%',
    347. },
    348. scaleX: {
    349. minValue: 1373045400000,
    350. step: 3000,
    351. transform: {
    352. type: 'date',
    353. all: '%D<br>%H:%i:%s',
    354. },
    355. },
    356. scaleY: {
    357. values: '0:100:25',
    358. item: {
    359. bold: true,
    360. fontColor: '#FB301E',
    361. },
    362. lineColor: '#FB301E',
    363. placement: 'default',
    364. tick: {
    365. lineColor: '#FB301E',
    366. },
    367. },
    368. scaleY2: {
    369. values: '0:20:5',
    370. item: {
    371. bold: true,
    372. fontColor: '#E2D51A',
    373. },
    374. lineColor: '#E2D51A',
    375. placement: 'default',
    376. tick: {
    377. lineColor: '#E2D51A',
    378. },
    379. },
    380. scaleY3: {
    381. values: '0:40:10',
    382. item: {
    383. bold: true,
    384. fontColor: '#00AE4D',
    385. },
    386. lineColor: '#00AE4D',
    387. placement: 'default',
    388. tick: {
    389. lineColor: '#00AE4D',
    390. },
    391. },
    392. crosshairX: {
    393. lineColor: '#23211E',
    394. plotLabel: {
    395. backgroundColor: '#f0ece8',
    396. borderColor: '#000',
    397. borderWidth: '1px',
    398. fontColor: '#414042',
    399. },
    400. scaleLabel: {
    401. backgroundColor: '#E3DEDA',
    402. fontColor: '#414042',
    403. },
    404. },
    405. mediaRules: [{
    406. maxWidth: '650px',
    407. width: '100%',
    408. height: '40%%',
    409. x: '0px',
    410. y: '60%',
    411. }, ],
    412. series: [{
    413. text: 'Energy Output',
    414. values: [35, 38, 40, 35, 38, 40, 35, 38, 40],
    415. lineColor: '#00AE4D',
    416. marker: {
    417. type: 'circle',
    418. backgroundColor: '#fff',
    419. borderColor: '#00AE4D',
    420. borderWidth: '2px',
    421. },
    422. scales: 'scale-x, scale-y-3',
    423. },
    424. {
    425. text: 'Energy Recycled',
    426. values: [11, 15, 19, 11, 15, 19, 11, 15, 19],
    427. lineColor: '#E2D51A',
    428. marker: {
    429. type: 'triangle',
    430. backgroundColor: '#fff',
    431. borderColor: '#E2D51A',
    432. borderWidth: '2px',
    433. size: '5px',
    434. },
    435. scales: 'scale-x, scale-y-2',
    436. },
    437. {
    438. text: 'Energy Consumed',
    439. values: [28, 21, 30, 28, 21, 30, 28, 21, 30],
    440. lineColor: '#FB301E',
    441. marker: {
    442. type: 'square',
    443. backgroundColor: '#fff',
    444. borderColor: '#FB301E',
    445. borderWidth: '2px',
    446. },
    447. scales: 'scale-x, scale-y',
    448. },
    449. ],
    450. },
    451. ],
    452. };
    453.  
    454. zingchart.render({
    455. id: 'myChart',
    456. data: chartConfig,
    457. height: '100%',
    458. width: '100%',
    459. });
    460.  
    461. /*
    462. * SetInterval is used to simulate live input. We also have
    463. * a feed attribute that takes in http requests, websockets,
    464. * and return value from a JS function.
    465. */
    466. setInterval(() => {
    467. let colors = ['#00AE4D', '#E2D51A', '#FB301E'];
    468. let Marker = (bgColor, ceiling) => {
    469. return {
    470. type: 'area',
    471. range: [0, ceiling],
    472. backgroundColor: bgColor,
    473. alpha: 0.95,
    474. };
    475. };
    476. let randomOffset0 = [-5, 5, 3, -3, 2, -2];
    477. let randomOffset1 = [10, -10, -5, 5, 3, -3, 2, -2, 7, -7];
    478. let output0 = Math.ceil(33 + randomOffset0[Math.floor(Math.random() * 6)]);
    479. let output1 = Math.ceil(11 + randomOffset0[Math.floor(Math.random() * 6)]);
    480. let output2 = Math.ceil(22 + randomOffset1[Math.floor(Math.random() * 9)]);
    481.  
    482. // 1) update gauge values
    483. zingchart.exec('myChart', 'appendseriesdata', {
    484. graphid: 0,
    485. plotindex: 0,
    486. update: false,
    487. data: {
    488. values: [output0],
    489. },
    490. });
    491. zingchart.exec('myChart', 'appendseriesdata', {
    492. graphid: 1,
    493. plotindex: 0,
    494. update: false,
    495. data: {
    496. values: [output1],
    497. },
    498. });
    499. zingchart.exec('myChart', 'appendseriesdata', {
    500. graphid: 2,
    501. plotindex: 0,
    502. update: false,
    503. data: {
    504. values: [output2],
    505. },
    506. });
    507.  
    508. // 2) update guage markers
    509. zingchart.exec('myChart', 'modify', {
    510. graphid: 0,
    511. update: false,
    512. data: {
    513. scaleR: {
    514. markers: [Marker(colors[0], output0)],
    515. },
    516. },
    517. });
    518. zingchart.exec('myChart', 'modify', {
    519. graphid: 1,
    520. update: false,
    521. data: {
    522. scaleR: {
    523. markers: [Marker(colors[1], output1)],
    524. },
    525. },
    526. });
    527. zingchart.exec('myChart', 'modify', {
    528. graphid: 2,
    529. update: false,
    530. data: {
    531. scaleR: {
    532. markers: [Marker(colors[2], output2)],
    533. },
    534. },
    535. });
    536.  
    537. // 3) update line graph
    538. zingchart.exec('myChart', 'appendseriesvalues', {
    539. graphid: 3,
    540. update: false,
    541. values: [
    542. [output0],
    543. [output1],
    544. [output2]
    545. ],
    546. });
    547.  
    548. // batch update all chart modifications
    549. zingchart.exec('myChart', 'update');
    550. }, 1500);
    551. </script>
    552. </body>
    553.  
    554. </html>
    1. <!doctype html>
    2. <html class="zc-html">
    3.  
    4. <head>
    5. <meta charset="utf-8">
    6. <title>ZingSoft Demo</title>
    7. <script src="https://cdn.zingchart.com/zingchart.min.js"></script>
    8. </head>
    9.  
    10. <body class="zc-body">
    11. <div id="myChart" class="chart--container">
    12. <a href="https://www.zingchart.com/" rel="noopener" class="zc-ref">Powered by ZingChart</a>
    13. </div>
    14.  
    15. </body>
    16.  
    17. </html>
    1. .zc-body {
    2. background: #fff;
    3. }
    4.  
    5. .chart--container {
    6. height: 100%;
    7. width: 100%;
    8. min-height: 530px;
    9. }
    10.  
    11. .zc-ref {
    12. display: none;
    13. }
    1. let chartConfig = {
    2. globals: {
    3. color: '#666',
    4. },
    5. backgroundColor: '#fff',
    6. graphset: [{
    7. type: 'gauge',
    8. width: '31.5%',
    9. height: '50%',
    10. x: '0px',
    11. y: '0px',
    12. title: {
    13. text: 'Energy Output',
    14. mediaRules: [{
    15. maxWidth: '650px',
    16. visible: false,
    17. }, ],
    18. },
    19. plot: {
    20. csize: '3%',
    21. size: '100%',
    22. },
    23. plotarea: {
    24. marginTop: '35%',
    25. },
    26. scale: {
    27. sizeFactor: 1.2,
    28. mediaRules: [{
    29. maxWidth: '650px',
    30. sizeFactor: 1.6,
    31. }, ],
    32. },
    33. scaleR: {
    34. values: '0:40:10',
    35. aperture: 130,
    36. center: {
    37. borderColor: '#23211E',
    38. borderWidth: '2px',
    39. mediaRules: [{
    40. maxWidth: '650px',
    41. size: '10px',
    42. }, ],
    43. size: '20px',
    44. },
    45. guide: {
    46. alpha: 1,
    47. backgroundColor: '#E3DEDA',
    48. },
    49. item: {
    50. offsetR: 0,
    51. },
    52. markers: [{
    53. type: 'area',
    54. alpha: 0.95,
    55. backgroundColor: '#00AE4D',
    56. range: [0, 35],
    57. }, ],
    58. ring: {
    59. backgroundColor: '#E3DEDA',
    60. mediaRules: [{
    61. maxWidth: '650px',
    62. visible: false,
    63. }, ],
    64. },
    65. tick: {
    66. visible: false,
    67. },
    68. },
    69. tooltip: {
    70. visible: false,
    71. },
    72. mediaRules: [{
    73. maxWidth: '650px',
    74. width: '100%',
    75. height: '20%',
    76. x: '0px',
    77. y: '2%',
    78. },
    79. {
    80. minWidth: '651px',
    81. width: '31.5%',
    82. height: '50%',
    83. x: '0px',
    84. y: '0px',
    85. },
    86. ],
    87. series: [{
    88. values: [35],
    89. valueBox: {
    90. text: '%v',
    91. fontColor: '#00AE4D',
    92. fontSize: '14px',
    93. mediaRules: [{
    94. fontSize: '10px',
    95. maxWidth: '650px',
    96. }, ],
    97. placement: 'center',
    98. },
    99. backgroundColor: '#23211E',
    100. }, ],
    101. },
    102. {
    103. type: 'gauge',
    104. width: '31.5%',
    105. height: '50%',
    106. x: '34.5%',
    107. y: '0px',
    108. title: {
    109. text: 'Energy Recycled',
    110. mediaRules: [{
    111. maxWidth: '650px',
    112. visible: false,
    113. }, ],
    114. },
    115. plot: {
    116. csize: '3%',
    117. size: '100%',
    118. },
    119. plotarea: {
    120. marginTop: '35%',
    121. },
    122. scale: {
    123. sizeFactor: 1.2,
    124. mediaRules: [{
    125. maxWidth: '650px',
    126. sizeFactor: 1.6,
    127. }, ],
    128. },
    129. scaleR: {
    130. values: '0:20:5',
    131. aperture: 130,
    132. center: {
    133. borderColor: '#23211E',
    134. borderWidth: '2px',
    135. mediaRules: [{
    136. maxWidth: '650px',
    137. size: '10px',
    138. }, ],
    139. size: '20px',
    140. },
    141. guide: {
    142. alpha: 1,
    143. backgroundColor: '#E3DEDA',
    144. },
    145. item: {
    146. offsetR: 0,
    147. },
    148. markers: [{
    149. type: 'area',
    150. alpha: 0.95,
    151. backgroundColor: '#E2D51A',
    152. range: [0, 11],
    153. }, ],
    154. ring: {
    155. backgroundColor: '#E3DEDA',
    156. mediaRules: [{
    157. maxWidth: '650px',
    158. visible: false,
    159. }, ],
    160. },
    161. tick: {
    162. visible: false,
    163. },
    164. },
    165. tooltip: {
    166. visible: false,
    167. },
    168. mediaRules: [{
    169. maxWidth: '650px',
    170. width: '100%',
    171. height: '20%',
    172. x: '0px',
    173. y: '20%',
    174. },
    175. {
    176. minWidth: '651px',
    177. width: '31.5%',
    178. height: '50%',
    179. x: '34.5%',
    180. y: '0px',
    181. },
    182. ],
    183. series: [{
    184. values: [11],
    185. valueBox: {
    186. text: '%v',
    187. fontColor: '#E2D51A',
    188. fontSize: '14px',
    189. mediaRules: [{
    190. fontSize: '10px',
    191. maxWidth: '650px',
    192. }, ],
    193. placement: 'center',
    194. },
    195. backgroundColor: '#23211E',
    196. }, ],
    197. },
    198. {
    199. type: 'gauge',
    200. width: '31.5%',
    201. height: '50%',
    202. x: '69%',
    203. y: '0px',
    204. title: {
    205. text: 'Energy Consumed',
    206. mediaRules: [{
    207. maxWidth: '650px',
    208. visible: false,
    209. }, ],
    210. },
    211. plot: {
    212. csize: '3%',
    213. size: '100%',
    214. },
    215. plotarea: {
    216. marginTop: '35%',
    217. },
    218. scale: {
    219. sizeFactor: 1.2,
    220. mediaRules: [{
    221. maxWidth: '650px',
    222. sizeFactor: 1.6,
    223. }, ],
    224. },
    225. scaleR: {
    226. values: '0:100:25',
    227. aperture: 130,
    228. center: {
    229. borderColor: '#23211E',
    230. borderWidth: '2px',
    231. mediaRules: [{
    232. maxWidth: '650px',
    233. size: '10px',
    234. }, ],
    235. size: '20px',
    236. },
    237. guide: {
    238. alpha: 1,
    239. backgroundColor: '#E3DEDA',
    240. },
    241. item: {
    242. offsetR: 0,
    243. },
    244. markers: [{
    245. type: 'area',
    246. alpha: 0.95,
    247. backgroundColor: '#FB301E',
    248. range: [0, 28],
    249. }, ],
    250. ring: {
    251. backgroundColor: '#E3DEDA',
    252. mediaRules: [{
    253. maxWidth: '650px',
    254. visible: false,
    255. }, ],
    256. },
    257. tick: {
    258. visible: false,
    259. },
    260. },
    261. tooltip: {
    262. visible: false,
    263. },
    264. mediaRules: [{
    265. maxWidth: '650px',
    266. width: '100%',
    267. height: '20%',
    268. x: '0px',
    269. y: '40%',
    270. },
    271. {
    272. minWidth: '651px',
    273. width: '31.5%',
    274. height: '50%',
    275. x: '69%',
    276. y: '0px',
    277. },
    278. ],
    279. series: [{
    280. values: [28],
    281. valueBox: {
    282. text: '%v',
    283. fontColor: '#FB301E',
    284. fontSize: '14px',
    285. mediaRules: [{
    286. fontSize: '10px',
    287. maxWidth: '650px',
    288. }, ],
    289. placement: 'center',
    290. },
    291. backgroundColor: '#23211E',
    292. }, ],
    293. },
    294. {
    295. type: 'line',
    296. width: '100%',
    297. height: '55%',
    298. x: '0px',
    299. y: '45%',
    300. title: {
    301. text: 'Meter History',
    302. adjustLayout: true,
    303. mediaRules: [{
    304. fontSize: '14px',
    305. maxWidth: '650px',
    306. }, ],
    307. },
    308. plot: {
    309. tooltip: {
    310. visible: false,
    311. },
    312. },
    313. plotarea: {
    314. margin: 'dynamic',
    315. marginRight: '4%',
    316. },
    317. scaleX: {
    318. minValue: 1373045400000,
    319. step: 3000,
    320. transform: {
    321. type: 'date',
    322. all: '%D<br>%H:%i:%s',
    323. },
    324. },
    325. scaleY: {
    326. values: '0:100:25',
    327. item: {
    328. bold: true,
    329. fontColor: '#FB301E',
    330. },
    331. lineColor: '#FB301E',
    332. placement: 'default',
    333. tick: {
    334. lineColor: '#FB301E',
    335. },
    336. },
    337. scaleY2: {
    338. values: '0:20:5',
    339. item: {
    340. bold: true,
    341. fontColor: '#E2D51A',
    342. },
    343. lineColor: '#E2D51A',
    344. placement: 'default',
    345. tick: {
    346. lineColor: '#E2D51A',
    347. },
    348. },
    349. scaleY3: {
    350. values: '0:40:10',
    351. item: {
    352. bold: true,
    353. fontColor: '#00AE4D',
    354. },
    355. lineColor: '#00AE4D',
    356. placement: 'default',
    357. tick: {
    358. lineColor: '#00AE4D',
    359. },
    360. },
    361. crosshairX: {
    362. lineColor: '#23211E',
    363. plotLabel: {
    364. backgroundColor: '#f0ece8',
    365. borderColor: '#000',
    366. borderWidth: '1px',
    367. fontColor: '#414042',
    368. },
    369. scaleLabel: {
    370. backgroundColor: '#E3DEDA',
    371. fontColor: '#414042',
    372. },
    373. },
    374. mediaRules: [{
    375. maxWidth: '650px',
    376. width: '100%',
    377. height: '40%%',
    378. x: '0px',
    379. y: '60%',
    380. }, ],
    381. series: [{
    382. text: 'Energy Output',
    383. values: [35, 38, 40, 35, 38, 40, 35, 38, 40],
    384. lineColor: '#00AE4D',
    385. marker: {
    386. type: 'circle',
    387. backgroundColor: '#fff',
    388. borderColor: '#00AE4D',
    389. borderWidth: '2px',
    390. },
    391. scales: 'scale-x, scale-y-3',
    392. },
    393. {
    394. text: 'Energy Recycled',
    395. values: [11, 15, 19, 11, 15, 19, 11, 15, 19],
    396. lineColor: '#E2D51A',
    397. marker: {
    398. type: 'triangle',
    399. backgroundColor: '#fff',
    400. borderColor: '#E2D51A',
    401. borderWidth: '2px',
    402. size: '5px',
    403. },
    404. scales: 'scale-x, scale-y-2',
    405. },
    406. {
    407. text: 'Energy Consumed',
    408. values: [28, 21, 30, 28, 21, 30, 28, 21, 30],
    409. lineColor: '#FB301E',
    410. marker: {
    411. type: 'square',
    412. backgroundColor: '#fff',
    413. borderColor: '#FB301E',
    414. borderWidth: '2px',
    415. },
    416. scales: 'scale-x, scale-y',
    417. },
    418. ],
    419. },
    420. ],
    421. };
    422.  
    423. zingchart.render({
    424. id: 'myChart',
    425. data: chartConfig,
    426. height: '100%',
    427. width: '100%',
    428. });
    429.  
    430. /*
    431. * SetInterval is used to simulate live input. We also have
    432. * a feed attribute that takes in http requests, websockets,
    433. * and return value from a JS function.
    434. */
    435. setInterval(() => {
    436. let colors = ['#00AE4D', '#E2D51A', '#FB301E'];
    437. let Marker = (bgColor, ceiling) => {
    438. return {
    439. type: 'area',
    440. range: [0, ceiling],
    441. backgroundColor: bgColor,
    442. alpha: 0.95,
    443. };
    444. };
    445. let randomOffset0 = [-5, 5, 3, -3, 2, -2];
    446. let randomOffset1 = [10, -10, -5, 5, 3, -3, 2, -2, 7, -7];
    447. let output0 = Math.ceil(33 + randomOffset0[Math.floor(Math.random() * 6)]);
    448. let output1 = Math.ceil(11 + randomOffset0[Math.floor(Math.random() * 6)]);
    449. let output2 = Math.ceil(22 + randomOffset1[Math.floor(Math.random() * 9)]);
    450.  
    451. // 1) update gauge values
    452. zingchart.exec('myChart', 'appendseriesdata', {
    453. graphid: 0,
    454. plotindex: 0,
    455. update: false,
    456. data: {
    457. values: [output0],
    458. },
    459. });
    460. zingchart.exec('myChart', 'appendseriesdata', {
    461. graphid: 1,
    462. plotindex: 0,
    463. update: false,
    464. data: {
    465. values: [output1],
    466. },
    467. });
    468. zingchart.exec('myChart', 'appendseriesdata', {
    469. graphid: 2,
    470. plotindex: 0,
    471. update: false,
    472. data: {
    473. values: [output2],
    474. },
    475. });
    476.  
    477. // 2) update guage markers
    478. zingchart.exec('myChart', 'modify', {
    479. graphid: 0,
    480. update: false,
    481. data: {
    482. scaleR: {
    483. markers: [Marker(colors[0], output0)],
    484. },
    485. },
    486. });
    487. zingchart.exec('myChart', 'modify', {
    488. graphid: 1,
    489. update: false,
    490. data: {
    491. scaleR: {
    492. markers: [Marker(colors[1], output1)],
    493. },
    494. },
    495. });
    496. zingchart.exec('myChart', 'modify', {
    497. graphid: 2,
    498. update: false,
    499. data: {
    500. scaleR: {
    501. markers: [Marker(colors[2], output2)],
    502. },
    503. },
    504. });
    505.  
    506. // 3) update line graph
    507. zingchart.exec('myChart', 'appendseriesvalues', {
    508. graphid: 3,
    509. update: false,
    510. values: [
    511. [output0],
    512. [output1],
    513. [output2]
    514. ],
    515. });
    516.  
    517. // batch update all chart modifications
    518. zingchart.exec('myChart', 'update');
    519. }, 1500);