trend.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Trend = void 0;
  4. var tslib_1 = require("tslib");
  5. var group_component_1 = require("../abstract/group-component");
  6. var constant_1 = require("./constant");
  7. var path_1 = require("./path");
  8. var Trend = /** @class */ (function (_super) {
  9. tslib_1.__extends(Trend, _super);
  10. function Trend() {
  11. return _super !== null && _super.apply(this, arguments) || this;
  12. }
  13. Trend.prototype.getDefaultCfg = function () {
  14. var cfg = _super.prototype.getDefaultCfg.call(this);
  15. return tslib_1.__assign(tslib_1.__assign({}, cfg), { name: 'trend', x: 0, y: 0, width: 200, height: 16, smooth: true, isArea: false, data: [], backgroundStyle: constant_1.BACKGROUND_STYLE, lineStyle: constant_1.LINE_STYLE, areaStyle: constant_1.AREA_STYLE });
  16. };
  17. Trend.prototype.renderInner = function (group) {
  18. var _a = this.cfg, width = _a.width, height = _a.height, data = _a.data, smooth = _a.smooth, isArea = _a.isArea, backgroundStyle = _a.backgroundStyle, lineStyle = _a.lineStyle, areaStyle = _a.areaStyle;
  19. // 背景
  20. this.addShape(group, {
  21. id: this.getElementId('background'),
  22. type: 'rect',
  23. attrs: tslib_1.__assign({ x: 0, y: 0, width: width,
  24. height: height }, backgroundStyle),
  25. });
  26. var path = path_1.dataToPath(data, width, height, smooth);
  27. // 线
  28. this.addShape(group, {
  29. id: this.getElementId('line'),
  30. type: 'path',
  31. attrs: tslib_1.__assign({ path: path }, lineStyle),
  32. });
  33. // area
  34. // 在 path 的基础上,增加两个坐标点
  35. if (isArea) {
  36. var areaPath = path_1.linePathToAreaPath(path, width, height, data);
  37. this.addShape(group, {
  38. id: this.getElementId('area'),
  39. type: 'path',
  40. attrs: tslib_1.__assign({ path: areaPath }, areaStyle),
  41. });
  42. }
  43. };
  44. Trend.prototype.applyOffset = function () {
  45. var _a = this.cfg, x = _a.x, y = _a.y;
  46. // 统一移动到对应的位置
  47. this.moveElementTo(this.get('group'), {
  48. x: x,
  49. y: y,
  50. });
  51. };
  52. return Trend;
  53. }(group_component_1.default));
  54. exports.Trend = Trend;
  55. exports.default = Trend;
  56. //# sourceMappingURL=trend.js.map