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