heatmap.src.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. (function (Highcharts) {
  2. var seriesTypes = Highcharts.seriesTypes,
  3. each = Highcharts.each;
  4. seriesTypes.heatmap = Highcharts.extendClass(seriesTypes.map, {
  5. colorKey: 'z',
  6. useMapGeometry: false,
  7. pointArrayMap: ['y', 'z'],
  8. translate: function () {
  9. var series = this,
  10. options = series.options,
  11. dataMin = Number.MAX_VALUE,
  12. dataMax = Number.MIN_VALUE;
  13. series.generatePoints();
  14. each(series.data, function (point) {
  15. var x = point.x,
  16. y = point.y,
  17. value = point.z,
  18. xPad = (options.colsize || 1) / 2,
  19. yPad = (options.rowsize || 1) / 2;
  20. point.path = [
  21. 'M', x - xPad, y - yPad,
  22. 'L', x + xPad, y - yPad,
  23. 'L', x + xPad, y + yPad,
  24. 'L', x - xPad, y + yPad,
  25. 'Z'
  26. ];
  27. point.shapeType = 'path';
  28. point.shapeArgs = {
  29. d: series.translatePath(point.path)
  30. };
  31. if (typeof value === 'number') {
  32. if (value > dataMax) {
  33. dataMax = value;
  34. } else if (value < dataMin) {
  35. dataMin = value;
  36. }
  37. }
  38. });
  39. series.translateColors(dataMin, dataMax);
  40. },
  41. getBox: function () {}
  42. });
  43. }(Highcharts));