index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Bar = void 0;
  4. var tslib_1 = require("tslib");
  5. var plot_1 = require("../../core/plot");
  6. var percent_1 = require("../../utils/transform/percent");
  7. var adaptor_1 = require("./adaptor");
  8. var constants_1 = require("./constants");
  9. /**
  10. * 条形图
  11. */
  12. var Bar = /** @class */ (function (_super) {
  13. tslib_1.__extends(Bar, _super);
  14. function Bar() {
  15. var _this = _super !== null && _super.apply(this, arguments) || this;
  16. /** 图表类型 */
  17. _this.type = 'bar';
  18. return _this;
  19. }
  20. /**
  21. * 获取 条形图 默认配置项
  22. * 供外部使用
  23. */
  24. Bar.getDefaultOptions = function () {
  25. return constants_1.DEFAULT_OPTIONS;
  26. };
  27. /**
  28. * @override
  29. */
  30. Bar.prototype.changeData = function (data) {
  31. var _a, _b;
  32. this.updateOption({ data: data });
  33. var _c = this, chart = _c.chart, options = _c.options;
  34. var isPercent = options.isPercent;
  35. var xField = options.xField, yField = options.yField, xAxis = options.xAxis, yAxis = options.yAxis;
  36. _a = [yField, xField], xField = _a[0], yField = _a[1];
  37. _b = [yAxis, xAxis], xAxis = _b[0], yAxis = _b[1];
  38. var switchedFieldOptions = tslib_1.__assign(tslib_1.__assign({}, options), { xField: xField, yField: yField, yAxis: yAxis, xAxis: xAxis });
  39. (0, adaptor_1.meta)({ chart: chart, options: switchedFieldOptions });
  40. chart.changeData((0, percent_1.getDataWhetherPercentage)(data, xField, yField, xField, isPercent));
  41. };
  42. /**
  43. * 获取 条形图 默认配置
  44. */
  45. Bar.prototype.getDefaultOptions = function () {
  46. return Bar.getDefaultOptions();
  47. };
  48. /**
  49. * 获取 条形图 的适配器
  50. */
  51. Bar.prototype.getSchemaAdaptor = function () {
  52. return adaptor_1.adaptor;
  53. };
  54. return Bar;
  55. }(plot_1.Plot));
  56. exports.Bar = Bar;
  57. //# sourceMappingURL=index.js.map