@antv/g2plot
Version:
G2 Plot, a market of plots built with the Grammar of Graphics'
32 lines • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var _ = tslib_1.__importStar(require("@antv/util"));
var global_1 = require("../../theme/global");
var SINGLE_TYPE = ['line', 'area', 'column', 'bar', 'bubble', 'scatter'];
function getColorConfig(type, props, count) {
if (props.color) {
return { single: false, color: props.color };
}
var isSingle = isSingleGraph(type, props);
var colors = global_1.getGlobalTheme().colors;
if (isSingle && !props.color) {
return { single: true, color: colors[count] };
}
}
exports.getColorConfig = getColorConfig;
/** 判断是不是单图元类型的图表:单折线图、基础柱状图、散点图、基础面积图等 */
function isSingleGraph(type, props) {
if (_.contains(SINGLE_TYPE, type)) {
if (type === 'line' && _.has(props, 'seriesField')) {
return false;
}
if (type === 'column' && _.has(props, 'colorField')) {
return false;
}
return true;
}
return false;
}
exports.isSingleGraph = isSingleGraph;
//# sourceMappingURL=adjustColorConfig.js.map