Skip to content

Commit adc0cc4

Browse files
committed
feat: add options full to lockStatisticsByDomain
1 parent e87b885 commit adc0cc4

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

packages/vchart/src/data/transforms/dimension-statistics.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export const dimensionStatisticsOfSimpleData = (
143143
if (f.customize) {
144144
result[key][op] = f.customize;
145145
} else {
146-
if (dataFieldInKey && dataFieldInKey.lockStatisticsByDomain && !isNil(dataFieldInKey.domain)) {
146+
if (dataFieldInKey && dataFieldInKey.lockStatisticsByDomain === true && !isNil(dataFieldInKey.domain)) {
147147
if (op === 'values') {
148148
result[key][op] = dataFieldInKey.domain.slice();
149149
return;

packages/vchart/src/series/base/base-series.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ export abstract class BaseSeries<T extends ISeriesSpec> extends BaseModel<T> imp
419419
} else if (this._rawData) {
420420
// 如果有设置统计信息,应当与设置值保持一致
421421
const fieldInfo = this._rawData.getFields()?.[field];
422-
if (fieldInfo && fieldInfo.domain) {
422+
if (fieldInfo && fieldInfo.lockStatisticsByDomain && fieldInfo.domain) {
423423
this._rawStatisticsCache[field] = {};
424424
if (isNumeric) {
425425
this._rawStatisticsCache[field].min = minInArray(fieldInfo.domain);

packages/vchart/src/typings/spec/common.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,18 @@ export type BuildInTransformOptions =
279279
export interface IFieldsMeta {
280280
/** TODO: 字段通用format, 暂时先不支持 */
281281
// format?: (datum: Datum, index: number) => unknown;
282-
/** 字段别名 */
282+
/**
283+
* 字段别名
284+
*/
283285
alias?: string;
284286
/** 字段取值范围 */
285287
domain?: StringOrNumber[];
286-
/** 是否使用 domain 锁定统计信息。默认为 false */
287-
lockStatisticsByDomain?: boolean;
288+
/**
289+
* 是否使用 domain 锁定统计信息。默认为 false
290+
* true - 在图例交互场景,也固定domain
291+
* 当设置为 `onlyFull` 时,仅在初始化的展示完整数据的场景锁定domain,在交互触发的筛选场景不锁定
292+
*/
293+
lockStatisticsByDomain?: boolean | 'onlyFull';
288294
/** 连续型 还是 离散型 */
289295
type?: 'ordinal' | 'linear';
290296
/** 排序顺序 不设置的话当前维度不进行排序 */

0 commit comments

Comments
 (0)