• 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. <input id="sc" type="checkbox" /><label for="sc">Show only small cities</label> (up to <select id="maxpop" disabled="disabled">
    27. <option value="100000">100.000</option>
    28. <option value="50000">50.000</option>
    29. <option value="10000">10.000</option>
    30. <option value="5000">5.000</option>
    31. <option value="1000">1.000</option>
    32. <option value="500">500</option>
    33. </select> people)
    34.  
    35. <div id="myChart" class="chart--container">
    36. <a href="https://www.zingchart.com/" rel="noopener" class="zc-ref">Powered by ZingChart</a>
    37. </div>
    38.  
    39. <script nonce="undefined" src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/374756/fr_pop_2010.js'></script>
    40.  
    41. <script>
    42. ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];
    43. let chartConfig = {
    44. type: 'null',
    45. backgroundColor: '#fff',
    46. flat: true,
    47. heatmap: {
    48. tooltip: {
    49. text: '~ %value people',
    50. thousandsSeparator: '.',
    51. decimals: 0
    52. },
    53. alpha: 1,
    54. sortData: true,
    55. async: true,
    56. brushType: 'square',
    57. size: 3,
    58. blur: 1,
    59. },
    60. tooltip: {
    61. padding: '5 10',
    62. fontSize: '11px',
    63. callout: true,
    64. calloutWidth: '10px',
    65. calloutHeight: '6px',
    66. calloutPosition: 'bottom',
    67. },
    68. colorScale: {
    69. aspect: 'gradient',
    70. gradientStops: '0.0 0.4 0.6 0.7 0.8 1.0',
    71. gradientColors: 'rgba(0,0,255,0) #0000ff #00ffff #bfff00 #ffff00 #ff0000',
    72. backgroundColor: null,
    73. alpha: 0.8,
    74. },
    75. shapes: [{
    76. type: 'zingchart.maps',
    77. options: {
    78. id: 'mapmain',
    79. name: 'fra',
    80. scale: true,
    81. zooming: false,
    82. panning: false,
    83. scrolling: false,
    84. style: {
    85. flat: true,
    86. controls: {
    87. visible: false,
    88. },
    89. borderAlpha: 0.1,
    90. borderColor: '#fff',
    91. label: {
    92. overlap: false,
    93. text: '%long-text',
    94. },
    95. hoverState: {
    96. visible: false,
    97. backgroundColor: 'none',
    98. shadowAlpha: 0.2,
    99. shadowDistance: 2,
    100. shadow: true,
    101. shadowColor: '#333',
    102. },
    103. },
    104. },
    105. }, ],
    106. };
    107.  
    108. zingchart.bind('myChart', 'load', function() {
    109. paintHeatmap();
    110. });
    111.  
    112. window.paintHeatmap = function(iMax, bSmallBrush) {
    113. let aData = [];
    114. let iMaxPop = 0;
    115. for (let i = 0; i < FR_POP_2010.length; i++) {
    116. if (iMax && FR_POP_2010[i][2] > iMax) {
    117. continue;
    118. }
    119. let fLon = FR_POP_2010[i][0],
    120. fLat = FR_POP_2010[i][1],
    121. iPop = FR_POP_2010[i][2];
    122. let aXY = zingchart.maps.getXY('mapmain', [fLon, fLat]);
    123. aData.push([aXY[0], aXY[1], iPop]);
    124. iMaxPop = Math.max(iMaxPop, iPop);
    125. }
    126. zingchart.exec('myChart', 'colorscale.update', {
    127. data: {
    128. maxValue: iMaxPop,
    129. },
    130. });
    131. let oCSInfo = zingchart.exec('myChart', 'colorscale.getinfo');
    132. zingchart.exec('myChart', 'heatmap.setdata', {
    133. minValue: 0,
    134. maxValue: oCSInfo.max,
    135. data: aData,
    136. size: bSmallBrush ? 4 : 12,
    137. blur: bSmallBrush ? 0 : 6,
    138. });
    139. };
    140.  
    141. zingchart.bind('myChart', 'heatmap.mousemove', function(oInfo) {
    142. if (oInfo.value !== null) {
    143. zingchart.exec(oInfo.id, 'colorscale.setvalue', {
    144. graphid: oInfo.graphid,
    145. value: oInfo.value,
    146. });
    147. } else {
    148. zingchart.exec(oInfo.id, 'colorscale.clear', {
    149. graphid: oInfo.graphid,
    150. });
    151. }
    152. });
    153.  
    154. document.querySelector('#sc').addEventListener('click', function() {
    155. if (this.checked) {
    156. paintHeatmap(100000, true);
    157. let maxpopRef = document.querySelector('#maxpop');
    158. maxpopRef.value = 100000;
    159. maxpopRef.removeAttribute('disabled');
    160. } else {
    161. paintHeatmap();
    162. let maxpopRef = document.querySelector('#maxpop');
    163. maxpopRef.setAttribute('disabled', 'disabled');
    164. }
    165. });
    166.  
    167. document.querySelector('#maxpop').addEventListener('change', function() {
    168. paintHeatmap(this.value, true);
    169. });
    170.  
    171. zingchart.loadModules('heatmap,color-scale,maps,maps-fra', function() {
    172. zingchart.render({
    173. id: 'myChart',
    174. width: '600px',
    175. height: '600px',
    176. output: 'canvas',
    177. data: chartConfig,
    178. modules: 'heatmap,color-scale',
    179. });
    180. });
    181. </script>
    182. </body>
    183.  
    184. </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. <input id="sc" type="checkbox" /><label for="sc">Show only small cities</label> (up to <select id="maxpop" disabled="disabled">
    12. <option value="100000">100.000</option>
    13. <option value="50000">50.000</option>
    14. <option value="10000">10.000</option>
    15. <option value="5000">5.000</option>
    16. <option value="1000">1.000</option>
    17. <option value="500">500</option>
    18. </select> people)
    19.  
    20. <div id="myChart" class="chart--container">
    21. <a href="https://www.zingchart.com/" rel="noopener" class="zc-ref">Powered by ZingChart</a>
    22. </div>
    23.  
    24. <script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/374756/fr_pop_2010.js'></script>
    25.  
    26. </body>
    27.  
    28. </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. type: 'null',
    3. backgroundColor: '#fff',
    4. flat: true,
    5. heatmap: {
    6. tooltip: {
    7. text: '~ %value people',
    8. thousandsSeparator: '.',
    9. decimals: 0
    10. },
    11. alpha: 1,
    12. sortData: true,
    13. async: true,
    14. brushType: 'square',
    15. size: 3,
    16. blur: 1,
    17. },
    18. tooltip: {
    19. padding: '5 10',
    20. fontSize: '11px',
    21. callout: true,
    22. calloutWidth: '10px',
    23. calloutHeight: '6px',
    24. calloutPosition: 'bottom',
    25. },
    26. colorScale: {
    27. aspect: 'gradient',
    28. gradientStops: '0.0 0.4 0.6 0.7 0.8 1.0',
    29. gradientColors: 'rgba(0,0,255,0) #0000ff #00ffff #bfff00 #ffff00 #ff0000',
    30. backgroundColor: null,
    31. alpha: 0.8,
    32. },
    33. shapes: [{
    34. type: 'zingchart.maps',
    35. options: {
    36. id: 'mapmain',
    37. name: 'fra',
    38. scale: true,
    39. zooming: false,
    40. panning: false,
    41. scrolling: false,
    42. style: {
    43. flat: true,
    44. controls: {
    45. visible: false,
    46. },
    47. borderAlpha: 0.1,
    48. borderColor: '#fff',
    49. label: {
    50. overlap: false,
    51. text: '%long-text',
    52. },
    53. hoverState: {
    54. visible: false,
    55. backgroundColor: 'none',
    56. shadowAlpha: 0.2,
    57. shadowDistance: 2,
    58. shadow: true,
    59. shadowColor: '#333',
    60. },
    61. },
    62. },
    63. }, ],
    64. };
    65.  
    66. zingchart.bind('myChart', 'load', function() {
    67. paintHeatmap();
    68. });
    69.  
    70. window.paintHeatmap = function(iMax, bSmallBrush) {
    71. let aData = [];
    72. let iMaxPop = 0;
    73. for (let i = 0; i < FR_POP_2010.length; i++) {
    74. if (iMax && FR_POP_2010[i][2] > iMax) {
    75. continue;
    76. }
    77. let fLon = FR_POP_2010[i][0],
    78. fLat = FR_POP_2010[i][1],
    79. iPop = FR_POP_2010[i][2];
    80. let aXY = zingchart.maps.getXY('mapmain', [fLon, fLat]);
    81. aData.push([aXY[0], aXY[1], iPop]);
    82. iMaxPop = Math.max(iMaxPop, iPop);
    83. }
    84. zingchart.exec('myChart', 'colorscale.update', {
    85. data: {
    86. maxValue: iMaxPop,
    87. },
    88. });
    89. let oCSInfo = zingchart.exec('myChart', 'colorscale.getinfo');
    90. zingchart.exec('myChart', 'heatmap.setdata', {
    91. minValue: 0,
    92. maxValue: oCSInfo.max,
    93. data: aData,
    94. size: bSmallBrush ? 4 : 12,
    95. blur: bSmallBrush ? 0 : 6,
    96. });
    97. };
    98.  
    99. zingchart.bind('myChart', 'heatmap.mousemove', function(oInfo) {
    100. if (oInfo.value !== null) {
    101. zingchart.exec(oInfo.id, 'colorscale.setvalue', {
    102. graphid: oInfo.graphid,
    103. value: oInfo.value,
    104. });
    105. } else {
    106. zingchart.exec(oInfo.id, 'colorscale.clear', {
    107. graphid: oInfo.graphid,
    108. });
    109. }
    110. });
    111.  
    112. document.querySelector('#sc').addEventListener('click', function() {
    113. if (this.checked) {
    114. paintHeatmap(100000, true);
    115. let maxpopRef = document.querySelector('#maxpop');
    116. maxpopRef.value = 100000;
    117. maxpopRef.removeAttribute('disabled');
    118. } else {
    119. paintHeatmap();
    120. let maxpopRef = document.querySelector('#maxpop');
    121. maxpopRef.setAttribute('disabled', 'disabled');
    122. }
    123. });
    124.  
    125. document.querySelector('#maxpop').addEventListener('change', function() {
    126. paintHeatmap(this.value, true);
    127. });
    128.  
    129. zingchart.loadModules('heatmap,color-scale,maps,maps-fra', function() {
    130. zingchart.render({
    131. id: 'myChart',
    132. width: '600px',
    133. height: '600px',
    134. output: 'canvas',
    135. data: chartConfig,
    136. modules: 'heatmap,color-scale',
    137. });
    138. });