• 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. colorScale: {
    48. alpha: 0.8,
    49. aspect: 'gradient',
    50. backgroundColor: null,
    51. gradientStops: '0.0 0.4 0.6 0.7 0.8 1.0',
    52. gradientColors: 'rgba(0,0,255,0) #0000ff #00ffff #bfff00 #ffff00 #ff0000',
    53. },
    54. heatmap: {
    55. alpha: 1,
    56. tooltip: {
    57. decimals: 0,
    58. thousandsSeparator: '.',
    59. text: '~ %value people'
    60. },
    61. sortData: true,
    62. async: true,
    63. brushType: 'square',
    64. size: 3,
    65. blur: 1
    66. },
    67. tooltip: {
    68. callout: true,
    69. calloutPosition: 'bottom',
    70. calloutWidth: 10,
    71. calloutHeight: 6,
    72. fontSize: 11,
    73. padding: '5 10',
    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. var aData = [];
    114. var iMaxPop = 0;
    115. for (var i = 0; i < FR_POP_2010.length; i++) {
    116. if (iMax && FR_POP_2010[i][2] > iMax) {
    117. continue;
    118. }
    119. var fLon = FR_POP_2010[i][0],
    120. fLat = FR_POP_2010[i][1],
    121. iPop = FR_POP_2010[i][2];
    122. var 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. var 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.  
    173. zingchart.render({
    174. id: 'myChart',
    175. width: 600,
    176. height: 600,
    177. output: 'canvas',
    178. data: chartConfig,
    179. modules: 'heatmap,color-scale'
    180. });
    181.  
    182. });
    183. </script>
    184. </body>
    185.  
    186. </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. colorScale: {
    6. alpha: 0.8,
    7. aspect: 'gradient',
    8. backgroundColor: null,
    9. gradientStops: '0.0 0.4 0.6 0.7 0.8 1.0',
    10. gradientColors: 'rgba(0,0,255,0) #0000ff #00ffff #bfff00 #ffff00 #ff0000',
    11. },
    12. heatmap: {
    13. alpha: 1,
    14. tooltip: {
    15. decimals: 0,
    16. thousandsSeparator: '.',
    17. text: '~ %value people'
    18. },
    19. sortData: true,
    20. async: true,
    21. brushType: 'square',
    22. size: 3,
    23. blur: 1
    24. },
    25. tooltip: {
    26. callout: true,
    27. calloutPosition: 'bottom',
    28. calloutWidth: 10,
    29. calloutHeight: 6,
    30. fontSize: 11,
    31. padding: '5 10',
    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. var aData = [];
    72. var iMaxPop = 0;
    73. for (var i = 0; i < FR_POP_2010.length; i++) {
    74. if (iMax && FR_POP_2010[i][2] > iMax) {
    75. continue;
    76. }
    77. var fLon = FR_POP_2010[i][0],
    78. fLat = FR_POP_2010[i][1],
    79. iPop = FR_POP_2010[i][2];
    80. var 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. var 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.  
    131. zingchart.render({
    132. id: 'myChart',
    133. width: 600,
    134. height: 600,
    135. output: 'canvas',
    136. data: chartConfig,
    137. modules: 'heatmap,color-scale'
    138. });
    139.  
    140. });