• 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. values: [],
    81. text: 'Week 1',
    82. },
    83. {
    84. values: [],
    85. text: 'Week 2'
    86. },
    87. {
    88. values: [],
    89. text: 'Week 3'
    90. }
    91. ]
    92. };
    93.  
    94. // fetch the remote json
    95. fetch('https://cdn.zingchart.com/datasets/remote-seriesvalues.json')
    96. .then(res => {
    97. return res.json();
    98. })
    99. .then(results => {
    100. // use setseriesdata to instantiate the chart data
    101. zingchart.exec('myChart', 'setseriesvalues', {
    102. values: results
    103. });
    104. })
    105. .catch(e => {
    106. // let the user know there was an error
    107. zingchart.exec('myChart', 'update', {
    108. data: {
    109. noData: {
    110. text: 'Error Fetching remote data, please refresh page.'
    111. }
    112. }
    113. });
    114. });
    115.  
    116. // render chart with width and height to
    117. // fill the parent container CSS dimensions
    118. zingchart.render({
    119. id: 'myChart',
    120. data: myConfig,
    121. height: '100%',
    122. width: '100%'
    123. });
    124. });
    125. </script>
    126. </body>
    127.  
    128. </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. values: [],
    47. text: 'Week 1',
    48. },
    49. {
    50. values: [],
    51. text: 'Week 2'
    52. },
    53. {
    54. values: [],
    55. text: 'Week 3'
    56. }
    57. ]
    58. };
    59.  
    60. // fetch the remote json
    61. fetch('https://cdn.zingchart.com/datasets/remote-seriesvalues.json')
    62. .then(res => {
    63. return res.json();
    64. })
    65. .then(results => {
    66. // use setseriesdata to instantiate the chart data
    67. zingchart.exec('myChart', 'setseriesvalues', {
    68. values: results
    69. });
    70. })
    71. .catch(e => {
    72. // let the user know there was an error
    73. zingchart.exec('myChart', 'update', {
    74. data: {
    75. noData: {
    76. text: 'Error Fetching remote data, please refresh page.'
    77. }
    78. }
    79. });
    80. });
    81.  
    82. // render chart with width and height to
    83. // fill the parent container CSS dimensions
    84. zingchart.render({
    85. id: 'myChart',
    86. data: myConfig,
    87. height: '100%',
    88. width: '100%'
    89. });
    90. });