heatmap.js

https://www.patrick-wied.at/static/heatmapjs
image.png

bizchart热点地图

参考 https://bizcharts.net/product/BizCharts4/demo/361
image.png
二维数组生成数据格式,一列5个,5个为一组进行展示

  1. const data = [
  2. [0, 0, 50],
  3. [0, 1, 79],
  4. [0, 2, 86],
  5. [0, 3, 24],
  6. [0, 4, 67],
  7. [1, 0, 92],
  8. [1, 1, 58],
  9. [1, 2, 78],
  10. [1, 3, 37],
  11. [1, 4, 48],
  12. [2, 0, 35],
  13. [2, 1, 85],
  14. [2, 2, 23],
  15. [2, 3, 64],
  16. [2, 4, 52],
  17. [3, 0, 72],
  18. [3, 1, 32],
  19. [3, 2, 34],
  20. [3, 3, 19],
  21. [3, 4, 16],
  22. [4, 0, 38],
  23. [4, 1, 56],
  24. [4, 2, 88],
  25. [4, 3, 87],
  26. [4, 4, 95],
  27. [5, 0, 88],
  28. [5, 1, 32],
  29. [5, 2, 12],
  30. [5, 3, 69],
  31. [5, 4, 20],
  32. [6, 0, 93],
  33. [6, 1, 44],
  34. [6, 2, 88],
  35. [6, 3, 98],
  36. [6, 4, 96],
  37. [7, 0, 31],
  38. [7, 1, 19],
  39. [7, 2, 82],
  40. [7, 3, 32],
  41. [7, 4, 30],
  42. [8, 0, 85],
  43. [8, 1, 97],
  44. [8, 2, 73],
  45. [8, 3, 64],
  46. [8, 4, 84],
  47. [9, 0, 0],
  48. [9, 1, 0],
  49. [9, 2, 0],
  50. [9, 3, 13],
  51. [9, 4, 32],
  52. ]
  53. // reduce
  54. const source = data.reduce((prev, next) => {
  55. const [name, day, sales] = next
  56. prev = [{name, day, sales}, ...prev] // 倒序
  57. // prev = [...prev, {name, day, sales}] // 正序
  58. return prev
  59. }, [])
  60. // for of 迭代
  61. const source = []
  62. for(const key of data) {
  63. const [name, day, sales] = key
  64. source.push({name, day, sales})
  65. }

热力图数据格式

  1. [
  2. { "name": 0, "day": 0, "sales": 50 },
  3. { "name": 0, "day": 1, "sales": 79 },
  4. { "name": 0, "day": 2, "sales": 86 },
  5. { "name": 0, "day": 3, "sales": 24 },
  6. { "name": 0, "day": 4, "sales": 67 },
  7. { "name": 1, "day": 0, "sales": 92 },
  8. { "name": 1, "day": 1, "sales": 58 },
  9. { "name": 1, "day": 2, "sales": 78 },
  10. { "name": 1, "day": 3, "sales": 37 },
  11. { "name": 1, "day": 4, "sales": 48 },
  12. { "name": 2, "day": 0, "sales": 35 },
  13. { "name": 2, "day": 1, "sales": 85 },
  14. { "name": 2, "day": 2, "sales": 23 },
  15. { "name": 2, "day": 3, "sales": 64 },
  16. { "name": 2, "day": 4, "sales": 52 },
  17. { "name": 3, "day": 0, "sales": 72 },
  18. { "name": 3, "day": 1, "sales": 32 },
  19. { "name": 3, "day": 2, "sales": 34 },
  20. { "name": 3, "day": 3, "sales": 19 },
  21. { "name": 3, "day": 4, "sales": 16 },
  22. { "name": 4, "day": 0, "sales": 38 },
  23. { "name": 4, "day": 1, "sales": 56 },
  24. { "name": 4, "day": 2, "sales": 88 },
  25. { "name": 4, "day": 3, "sales": 87 },
  26. { "name": 4, "day": 4, "sales": 95 },
  27. { "name": 5, "day": 0, "sales": 88 },
  28. { "name": 5, "day": 1, "sales": 32 },
  29. { "name": 5, "day": 2, "sales": 12 },
  30. { "name": 5, "day": 3, "sales": 69 },
  31. { "name": 5, "day": 4, "sales": 20 },
  32. { "name": 6, "day": 0, "sales": 93 },
  33. { "name": 6, "day": 1, "sales": 44 },
  34. { "name": 6, "day": 2, "sales": 88 },
  35. { "name": 6, "day": 3, "sales": 98 },
  36. { "name": 6, "day": 4, "sales": 96 },
  37. { "name": 7, "day": 0, "sales": 31 },
  38. { "name": 7, "day": 1, "sales": 19 },
  39. { "name": 7, "day": 2, "sales": 82 },
  40. { "name": 7, "day": 3, "sales": 32 },
  41. { "name": 7, "day": 4, "sales": 30 },
  42. { "name": 8, "day": 0, "sales": 85 },
  43. { "name": 8, "day": 1, "sales": 97 },
  44. { "name": 8, "day": 2, "sales": 73 },
  45. { "name": 8, "day": 3, "sales": 64 },
  46. { "name": 8, "day": 4, "sales": 84 },
  47. { "name": 9, "day": 0, "sales": 0 },
  48. { "name": 9, "day": 1, "sales": 0 },
  49. { "name": 9, "day": 2, "sales": 0 },
  50. { "name": 9, "day": 3, "sales": 13 },
  51. { "name": 9, "day": 4, "sales": 32 }
  52. ]

echarts热力图