• Edit
  • Download
    1. <!DOCTYPE html>
    2. <html>
    3.  
    4. <head>
    5. <meta charset="utf-8">
    6. <title>ZingGrid: Blank Grid</title>
    7. <script nonce="undefined" src="https://cdn.zingchart.com/zingchart.min.js"></script>
    8. <style>
    9. html,
    10. body {
    11. height: 100%;
    12. width: 100%;
    13. margin: 0;
    14. padding: 0;
    15. }
    16.  
    17. #myChart {
    18. margin: 0 auto;
    19. height: 380px;
    20. width: 98%;
    21. box-shadow: 5px 5px 5px #eee;
    22. background-color: #fff;
    23. border: 1px solid #eee;
    24. display: flex;
    25. flex-flow: column wrap;
    26. }
    27.  
    28. .controls--container {
    29. display: flex;
    30. align-items: center;
    31. justify-content: center;
    32. }
    33.  
    34. .controls--container button {
    35. margin: 40px;
    36. padding: 15px;
    37. background-color: #FF4081;
    38. border: none;
    39. color: #fff;
    40. box-shadow: 5px 5px 5px #eee;
    41. font-size: 16px;
    42. font-family: Roboto;
    43. cursor: pointer;
    44. transition: .1s;
    45. }
    46.  
    47. .controls--container button:hover {
    48. opacity: .9;
    49. }
    50.  
    51. /*button movement*/
    52. .controls--container button:active {
    53. border-width: 0 0 2px 0;
    54. transform: translateY(8px);
    55. opacity: 0.9;
    56. }
    57.  
    58. .zc-ref {
    59. display: none;
    60. }
    61. </style>
    62. </head>
    63.  
    64. <body>
    65. <!-- CHART CONTAINER -->
    66. <div id="myChart">
    67. <a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a>
    68. </div>
    69. <div class="controls--container">
    70. <button id="clear">Clear</button>
    71. <button id="stop">Stop</button>
    72. <button id="start">Start</button>
    73. </div>
    74. <script>
    75. ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"]; //real-time feed random math function
    76. function realTimeFeed(callback) {
    77. var tick = {};
    78. tick.plot0 = parseInt(10 + 90 * Math.random(), 10);
    79. tick.plot1 = parseInt(10 + 90 * Math.random(), 10);
    80. callback(JSON.stringify(tick));
    81. };
    82.  
    83. // define top level feed control functions
    84. function clearGraph() {
    85. zingchart.exec('myChart', 'clearfeed')
    86. }
    87.  
    88. function startGraph() {
    89. zingchart.exec('myChart', 'startfeed');
    90. }
    91.  
    92. function stopGraph() {
    93. zingchart.exec('myChart', 'stopfeed');
    94. }
    95.  
    96. // window:load event for Javascript to run after HTML
    97. // because this Javascript is injected into the document head
    98. window.addEventListener('load', () => {
    99. // Javascript code to execute after DOM content
    100.  
    101. //clear start stop click events
    102. document.getElementById('clear').addEventListener('click', clearGraph);
    103. document.getElementById('start').addEventListener('click', startGraph);
    104. document.getElementById('stop').addEventListener('click', stopGraph);
    105.  
    106. // full ZingChart schema can be found here:
    107. // https://www.zingchart.com/docs/api/json-configuration/
    108. const myConfig = {
    109. //chart styling
    110. type: 'line',
    111. globals: {
    112. fontFamily: 'Roboto',
    113. },
    114. backgroundColor: '#fff',
    115. title: {
    116. backgroundColor: '#1565C0',
    117. text: 'Real-Time Line Chart',
    118. color: '#fff',
    119. height: '30x',
    120. },
    121. plotarea: {
    122. marginTop: '80px'
    123. },
    124. crosshairX: {
    125. lineWidth: 4,
    126. lineStyle: 'dashed',
    127. lineColor: '#424242',
    128. marker: {
    129. visible: true,
    130. size: 9
    131. },
    132. plotLabel: {
    133. backgroundColor: '#fff',
    134. borderColor: '#e3e3e3',
    135. borderRadius: 5,
    136. padding: 15,
    137. fontSize: 15,
    138. shadow: true,
    139. shadowAlpha: 0.2,
    140. shadowBlur: 5,
    141. shadowDistance: 4,
    142. },
    143. scaleLabel: {
    144. backgroundColor: '#424242',
    145. padding: 5
    146. }
    147. },
    148. scaleY: {
    149. guide: {
    150. visible: false
    151. },
    152. values: '0:100:25'
    153. },
    154. tooltip: {
    155. visible: false
    156. },
    157. //real-time feed
    158. refresh: {
    159. type: 'feed',
    160. transport: 'js',
    161. url: 'realTimeFeed()',
    162. interval: 500,
    163. },
    164. plot: {
    165. shadow: 1,
    166. shadowColor: '#eee',
    167. shadowDistance: '10px',
    168. lineWidth: 5,
    169. hoverState: {
    170. visible: false
    171. },
    172. marker: {
    173. visible: false
    174. },
    175. aspect: 'spline'
    176. },
    177. series: [{
    178. values: [],
    179. lineColor: '#2196F3',
    180. text: 'Blue Line'
    181. }, {
    182. values: [],
    183. lineColor: '#ff9800',
    184. text: 'Orange Line'
    185. }]
    186. };
    187.  
    188. // render chart with width and height to
    189. // fill the parent container CSS dimensions
    190. zingchart.render({
    191. id: 'myChart',
    192. data: myConfig,
    193. height: '100%',
    194. width: '100%',
    195. });
    196. });
    197. </script>
    198. </body>
    199.  
    200. </html>
    1. <!DOCTYPE html>
    2. <html>
    3.  
    4. <head>
    5. <meta charset="utf-8">
    6. <title>ZingGrid: Blank Grid</title>
    7. <script src="https://cdn.zingchart.com/zingchart.min.js"></script>
    8. </head>
    9.  
    10. <body>
    11. <!-- CHART CONTAINER -->
    12. <div id="myChart">
    13. <a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a>
    14. </div>
    15. <div class="controls--container">
    16. <button id="clear">Clear</button>
    17. <button id="stop">Stop</button>
    18. <button id="start">Start</button>
    19. </div>
    20. </body>
    21.  
    22. </html>
    1. html,
    2. body {
    3. height: 100%;
    4. width: 100%;
    5. margin: 0;
    6. padding: 0;
    7. }
    8.  
    9. #myChart {
    10. margin: 0 auto;
    11. height: 380px;
    12. width: 98%;
    13. box-shadow: 5px 5px 5px #eee;
    14. background-color: #fff;
    15. border: 1px solid #eee;
    16. display: flex;
    17. flex-flow: column wrap;
    18. }
    19.  
    20. .controls--container {
    21. display: flex;
    22. align-items: center;
    23. justify-content: center;
    24. }
    25.  
    26. .controls--container button {
    27. margin: 40px;
    28. padding: 15px;
    29. background-color: #FF4081;
    30. border: none;
    31. color: #fff;
    32. box-shadow: 5px 5px 5px #eee;
    33. font-size: 16px;
    34. font-family: Roboto;
    35. cursor: pointer;
    36. transition: .1s;
    37. }
    38.  
    39. .controls--container button:hover {
    40. opacity: .9;
    41. }
    42.  
    43. /*button movement*/
    44. .controls--container button:active {
    45. border-width: 0 0 2px 0;
    46. transform: translateY(8px);
    47. opacity: 0.9;
    48. }
    49.  
    50. .zc-ref {
    51. display: none;
    52. }
    1. //real-time feed random math function
    2. function realTimeFeed(callback) {
    3. var tick = {};
    4. tick.plot0 = parseInt(10 + 90 * Math.random(), 10);
    5. tick.plot1 = parseInt(10 + 90 * Math.random(), 10);
    6. callback(JSON.stringify(tick));
    7. };
    8.  
    9. // define top level feed control functions
    10. function clearGraph() {
    11. zingchart.exec('myChart', 'clearfeed')
    12. }
    13.  
    14. function startGraph() {
    15. zingchart.exec('myChart', 'startfeed');
    16. }
    17.  
    18. function stopGraph() {
    19. zingchart.exec('myChart', 'stopfeed');
    20. }
    21.  
    22. // window:load event for Javascript to run after HTML
    23. // because this Javascript is injected into the document head
    24. window.addEventListener('load', () => {
    25. // Javascript code to execute after DOM content
    26.  
    27. //clear start stop click events
    28. document.getElementById('clear').addEventListener('click', clearGraph);
    29. document.getElementById('start').addEventListener('click', startGraph);
    30. document.getElementById('stop').addEventListener('click', stopGraph);
    31.  
    32. // full ZingChart schema can be found here:
    33. // https://www.zingchart.com/docs/api/json-configuration/
    34. const myConfig = {
    35. //chart styling
    36. type: 'line',
    37. globals: {
    38. fontFamily: 'Roboto',
    39. },
    40. backgroundColor: '#fff',
    41. title: {
    42. backgroundColor: '#1565C0',
    43. text: 'Real-Time Line Chart',
    44. color: '#fff',
    45. height: '30x',
    46. },
    47. plotarea: {
    48. marginTop: '80px'
    49. },
    50. crosshairX: {
    51. lineWidth: 4,
    52. lineStyle: 'dashed',
    53. lineColor: '#424242',
    54. marker: {
    55. visible: true,
    56. size: 9
    57. },
    58. plotLabel: {
    59. backgroundColor: '#fff',
    60. borderColor: '#e3e3e3',
    61. borderRadius: 5,
    62. padding: 15,
    63. fontSize: 15,
    64. shadow: true,
    65. shadowAlpha: 0.2,
    66. shadowBlur: 5,
    67. shadowDistance: 4,
    68. },
    69. scaleLabel: {
    70. backgroundColor: '#424242',
    71. padding: 5
    72. }
    73. },
    74. scaleY: {
    75. guide: {
    76. visible: false
    77. },
    78. values: '0:100:25'
    79. },
    80. tooltip: {
    81. visible: false
    82. },
    83. //real-time feed
    84. refresh: {
    85. type: 'feed',
    86. transport: 'js',
    87. url: 'realTimeFeed()',
    88. interval: 500,
    89. },
    90. plot: {
    91. shadow: 1,
    92. shadowColor: '#eee',
    93. shadowDistance: '10px',
    94. lineWidth: 5,
    95. hoverState: {
    96. visible: false
    97. },
    98. marker: {
    99. visible: false
    100. },
    101. aspect: 'spline'
    102. },
    103. series: [{
    104. values: [],
    105. lineColor: '#2196F3',
    106. text: 'Blue Line'
    107. }, {
    108. values: [],
    109. lineColor: '#ff9800',
    110. text: 'Orange Line'
    111. }]
    112. };
    113.  
    114. // render chart with width and height to
    115. // fill the parent container CSS dimensions
    116. zingchart.render({
    117. id: 'myChart',
    118. data: myConfig,
    119. height: '100%',
    120. width: '100%',
    121. });
    122. });