Skip to content

Commit

Permalink
Merge branch 'master' into venn-interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
visiky authored Oct 15, 2021
2 parents 8b72110 + c369496 commit e82d909
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/plots/venn/adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ export const LEGEND_SPACE = 40;
function colorMap(params: Params<VennOptions>, data: VennData, colorPalette?: string[]) {
const { chart, options } = params;
const { blendMode, setsField } = options;
const { colors10, colors20 } = chart.getTheme();

let palette = colorPalette;
if (!isArray(palette)) {
palette = data.filter((d) => d[setsField].length === 1).length <= 10 ? colors10 : colors20;
}

const map = getColorMap(palette, data, blendMode, setsField);

return (id: string) => map.get(id) || palette[0];
Expand All @@ -44,17 +45,12 @@ function colorMap(params: Params<VennOptions>, data: VennData, colorPalette?: st
* color options 转换
*/
function transformColor(params: Params<VennOptions>, data: VennData): VennOptions['color'] {
const { chart, options } = params;
const { color, setsField, blendMode } = options;
const { options } = params;
const { color } = options;

if (typeof color !== 'function') {
let colorPalette = typeof color === 'string' ? [color] : color;
if (!isArray(colorPalette)) {
const { colors10, colors20 } = chart.getTheme();
colorPalette = data.filter((d) => d[setsField].length === 1).length <= 10 ? colors10 : colors20;
}
const colorMap = getColorMap(colorPalette, data, blendMode, setsField);
return (datum: Datum) => colorMap.get(datum[ID_FIELD]) || colorPalette[0];
const colorPalette = typeof color === 'string' ? [color] : color;
return (datum: Datum) => colorMap(params, data, colorPalette)(datum[ID_FIELD]);
}
return color;
}
Expand Down

0 comments on commit e82d909

Please sign in to comment.