• 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. cursor: {
    54. type: 'gear3',
    55. size: 10,
    56. backgroundColor: 'red'
    57. },
    58. },
    59. heatmap: {
    60. alpha: 1,
    61. tooltip: {
    62. decimals: 0,
    63. thousandsSeparator: '.',
    64. text: '~ %value people'
    65. },
    66. sortData: true,
    67. async: true,
    68. brushType: 'square',
    69. size: 3,
    70. blur: 1
    71. },
    72. tooltip: {
    73. callout: true,
    74. calloutPosition: 'bottom',
    75. calloutWidth: 10,
    76. calloutHeight: 6,
    77. fontSize: 11,
    78. padding: '5 10',
    79. },
    80. shapes: [{
    81. type: 'zingchart.maps',
    82. options: {
    83. id: 'mapmain',
    84. name: 'fra',
    85. scale: true,
    86. zooming: false,
    87. panning: false,
    88. scrolling: false,
    89. style: {
    90. flat: true,
    91. controls: {
    92. visible: false
    93. },
    94. borderAlpha: 0.1,
    95. borderColor: '#fff',
    96. label: {
    97. overlap: false,
    98. text: '%long-text'
    99. },
    100. hoverState: {
    101. visible: false,
    102. backgroundColor: 'none',
    103. shadowAlpha: 0.2,
    104. shadowDistance: 2,
    105. shadow: true,
    106. shadowColor: '#333'
    107. }
    108. }
    109. }
    110. }]
    111. };
    112.  
    113. zingchart.bind('myChart', 'load', function() {
    114. paintHeatmap();
    115. });
    116.  
    117. window.paintHeatmap = function(iMax, bSmallBrush) {
    118. var aData = [];
    119. var iMaxPop = 0;
    120. for (var i = 0; i < FR_POP_2010.length; i++) {
    121. if (iMax && FR_POP_2010[i][2] > iMax) {
    122. continue;
    123. }
    124. var fLon = FR_POP_2010[i][0],
    125. fLat = FR_POP_2010[i][1],
    126. iPop = FR_POP_2010[i][2];
    127. var aXY = zingchart.maps.getXY('mapmain', [fLon, fLat]);
    128. aData.push([aXY[0], aXY[1], iPop]);
    129. iMaxPop = Math.max(iMaxPop, iPop);
    130. }
    131. zingchart.exec('myChart', 'colorscale.update', {
    132. data: {
    133. maxValue: iMaxPop
    134. }
    135. });
    136. var oCSInfo = zingchart.exec('myChart', 'colorscale.getinfo');
    137. zingchart.exec('myChart', 'heatmap.setdata', {
    138. minValue: 0,
    139. maxValue: oCSInfo.max,
    140. data: aData,
    141. size: bSmallBrush ? 4 : 12,
    142. blur: bSmallBrush ? 0 : 6
    143. });
    144. }
    145.  
    146. zingchart.bind('myChart', 'heatmap.mousemove', function(oInfo) {
    147. if (oInfo.value !== null) {
    148. zingchart.exec(oInfo.id, 'colorscale.setvalue', {
    149. graphid: oInfo.graphid,
    150. value: oInfo.value
    151. });
    152. } else {
    153. zingchart.exec(oInfo.id, 'colorscale.clear', {
    154. graphid: oInfo.graphid
    155. });
    156. }
    157. });
    158.  
    159. document.querySelector('#sc').addEventListener('click', function() {
    160. if (this.checked) {
    161. paintHeatmap(100000, true);
    162. let maxpopRef = document.querySelector('#maxpop');
    163. maxpopRef.value = 100000;
    164. maxpopRef.removeAttribute('disabled')
    165. } else {
    166. paintHeatmap();
    167. let maxpopRef = document.querySelector('#maxpop');
    168. maxpopRef.setAttribute('disabled', 'disabled')
    169. }
    170. });
    171.  
    172. document.querySelector('#maxpop').addEventListener('change', function() {
    173. paintHeatmap(this.value, true);
    174. });
    175.  
    176. zingchart.loadModules('heatmap,color-scale,maps,maps-fra', function() {
    177.  
    178. zingchart.render({
    179. id: 'myChart',
    180. width: '100%',
    181. height: '100%',
    182. output: 'canvas',
    183. data: chartConfig,
    184. modules: 'heatmap,color-scale'
    185. });
    186.  
    187. });
    188. </script>
    189. </body>
    190.  
    191. </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. cursor: {
    12. type: 'gear3',
    13. size: 10,
    14. backgroundColor: 'red'
    15. },
    16. },
    17. heatmap: {
    18. alpha: 1,
    19. tooltip: {
    20. decimals: 0,
    21. thousandsSeparator: '.',
    22. text: '~ %value people'
    23. },
    24. sortData: true,
    25. async: true,
    26. brushType: 'square',
    27. size: 3,
    28. blur: 1
    29. },
    30. tooltip: {
    31. callout: true,
    32. calloutPosition: 'bottom',
    33. calloutWidth: 10,
    34. calloutHeight: 6,
    35. fontSize: 11,
    36. padding: '5 10',
    37. },
    38. shapes: [{
    39. type: 'zingchart.maps',
    40. options: {
    41. id: 'mapmain',
    42. name: 'fra',
    43. scale: true,
    44. zooming: false,
    45. panning: false,
    46. scrolling: false,
    47. style: {
    48. flat: true,
    49. controls: {
    50. visible: false
    51. },
    52. borderAlpha: 0.1,
    53. borderColor: '#fff',
    54. label: {
    55. overlap: false,
    56. text: '%long-text'
    57. },
    58. hoverState: {
    59. visible: false,
    60. backgroundColor: 'none',
    61. shadowAlpha: 0.2,
    62. shadowDistance: 2,
    63. shadow: true,
    64. shadowColor: '#333'
    65. }
    66. }
    67. }
    68. }]
    69. };
    70.  
    71. zingchart.bind('myChart', 'load', function() {
    72. paintHeatmap();
    73. });
    74.  
    75. window.paintHeatmap = function(iMax, bSmallBrush) {
    76. var aData = [];
    77. var iMaxPop = 0;
    78. for (var i = 0; i < FR_POP_2010.length; i++) {
    79. if (iMax && FR_POP_2010[i][2] > iMax) {
    80. continue;
    81. }
    82. var fLon = FR_POP_2010[i][0],
    83. fLat = FR_POP_2010[i][1],
    84. iPop = FR_POP_2010[i][2];
    85. var aXY = zingchart.maps.getXY('mapmain', [fLon, fLat]);
    86. aData.push([aXY[0], aXY[1], iPop]);
    87. iMaxPop = Math.max(iMaxPop, iPop);
    88. }
    89. zingchart.exec('myChart', 'colorscale.update', {
    90. data: {
    91. maxValue: iMaxPop
    92. }
    93. });
    94. var oCSInfo = zingchart.exec('myChart', 'colorscale.getinfo');
    95. zingchart.exec('myChart', 'heatmap.setdata', {
    96. minValue: 0,
    97. maxValue: oCSInfo.max,
    98. data: aData,
    99. size: bSmallBrush ? 4 : 12,
    100. blur: bSmallBrush ? 0 : 6
    101. });
    102. }
    103.  
    104. zingchart.bind('myChart', 'heatmap.mousemove', function(oInfo) {
    105. if (oInfo.value !== null) {
    106. zingchart.exec(oInfo.id, 'colorscale.setvalue', {
    107. graphid: oInfo.graphid,
    108. value: oInfo.value
    109. });
    110. } else {
    111. zingchart.exec(oInfo.id, 'colorscale.clear', {
    112. graphid: oInfo.graphid
    113. });
    114. }
    115. });
    116.  
    117. document.querySelector('#sc').addEventListener('click', function() {
    118. if (this.checked) {
    119. paintHeatmap(100000, true);
    120. let maxpopRef = document.querySelector('#maxpop');
    121. maxpopRef.value = 100000;
    122. maxpopRef.removeAttribute('disabled')
    123. } else {
    124. paintHeatmap();
    125. let maxpopRef = document.querySelector('#maxpop');
    126. maxpopRef.setAttribute('disabled', 'disabled')
    127. }
    128. });
    129.  
    130. document.querySelector('#maxpop').addEventListener('change', function() {
    131. paintHeatmap(this.value, true);
    132. });
    133.  
    134. zingchart.loadModules('heatmap,color-scale,maps,maps-fra', function() {
    135.  
    136. zingchart.render({
    137. id: 'myChart',
    138. width: '100%',
    139. height: '100%',
    140. output: 'canvas',
    141. data: chartConfig,
    142. modules: 'heatmap,color-scale'
    143. });
    144.  
    145. });