• 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. .chart--container {
    18. height: 100%;
    19. width: 100%;
    20. min-height: 150px;
    21. }
    22.  
    23. .zc-ref {
    24. display: none;
    25. }
    26. </style>
    27. </head>
    28.  
    29. <body>
    30. <!-- CHART CONTAINER -->
    31. <div id="myChart" class="chart--container">
    32. <a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a>
    33. </div>
    34. <script>
    35. ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"]; // window:load event for Javascript to run after HTML
    36. // because this Javascript is injected into the document head
    37. window.addEventListener('load', () => {
    38. // Javascript code to execute after DOM content
    39. const myConfig = {
    40. type: 'bar',
    41. title: {
    42. text: 'Data Basics - Remote Data',
    43. fontSize: 24,
    44. },
    45. legend: {
    46. draggable: true,
    47. },
    48. scaleX: {
    49. // set scale label
    50. label: {
    51. text: 'Days'
    52. },
    53. // convert text on scale indices
    54. labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    55. },
    56. scaleY: {
    57. // scale label with unicode character
    58. label: {
    59. text: 'Temperature (°F)'
    60. }
    61. },
    62. plot: {
    63. // animation docs here:
    64. // https://www.zingchart.com/docs/tutorials/design-and-styling/chart-animation/#animation__effect
    65. animation: {
    66. effect: 'ANIMATION_EXPAND_BOTTOM',
    67. method: 'ANIMATION_STRONG_EASE_OUT',
    68. sequence: 'ANIMATION_BY_NODE',
    69. speed: 275,
    70. }
    71. },
    72. noData: {
    73. text: 'Fetching remote data...',
    74. backgroundColor: '#eeeeee',
    75. fontSize: 18
    76. },
    77. // the commented out data is the series (data)
    78. // objects we are fetching remotely
    79. series: [
    80. /*
    81. {
    82. values: [23,20,27,29,25,17,15],
    83. text: 'Week 1',
    84. },
    85. {
    86. values: [35,42,33,49,35,47,35],
    87. text: 'Week 2'
    88. },
    89. {
    90. values: [15,22,13,33,44,27,31],
    91. text: 'Week 3'
    92. }
    93. */
    94. ]
    95. };
    96.  
    97. // fetch the remote json
    98. fetch('https://cdn.zingchart.com/datasets/remote-data.json')
    99. .then(res => {
    100. return res.json();
    101. })
    102. .then(results => {
    103. // use setseriesdata to instantiate the chart data
    104. zingchart.exec('myChart', 'setseriesdata', {
    105. data: results
    106. });
    107. })
    108. .catch(e => {
    109. // let the user know there was an error
    110. zingchart.exec('myChart', 'update', {
    111. data: {
    112. noData: {
    113. text: 'Error Fetching remote data, please refresh page.'
    114. }
    115. }
    116. });
    117. });
    118.  
    119. // render chart with width and height to
    120. // fill the parent container CSS dimensions
    121. zingchart.render({
    122. id: 'myChart',
    123. data: myConfig,
    124. height: '100%',
    125. width: '100%'
    126. });
    127. });
    128. </script>
    129. </body>
    130.  
    131. </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" 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. height: 100%;
    4. width: 100%;
    5. margin: 0;
    6. padding: 0;
    7. }
    8.  
    9. .chart--container {
    10. height: 100%;
    11. width: 100%;
    12. min-height: 150px;
    13. }
    14.  
    15. .zc-ref {
    16. display: none;
    17. }
    1. // window:load event for Javascript to run after HTML
    2. // because this Javascript is injected into the document head
    3. window.addEventListener('load', () => {
    4. // Javascript code to execute after DOM content
    5. const myConfig = {
    6. type: 'bar',
    7. title: {
    8. text: 'Data Basics - Remote Data',
    9. fontSize: 24,
    10. },
    11. legend: {
    12. draggable: true,
    13. },
    14. scaleX: {
    15. // set scale label
    16. label: {
    17. text: 'Days'
    18. },
    19. // convert text on scale indices
    20. labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    21. },
    22. scaleY: {
    23. // scale label with unicode character
    24. label: {
    25. text: 'Temperature (°F)'
    26. }
    27. },
    28. plot: {
    29. // animation docs here:
    30. // https://www.zingchart.com/docs/tutorials/design-and-styling/chart-animation/#animation__effect
    31. animation: {
    32. effect: 'ANIMATION_EXPAND_BOTTOM',
    33. method: 'ANIMATION_STRONG_EASE_OUT',
    34. sequence: 'ANIMATION_BY_NODE',
    35. speed: 275,
    36. }
    37. },
    38. noData: {
    39. text: 'Fetching remote data...',
    40. backgroundColor: '#eeeeee',
    41. fontSize: 18
    42. },
    43. // the commented out data is the series (data)
    44. // objects we are fetching remotely
    45. series: [
    46. /*
    47. {
    48. values: [23,20,27,29,25,17,15],
    49. text: 'Week 1',
    50. },
    51. {
    52. values: [35,42,33,49,35,47,35],
    53. text: 'Week 2'
    54. },
    55. {
    56. values: [15,22,13,33,44,27,31],
    57. text: 'Week 3'
    58. }
    59. */
    60. ]
    61. };
    62.  
    63. // fetch the remote json
    64. fetch('https://cdn.zingchart.com/datasets/remote-data.json')
    65. .then(res => {
    66. return res.json();
    67. })
    68. .then(results => {
    69. // use setseriesdata to instantiate the chart data
    70. zingchart.exec('myChart', 'setseriesdata', {
    71. data: results
    72. });
    73. })
    74. .catch(e => {
    75. // let the user know there was an error
    76. zingchart.exec('myChart', 'update', {
    77. data: {
    78. noData: {
    79. text: 'Error Fetching remote data, please refresh page.'
    80. }
    81. }
    82. });
    83. });
    84.  
    85. // render chart with width and height to
    86. // fill the parent container CSS dimensions
    87. zingchart.render({
    88. id: 'myChart',
    89. data: myConfig,
    90. height: '100%',
    91. width: '100%'
    92. });
    93. });