@antv/g2plot
Version:
G2 Plot, a market of plots built with the Grammar of Graphics'
63 lines • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var G2 = tslib_1.__importStar(require("@antv/g2"));
var _ = tslib_1.__importStar(require("@antv/util"));
// import Theme from '../../theme';
var theme_1 = require("../../theme");
var axis_1 = require("../../util/axis");
var theme_2 = require("../../util/responsive/theme");
/**
* 负责图表theme的管理
*/
var G2DefaultTheme = G2.Global.theme;
var ThemeController = /** @class */ (function () {
function ThemeController() {
}
/**
* 获取指定的全局theme
* @param theme
*/
ThemeController.getGlobalTheme = function (theme) {
if (_.isString(theme)) {
return theme_1.getGlobalTheme(theme);
}
return _.deepMix({}, theme_1.getGlobalTheme(), theme);
};
/**
* 通过 theme 和图表类型,获取当前 plot 对应的主题
* @param props
* @param type
*/
ThemeController.prototype.getPlotTheme = function (props, type) {
var theme = props.theme;
if (_.isString(theme)) {
return _.deepMix({}, theme_1.getGlobalTheme(theme), theme_1.getTheme(type));
}
return _.deepMix({}, theme_1.getGlobalTheme(), theme_1.getTheme(type), theme);
};
/**
* 获取转化成 G2 的结构主题
* @param props
* @param type
*/
ThemeController.prototype.getTheme = function (props, type) {
var plotG2Theme = theme_1.convertToG2Theme(this.getPlotTheme(props, type));
var g2Theme = _.deepMix({}, G2DefaultTheme, plotG2Theme);
// this._processVisible(g2Theme);
return g2Theme;
};
ThemeController.prototype.getResponsiveTheme = function (type) {
return theme_2.getResponsiveTheme(type) || theme_2.getResponsiveTheme('default');
};
ThemeController.prototype._processVisible = function (theme) {
axis_1.processAxisVisible(theme.axis.left);
axis_1.processAxisVisible(theme.axis.right);
axis_1.processAxisVisible(theme.axis.top);
axis_1.processAxisVisible(theme.axis.bottom);
return theme;
};
return ThemeController;
}());
exports.default = ThemeController;
//# sourceMappingURL=theme.js.map