heatmap.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Heatmap = void 0;
  4. const utils_1 = require("./utils");
  5. /**
  6. * Draw heatmap with gradient.
  7. */
  8. const Heatmap = (options) => {
  9. return (index, scale, value, coordinate) => {
  10. const { x: X, y: Y, size: S, color: C } = value;
  11. const P = Array.from(index, (i) => {
  12. // Default size = 40.
  13. const r = S ? +S[i] : 40;
  14. // Warning: x, y, value, radius.
  15. return [...coordinate.map([+X[i], +Y[i]]), C[i], r];
  16. });
  17. return [[0], [P]];
  18. };
  19. };
  20. exports.Heatmap = Heatmap;
  21. const shapes = ['heatmap'];
  22. exports.Heatmap.props = {
  23. defaultShape: 'heatmap',
  24. defaultLabelShape: 'label',
  25. composite: false,
  26. channels: [
  27. ...(0, utils_1.baseGeometryChannels)({ shapes }),
  28. { name: 'x', required: true },
  29. { name: 'y', required: true },
  30. { name: 'color', scale: 'identity', required: true },
  31. { name: 'size' },
  32. ],
  33. preInference: [
  34. ...(0, utils_1.basePreInference)(),
  35. { type: 'maybeZeroY' },
  36. { type: 'maybeZeroX' },
  37. ],
  38. postInference: [...(0, utils_1.basePostInference)(), ...(0, utils_1.tooltip2d)()],
  39. };
  40. //# sourceMappingURL=heatmap.js.map