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