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