• Edit
  • Download
    1. <!DOCTYPE html>
    2. <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. html,
    10. body {
    11. margin: 0;
    12. padding: 0;
    13. width: 100%;
    14. height: 100%;
    15. }
    16.  
    17. .chart--container {
    18. min-height: 550px;
    19. width: 100%;
    20. }
    21.  
    22. .zc-ref {
    23. display: none;
    24. }
    25. </style>
    26. </head>
    27.  
    28. <body>
    29. <!-- CHART CONTAINER -->
    30. <div id="myChart" class="chart--container">
    31. <a class="zc-ref" href="https://www.zingchart.com/">Powered by ZingChart</a>
    32. </div>
    33. <script>
    34. ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];
    35. let gSeriesData = {
    36. text: '7 Year Data',
    37. values: []
    38. };
    39.  
    40. // toggle the type of chart
    41.  
    42. // window:load event for Javascript to run after HTML
    43. // because this Javascript is injected into the document head
    44. window.addEventListener('load', () => {
    45. // Javascript code to execute after DOM content
    46.  
    47.  
    48. // full ZingChart schema can be found here:
    49. // https://www.zingchart.com/docs/api/json-configuration/
    50. let chartConfig = {
    51. type: 'line',
    52. globals: {
    53. fontFamily: 'Lucida Sans Unicode'
    54. },
    55. plotarea: {
    56. margin: '50px 40px 40px 80px'
    57. },
    58. scaleX: {
    59. item: {
    60. fontSize: '10px'
    61. },
    62. transform: {
    63. type: 'date',
    64. item: {
    65. visible: true
    66. }
    67. },
    68. zooming: true
    69. },
    70. scaleY: {
    71. autoFit: true,
    72. guide: {
    73. lineStyle: 'solid'
    74. },
    75. item: {
    76. fontSize: '10px'
    77. },
    78. label: {
    79. text: 'VOLUMES'
    80. },
    81. minValue: 'auto',
    82. short: true
    83. },
    84. crosshairX: {
    85. plotLabel: {
    86. short: true,
    87. decimals: 1
    88. }
    89. },
    90. preview: {
    91. adjustLayout: true,
    92. borderWidth: '1px',
    93. handle: {
    94. height: '20px',
    95. lineWidth: '0px'
    96. }
    97. },
    98. noData: {
    99. text: 'No data found',
    100. backgroundColor: '#efefef'
    101. },
    102. // define zoom module options
    103. options: {
    104. // define custom buttons
    105. buttons: [{
    106. text: '2006',
    107. type: 'year',
    108. // Difference from farthest year 2013 - 2006
    109. count: 2013 - 2010
    110. },
    111. {
    112. text: '2011',
    113. type: 'year',
    114.  
    115. count: 2013 - 2011
    116. },
    117. {
    118. text: '2012',
    119. type: 'year',
    120. count: 2013 - 2012
    121. },
    122. {
    123. text: 'All',
    124. type: 'all',
    125. },
    126. ]
    127. },
    128. // if fetching data remotely define an empty series
    129. series: [{}]
    130. };
    131.  
    132. // ONLY ONCE we have loaded the zoom-button module
    133. zingchart.loadModules('zoom-buttons', () => {
    134.  
    135. // render the chart right away
    136. zingchart.render({
    137. id: 'myChart',
    138. data: chartConfig,
    139. height: '100%',
    140. width: '100%',
    141. modules: 'zoom-buttons',
    142. });
    143.  
    144. // fetch the data remotely
    145. fetch('https://cdn.zingchart.com/datasets/timeseries-sample-data.json')
    146. .then(res => res.json())
    147. .then(timeseriesData => {
    148. // assign data
    149. gSeriesData.values = timeseriesData.values;
    150. zingchart.exec('myChart', 'setseriesdata', {
    151. data: [gSeriesData]
    152. })
    153. })
    154. .catch(e => {
    155. // if error, render blank chart
    156. console.error('--- error fetching data from: https://cdn.zingchart.com/datasets/timeseries-sample-data.json ---');
    157. chartConfig.title = {};
    158. chartConfig.title.text = 'Error Fetching https://cdn.zingchart.com/datasets/timeseries-sample-data.json';
    159. // just exec setdata api method since we don't need to render the zoom modules
    160. // https://www.zingchart.com/docs/api/methods/
    161. zingchart.exec('myChart', 'setdata', {
    162. data: chartConfig
    163. });
    164. });
    165. });
    166. });
    167. </script>
    168. </body>
    169.  
    170. </html>
    1. <!DOCTYPE html>
    2. <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>
    11. <!-- CHART CONTAINER -->
    12. <div id="myChart" class="chart--container">
    13. <a class="zc-ref" href="https://www.zingchart.com/">Powered by ZingChart</a>
    14. </div>
    15. </body>
    16.  
    17. </html>
    1. html,
    2. body {
    3. margin: 0;
    4. padding: 0;
    5. width: 100%;
    6. height: 100%;
    7. }
    8.  
    9. .chart--container {
    10. min-height: 550px;
    11. width: 100%;
    12. }
    13.  
    14. .zc-ref {
    15. display: none;
    16. }
    1. let gSeriesData = {
    2. text: '7 Year Data',
    3. values: []
    4. };
    5.  
    6. // toggle the type of chart
    7.  
    8. // window:load event for Javascript to run after HTML
    9. // because this Javascript is injected into the document head
    10. window.addEventListener('load', () => {
    11. // Javascript code to execute after DOM content
    12.  
    13.  
    14. // full ZingChart schema can be found here:
    15. // https://www.zingchart.com/docs/api/json-configuration/
    16. let chartConfig = {
    17. type: 'line',
    18. globals: {
    19. fontFamily: 'Lucida Sans Unicode'
    20. },
    21. plotarea: {
    22. margin: '50px 40px 40px 80px'
    23. },
    24. scaleX: {
    25. item: {
    26. fontSize: '10px'
    27. },
    28. transform: {
    29. type: 'date',
    30. item: {
    31. visible: true
    32. }
    33. },
    34. zooming: true
    35. },
    36. scaleY: {
    37. autoFit: true,
    38. guide: {
    39. lineStyle: 'solid'
    40. },
    41. item: {
    42. fontSize: '10px'
    43. },
    44. label: {
    45. text: 'VOLUMES'
    46. },
    47. minValue: 'auto',
    48. short: true
    49. },
    50. crosshairX: {
    51. plotLabel: {
    52. short: true,
    53. decimals: 1
    54. }
    55. },
    56. preview: {
    57. adjustLayout: true,
    58. borderWidth: '1px',
    59. handle: {
    60. height: '20px',
    61. lineWidth: '0px'
    62. }
    63. },
    64. noData: {
    65. text: 'No data found',
    66. backgroundColor: '#efefef'
    67. },
    68. // define zoom module options
    69. options: {
    70. // define custom buttons
    71. buttons: [{
    72. text: '2006',
    73. type: 'year',
    74. // Difference from farthest year 2013 - 2006
    75. count: 2013 - 2010
    76. },
    77. {
    78. text: '2011',
    79. type: 'year',
    80.  
    81. count: 2013 - 2011
    82. },
    83. {
    84. text: '2012',
    85. type: 'year',
    86. count: 2013 - 2012
    87. },
    88. {
    89. text: 'All',
    90. type: 'all',
    91. },
    92. ]
    93. },
    94. // if fetching data remotely define an empty series
    95. series: [{}]
    96. };
    97.  
    98. // ONLY ONCE we have loaded the zoom-button module
    99. zingchart.loadModules('zoom-buttons', () => {
    100.  
    101. // render the chart right away
    102. zingchart.render({
    103. id: 'myChart',
    104. data: chartConfig,
    105. height: '100%',
    106. width: '100%',
    107. modules: 'zoom-buttons',
    108. });
    109.  
    110. // fetch the data remotely
    111. fetch('https://cdn.zingchart.com/datasets/timeseries-sample-data.json')
    112. .then(res => res.json())
    113. .then(timeseriesData => {
    114. // assign data
    115. gSeriesData.values = timeseriesData.values;
    116. zingchart.exec('myChart', 'setseriesdata', {
    117. data: [gSeriesData]
    118. })
    119. })
    120. .catch(e => {
    121. // if error, render blank chart
    122. console.error('--- error fetching data from: https://cdn.zingchart.com/datasets/timeseries-sample-data.json ---');
    123. chartConfig.title = {};
    124. chartConfig.title.text = 'Error Fetching https://cdn.zingchart.com/datasets/timeseries-sample-data.json';
    125. // just exec setdata api method since we don't need to render the zoom modules
    126. // https://www.zingchart.com/docs/api/methods/
    127. zingchart.exec('myChart', 'setdata', {
    128. data: chartConfig
    129. });
    130. });
    131. });
    132. });