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