index.js 1.8 KB

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