@antv/g2plot
Version:
G2 Plot, a market of plots built with the Grammar of Graphics'
27 lines • 972 B
JavaScript
import * as _ from '@antv/util';
import { getGlobalTheme } from '../../theme/global';
var SINGLE_TYPE = ['line', 'area', 'column', 'bar', 'bubble', 'scatter'];
export function getColorConfig(type, props, count) {
if (props.color) {
return { single: false, color: props.color };
}
var isSingle = isSingleGraph(type, props);
var colors = getGlobalTheme().colors;
if (isSingle && !props.color) {
return { single: true, color: colors[count] };
}
}
/** 判断是不是单图元类型的图表:单折线图、基础柱状图、散点图、基础面积图等 */
export 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;
}
//# sourceMappingURL=adjustColorConfig.js.map