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