Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions __tests__/unit/adaptor/geometries/base-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ describe('adaptor - geometry', () => {
});
});

it('color with colorField and interval', () => {
const plot = getPlot('interval', {
xField: 'date',
yField: 'value',
colorField: 'type',
mapping: {
color: function () {
return 'red';
},
},
});

expect(plot.chart.geometries[0].type).toBe('interval');
expect(plot.chart.geometries[0].getAttribute('color').getFields()).toEqual(['type', 'date', 'value']);
});

it('size without sizeField', () => {
let p;
const plot = getPlot('interval', {
Expand Down
5 changes: 3 additions & 2 deletions src/adaptor/geometries/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ export function geometry<O extends GeometryOptions>(params: Params<O>): Params<O
if (isString(color)) {
colorField ? geometry.color(colorField, color) : geometry.color(color);
} else if (isFunction(color)) {
// 对于单折线图的特殊处理,如果 x 轴是分类 scale,会导致映射错误
const mappingFields = getMappingField(options, 'color').filter((f: string) => f !== xField);
// 对于单折线图、单面积图的特殊处理,如果 x 轴是分类 scale,会导致映射错误
let mappingFields = getMappingField(options, 'color');
mappingFields = ['line', 'area'].includes(type) ? mappingFields.filter((f: string) => f !== xField) : mappingFields;
geometry.color(mappingFields.join('*'), getMappingFunction(mappingFields, color));
} else {
colorField && geometry.color(colorField, color);
Expand Down
2 changes: 1 addition & 1 deletion src/plots/pie/interaction/pie-statistic-action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Action } from '@antv/g2/lib/interaction';
import { ComponentOption } from '@antv/g2/lib/interface';
import { each, get, isFunction } from '@antv/util';
import { each, get } from '@antv/util';

/**
* Pie 中心文本事件的 Action
Expand Down
1 change: 0 additions & 1 deletion src/plots/tiny-line/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { get } from '@antv/util';
import { Data } from '../../types';

export const DEFAULT_TOOLTIP_OPTIONS = {
showTitle: false,
Expand Down