You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

7 years ago
  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));