@visactor/vgrammar-core 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/component/title.d.ts +4 -3
- package/cjs/component/title.js.map +1 -1
- package/cjs/graph/animation/animate.js +5 -3
- package/cjs/graph/animation/animate.js.map +1 -1
- package/cjs/graph/animation/animator.js +2 -1
- package/cjs/graph/animation/animator.js.map +1 -1
- package/cjs/graph/animation/config.js +9 -7
- package/cjs/graph/animation/config.js.map +1 -1
- package/cjs/graph/attributes/line.d.ts +1 -0
- package/cjs/graph/attributes/line.js +11 -3
- package/cjs/graph/attributes/line.js.map +1 -1
- package/cjs/graph/attributes/transform.js +0 -24
- package/cjs/graph/attributes/transform.js.map +1 -1
- package/cjs/graph/constants.d.ts +1 -0
- package/cjs/graph/constants.js +3 -3
- package/cjs/graph/constants.js.map +1 -1
- package/cjs/graph/element.d.ts +1 -1
- package/cjs/graph/element.js +14 -17
- package/cjs/graph/element.js.map +1 -1
- package/cjs/graph/glyph-element.js +2 -3
- package/cjs/graph/glyph-element.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/parse/scale.js +1 -1
- package/cjs/parse/scale.js.map +1 -1
- package/cjs/semantic-marks/interval.js +4 -2
- package/cjs/semantic-marks/interval.js.map +1 -1
- package/cjs/transforms/data/contour.js +2 -1
- package/cjs/transforms/data/contour.js.map +1 -1
- package/cjs/transforms/data/sampling.js +3 -3
- package/cjs/transforms/data/sampling.js.map +1 -1
- package/cjs/transforms/data/unfold.js +2 -2
- package/cjs/transforms/data/unfold.js.map +1 -1
- package/cjs/transforms/mark/symmetry.js +2 -1
- package/cjs/transforms/mark/symmetry.js.map +1 -1
- package/cjs/transforms/util/util.d.ts +0 -2
- package/cjs/transforms/util/util.js +2 -11
- package/cjs/transforms/util/util.js.map +1 -1
- package/cjs/types/animate.d.ts +2 -0
- package/cjs/types/animate.js.map +1 -1
- package/cjs/types/component.d.ts +5 -5
- package/cjs/types/component.js.map +1 -1
- package/cjs/types/grammar.d.ts +2 -1
- package/cjs/types/grammar.js.map +1 -1
- package/cjs/types/mark.d.ts +1 -0
- package/cjs/types/mark.js.map +1 -1
- package/cjs/view/mark.d.ts +3 -1
- package/cjs/view/mark.js +9 -3
- package/cjs/view/mark.js.map +1 -1
- package/es/component/title.d.ts +4 -3
- package/es/component/title.js.map +1 -1
- package/es/graph/animation/animate.js +4 -3
- package/es/graph/animation/animate.js.map +1 -1
- package/es/graph/animation/animator.js +2 -1
- package/es/graph/animation/animator.js.map +1 -1
- package/es/graph/animation/config.js +10 -8
- package/es/graph/animation/config.js.map +1 -1
- package/es/graph/attributes/line.d.ts +1 -0
- package/es/graph/attributes/line.js +8 -1
- package/es/graph/attributes/line.js.map +1 -1
- package/es/graph/attributes/transform.js +0 -24
- package/es/graph/attributes/transform.js.map +1 -1
- package/es/graph/constants.d.ts +1 -0
- package/es/graph/constants.js +2 -0
- package/es/graph/constants.js.map +1 -1
- package/es/graph/element.d.ts +1 -1
- package/es/graph/element.js +15 -18
- package/es/graph/element.js.map +1 -1
- package/es/graph/glyph-element.js +2 -3
- package/es/graph/glyph-element.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interactions/brush-filter.js +2 -1
- package/es/interactions/element-highlight-by-group.js +1 -2
- package/es/interactions/index.js +2 -1
- package/es/interactions/legend-filter.js +1 -1
- package/es/interactions/player-filter.js +1 -1
- package/es/interactions/roll-up.js +1 -1
- package/es/interactions/scrollbar-filter.js +1 -1
- package/es/interactions/slider-filter.js +1 -1
- package/es/interactions/tooltip.js +1 -1
- package/es/interactions/view-drag-mixin.js +1 -1
- package/es/parse/coordinate.js +1 -1
- package/es/parse/event.js +1 -1
- package/es/parse/mark.js +1 -1
- package/es/parse/option.js +1 -1
- package/es/parse/scale.js +3 -4
- package/es/parse/scale.js.map +1 -1
- package/es/parse/transform.js +1 -1
- package/es/parse/util.js +1 -1
- package/es/parse/view.js +1 -1
- package/es/semantic-marks/interval.js +3 -3
- package/es/semantic-marks/interval.js.map +1 -1
- package/es/transforms/data/contour.js +2 -2
- package/es/transforms/data/contour.js.map +1 -1
- package/es/transforms/data/sampling.js +5 -3
- package/es/transforms/data/sampling.js.map +1 -1
- package/es/transforms/data/unfold.js +3 -3
- package/es/transforms/data/unfold.js.map +1 -1
- package/es/transforms/mark/symmetry.js +2 -2
- package/es/transforms/mark/symmetry.js.map +1 -1
- package/es/transforms/util/util.d.ts +0 -2
- package/es/transforms/util/util.js +0 -8
- package/es/transforms/util/util.js.map +1 -1
- package/es/types/animate.d.ts +2 -0
- package/es/types/animate.js.map +1 -1
- package/es/types/component.d.ts +5 -5
- package/es/types/component.js.map +1 -1
- package/es/types/grammar.d.ts +2 -1
- package/es/types/grammar.js.map +1 -1
- package/es/types/mark.d.ts +1 -0
- package/es/types/mark.js.map +1 -1
- package/es/view/mark.d.ts +3 -1
- package/es/view/mark.js +9 -3
- package/es/view/mark.js.map +1 -1
- package/package.json +10 -10
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), aggregateFuncs = {
|
|
8
8
|
sum: arr => arr.reduce(((sum, val) => sum + val), 0),
|
|
9
|
-
min: arr =>
|
|
10
|
-
max: arr =>
|
|
9
|
+
min: arr => (0, vutils_1.minInArray)(arr),
|
|
10
|
+
max: arr => (0, vutils_1.maxInArray)(arr),
|
|
11
11
|
count: arr => arr.length,
|
|
12
12
|
mean: arr => arr.reduce(((sum, val) => sum + val), 0) / arr.length
|
|
13
13
|
}, transform = (options, upstreamData) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transforms/data/unfold.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"sources":["../src/transforms/data/unfold.ts"],"names":[],"mappings":"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","file":"unfold.js","sourcesContent":["import type { UnfoldTransformOptions } from '../../types';\nimport { array, maxInArray, minInArray } from '@visactor/vutils';\n\nconst aggregateFuncs = {\n sum: (arr: number[]) => arr.reduce((sum: number, val: number) => sum + val, 0),\n min: (arr: number[]) => minInArray(arr),\n max: (arr: number[]) => maxInArray(arr),\n count: (arr: number[]) => arr.length,\n mean: (arr: number[]) => arr.reduce((sum: number, val: number) => sum + val, 0) / arr.length\n};\n\nexport const transform = (options: UnfoldTransformOptions, upstreamData: any[]) => {\n if (!upstreamData || !upstreamData.length) {\n return [];\n }\n\n const res: any[] = [];\n const groups = {};\n const keyField = options.keyField;\n const valueField = options.valueField;\n const aggregate = aggregateFuncs[options.aggregateType ?? 'sum'];\n\n if (options.groupBy) {\n const groupByFields = array(options.groupBy);\n upstreamData.forEach((entry: any) => {\n if (!entry) {\n return;\n }\n const datum = {};\n const keys: any[] = [];\n\n groupByFields.forEach((field: string) => {\n datum[field] = entry[field];\n keys.push(entry[field]);\n });\n\n const groupKey = keys.join('~');\n\n if (groups[groupKey]) {\n if (groups[groupKey].values[entry[keyField]]) {\n groups[groupKey].values[entry[keyField]].push(entry[valueField]);\n } else {\n groups[groupKey].values[entry[keyField]] = [entry[valueField]];\n }\n } else {\n groups[groupKey] = { datum, values: { [entry[keyField]]: [entry[valueField]] } };\n }\n });\n } else {\n groups[0] = { datum: {}, values: {} };\n upstreamData.forEach((entry: any) => {\n if (!entry) {\n return;\n }\n\n if (groups[0].values[entry[keyField]]) {\n groups[0].values[entry[keyField]].push(entry[valueField]);\n } else {\n groups[0].values[entry[keyField]] = [entry[valueField]];\n }\n });\n }\n Object.keys(groups).forEach(groupKey => {\n const datum = groups[groupKey].datum;\n const values = groups[groupKey].values;\n\n Object.keys(values).forEach(key => {\n const rows = values[key];\n\n datum[key] = aggregate(rows as number[]);\n });\n\n res.push(datum);\n });\n\n return res;\n};\n"]}
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), symmetryByChannel = (upstreamData, channel, align) => {
|
|
8
8
|
const baseChannel = `${channel}1`, hasRangeValue = upstreamData.some((el => !(0,
|
|
9
|
-
vutils_1.isNil)(el.getItemAttribute(baseChannel)))), middleValues = hasRangeValue ? upstreamData.map((el => (el.getItemAttribute(baseChannel) + el.getItemAttribute(channel)) / 2)) : upstreamData.map((el => el.getItemAttribute(channel))), maxMid = "min" === align ?
|
|
9
|
+
vutils_1.isNil)(el.getItemAttribute(baseChannel)))), middleValues = hasRangeValue ? upstreamData.map((el => (el.getItemAttribute(baseChannel) + el.getItemAttribute(channel)) / 2)) : upstreamData.map((el => el.getItemAttribute(channel))), maxMid = "min" === align ? (0,
|
|
10
|
+
vutils_1.minInArray)(middleValues) : (0, vutils_1.maxInArray)(middleValues);
|
|
10
11
|
return (0, vutils_1.isValidNumber)(maxMid) && upstreamData.forEach(((el, index) => {
|
|
11
12
|
const offset = maxMid - middleValues[index];
|
|
12
13
|
hasRangeValue ? el.setItemAttributes({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transforms/mark/symmetry.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/transforms/mark/symmetry.ts"],"names":[],"mappings":";;;AAAA,6CAAgF;AAGhF,MAAM,iBAAiB,GAAG,CAAC,YAAwB,EAAE,OAAkB,EAAE,KAAqB,EAAE,EAAE;IAChG,MAAM,WAAW,GAAG,GAAG,OAAO,GAAG,CAAC;IAClC,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACxF,MAAM,YAAY,GAAG,aAAa;QAChC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;QAC/F,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,IAAA,mBAAU,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAU,EAAC,YAAY,CAAC,CAAC;IAErF,IAAI,IAAA,sBAAa,EAAC,MAAM,CAAC,EAAE;QACzB,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;YACjC,MAAM,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;YAC5C,IAAI,aAAa,EAAE;gBACjB,EAAE,CAAC,iBAAiB,CAAC;oBACnB,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,MAAM;oBACxD,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,GAAG,MAAM;iBACjD,CAAC,CAAC;aACJ;iBAAM;gBACL,EAAE,CAAC,iBAAiB,CAAC;oBACnB,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,GAAG,MAAM;iBACjD,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAKK,MAAM,QAAQ,GAAG,CAAC,OAAiC,EAAE,YAAwB,EAAE,EAAE;;IACtF,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAA,MAAA,YAAY,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAA,EAAE;QACxE,OAAO,YAAY,CAAC;KACrB;IAED,OAAO,iBAAiB,CAAC,YAAY,EAAE,MAAA,OAAO,CAAC,OAAO,mCAAI,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AAChF,CAAC,CAAC;AANW,QAAA,QAAQ,YAMnB","file":"symmetry.js","sourcesContent":["import { isNil, isValidNumber, maxInArray, minInArray } from '@visactor/vutils';\nimport type { IElement, SymmetryTransformOptions } from '../../types';\n\nconst symmetryByChannel = (upstreamData: IElement[], channel: 'x' | 'y', align?: 'min' | 'max') => {\n const baseChannel = `${channel}1`;\n const hasRangeValue = upstreamData.some(el => !isNil(el.getItemAttribute(baseChannel)));\n const middleValues = hasRangeValue\n ? upstreamData.map(el => (el.getItemAttribute(baseChannel) + el.getItemAttribute(channel)) / 2)\n : upstreamData.map(el => el.getItemAttribute(channel));\n const maxMid = align === 'min' ? minInArray(middleValues) : maxInArray(middleValues);\n\n if (isValidNumber(maxMid)) {\n upstreamData.forEach((el, index) => {\n const offset = maxMid - middleValues[index];\n if (hasRangeValue) {\n el.setItemAttributes({\n [baseChannel]: el.getItemAttribute(baseChannel) + offset,\n [channel]: el.getItemAttribute(channel) + offset\n });\n } else {\n el.setItemAttributes({\n [channel]: el.getItemAttribute(channel) + offset\n });\n }\n });\n }\n\n return upstreamData;\n};\n\n/**\n * 针对mark的symmetry变换,支持x、y方向\n */\nexport const symmetry = (options: SymmetryTransformOptions, upstreamData: IElement[]) => {\n if (!upstreamData || upstreamData.length === 0 || !upstreamData[0]?.mark) {\n return upstreamData;\n }\n\n return symmetryByChannel(upstreamData, options.channel ?? 'y', options.align);\n};\n"]}
|
|
@@ -5,5 +5,3 @@ export declare function normalizeAngle(angle: number): number;
|
|
|
5
5
|
export declare function computeQuadrant(angle: number): 1 | 2 | 3 | 4;
|
|
6
6
|
export declare function sum(arr: any[]): any;
|
|
7
7
|
export declare function average(arr: any[]): number;
|
|
8
|
-
export declare function min(arr: any[]): number;
|
|
9
|
-
export declare function max(arr: any[]): number;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.
|
|
5
|
+
}), exports.average = exports.sum = exports.computeQuadrant = exports.normalizeAngle = exports.partition = exports.fieldNames = void 0;
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), vgrammar_util_1 = require("@visactor/vgrammar-util");
|
|
8
8
|
|
|
@@ -45,15 +45,6 @@ function average(arr) {
|
|
|
45
45
|
return sum(arr) / arr.length;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function min(arr) {
|
|
49
|
-
return Math.min(...arr);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function max(arr) {
|
|
53
|
-
return Math.max(...arr);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
48
|
exports.fieldNames = fieldNames, exports.partition = partition, exports.normalizeAngle = normalizeAngle,
|
|
57
|
-
exports.computeQuadrant = computeQuadrant, exports.sum = sum, exports.average = average
|
|
58
|
-
exports.min = min, exports.max = max;
|
|
49
|
+
exports.computeQuadrant = computeQuadrant, exports.sum = sum, exports.average = average;
|
|
59
50
|
//# sourceMappingURL=util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transforms/util/util.ts"],"names":[],"mappings":"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
|
|
1
|
+
{"version":3,"sources":["../src/transforms/util/util.ts"],"names":[],"mappings":"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","file":"util.js","sourcesContent":["/* Adapted from vega by University of Washington Interactive Data Lab\n * https://vega.github.io/vega/\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/vega/vega/blob/main/packages/vega-transforms/src/util/util.js\n * License: https://github.com/vega/vega/blob/main/LICENSE\n * @license\n */\n\nimport { isNil, isString } from '@visactor/vutils';\nimport type { FieldGetterFunction } from '@visactor/vgrammar-util';\nimport { accessorName } from '@visactor/vgrammar-util';\n\n// use either provided alias or accessor field name\nexport function fieldNames(fields: string[] | FieldGetterFunction[], as?: string[]) {\n if (!fields) {\n return null;\n }\n return fields.map((f, i) => {\n return as[i] ?? (isString(f) ? f : accessorName(f));\n });\n}\n\nexport function partition(data?: any[], groupBy?: FieldGetterFunction[], field?: FieldGetterFunction) {\n // partition data points into groups\n if (isNil(groupBy)) {\n return [data.map(field)];\n }\n\n const groups: any[] = [];\n const map: Record<string, any> = {};\n data.forEach((entry: any) => {\n const groupKey = groupBy.map((groupFunc: (arg: any) => any) => groupFunc(entry)).toString();\n\n if (!map[groupKey]) {\n const groupItem: any[] = [];\n (groupItem as any).dims = groupKey;\n groups.push(groupItem);\n map[groupKey] = groupItem;\n } else {\n map[groupKey].push(field(entry));\n }\n });\n\n return groups;\n}\n\nexport function normalizeAngle(angle: number): number {\n while (angle < 0) {\n angle += Math.PI * 2;\n }\n while (angle >= Math.PI * 2) {\n angle -= Math.PI * 2;\n }\n return angle;\n}\n\nexport function computeQuadrant(angle: number): 1 | 2 | 3 | 4 {\n angle = normalizeAngle(angle);\n if (angle > 0 && angle <= Math.PI / 2) {\n return 2;\n } else if (angle > Math.PI / 2 && angle <= Math.PI) {\n return 3;\n } else if (angle > Math.PI && angle <= (3 * Math.PI) / 2) {\n return 4;\n }\n return 1;\n}\n\nexport function sum(arr: any[]) {\n return arr.reduce((accumulator, currentValue) => accumulator + currentValue, 0);\n}\n\nexport function average(arr: any[]) {\n if (arr.length === 0) {\n return 0;\n }\n const total = sum(arr);\n return total / arr.length;\n}\n"]}
|
package/cjs/types/animate.d.ts
CHANGED
|
@@ -81,6 +81,7 @@ export interface IAnimationTypeConfig {
|
|
|
81
81
|
customParameters?: MarkFunctionValueType<any>;
|
|
82
82
|
easing?: EasingType;
|
|
83
83
|
delay?: MarkFunctionValueType<number>;
|
|
84
|
+
delayAfter?: MarkFunctionValueType<number>;
|
|
84
85
|
duration?: MarkFunctionValueType<number>;
|
|
85
86
|
oneByOne?: MarkFunctionValueType<boolean | number>;
|
|
86
87
|
startTime?: MarkFunctionValueType<number>;
|
|
@@ -104,6 +105,7 @@ export interface IAnimationTimeSlice {
|
|
|
104
105
|
effects: IAnimationEffect | IAnimationEffect[];
|
|
105
106
|
duration?: MarkFunctionValueType<number>;
|
|
106
107
|
delay?: MarkFunctionValueType<number>;
|
|
108
|
+
delayAfter?: MarkFunctionValueType<number>;
|
|
107
109
|
}
|
|
108
110
|
export type IAnimationChannelFunction = (datum: any, element: IElement, parameters: IAnimationParameters) => any;
|
|
109
111
|
export type IAnimationChannelAttrs = Record<string, {
|
package/cjs/types/animate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { IGraphic, ACustomAnimate, EasingType } from '@visactor/vrender-core';\nimport type { IPointLike } from '@visactor/vutils';\nimport type { MarkFunctionCallback, MarkFunctionType } from './mark';\nimport type { IMark } from './grammar';\nimport type { IElement } from './element';\nimport type { FunctionCallback } from './signal';\n\nexport type TypeAnimation<T extends IElement> = (\n element: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nexport interface IClipAnimationOptions {\n clipDimension?: 'x' | 'y' | 'auto' | 'default';\n}\n\nexport interface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IGrowAngleAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n overall?: boolean | number;\n}\n\nexport interface IGrowRadiusAnimationOptions {\n orient?: 'inside' | 'outside';\n overall?: boolean | number;\n}\n\nexport interface IGrowPointsAnimationOptions {\n orient?: 'positive' | 'negative';\n}\n\nexport interface IGrowPointsOverallAnimationOptions extends IGrowPointsAnimationOptions {\n center?: IPointLike;\n}\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n}\n\nexport interface IRotateAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n angle?: number;\n}\n\n/** VGrammar 层提供的图元text上的图形属性,现在暂时会和VRender不一致 */\nexport interface TextItemAttributes {\n fontSize?: number;\n lineHeight?: number;\n font?: string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string | number;\n lineBreak?: string;\n text?: string | string[];\n limit?: number;\n align?: string;\n baseline?: string;\n ellipsis?: string | boolean;\n dir?: string;\n}\n\n/** animation */\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n\n/**\n * state动画,暂时只支持简单配置\n */\nexport interface IStateAnimationConfig {\n duration?: number;\n easing?: EasingType;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n delay?: MarkFunctionValueType<number>;\n duration?: MarkFunctionValueType<number>;\n oneByOne?: MarkFunctionValueType<boolean | number>;\n startTime?: MarkFunctionValueType<number>;\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IElement, elementB: IElement, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\nexport interface IAnimationTimeSlice {\n effects: IAnimationEffect | IAnimationEffect[];\n duration?: MarkFunctionValueType<number>;\n delay?: MarkFunctionValueType<number>;\n}\n\nexport type IAnimationChannelFunction = (datum: any, element: IElement, parameters: IAnimationParameters) => any;\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IElement,\n parameters: IAnimationParameters\n) => boolean | void;\n\n// TODO: fix ACustomAnimate<any>\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n}\n\n/**\n * Animation timeline should be parsed into animation units,\n * which record all necessary configs for animator to execute animation.\n *\n * animation unit time:\n * |<--initialDelay-->| |<--loopDelay--><--Slices--><--looDelayAfter-->| |<--loopDuration-->|\n * |<-----------------loopDuration--------------->|\n */\nexport interface IAnimationUnit {\n /**\n * initial delay time before any animation loop\n */\n initialDelay: number;\n /**\n * total time for one animation loop\n */\n loopDuration: number;\n /**\n * delay time before time slices\n */\n loopDelay: number;\n /**\n * delay time after time slices\n */\n loopDelayAfter: number;\n /**\n * animating time in one animation loop\n */\n loopAnimateDuration: number;\n loopCount: number;\n totalTime: number;\n timeSlices: IAnimationTimeSlice[];\n}\n\nexport interface IAnimationRecord {\n start: IGraphic;\n end: IGraphic;\n changes: any[];\n}\n\nexport interface IAnimationParameters {\n width: number;\n height: number;\n mark: IMark;\n group: IMark | null;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\nexport interface IParsedAnimationConfig {\n state: string;\n timeline: IAnimationTimeline;\n originConfig: IAnimationConfig;\n id: string;\n}\n\nexport interface IParsedAnimationAttrs {\n from?: any;\n to?: any;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: any;\n}\n\n// animate structure\n\nexport interface IAnimatorOptions {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n}\n\nexport interface IAnimator {\n id: number;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean;\n\n /** execute animation */\n animate: (animationParameters: IAnimationParameters, parameters: any) => this;\n /** set animation callback */\n callback: (callbackFunction: (...args: any[]) => void) => this;\n\n // animation control\n stop: (stopState?: 'start' | 'end', invokeCallback?: boolean) => this;\n pause: () => this;\n resume: () => this;\n\n /** set additional initial animation delay */\n startAt: (startTime: number) => this;\n /** get total animation execution time */\n getTotalAnimationTime: () => number;\n\n getEndAttributes: () => Record<string, any>;\n}\n\nexport interface IAnimateArranger {\n // animation control api\n parallel: (arranger: IAnimateArranger) => this;\n after: (arranger: IAnimateArranger) => this;\n\n // internal properties\n afterArranger: IAnimateArranger;\n parallelArrangers: IAnimateArranger[];\n animators: IAnimator[];\n totalTime: number;\n startTime: number;\n endTime: number;\n arrangeTime: () => void;\n}\n\nexport interface IBaseAnimate {\n // animation control\n stop: () => this;\n pause: () => this;\n resume: () => this;\n\n // internal animation process api\n animate: () => this;\n enable: () => this;\n disable: () => this;\n enableAnimationState: (state: string | string[]) => this;\n disableAnimationState: (state: string | string[]) => this;\n isAnimating: () => boolean;\n\n release: () => void;\n}\n\nexport interface IViewAnimate extends IBaseAnimate {\n animateAddition: (mark: IMark) => this;\n}\n\nexport interface IAnimate extends IBaseAnimate {\n mark: IMark;\n\n // additional animation control\n run: (config: IAnimationConfig | IAnimationConfig[]) => IAnimateArranger;\n runAnimationByState: (animationState: string) => IAnimateArranger;\n stopAnimationByState: (animationState: string) => this;\n pauseAnimationByState: (animationState: string) => this;\n resumeAnimationByState: (animationState: string) => this;\n reverse: () => this;\n restart: () => this;\n record: () => this;\n recordEnd: () => this;\n\n // internal animation process api\n getAnimationConfigs: (animationState: string) => IParsedAnimationConfig[];\n updateConfig: (config: Record<string, IAnimationConfig | IAnimationConfig[]>) => void;\n updateState: (state: MarkFunctionType<string> | null) => void;\n isElementAnimating: (element: IElement) => boolean;\n getAnimatorCount: () => number;\n getElementAnimators: (element: IElement | IElement[], animationState?: string) => IAnimator[];\n release: () => void;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { IGraphic, ACustomAnimate, EasingType } from '@visactor/vrender-core';\nimport type { IPointLike } from '@visactor/vutils';\nimport type { MarkFunctionCallback, MarkFunctionType } from './mark';\nimport type { IMark } from './grammar';\nimport type { IElement } from './element';\nimport type { FunctionCallback } from './signal';\n\nexport type TypeAnimation<T extends IElement> = (\n element: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nexport interface IClipAnimationOptions {\n clipDimension?: 'x' | 'y' | 'auto' | 'default';\n}\n\nexport interface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IGrowAngleAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n overall?: boolean | number;\n}\n\nexport interface IGrowRadiusAnimationOptions {\n orient?: 'inside' | 'outside';\n overall?: boolean | number;\n}\n\nexport interface IGrowPointsAnimationOptions {\n orient?: 'positive' | 'negative';\n}\n\nexport interface IGrowPointsOverallAnimationOptions extends IGrowPointsAnimationOptions {\n center?: IPointLike;\n}\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n}\n\nexport interface IRotateAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n angle?: number;\n}\n\n/** VGrammar 层提供的图元text上的图形属性,现在暂时会和VRender不一致 */\nexport interface TextItemAttributes {\n fontSize?: number;\n lineHeight?: number;\n font?: string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string | number;\n lineBreak?: string;\n text?: string | string[];\n limit?: number;\n align?: string;\n baseline?: string;\n ellipsis?: string | boolean;\n dir?: string;\n}\n\n/** animation */\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n\n/**\n * state动画,暂时只支持简单配置\n */\nexport interface IStateAnimationConfig {\n duration?: number;\n easing?: EasingType;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n duration?: MarkFunctionValueType<number>;\n oneByOne?: MarkFunctionValueType<boolean | number>;\n startTime?: MarkFunctionValueType<number>;\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IElement, elementB: IElement, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\nexport interface IAnimationTimeSlice {\n effects: IAnimationEffect | IAnimationEffect[];\n duration?: MarkFunctionValueType<number>;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport type IAnimationChannelFunction = (datum: any, element: IElement, parameters: IAnimationParameters) => any;\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IElement,\n parameters: IAnimationParameters\n) => boolean | void;\n\n// TODO: fix ACustomAnimate<any>\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n}\n\n/**\n * Animation timeline should be parsed into animation units,\n * which record all necessary configs for animator to execute animation.\n *\n * animation unit time:\n * |<--initialDelay-->| |<--loopDelay--><--Slices--><--looDelayAfter-->| |<--loopDuration-->|\n * |<-----------------loopDuration--------------->|\n */\nexport interface IAnimationUnit {\n /**\n * initial delay time before any animation loop\n */\n initialDelay: number;\n /**\n * total time for one animation loop\n */\n loopDuration: number;\n /**\n * delay time before time slices\n */\n loopDelay: number;\n /**\n * delay time after time slices\n */\n loopDelayAfter: number;\n /**\n * animating time in one animation loop\n */\n loopAnimateDuration: number;\n loopCount: number;\n totalTime: number;\n timeSlices: IAnimationTimeSlice[];\n}\n\nexport interface IAnimationRecord {\n start: IGraphic;\n end: IGraphic;\n changes: any[];\n}\n\nexport interface IAnimationParameters {\n width: number;\n height: number;\n mark: IMark;\n group: IMark | null;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\nexport interface IParsedAnimationConfig {\n state: string;\n timeline: IAnimationTimeline;\n originConfig: IAnimationConfig;\n id: string;\n}\n\nexport interface IParsedAnimationAttrs {\n from?: any;\n to?: any;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: any;\n}\n\n// animate structure\n\nexport interface IAnimatorOptions {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n}\n\nexport interface IAnimator {\n id: number;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean;\n\n /** execute animation */\n animate: (animationParameters: IAnimationParameters, parameters: any) => this;\n /** set animation callback */\n callback: (callbackFunction: (...args: any[]) => void) => this;\n\n // animation control\n stop: (stopState?: 'start' | 'end', invokeCallback?: boolean) => this;\n pause: () => this;\n resume: () => this;\n\n /** set additional initial animation delay */\n startAt: (startTime: number) => this;\n /** get total animation execution time */\n getTotalAnimationTime: () => number;\n\n getEndAttributes: () => Record<string, any>;\n}\n\nexport interface IAnimateArranger {\n // animation control api\n parallel: (arranger: IAnimateArranger) => this;\n after: (arranger: IAnimateArranger) => this;\n\n // internal properties\n afterArranger: IAnimateArranger;\n parallelArrangers: IAnimateArranger[];\n animators: IAnimator[];\n totalTime: number;\n startTime: number;\n endTime: number;\n arrangeTime: () => void;\n}\n\nexport interface IBaseAnimate {\n // animation control\n stop: () => this;\n pause: () => this;\n resume: () => this;\n\n // internal animation process api\n animate: () => this;\n enable: () => this;\n disable: () => this;\n enableAnimationState: (state: string | string[]) => this;\n disableAnimationState: (state: string | string[]) => this;\n isAnimating: () => boolean;\n\n release: () => void;\n}\n\nexport interface IViewAnimate extends IBaseAnimate {\n animateAddition: (mark: IMark) => this;\n}\n\nexport interface IAnimate extends IBaseAnimate {\n mark: IMark;\n\n // additional animation control\n run: (config: IAnimationConfig | IAnimationConfig[]) => IAnimateArranger;\n runAnimationByState: (animationState: string) => IAnimateArranger;\n stopAnimationByState: (animationState: string) => this;\n pauseAnimationByState: (animationState: string) => this;\n resumeAnimationByState: (animationState: string) => this;\n reverse: () => this;\n restart: () => this;\n record: () => this;\n recordEnd: () => this;\n\n // internal animation process api\n getAnimationConfigs: (animationState: string) => IParsedAnimationConfig[];\n updateConfig: (config: Record<string, IAnimationConfig | IAnimationConfig[]>) => void;\n updateState: (state: MarkFunctionType<string> | null) => void;\n isElementAnimating: (element: IElement) => boolean;\n getAnimatorCount: () => number;\n getElementAnimators: (element: IElement | IElement[], animationState?: string) => IAnimator[];\n release: () => void;\n}\n"]}
|
package/cjs/types/component.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IGraphicAttribute, ITextAttribute } from '@visactor/vrender-core';
|
|
1
|
+
import type { IGraphicAttribute, IRichTextCharacter, ITextAttribute } from '@visactor/vrender-core';
|
|
2
2
|
import type { AxisBaseAttributes, BaseLabelAttrs, DataLabelAttrs, DataZoomAttributes, Direction, GridBaseAttributes, LegendBaseAttributes, OrientType, PlayerAttributes, ScrollBarAttributes, SliderAttributes, TitleAttrs } from '@visactor/vrender-components';
|
|
3
3
|
import type { AxisEnum, ComponentEnum } from '../graph';
|
|
4
4
|
import type { Nil } from './base';
|
|
@@ -135,13 +135,13 @@ export interface PlayerSpec extends ComponentSpec<Partial<PlayerAttributes>> {
|
|
|
135
135
|
source?: IData | string | any[];
|
|
136
136
|
}
|
|
137
137
|
export interface ITitle extends IComponent {
|
|
138
|
-
title: (text: MarkFunctionType<string | number | number[] | string[]> | Nil) => this;
|
|
139
|
-
subTitle: (text: MarkFunctionType<string | number | number[] | string[]> | Nil) => this;
|
|
138
|
+
title: (text: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]> | Nil) => this;
|
|
139
|
+
subTitle: (text: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]> | Nil) => this;
|
|
140
140
|
}
|
|
141
141
|
export interface TitleSpec extends ComponentSpec<Partial<TitleAttrs>> {
|
|
142
142
|
componentType: ComponentEnum.title;
|
|
143
|
-
title?: MarkFunctionType<string | number | number[] | string[]>;
|
|
144
|
-
subTitle?: MarkFunctionType<string | number | number[] | string[]>;
|
|
143
|
+
title?: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]>;
|
|
144
|
+
subTitle?: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]>;
|
|
145
145
|
}
|
|
146
146
|
export type ScrollbarFilterValue = {
|
|
147
147
|
start?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/component.ts"],"names":[],"mappings":"","file":"component.js","sourcesContent":["import type { IGraphicAttribute, ITextAttribute } from '@visactor/vrender-core';\nimport type {\n AxisBaseAttributes,\n BaseLabelAttrs,\n DataLabelAttrs,\n DataZoomAttributes,\n Direction,\n GridBaseAttributes,\n LegendBaseAttributes,\n OrientType,\n PlayerAttributes,\n ScrollBarAttributes,\n SliderAttributes,\n TitleAttrs\n} from '@visactor/vrender-components';\nimport type { AxisEnum, ComponentEnum } from '../graph';\nimport type { Nil } from './base';\nimport type { IComponent, IData, IGroupMark, IMark, IScale } from './grammar';\nimport type {\n ChannelEncodeType,\n ComponentSpec,\n GenerateBasicEncoderSpec,\n MarkFunctionType,\n ScaleEncodeType\n} from './mark';\nimport type { IView } from './view';\nimport type { IBaseScale } from '@visactor/vscale';\nimport type { SimpleSignalType } from './signal';\n\n// scale component\n\nexport interface IScaleComponent extends IComponent {\n scale: (scale?: IScale | string | Nil) => this;\n\n // internal interface\n getScale: () => IScale;\n}\n\nexport interface ScaleComponentSpec<\n BasicEncoderSpec extends GenerateBasicEncoderSpec<IGraphicAttribute> = GenerateBasicEncoderSpec<IGraphicAttribute>\n> extends ComponentSpec<BasicEncoderSpec> {\n scale?: IScale | string;\n}\n\n// axis component\n\nexport type AxisType = 'line' | 'circle';\n\nexport interface IAxis extends IScaleComponent {\n axisType: (axisType: AxisType | Nil) => this;\n tickCount: (tickCount: SimpleSignalType<number> | Nil) => this;\n inside: (inside: MarkFunctionType<boolean> | Nil) => this;\n baseValue: (baseValue: MarkFunctionType<number> | Nil) => this;\n\n // internal interface\n getAxisComponentType: () => keyof typeof AxisEnum;\n}\n\nexport interface AxisSpec extends ScaleComponentSpec<Partial<AxisBaseAttributes>> {\n componentType: ComponentEnum.axis;\n axisType?: AxisType;\n tickCount?: SimpleSignalType<number>;\n inside?: MarkFunctionType<boolean>;\n baseValue?: MarkFunctionType<number>;\n}\n\n// grid component\n\nexport type GridShape = 'line' | 'circle' | 'polygon';\n\nexport interface IGrid extends IScaleComponent {\n gridType: (gridType: AxisType | Nil) => this;\n gridShape: (gridShape: GridShape | Nil) => this;\n target: (axis: IAxis | string | Nil) => this;\n tickCount: (tickCount: SimpleSignalType<number> | Nil) => this;\n inside: (inside: MarkFunctionType<boolean> | Nil) => this;\n baseValue: (baseValue: MarkFunctionType<number> | Nil) => this;\n}\n\nexport interface GridSpec extends ScaleComponentSpec<Partial<GridBaseAttributes>> {\n componentType: ComponentEnum.grid;\n gridType?: AxisType;\n gridShape?: GridShape;\n target?: IAxis | string;\n tickCount?: MarkFunctionType<number>;\n inside?: MarkFunctionType<boolean>;\n baseValue?: MarkFunctionType<number>;\n}\n\n// legend component\n\nexport type LegendType = 'auto' | 'discrete' | 'color' | 'size';\n\nexport interface ILegend extends IScaleComponent {\n legendType: (legendType: LegendType | Nil) => this;\n\n // immediate functions\n setSelected: (selectedValues: any[]) => this;\n\n // internal interface\n isContinuousLegend: () => boolean;\n}\n\nexport interface LegendSpec extends ScaleComponentSpec<LegendBaseAttributes> {\n componentType: ComponentEnum.legend;\n legendType?: LegendType;\n shapeScale?: IScale | string;\n}\n\n// slider component\n\nexport type SliderFilterValue = { start: number; end: number };\n\nexport interface ISlider extends IComponent {\n min: (min: MarkFunctionType<number> | Nil) => this;\n max: (max: MarkFunctionType<number> | Nil) => this;\n\n // immediate functions\n setStartEndValue: (start?: number, end?: number) => this;\n}\n\nexport interface SliderSpec extends ComponentSpec<Partial<SliderAttributes>> {\n componentType: ComponentEnum.slider;\n min?: MarkFunctionType<number>;\n max?: MarkFunctionType<number>;\n}\n\n// datazoom component\n\nexport type DatazoomFilterValue = { start: number; end: number; startRatio: number; endRatio: number };\n\nexport interface IDatazoom extends IComponent {\n preview: (\n data: IData | string | Nil,\n x: ScaleEncodeType | Nil,\n y: ScaleEncodeType | Nil,\n x1?: ChannelEncodeType | Nil,\n y1?: ChannelEncodeType | Nil\n ) => this;\n\n // immediate functions\n setStartEndValue: (start?: number, end?: number) => this;\n getStartEndValue: () => { start: number; end: number } | Nil;\n\n // internal interface\n invertDatazoomRatio: (ratio: number) => any;\n getDatazoomMainScale: () => IBaseScale;\n}\n\nexport type DataZoomEncoderSpec = GenerateBasicEncoderSpec<Partial<DataZoomAttributes> & { x1?: number; y1?: number }>;\nexport interface DatazoomSpec extends ComponentSpec<DataZoomEncoderSpec> {\n componentType: ComponentEnum.datazoom;\n preview?: {\n data: IData | string;\n x?: ScaleEncodeType;\n y?: ScaleEncodeType;\n x1?: ChannelEncodeType;\n y1?: ChannelEncodeType;\n };\n}\n\n// label component\n\nexport interface ILabel extends IComponent {\n labelStyle: (attributes: MarkFunctionType<Partial<BaseLabelAttrs>>) => this;\n size: (attributes: MarkFunctionType<DataLabelAttrs['size']>) => this;\n target: (mark: IMark | IMark[] | string | string[] | Nil) => this;\n}\n\nexport type LabelEncoderSpec = GenerateBasicEncoderSpec<Partial<BaseLabelAttrs> & { text?: ITextAttribute['text'] }>;\nexport interface LabelSpec extends ComponentSpec<LabelEncoderSpec> {\n componentType: ComponentEnum.label;\n labelStyle?: MarkFunctionType<Partial<BaseLabelAttrs>>;\n size?: MarkFunctionType<DataLabelAttrs['size']>;\n target?: IMark | IMark[] | string | string[];\n}\n\n// player component\n\nexport type PlayerType = 'auto' | 'discrete' | 'continuous';\n\nexport type PlayerFilterValue = { index: number; value: any };\n\nexport interface IPlayer extends IComponent {\n playerType: (playerType: PlayerType) => this;\n source: (source: IData | string | any[] | Nil) => this;\n\n // immediate functions\n play: () => this;\n pause: () => this;\n backward: () => this;\n forward: () => this;\n}\n\nexport interface PlayerSpec extends ComponentSpec<Partial<PlayerAttributes>> {\n componentType: ComponentEnum.player;\n playerType?: PlayerType;\n source?: IData | string | any[];\n}\n\n// title component\n\nexport interface ITitle extends IComponent {\n title: (text: MarkFunctionType<string | number | number[] | string[]> | Nil) => this;\n subTitle: (text: MarkFunctionType<string | number | number[] | string[]> | Nil) => this;\n}\n\nexport interface TitleSpec extends ComponentSpec<Partial<TitleAttrs>> {\n componentType: ComponentEnum.title;\n title?: MarkFunctionType<string | number | number[] | string[]>;\n subTitle?: MarkFunctionType<string | number | number[] | string[]>;\n}\n\n// scrollbar component\n\nexport type ScrollbarFilterValue = { start?: number; end?: number; startRatio: number; endRatio: number };\n\nexport interface IScrollbar extends IScaleComponent {\n container: (container: IGroupMark | string | Nil) => this;\n direction: (direction: MarkFunctionType<Direction> | Nil) => this;\n position: (position: MarkFunctionType<OrientType> | Nil) => this;\n\n // immediate functions\n setScrollStart: (start: number) => this;\n getScrollRange: () => [number, number] | Nil;\n}\n\nexport interface ScrollbarSpec extends ScaleComponentSpec<Partial<ScrollBarAttributes>> {\n componentType: ComponentEnum.scrollbar;\n container?: IGroupMark | string;\n direction?: MarkFunctionType<Direction>;\n position?: MarkFunctionType<OrientType>;\n}\n\n// built-in components\n\nexport type BuiltInComponentSpec =\n | AxisSpec\n | LegendSpec\n | SliderSpec\n | DatazoomSpec\n | LabelSpec\n | PlayerSpec\n | TitleSpec\n | ScrollbarSpec;\n\nexport interface IComponentConstructor {\n readonly componentType: string;\n\n new (view: IView, group?: IGroupMark, mode?: '2d' | '3d'): IComponent;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/component.ts"],"names":[],"mappings":"","file":"component.js","sourcesContent":["import type { IGraphicAttribute, IRichTextCharacter, ITextAttribute } from '@visactor/vrender-core';\nimport type {\n AxisBaseAttributes,\n BaseLabelAttrs,\n DataLabelAttrs,\n DataZoomAttributes,\n Direction,\n GridBaseAttributes,\n LegendBaseAttributes,\n OrientType,\n PlayerAttributes,\n ScrollBarAttributes,\n SliderAttributes,\n TitleAttrs\n} from '@visactor/vrender-components';\nimport type { AxisEnum, ComponentEnum } from '../graph';\nimport type { Nil } from './base';\nimport type { IComponent, IData, IGroupMark, IMark, IScale } from './grammar';\nimport type {\n ChannelEncodeType,\n ComponentSpec,\n GenerateBasicEncoderSpec,\n MarkFunctionType,\n ScaleEncodeType\n} from './mark';\nimport type { IView } from './view';\nimport type { IBaseScale } from '@visactor/vscale';\nimport type { SimpleSignalType } from './signal';\n\n// scale component\n\nexport interface IScaleComponent extends IComponent {\n scale: (scale?: IScale | string | Nil) => this;\n\n // internal interface\n getScale: () => IScale;\n}\n\nexport interface ScaleComponentSpec<\n BasicEncoderSpec extends GenerateBasicEncoderSpec<IGraphicAttribute> = GenerateBasicEncoderSpec<IGraphicAttribute>\n> extends ComponentSpec<BasicEncoderSpec> {\n scale?: IScale | string;\n}\n\n// axis component\n\nexport type AxisType = 'line' | 'circle';\n\nexport interface IAxis extends IScaleComponent {\n axisType: (axisType: AxisType | Nil) => this;\n tickCount: (tickCount: SimpleSignalType<number> | Nil) => this;\n inside: (inside: MarkFunctionType<boolean> | Nil) => this;\n baseValue: (baseValue: MarkFunctionType<number> | Nil) => this;\n\n // internal interface\n getAxisComponentType: () => keyof typeof AxisEnum;\n}\n\nexport interface AxisSpec extends ScaleComponentSpec<Partial<AxisBaseAttributes>> {\n componentType: ComponentEnum.axis;\n axisType?: AxisType;\n tickCount?: SimpleSignalType<number>;\n inside?: MarkFunctionType<boolean>;\n baseValue?: MarkFunctionType<number>;\n}\n\n// grid component\n\nexport type GridShape = 'line' | 'circle' | 'polygon';\n\nexport interface IGrid extends IScaleComponent {\n gridType: (gridType: AxisType | Nil) => this;\n gridShape: (gridShape: GridShape | Nil) => this;\n target: (axis: IAxis | string | Nil) => this;\n tickCount: (tickCount: SimpleSignalType<number> | Nil) => this;\n inside: (inside: MarkFunctionType<boolean> | Nil) => this;\n baseValue: (baseValue: MarkFunctionType<number> | Nil) => this;\n}\n\nexport interface GridSpec extends ScaleComponentSpec<Partial<GridBaseAttributes>> {\n componentType: ComponentEnum.grid;\n gridType?: AxisType;\n gridShape?: GridShape;\n target?: IAxis | string;\n tickCount?: MarkFunctionType<number>;\n inside?: MarkFunctionType<boolean>;\n baseValue?: MarkFunctionType<number>;\n}\n\n// legend component\n\nexport type LegendType = 'auto' | 'discrete' | 'color' | 'size';\n\nexport interface ILegend extends IScaleComponent {\n legendType: (legendType: LegendType | Nil) => this;\n\n // immediate functions\n setSelected: (selectedValues: any[]) => this;\n\n // internal interface\n isContinuousLegend: () => boolean;\n}\n\nexport interface LegendSpec extends ScaleComponentSpec<LegendBaseAttributes> {\n componentType: ComponentEnum.legend;\n legendType?: LegendType;\n shapeScale?: IScale | string;\n}\n\n// slider component\n\nexport type SliderFilterValue = { start: number; end: number };\n\nexport interface ISlider extends IComponent {\n min: (min: MarkFunctionType<number> | Nil) => this;\n max: (max: MarkFunctionType<number> | Nil) => this;\n\n // immediate functions\n setStartEndValue: (start?: number, end?: number) => this;\n}\n\nexport interface SliderSpec extends ComponentSpec<Partial<SliderAttributes>> {\n componentType: ComponentEnum.slider;\n min?: MarkFunctionType<number>;\n max?: MarkFunctionType<number>;\n}\n\n// datazoom component\n\nexport type DatazoomFilterValue = { start: number; end: number; startRatio: number; endRatio: number };\n\nexport interface IDatazoom extends IComponent {\n preview: (\n data: IData | string | Nil,\n x: ScaleEncodeType | Nil,\n y: ScaleEncodeType | Nil,\n x1?: ChannelEncodeType | Nil,\n y1?: ChannelEncodeType | Nil\n ) => this;\n\n // immediate functions\n setStartEndValue: (start?: number, end?: number) => this;\n getStartEndValue: () => { start: number; end: number } | Nil;\n\n // internal interface\n invertDatazoomRatio: (ratio: number) => any;\n getDatazoomMainScale: () => IBaseScale;\n}\n\nexport type DataZoomEncoderSpec = GenerateBasicEncoderSpec<Partial<DataZoomAttributes> & { x1?: number; y1?: number }>;\nexport interface DatazoomSpec extends ComponentSpec<DataZoomEncoderSpec> {\n componentType: ComponentEnum.datazoom;\n preview?: {\n data: IData | string;\n x?: ScaleEncodeType;\n y?: ScaleEncodeType;\n x1?: ChannelEncodeType;\n y1?: ChannelEncodeType;\n };\n}\n\n// label component\n\nexport interface ILabel extends IComponent {\n labelStyle: (attributes: MarkFunctionType<Partial<BaseLabelAttrs>>) => this;\n size: (attributes: MarkFunctionType<DataLabelAttrs['size']>) => this;\n target: (mark: IMark | IMark[] | string | string[] | Nil) => this;\n}\n\nexport type LabelEncoderSpec = GenerateBasicEncoderSpec<Partial<BaseLabelAttrs> & { text?: ITextAttribute['text'] }>;\nexport interface LabelSpec extends ComponentSpec<LabelEncoderSpec> {\n componentType: ComponentEnum.label;\n labelStyle?: MarkFunctionType<Partial<BaseLabelAttrs>>;\n size?: MarkFunctionType<DataLabelAttrs['size']>;\n target?: IMark | IMark[] | string | string[];\n}\n\n// player component\n\nexport type PlayerType = 'auto' | 'discrete' | 'continuous';\n\nexport type PlayerFilterValue = { index: number; value: any };\n\nexport interface IPlayer extends IComponent {\n playerType: (playerType: PlayerType) => this;\n source: (source: IData | string | any[] | Nil) => this;\n\n // immediate functions\n play: () => this;\n pause: () => this;\n backward: () => this;\n forward: () => this;\n}\n\nexport interface PlayerSpec extends ComponentSpec<Partial<PlayerAttributes>> {\n componentType: ComponentEnum.player;\n playerType?: PlayerType;\n source?: IData | string | any[];\n}\n\n// title component\n\nexport interface ITitle extends IComponent {\n title: (text: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]> | Nil) => this;\n subTitle: (text: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]> | Nil) => this;\n}\n\nexport interface TitleSpec extends ComponentSpec<Partial<TitleAttrs>> {\n componentType: ComponentEnum.title;\n title?: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]>;\n subTitle?: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]>;\n}\n\n// scrollbar component\n\nexport type ScrollbarFilterValue = { start?: number; end?: number; startRatio: number; endRatio: number };\n\nexport interface IScrollbar extends IScaleComponent {\n container: (container: IGroupMark | string | Nil) => this;\n direction: (direction: MarkFunctionType<Direction> | Nil) => this;\n position: (position: MarkFunctionType<OrientType> | Nil) => this;\n\n // immediate functions\n setScrollStart: (start: number) => this;\n getScrollRange: () => [number, number] | Nil;\n}\n\nexport interface ScrollbarSpec extends ScaleComponentSpec<Partial<ScrollBarAttributes>> {\n componentType: ComponentEnum.scrollbar;\n container?: IGroupMark | string;\n direction?: MarkFunctionType<Direction>;\n position?: MarkFunctionType<OrientType>;\n}\n\n// built-in components\n\nexport type BuiltInComponentSpec =\n | AxisSpec\n | LegendSpec\n | SliderSpec\n | DatazoomSpec\n | LabelSpec\n | PlayerSpec\n | TitleSpec\n | ScrollbarSpec;\n\nexport interface IComponentConstructor {\n readonly componentType: string;\n\n new (view: IView, group?: IGroupMark, mode?: '2d' | '3d'): IComponent;\n}\n"]}
|
package/cjs/types/grammar.d.ts
CHANGED
|
@@ -128,7 +128,6 @@ export interface IProgressiveGrammar {
|
|
|
128
128
|
export interface IMark extends IGrammarBase, IProgressiveGrammar {
|
|
129
129
|
group?: IGroupMark;
|
|
130
130
|
markType: MarkType;
|
|
131
|
-
context: any;
|
|
132
131
|
coord: ICoordinate;
|
|
133
132
|
disableCoordinateTransform?: boolean;
|
|
134
133
|
elements: IElement[];
|
|
@@ -145,11 +144,13 @@ export interface IMark extends IGrammarBase, IProgressiveGrammar {
|
|
|
145
144
|
animationState: (animationState: MarkFunctionType<string> | Nil) => this;
|
|
146
145
|
layout: (layout: MarkLayoutSpec | MarkLayoutCallback | Nil) => this;
|
|
147
146
|
configure: (config: IMarkConfig | Nil) => this;
|
|
147
|
+
context: (context: any) => this;
|
|
148
148
|
transform: (transform: TransformSpec[] | Nil) => this;
|
|
149
149
|
needAnimate: () => boolean;
|
|
150
150
|
getBounds: () => IBounds;
|
|
151
151
|
isCollectionMark: () => boolean;
|
|
152
152
|
getAllElements: () => IElement[];
|
|
153
|
+
getContext: () => any;
|
|
153
154
|
isUpdated: boolean;
|
|
154
155
|
getGroupGraphicItem: () => any;
|
|
155
156
|
cleanExitElements: () => void;
|
package/cjs/types/grammar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/grammar.ts"],"names":[],"mappings":"","file":"grammar.js","sourcesContent":["import type { EventEmitter, IBounds, IPointLike } from '@visactor/vutils';\nimport type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport type { IBaseScale, ScaleFishEyeOptions, TickData } from '@visactor/vscale';\nimport type { ITransform, TransformSpec } from './transform';\nimport type { DataFormatSpec, IDataFilter } from './data';\nimport type { ParameterFunctionType, SignalFunctionType } from './signal';\nimport type { IAnimate } from './animate';\nimport type { IGlyphMeta } from './glyph';\nimport type { GrammarTypeEnum } from '../graph/enums';\nimport type { Nil } from './base';\nimport type { CoordinateFunctionType } from './coordinate';\nimport type { IElement } from './element';\nimport type {\n MarkFunctionType,\n MarkAnimationSpec,\n MarkType,\n MarkLayoutSpec,\n MarkLayoutCallback,\n MarkSortSpec,\n MarkKeySpec,\n IMarkConfig,\n ChannelEncodeType,\n AttributeTransform,\n BaseSignleEncodeSpec\n} from './mark';\nimport type { ScaleConfigureSpec, ScaleData, ScaleFunctionType, GrammarScaleType, MultiScaleData } from './scale';\nimport type { IView } from './view';\nimport type { BaseEventHandler } from './event';\nimport type { ICartesianCoordinate, IPolarCoordinate } from '@visactor/vgrammar-coordinate';\n\nexport type BuiltInGrammarType = keyof typeof GrammarTypeEnum;\nexport type GrammarType = BuiltInGrammarType | string;\n\n/** 语法元素内置运行的任务 */\nexport interface IGrammarTask extends ITransform {\n /**\n * 参数依赖\n * 只做一级解析\n */\n options?: Record<string, any | IGrammarBase> | (IGrammarBase | any)[];\n /**\n * 依赖的语法元素\n */\n references?: IGrammarBase[];\n /**\n * 是否只支持简单的options配置,不支持在options引用语法元素\n */\n isRawOptions?: boolean;\n}\n\nexport interface GrammarSpec {\n id?: string;\n dependency?: IGrammarBase[] | IGrammarBase | string[] | string;\n}\n\nexport interface IGrammarBase {\n readonly grammarType: GrammarType;\n readonly view: IView;\n readonly uid: number;\n /**\n * 执行的上游节点\n */\n grammarSource: IGrammarBase;\n /**\n * 影响的下游节点\n */\n targets: IGrammarBase[];\n /**\n * 依赖的上游节点,由于不同 spec 配置项中可能引用同一个节点,需要进行计数\n */\n references: Map<IGrammarBase, number>;\n\n depend: (grammar: IGrammarBase[] | IGrammarBase | string[] | string) => this;\n\n addEventListener: (type: string, handler: BaseEventHandler, options?: any) => this;\n removeEventListener: (type: string, handler: BaseEventHandler) => this;\n\n // extended from EventEmitter\n emit: <T extends EventEmitter.EventNames<string | symbol>>(\n event: T,\n ...args: EventEmitter.EventArgs<string | symbol, T>\n ) => boolean;\n emitGrammarEvent: <T extends EventEmitter.EventNames<string | symbol>>(\n event: T,\n ...args: EventEmitter.EventArgs<string | symbol, T>\n ) => boolean;\n\n tasks?: IGrammarTask[];\n // value?: any;\n /** FIXME: operator执行顺序,改造后,dataflow执行元素,应该抽象出来 */\n rank?: number;\n // todo\n set: (value: any) => boolean;\n id: (() => string) & ((id: string) => this);\n name: (() => string) & ((name: string) => this);\n attach: (reference: IGrammarBase | IGrammarBase[], count?: number) => this;\n detach: (reference: IGrammarBase | IGrammarBase[], count?: number) => this;\n detachAll: () => void;\n commit: () => void;\n output: () => any;\n parse: (spec: any) => this;\n parameters: () => { [key: string]: any };\n evaluateSync?: (upstream: any, parameters: any) => this;\n getSpec: () => any;\n reuse: (grammar: IGrammarBase) => this;\n /** clear references */\n clear: () => void;\n /** release all memory storage */\n release: () => void;\n}\n\nexport interface IData extends IGrammarBase {\n values: (values: any | Nil, format?: ParameterFunctionType<DataFormatSpec>, load?: boolean) => this;\n url: (\n url: ParameterFunctionType<string> | Nil,\n format?: ParameterFunctionType<DataFormatSpec>,\n load?: boolean\n ) => this;\n source: (\n source: string | string[] | IData | IData[],\n format?: ParameterFunctionType<DataFormatSpec>,\n load?: boolean\n ) => this;\n transform: (transform: TransformSpec[] | Nil) => this;\n\n // only used in VGrammar\n addDataFilter: (filter: IDataFilter | IDataFilter[]) => this;\n removeDataFilter: (filter: IDataFilter | IDataFilter[]) => this;\n\n // data util methods\n field: (field: string) => any[];\n getValue: () => any[];\n getInput: () => any[];\n getDataIDKey: () => string;\n}\n\n/** 语法元素,TODO */\nexport interface ISignal<T> extends IGrammarBase {\n value: (value: T | Nil) => this;\n update: (update: SignalFunctionType<T> | Nil) => this;\n\n getValue: () => T;\n}\n\n/** 语法元素,TODO */\nexport interface IScale extends IGrammarBase {\n domain: (domain: ScaleFunctionType<any[]> | ScaleData | MultiScaleData | Nil) => this;\n range: (range: ScaleFunctionType<any[]> | ScaleData | MultiScaleData | Nil) => this;\n configure: (config: ScaleConfigureSpec | Nil) => this;\n tickCount: (tickCount: ScaleFunctionType<number> | Nil) => this;\n\n // only used in VGrammar\n getRangeFactor: () => [number, number] | Nil;\n setRangeFactor: (range?: [number, number]) => this;\n getFishEye: () => ScaleFishEyeOptions | Nil;\n setFishEye: (option?: ScaleFishEyeOptions) => this;\n\n // scale util methods\n getScaleType: () => GrammarScaleType;\n getScale: () => IBaseScale;\n ticks: (count?: number) => TickData[];\n getCoordinateAxisPoints: (baseValue?: number) => [IPointLike, IPointLike];\n getCoordinate: () => IPolarCoordinate | ICartesianCoordinate;\n getCoordinateAxisPosition: () => 'top' | 'bottom' | 'left' | 'right' | 'inside' | 'outside' | 'start' | 'end';\n}\n\nexport interface ICoordinate extends IGrammarBase {\n start: (start: CoordinateFunctionType<[number, number]> | Nil) => this;\n end: (end: CoordinateFunctionType<[number, number]> | Nil) => this;\n origin: (origin: CoordinateFunctionType<[number, number]> | Nil) => this;\n\n translate: (offset: CoordinateFunctionType<[number, number]> | Nil) => this;\n rotate: (angle: CoordinateFunctionType<number> | Nil) => this;\n scale: (ratio: CoordinateFunctionType<[number, number]> | Nil) => this;\n transpose: (isTransposed: CoordinateFunctionType<boolean> | Nil) => this;\n\n // coordinate util methods\n}\n\n/** 语法元素,TODO */\n\n/** group mark */\nexport interface IGroupMark extends IMark {\n children: (IMark | IGroupMark | IGlyphMark)[];\n\n layoutChildren?: (IMark | IGroupMark | IGlyphMark)[];\n\n appendChild: (mark: IMark | IGroupMark | IGlyphMark) => this;\n removeChild: (mark: IMark | IGroupMark | IGlyphMark) => this;\n includesChild: (mark: IMark, descendant?: boolean) => boolean;\n\n updateLayoutChildren: () => this;\n}\n\nexport interface IGlyphMark extends IMark {\n glyphType: string;\n getGlyphMeta: () => IGlyphMeta;\n configureGlyph: (config: any) => this;\n getGlyphConfig: () => any;\n}\n\nexport interface IComponent extends IMark {\n componentType: string;\n configureComponent: (config: any) => this;\n}\n\nexport interface IProgressiveGrammar {\n /** 是否启动了增量渲染模式 */\n isProgressive: () => boolean;\n /** 是否正在执行增量渲染 */\n isDoingProgressive: () => boolean;\n /** 清除增量渲染相关状态 */\n clearProgressive: () => void;\n /** 从第一帧开始增量计算 */\n restartProgressive: () => void;\n /** 分片执行 */\n evaluateProgressive: () => void;\n}\n\nexport interface IMark extends IGrammarBase, IProgressiveGrammar {\n group?: IGroupMark;\n\n markType: MarkType;\n context: any;\n coord: ICoordinate;\n /**\n * disable coordinate transform when need\n */\n disableCoordinateTransform?: boolean;\n elements: IElement[];\n elementMap: Map<string, IElement>;\n graphicIndex: number;\n graphicItem?: IGroup;\n animate?: IAnimate;\n\n join: (\n data: IData | string | Nil,\n key?: MarkKeySpec,\n sort?: MarkSortSpec,\n groupBy?: MarkKeySpec,\n groupSort?: MarkSortSpec\n ) => this;\n coordinate: (coordinate: ICoordinate | string | Nil) => this;\n state: (state: MarkFunctionType<string | string[]> | Nil) => this;\n encode: ((encoders: BaseSignleEncodeSpec) => this) & ((channel: string, value: ChannelEncodeType) => this);\n encodeState: ((state: string, channel: string, value: ChannelEncodeType) => this) &\n ((state: string, encoders: BaseSignleEncodeSpec) => this);\n animation: (animationConfig: MarkAnimationSpec | Nil) => this;\n animationState: (animationState: MarkFunctionType<string> | Nil) => this;\n layout: (layout: MarkLayoutSpec | MarkLayoutCallback | Nil) => this;\n configure: (config: IMarkConfig | Nil) => this;\n transform: (transform: TransformSpec[] | Nil) => this;\n\n needAnimate: () => boolean;\n getBounds: () => IBounds;\n isCollectionMark: () => boolean;\n getAllElements: () => IElement[];\n\n // position: () => this;\n // color: () => this;\n // shape: () => this;\n\n // mark 执行流程相关接口\n\n isUpdated: boolean;\n getGroupGraphicItem: () => any;\n cleanExitElements: () => void;\n addGraphicItem: (attrs: any, groupKey?: string) => IGraphic;\n getMorphConfig: () => { morph: boolean; morphKey: string | undefined; morphElementKey: string | undefined };\n prepareRelease: () => void;\n\n layoutBounds?: IBounds;\n relativePosition?: { top?: number; bottom?: number; left?: number; right?: number };\n needLayout: () => boolean;\n handleLayoutEnd: () => void;\n handleRenderEnd: () => void;\n isLargeMode: () => boolean;\n getAttributeTransforms: () => AttributeTransform[];\n\n getScalesByChannel: () => Record<string, IBaseScale> | undefined;\n getFieldsByChannel: () => Record<string, string> | undefined;\n getScales: () => Record<string, IBaseScale> | undefined;\n}\n\nexport interface IGrammarBaseConstructor {\n new (view: IView): IGrammarBase;\n}\n\nexport interface ProgressiveContext {\n currentIndex: number;\n totalStep: number;\n step: number;\n data: any[];\n groupKeys?: string[];\n groupedData?: Map<string, any[]>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/grammar.ts"],"names":[],"mappings":"","file":"grammar.js","sourcesContent":["import type { EventEmitter, IBounds, IPointLike } from '@visactor/vutils';\nimport type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport type { IBaseScale, ScaleFishEyeOptions, TickData } from '@visactor/vscale';\nimport type { ITransform, TransformSpec } from './transform';\nimport type { DataFormatSpec, IDataFilter } from './data';\nimport type { ParameterFunctionType, SignalFunctionType } from './signal';\nimport type { IAnimate } from './animate';\nimport type { IGlyphMeta } from './glyph';\nimport type { GrammarTypeEnum } from '../graph/enums';\nimport type { Nil } from './base';\nimport type { CoordinateFunctionType } from './coordinate';\nimport type { IElement } from './element';\nimport type {\n MarkFunctionType,\n MarkAnimationSpec,\n MarkType,\n MarkLayoutSpec,\n MarkLayoutCallback,\n MarkSortSpec,\n MarkKeySpec,\n IMarkConfig,\n ChannelEncodeType,\n AttributeTransform,\n BaseSignleEncodeSpec\n} from './mark';\nimport type { ScaleConfigureSpec, ScaleData, ScaleFunctionType, GrammarScaleType, MultiScaleData } from './scale';\nimport type { IView } from './view';\nimport type { BaseEventHandler } from './event';\nimport type { ICartesianCoordinate, IPolarCoordinate } from '@visactor/vgrammar-coordinate';\n\nexport type BuiltInGrammarType = keyof typeof GrammarTypeEnum;\nexport type GrammarType = BuiltInGrammarType | string;\n\n/** 语法元素内置运行的任务 */\nexport interface IGrammarTask extends ITransform {\n /**\n * 参数依赖\n * 只做一级解析\n */\n options?: Record<string, any | IGrammarBase> | (IGrammarBase | any)[];\n /**\n * 依赖的语法元素\n */\n references?: IGrammarBase[];\n /**\n * 是否只支持简单的options配置,不支持在options引用语法元素\n */\n isRawOptions?: boolean;\n}\n\nexport interface GrammarSpec {\n id?: string;\n dependency?: IGrammarBase[] | IGrammarBase | string[] | string;\n}\n\nexport interface IGrammarBase {\n readonly grammarType: GrammarType;\n readonly view: IView;\n readonly uid: number;\n /**\n * 执行的上游节点\n */\n grammarSource: IGrammarBase;\n /**\n * 影响的下游节点\n */\n targets: IGrammarBase[];\n /**\n * 依赖的上游节点,由于不同 spec 配置项中可能引用同一个节点,需要进行计数\n */\n references: Map<IGrammarBase, number>;\n\n depend: (grammar: IGrammarBase[] | IGrammarBase | string[] | string) => this;\n\n addEventListener: (type: string, handler: BaseEventHandler, options?: any) => this;\n removeEventListener: (type: string, handler: BaseEventHandler) => this;\n\n // extended from EventEmitter\n emit: <T extends EventEmitter.EventNames<string | symbol>>(\n event: T,\n ...args: EventEmitter.EventArgs<string | symbol, T>\n ) => boolean;\n emitGrammarEvent: <T extends EventEmitter.EventNames<string | symbol>>(\n event: T,\n ...args: EventEmitter.EventArgs<string | symbol, T>\n ) => boolean;\n\n tasks?: IGrammarTask[];\n // value?: any;\n /** FIXME: operator执行顺序,改造后,dataflow执行元素,应该抽象出来 */\n rank?: number;\n // todo\n set: (value: any) => boolean;\n id: (() => string) & ((id: string) => this);\n name: (() => string) & ((name: string) => this);\n attach: (reference: IGrammarBase | IGrammarBase[], count?: number) => this;\n detach: (reference: IGrammarBase | IGrammarBase[], count?: number) => this;\n detachAll: () => void;\n commit: () => void;\n output: () => any;\n parse: (spec: any) => this;\n parameters: () => { [key: string]: any };\n evaluateSync?: (upstream: any, parameters: any) => this;\n getSpec: () => any;\n reuse: (grammar: IGrammarBase) => this;\n /** clear references */\n clear: () => void;\n /** release all memory storage */\n release: () => void;\n}\n\nexport interface IData extends IGrammarBase {\n values: (values: any | Nil, format?: ParameterFunctionType<DataFormatSpec>, load?: boolean) => this;\n url: (\n url: ParameterFunctionType<string> | Nil,\n format?: ParameterFunctionType<DataFormatSpec>,\n load?: boolean\n ) => this;\n source: (\n source: string | string[] | IData | IData[],\n format?: ParameterFunctionType<DataFormatSpec>,\n load?: boolean\n ) => this;\n transform: (transform: TransformSpec[] | Nil) => this;\n\n // only used in VGrammar\n addDataFilter: (filter: IDataFilter | IDataFilter[]) => this;\n removeDataFilter: (filter: IDataFilter | IDataFilter[]) => this;\n\n // data util methods\n field: (field: string) => any[];\n getValue: () => any[];\n getInput: () => any[];\n getDataIDKey: () => string;\n}\n\n/** 语法元素,TODO */\nexport interface ISignal<T> extends IGrammarBase {\n value: (value: T | Nil) => this;\n update: (update: SignalFunctionType<T> | Nil) => this;\n\n getValue: () => T;\n}\n\n/** 语法元素,TODO */\nexport interface IScale extends IGrammarBase {\n domain: (domain: ScaleFunctionType<any[]> | ScaleData | MultiScaleData | Nil) => this;\n range: (range: ScaleFunctionType<any[]> | ScaleData | MultiScaleData | Nil) => this;\n configure: (config: ScaleConfigureSpec | Nil) => this;\n tickCount: (tickCount: ScaleFunctionType<number> | Nil) => this;\n\n // only used in VGrammar\n getRangeFactor: () => [number, number] | Nil;\n setRangeFactor: (range?: [number, number]) => this;\n getFishEye: () => ScaleFishEyeOptions | Nil;\n setFishEye: (option?: ScaleFishEyeOptions) => this;\n\n // scale util methods\n getScaleType: () => GrammarScaleType;\n getScale: () => IBaseScale;\n ticks: (count?: number) => TickData[];\n getCoordinateAxisPoints: (baseValue?: number) => [IPointLike, IPointLike];\n getCoordinate: () => IPolarCoordinate | ICartesianCoordinate;\n getCoordinateAxisPosition: () => 'top' | 'bottom' | 'left' | 'right' | 'inside' | 'outside' | 'start' | 'end';\n}\n\nexport interface ICoordinate extends IGrammarBase {\n start: (start: CoordinateFunctionType<[number, number]> | Nil) => this;\n end: (end: CoordinateFunctionType<[number, number]> | Nil) => this;\n origin: (origin: CoordinateFunctionType<[number, number]> | Nil) => this;\n\n translate: (offset: CoordinateFunctionType<[number, number]> | Nil) => this;\n rotate: (angle: CoordinateFunctionType<number> | Nil) => this;\n scale: (ratio: CoordinateFunctionType<[number, number]> | Nil) => this;\n transpose: (isTransposed: CoordinateFunctionType<boolean> | Nil) => this;\n\n // coordinate util methods\n}\n\n/** 语法元素,TODO */\n\n/** group mark */\nexport interface IGroupMark extends IMark {\n children: (IMark | IGroupMark | IGlyphMark)[];\n\n layoutChildren?: (IMark | IGroupMark | IGlyphMark)[];\n\n appendChild: (mark: IMark | IGroupMark | IGlyphMark) => this;\n removeChild: (mark: IMark | IGroupMark | IGlyphMark) => this;\n includesChild: (mark: IMark, descendant?: boolean) => boolean;\n\n updateLayoutChildren: () => this;\n}\n\nexport interface IGlyphMark extends IMark {\n glyphType: string;\n getGlyphMeta: () => IGlyphMeta;\n configureGlyph: (config: any) => this;\n getGlyphConfig: () => any;\n}\n\nexport interface IComponent extends IMark {\n componentType: string;\n configureComponent: (config: any) => this;\n}\n\nexport interface IProgressiveGrammar {\n /** 是否启动了增量渲染模式 */\n isProgressive: () => boolean;\n /** 是否正在执行增量渲染 */\n isDoingProgressive: () => boolean;\n /** 清除增量渲染相关状态 */\n clearProgressive: () => void;\n /** 从第一帧开始增量计算 */\n restartProgressive: () => void;\n /** 分片执行 */\n evaluateProgressive: () => void;\n}\n\nexport interface IMark extends IGrammarBase, IProgressiveGrammar {\n group?: IGroupMark;\n\n markType: MarkType;\n coord: ICoordinate;\n /**\n * disable coordinate transform when need\n */\n disableCoordinateTransform?: boolean;\n elements: IElement[];\n elementMap: Map<string, IElement>;\n graphicIndex: number;\n graphicItem?: IGroup;\n animate?: IAnimate;\n\n join: (\n data: IData | string | Nil,\n key?: MarkKeySpec,\n sort?: MarkSortSpec,\n groupBy?: MarkKeySpec,\n groupSort?: MarkSortSpec\n ) => this;\n coordinate: (coordinate: ICoordinate | string | Nil) => this;\n state: (state: MarkFunctionType<string | string[]> | Nil) => this;\n encode: ((encoders: BaseSignleEncodeSpec) => this) & ((channel: string, value: ChannelEncodeType) => this);\n encodeState: ((state: string, channel: string, value: ChannelEncodeType) => this) &\n ((state: string, encoders: BaseSignleEncodeSpec) => this);\n animation: (animationConfig: MarkAnimationSpec | Nil) => this;\n animationState: (animationState: MarkFunctionType<string> | Nil) => this;\n layout: (layout: MarkLayoutSpec | MarkLayoutCallback | Nil) => this;\n configure: (config: IMarkConfig | Nil) => this;\n context: (context: any) => this;\n transform: (transform: TransformSpec[] | Nil) => this;\n\n needAnimate: () => boolean;\n getBounds: () => IBounds;\n isCollectionMark: () => boolean;\n getAllElements: () => IElement[];\n getContext: () => any;\n\n // position: () => this;\n // color: () => this;\n // shape: () => this;\n\n // mark 执行流程相关接口\n\n isUpdated: boolean;\n getGroupGraphicItem: () => any;\n cleanExitElements: () => void;\n addGraphicItem: (attrs: any, groupKey?: string) => IGraphic;\n getMorphConfig: () => { morph: boolean; morphKey: string | undefined; morphElementKey: string | undefined };\n prepareRelease: () => void;\n\n layoutBounds?: IBounds;\n relativePosition?: { top?: number; bottom?: number; left?: number; right?: number };\n needLayout: () => boolean;\n handleLayoutEnd: () => void;\n handleRenderEnd: () => void;\n isLargeMode: () => boolean;\n getAttributeTransforms: () => AttributeTransform[];\n\n getScalesByChannel: () => Record<string, IBaseScale> | undefined;\n getFieldsByChannel: () => Record<string, string> | undefined;\n getScales: () => Record<string, IBaseScale> | undefined;\n}\n\nexport interface IGrammarBaseConstructor {\n new (view: IView): IGrammarBase;\n}\n\nexport interface ProgressiveContext {\n currentIndex: number;\n totalStep: number;\n step: number;\n data: any[];\n groupKeys?: string[];\n groupedData?: Map<string, any[]>;\n}\n"]}
|
package/cjs/types/mark.d.ts
CHANGED
|
@@ -139,6 +139,7 @@ export interface IMarkConfig {
|
|
|
139
139
|
morphKey?: string;
|
|
140
140
|
morphElementKey?: string;
|
|
141
141
|
attributeTransforms?: AttributeTransform[];
|
|
142
|
+
enableSegments?: boolean;
|
|
142
143
|
}
|
|
143
144
|
export interface GenerateMarkSpec<T extends MarkType = string, P = any> extends IMarkConfig, GrammarSpec {
|
|
144
145
|
type: T;
|
package/cjs/types/mark.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/mark.ts"],"names":[],"mappings":"","file":"mark.js","sourcesContent":["import type {\n ICustomPath2D,\n IPyramid3dGraphicAttribute,\n IArc3dGraphicAttribute,\n IRect3dGraphicAttribute,\n ISymbolAttribute,\n IRectGraphicAttribute,\n ILineGraphicAttribute,\n ICircleGraphicAttribute,\n IArcGraphicAttribute,\n IPolygonGraphicAttribute,\n IAreaGraphicAttribute,\n IGlyphGraphicAttribute,\n IImageGraphicAttribute,\n IPathGraphicAttribute,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute,\n IGraphicAttribute,\n IGroupGraphicAttribute,\n IRichTextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { Bounds, IPointLike } from '@visactor/vutils';\nimport type { IAnimationConfig, IStateAnimationConfig } from './animate';\nimport type { IElement } from './element';\nimport type { IMark, IScale, IGroupMark, ICoordinate, GrammarSpec, IData } from './grammar';\nimport type { GenericFunctionType } from './signal';\nimport type { TransformSpec } from './transform';\nimport type { CommonPaddingSpec } from './base';\nimport type { ILayoutOptions, IView } from './view';\nimport type {\n AxisSpec,\n BuiltInComponentSpec,\n DatazoomSpec,\n LabelSpec,\n LegendSpec,\n PlayerSpec,\n SliderSpec\n} from './component';\nimport type { GrammarMarkType } from '../graph/enums';\n\nexport type MarkFunctionCallback<T> = (datum: any, element: IElement, parameters: any) => T;\n\nexport type MarkFunctionType<T> = GenericFunctionType<MarkFunctionCallback<T>, T>;\n\nexport type MarkType = keyof typeof GrammarMarkType | string;\n\nexport interface MarkFromSpec {\n data: string | IData;\n transform?: {\n name: string;\n transform?: TransformSpec[];\n };\n}\n\nexport type MarkStateSpec = MarkFunctionType<string | string[]>;\n\nexport type ScaleEncodeType = {\n scale: IScale | string;\n field?: string | ((datum: any) => any) | string[] | ((datum: any) => any)[];\n value?: any;\n band?: number;\n offset?: number;\n};\n\nexport type FieldEncodeType = {\n field: string | ((datum: any) => any) | string[] | ((datum: any) => any)[];\n};\n\nexport type ChannelEncodeType<T = any> = MarkFunctionType<T> | ScaleEncodeType | FieldEncodeType;\n\nexport type GenerateEncoderSpec<T> = {\n [Key in keyof T]?: ChannelEncodeType<T[Key]>;\n};\n\n/**\n * the common channel supported by graphic marks\n */\nexport type GenerateBasicEncoderSpec<T> = Partial<\n Omit<\n T,\n | 'strokeSeg'\n | 'boundsPadding'\n | 'pickMode'\n | 'boundsMode'\n | 'customPickShape'\n | 'pickable'\n | 'childrenPickable'\n | 'visible'\n | 'zIndex'\n | 'layout'\n | 'keepDirIn3d'\n | 'postMatrix'\n | 'anchor'\n | 'anchor3d'\n >\n>;\n\nexport type BasicEncoderSpecMap = {\n rect: GenerateBasicEncoderSpec<IRectGraphicAttribute & { y1?: number; x1?: number }>;\n line: Omit<GenerateBasicEncoderSpec<ILineGraphicAttribute>, 'points' | 'segments'>;\n circle: GenerateBasicEncoderSpec<ICircleGraphicAttribute>;\n arc: GenerateBasicEncoderSpec<IArcGraphicAttribute>;\n polygon: GenerateBasicEncoderSpec<IPolygonGraphicAttribute>;\n arc3d: GenerateBasicEncoderSpec<IArc3dGraphicAttribute>;\n pyramid3d: GenerateBasicEncoderSpec<IPyramid3dGraphicAttribute>;\n area: Omit<GenerateBasicEncoderSpec<IAreaGraphicAttribute>, 'points' | 'segments'>;\n group: GenerateBasicEncoderSpec<IGroupGraphicAttribute>;\n glyph: GenerateBasicEncoderSpec<IGlyphGraphicAttribute & any>;\n image: GenerateBasicEncoderSpec<IImageGraphicAttribute>;\n rect3d: GenerateBasicEncoderSpec<IRect3dGraphicAttribute>;\n path: GenerateBasicEncoderSpec<IPathGraphicAttribute>;\n rule: Omit<GenerateBasicEncoderSpec<ILineGraphicAttribute>, 'points' | 'segments'> & { x1?: number; y1?: number };\n shape: GenerateBasicEncoderSpec<IPathGraphicAttribute>;\n symbol: GenerateBasicEncoderSpec<ISymbolGraphicAttribute> & {\n shape?: ISymbolGraphicAttribute['symbolType'];\n image?: ISymbolGraphicAttribute['background'];\n };\n text: GenerateBasicEncoderSpec<ITextGraphicAttribute> & {\n limit?: number;\n autoLimit?: number;\n };\n richtext: GenerateBasicEncoderSpec<IRichTextGraphicAttribute>;\n interval: Omit<GenerateBasicEncoderSpec<IRectGraphicAttribute>, 'width' | 'height'> & {\n /**\n * the gap for two graphic elements\n */\n innerGap?: number | string;\n /**\n * only used for rect / interval mark\n */\n maxWidth?: number;\n minWidth?: number;\n /** the gap between two category */\n categoryGap?: number | string;\n };\n cell: GenerateBasicEncoderSpec<ISymbolGraphicAttribute> & {\n padding?: number | [number, number];\n shape?: ISymbolAttribute['symbolType'];\n };\n};\nexport type GenerateBaseEncodeSpec<BasicSpec = GenerateBasicEncoderSpec<IGraphicAttribute>> =\n | GenerateEncoderSpec<BasicSpec>\n | MarkFunctionCallback<BasicSpec>;\n\nexport type StateProxyEncodeSpec<T = any> = (datum: any, element: IElement, state: string, nextStates: string[]) => T;\n\nexport type StateEncodeSpec<BasicSpec = GenerateBasicEncoderSpec<IGraphicAttribute>> =\n | {\n enter?: GenerateBaseEncodeSpec<BasicSpec>;\n update?: GenerateBaseEncodeSpec<BasicSpec>;\n exit?: GenerateBaseEncodeSpec<BasicSpec>;\n }\n | {\n [state: string]: GenerateEncoderSpec<BasicSpec> | StateProxyEncodeSpec<BasicSpec>;\n };\n\nexport type MarkAnimationSpec = Record<string, IAnimationConfig | IAnimationConfig[]> & {\n state?: IStateAnimationConfig;\n};\n\n// TODO: support string[]\nexport type MarkKeySpec = string | ((datum: any) => string);\n\nexport type MarkSortSpec = (datumA: any, datumB: any) => number;\n\nexport type MarkStateSortSpec = (stateA: string, stateB: string) => number;\n\nexport interface MarkGridContainerSpec extends MarkBaseLayoutSpec {\n display: 'grid';\n gridTemplateRows?: (number | string | 'auto')[];\n gridTemplateColumns?: (number | string | 'auto')[];\n gridRowGap?: number;\n gridColumnGap?: number;\n}\n\nexport interface MarkGridItemSpec extends MarkBaseLayoutSpec {\n gridRowStart?: number;\n gridRowEnd?: number;\n gridColumnStart?: number;\n gridColumnEnd?: number;\n}\n\nexport interface MarkBaseLayoutSpec {\n callback?: MarkLayoutCallback;\n skipBeforeLayouted?: boolean;\n updateViewSignals?: boolean;\n}\n\nexport interface MarkRelativeItemSpec extends MarkBaseLayoutSpec {\n position?: 'top' | 'bottom' | 'left' | 'right' | 'content' | 'auto' | string;\n padding?: CommonPaddingSpec;\n align?: 'left' | 'right' | 'center' | 'top' | 'bottom' | 'middle';\n order?: number;\n}\n\nexport interface MarkRelativeContainerSpec extends MarkBaseLayoutSpec {\n display: 'relative';\n maxChildWidth?: string | number;\n maxChildHeight?: string | number;\n}\n\nexport type MarkLayoutSpec =\n | MarkGridContainerSpec\n | MarkGridItemSpec\n | MarkRelativeContainerSpec\n | MarkRelativeItemSpec;\n\nexport type MarkLayoutCallback = (\n group: IGroupMark,\n children: IMark[],\n parentLayoutBounds: Bounds,\n options?: ILayoutOptions\n) => void;\n\nexport interface IMarkConfig {\n clip?: boolean;\n zIndex?: number;\n interactive?: boolean;\n context?: any;\n skipTheme?: boolean;\n /**\n * set customized shape\n */\n setCustomizedShape?: (datum: any[], attrs: any, path: ICustomPath2D) => ICustomPath2D;\n /** 是否开启大数据渲染模式 */\n large?: boolean;\n /** 开启大数据渲染优化的阀值,对应的是data的长度 */\n largeThreshold?: number;\n /** 分片长度 */\n progressiveStep?: number;\n /** 开启分片渲染的阀值,对应的是单系列data的长度 */\n progressiveThreshold?: number;\n /**\n * use 'sequential' for symbol chart\n * use 'mod' for bar/line chart\n */\n // largeChunkMode?: 'sequential' | 'mod';\n support3d?: boolean;\n /**\n * enable global morphing animation of the mark\n */\n morph?: boolean;\n /**\n * this key will be used to match the mark to morph\n */\n morphKey?: string;\n /**\n * this key will be used to match the element of two marks to morph\n * If not specified, we'll use the \"key\" of the mark by default\n */\n morphElementKey?: string;\n /** transforms of attributes */\n attributeTransforms?: AttributeTransform[];\n}\n\n/**\n * Base mark specification type\n */\nexport interface GenerateMarkSpec<T extends MarkType = string, P = any> extends IMarkConfig, GrammarSpec {\n type: T;\n name?: string;\n group?: string | IGroupMark;\n // data attributes\n from?: MarkFromSpec;\n key?: MarkKeySpec;\n /**\n * sort all the elements in the mark\n */\n sort?: MarkSortSpec;\n /**\n * set the group key of the mark\n */\n groupBy?: MarkKeySpec;\n /**\n * sort the data of each group\n */\n groupSort?: MarkSortSpec;\n context?: any;\n // coordinate attributes\n coordinate?: string | ICoordinate;\n // encode attributes\n state?: MarkStateSpec;\n stateSort?: MarkStateSortSpec;\n encode?: GetEncoderSpecByType<T, P>;\n // animation attributes\n animationState?: MarkFunctionType<string>;\n animation?: MarkAnimationSpec;\n transform?: TransformSpec[];\n layout?: MarkLayoutSpec | MarkLayoutCallback;\n}\n\nexport type CircleMarkSpec = GenerateMarkSpec<'circle'>;\nexport type ArcMarkSpec = GenerateMarkSpec<'arc'>;\nexport type AreaMarkSpec = GenerateMarkSpec<'area'>;\nexport type LineMarkSpec = GenerateMarkSpec<'line'>;\nexport type RectMarkSpec = GenerateMarkSpec<'rect'>;\nexport type ImageMarkSpec = GenerateMarkSpec<'image'>;\nexport type PathMarkSpec = GenerateMarkSpec<'path'>;\nexport type RuleMarkSpec = GenerateMarkSpec<'rule'>;\nexport type ShapeMarkSpec = GenerateMarkSpec<'shape'>;\nexport type SymbolMarkSpec = GenerateMarkSpec<'symbol'>;\nexport type TextMarkSpec = GenerateMarkSpec<'text'>;\nexport type RichTextMarkSpec = GenerateMarkSpec<'richtext'>;\nexport type PolygonMarkSpec = GenerateMarkSpec<'polygon'>;\nexport type CellMarkSpec = GenerateMarkSpec<'cell'>;\nexport type IntervalMarkSpec = GenerateMarkSpec<'interval'>;\nexport type Arc3dMarkSpec = GenerateMarkSpec<'arc3d'>;\nexport type Pyramid3dMarkSpec = GenerateMarkSpec<'pyramid3d'>;\nexport type Rect3dMarkSpec = GenerateMarkSpec<'rect3d'>;\n\nexport type BasicGlyphEncoderSpec = BasicEncoderSpecMap['glyph'];\nexport type BasicGroupEncoderSpec = BasicEncoderSpecMap['group'];\nexport interface GroupMarkSpec extends GenerateMarkSpec<'group'> {\n marks?: MarkSpec[];\n}\n\nexport interface GlyphMarkSpec<CustomizedEncoderSpec = any> extends GenerateMarkSpec<'glyph', CustomizedEncoderSpec> {\n glyphType: string;\n glyphConfig?: any;\n}\n\nexport interface BoxPlotEncoderSpec extends BasicGlyphEncoderSpec {\n boxWidth?: number;\n boxHeight?: number;\n ruleWidth?: number;\n ruleHeight?: number;\n q1?: number;\n q3?: number;\n min?: number;\n max?: number;\n median?: number;\n angle?: number;\n anchor?: [number, number];\n}\n\nexport interface BarBoxPlotEncoderSpec extends BasicGlyphEncoderSpec {\n minMaxWidth?: number;\n q1q3Width?: number;\n minMaxHeight?: number;\n q1q3Height?: number;\n q1?: number;\n q3?: number;\n min?: number;\n max?: number;\n median?: number;\n angle?: number;\n lineWidth?: number;\n minMaxFillOpacity?: number;\n anchor?: [number, number];\n}\n\nexport interface LinkPathEncoderSpec extends BasicGlyphEncoderSpec {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n thickness: number;\n curvature?: number;\n /** round all the coordinates */\n round?: boolean;\n /** the ratio of normal style path */\n ratio?: number;\n align?: 'start' | 'end' | 'center';\n pathType?: 'line' | 'smooth' | 'polyline';\n endArrow?: boolean;\n startArrow?: boolean;\n backgroundStyle?: any;\n direction?: 'horizontal' | 'vertical' | 'LR' | 'RL' | 'TB' | 'BL' | 'radial';\n}\nexport interface TreePathEncoderSpec extends BasicGlyphEncoderSpec {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n curvature?: number;\n /** round all the coordinates */\n round?: boolean;\n /** the ratio of normal style path */\n align?: 'start' | 'end' | 'center';\n pathType?: 'line' | 'smooth' | 'polyline';\n startArrowStyle?: Partial<IGraphicAttribute>;\n endArrowStyle?: Partial<IGraphicAttribute>;\n endArrow?: boolean;\n startArrow?: boolean;\n arrowSize?: number;\n backgroundStyle?: any;\n direction?: 'horizontal' | 'vertical' | 'LR' | 'RL' | 'TB' | 'BL' | 'radial';\n}\n\nexport interface RipplePointEncoderSpec extends BasicGlyphEncoderSpec {\n ripple?: number;\n size?: number;\n}\n\nexport interface ViolinEncoderSpec extends BasicGlyphEncoderSpec {\n violinFill: string;\n violinStroke: string;\n medianFill?: string;\n density?: IPointLike[];\n boxWidth?: number;\n q1?: number;\n q3?: number;\n min?: number;\n max?: number;\n median?: number;\n angle?: number;\n anchor?: [number, number];\n}\n\nexport interface WaveEncoderSpec extends BasicGlyphEncoderSpec {\n wave?: number;\n}\nexport interface BoxPlotGlyphSpec extends GlyphMarkSpec<BoxPlotEncoderSpec> {\n glyphType: 'boxplot';\n}\nexport interface BarBoxPlotGlyphSpec extends GlyphMarkSpec<BarBoxPlotEncoderSpec> {\n glyphType: 'barBoxplot';\n}\nexport interface LinkPathGlyphSpec extends GlyphMarkSpec<LinkPathEncoderSpec> {\n glyphType: 'linkPath';\n}\nexport interface TreePathGlyphSpec extends GlyphMarkSpec<TreePathEncoderSpec> {\n glyphType: 'treePath';\n}\nexport interface RipplePointGlyphSpec extends GlyphMarkSpec<RipplePointEncoderSpec> {\n glyphType: 'ripplePoint';\n}\nexport interface ViolinGlyphSpec extends GlyphMarkSpec<ViolinEncoderSpec> {\n glyphType: 'violin';\n}\nexport interface WaveGlyphSpec extends GlyphMarkSpec<WaveEncoderSpec> {\n glyphType: 'wave';\n}\n\nexport interface ComponentSpec<\n BasicEncoderSpec extends GenerateBasicEncoderSpec<IGraphicAttribute> = GenerateBasicEncoderSpec<IGraphicAttribute>\n> extends GenerateMarkSpec<'component', BasicEncoderSpec> {\n componentType: string;\n componentConfig?: any;\n mode?: '2d' | '3d';\n}\n\nexport type BaseMarkSpec = GenerateMarkSpec<MarkType>;\nexport type MarkSpecMap = {\n circle: CircleMarkSpec;\n arc: ArcMarkSpec;\n area: AreaMarkSpec;\n image: ImageMarkSpec;\n line: LineMarkSpec;\n path: PathMarkSpec;\n rule: RuleMarkSpec;\n shape: ShapeMarkSpec;\n symbol: SymbolMarkSpec;\n text: TextMarkSpec;\n richtext: RichTextMarkSpec;\n polygon: PolygonMarkSpec;\n cell: CellMarkSpec;\n interval: IntervalMarkSpec;\n rect: RectMarkSpec;\n rect3d: Rect3dMarkSpec;\n arc3d: Arc3dMarkSpec;\n pyramid3d: Pyramid3dMarkSpec;\n group: GroupMarkSpec;\n glyph: GlyphMarkSpec;\n linkPath: LinkPathGlyphSpec;\n treePath: TreePathGlyphSpec;\n wave: WaveEncoderSpec;\n ripplePoint: RipplePointGlyphSpec;\n barBoxplot: BarBoxPlotGlyphSpec;\n boxPlot: BoxPlotGlyphSpec;\n component: ComponentSpec;\n axis: AxisSpec;\n legend: LegendSpec;\n slider: SliderSpec;\n datazoom: DatazoomSpec;\n label: LabelSpec;\n player: PlayerSpec;\n};\n\nexport type GetMarkSpecByType<T, P = any> = T extends keyof MarkSpecMap ? MarkSpecMap[T] : GenerateMarkSpec<string, P>;\nexport type GetBasicEncoderSpecByType<T, P = any> = T extends keyof BasicEncoderSpecMap\n ? BasicEncoderSpecMap[T]\n : GenerateBasicEncoderSpec<IGraphicAttribute & P>;\nexport type GetEncoderSpecByType<T, P = any> = T extends keyof BasicEncoderSpecMap\n ? StateEncodeSpec<BasicEncoderSpecMap[T]>\n : StateEncodeSpec<GenerateBasicEncoderSpec<IGraphicAttribute> & P>;\n\nexport type BaseEncodeSpec<P = any> = StateEncodeSpec<GenerateBasicEncoderSpec<IGraphicAttribute & P>>;\nexport type BaseSignleEncodeSpec<P = any> =\n | GenerateEncoderSpec<GenerateBasicEncoderSpec<IGraphicAttribute & P>>\n | StateProxyEncodeSpec<GenerateBasicEncoderSpec<IGraphicAttribute & P>>;\n\nexport type GetSignleEncodeSpecByType<T, P = any> = T extends keyof BasicEncoderSpecMap\n ? GenerateEncoderSpec<BasicEncoderSpecMap[T]> | StateProxyEncodeSpec<BasicEncoderSpecMap[T]>\n : BaseSignleEncodeSpec<P>;\n\nexport type MarkSpec =\n | GenerateMarkSpec<string, any>\n | CircleMarkSpec\n | ArcMarkSpec\n | AreaMarkSpec\n | ImageMarkSpec\n | LineMarkSpec\n | PathMarkSpec\n | RuleMarkSpec\n | ShapeMarkSpec\n | SymbolMarkSpec\n | TextMarkSpec\n | RichTextMarkSpec\n | PolygonMarkSpec\n | CellMarkSpec\n | IntervalMarkSpec\n | RectMarkSpec\n | Rect3dMarkSpec\n | Arc3dMarkSpec\n | Pyramid3dMarkSpec\n | GroupMarkSpec\n | GlyphMarkSpec\n | LinkPathGlyphSpec\n | TreePathGlyphSpec\n | WaveGlyphSpec\n | RipplePointGlyphSpec\n | BarBoxPlotGlyphSpec\n | BoxPlotGlyphSpec\n | ViolinGlyphSpec\n | ComponentSpec\n | BuiltInComponentSpec;\n\nexport interface AttributeTransform {\n channels: string[];\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => void;\n storedAttrs?: string;\n}\n\nexport interface IMarkConstructor {\n readonly markType: string;\n\n new (view: IView, markType: MarkType, group?: IGroupMark): IMark;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/mark.ts"],"names":[],"mappings":"","file":"mark.js","sourcesContent":["import type {\n ICustomPath2D,\n IPyramid3dGraphicAttribute,\n IArc3dGraphicAttribute,\n IRect3dGraphicAttribute,\n ISymbolAttribute,\n IRectGraphicAttribute,\n ILineGraphicAttribute,\n ICircleGraphicAttribute,\n IArcGraphicAttribute,\n IPolygonGraphicAttribute,\n IAreaGraphicAttribute,\n IGlyphGraphicAttribute,\n IImageGraphicAttribute,\n IPathGraphicAttribute,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute,\n IGraphicAttribute,\n IGroupGraphicAttribute,\n IRichTextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { Bounds, IPointLike } from '@visactor/vutils';\nimport type { IAnimationConfig, IStateAnimationConfig } from './animate';\nimport type { IElement } from './element';\nimport type { IMark, IScale, IGroupMark, ICoordinate, GrammarSpec, IData } from './grammar';\nimport type { GenericFunctionType } from './signal';\nimport type { TransformSpec } from './transform';\nimport type { CommonPaddingSpec } from './base';\nimport type { ILayoutOptions, IView } from './view';\nimport type {\n AxisSpec,\n BuiltInComponentSpec,\n DatazoomSpec,\n LabelSpec,\n LegendSpec,\n PlayerSpec,\n SliderSpec\n} from './component';\nimport type { GrammarMarkType } from '../graph/enums';\n\nexport type MarkFunctionCallback<T> = (datum: any, element: IElement, parameters: any) => T;\n\nexport type MarkFunctionType<T> = GenericFunctionType<MarkFunctionCallback<T>, T>;\n\nexport type MarkType = keyof typeof GrammarMarkType | string;\n\nexport interface MarkFromSpec {\n data: string | IData;\n transform?: {\n name: string;\n transform?: TransformSpec[];\n };\n}\n\nexport type MarkStateSpec = MarkFunctionType<string | string[]>;\n\nexport type ScaleEncodeType = {\n scale: IScale | string;\n field?: string | ((datum: any) => any) | string[] | ((datum: any) => any)[];\n value?: any;\n band?: number;\n offset?: number;\n};\n\nexport type FieldEncodeType = {\n field: string | ((datum: any) => any) | string[] | ((datum: any) => any)[];\n};\n\nexport type ChannelEncodeType<T = any> = MarkFunctionType<T> | ScaleEncodeType | FieldEncodeType;\n\nexport type GenerateEncoderSpec<T> = {\n [Key in keyof T]?: ChannelEncodeType<T[Key]>;\n};\n\n/**\n * the common channel supported by graphic marks\n */\nexport type GenerateBasicEncoderSpec<T> = Partial<\n Omit<\n T,\n | 'strokeSeg'\n | 'boundsPadding'\n | 'pickMode'\n | 'boundsMode'\n | 'customPickShape'\n | 'pickable'\n | 'childrenPickable'\n | 'visible'\n | 'zIndex'\n | 'layout'\n | 'keepDirIn3d'\n | 'postMatrix'\n | 'anchor'\n | 'anchor3d'\n >\n>;\n\nexport type BasicEncoderSpecMap = {\n rect: GenerateBasicEncoderSpec<IRectGraphicAttribute & { y1?: number; x1?: number }>;\n line: Omit<GenerateBasicEncoderSpec<ILineGraphicAttribute>, 'points' | 'segments'>;\n circle: GenerateBasicEncoderSpec<ICircleGraphicAttribute>;\n arc: GenerateBasicEncoderSpec<IArcGraphicAttribute>;\n polygon: GenerateBasicEncoderSpec<IPolygonGraphicAttribute>;\n arc3d: GenerateBasicEncoderSpec<IArc3dGraphicAttribute>;\n pyramid3d: GenerateBasicEncoderSpec<IPyramid3dGraphicAttribute>;\n area: Omit<GenerateBasicEncoderSpec<IAreaGraphicAttribute>, 'points' | 'segments'>;\n group: GenerateBasicEncoderSpec<IGroupGraphicAttribute>;\n glyph: GenerateBasicEncoderSpec<IGlyphGraphicAttribute & any>;\n image: GenerateBasicEncoderSpec<IImageGraphicAttribute>;\n rect3d: GenerateBasicEncoderSpec<IRect3dGraphicAttribute>;\n path: GenerateBasicEncoderSpec<IPathGraphicAttribute>;\n rule: Omit<GenerateBasicEncoderSpec<ILineGraphicAttribute>, 'points' | 'segments'> & { x1?: number; y1?: number };\n shape: GenerateBasicEncoderSpec<IPathGraphicAttribute>;\n symbol: GenerateBasicEncoderSpec<ISymbolGraphicAttribute> & {\n shape?: ISymbolGraphicAttribute['symbolType'];\n image?: ISymbolGraphicAttribute['background'];\n };\n text: GenerateBasicEncoderSpec<ITextGraphicAttribute> & {\n limit?: number;\n autoLimit?: number;\n };\n richtext: GenerateBasicEncoderSpec<IRichTextGraphicAttribute>;\n interval: Omit<GenerateBasicEncoderSpec<IRectGraphicAttribute>, 'width' | 'height'> & {\n /**\n * the gap for two graphic elements\n */\n innerGap?: number | string;\n /**\n * only used for rect / interval mark\n */\n maxWidth?: number;\n minWidth?: number;\n /** the gap between two category */\n categoryGap?: number | string;\n };\n cell: GenerateBasicEncoderSpec<ISymbolGraphicAttribute> & {\n padding?: number | [number, number];\n shape?: ISymbolAttribute['symbolType'];\n };\n};\nexport type GenerateBaseEncodeSpec<BasicSpec = GenerateBasicEncoderSpec<IGraphicAttribute>> =\n | GenerateEncoderSpec<BasicSpec>\n | MarkFunctionCallback<BasicSpec>;\n\nexport type StateProxyEncodeSpec<T = any> = (datum: any, element: IElement, state: string, nextStates: string[]) => T;\n\nexport type StateEncodeSpec<BasicSpec = GenerateBasicEncoderSpec<IGraphicAttribute>> =\n | {\n enter?: GenerateBaseEncodeSpec<BasicSpec>;\n update?: GenerateBaseEncodeSpec<BasicSpec>;\n exit?: GenerateBaseEncodeSpec<BasicSpec>;\n }\n | {\n [state: string]: GenerateEncoderSpec<BasicSpec> | StateProxyEncodeSpec<BasicSpec>;\n };\n\nexport type MarkAnimationSpec = Record<string, IAnimationConfig | IAnimationConfig[]> & {\n state?: IStateAnimationConfig;\n};\n\n// TODO: support string[]\nexport type MarkKeySpec = string | ((datum: any) => string);\n\nexport type MarkSortSpec = (datumA: any, datumB: any) => number;\n\nexport type MarkStateSortSpec = (stateA: string, stateB: string) => number;\n\nexport interface MarkGridContainerSpec extends MarkBaseLayoutSpec {\n display: 'grid';\n gridTemplateRows?: (number | string | 'auto')[];\n gridTemplateColumns?: (number | string | 'auto')[];\n gridRowGap?: number;\n gridColumnGap?: number;\n}\n\nexport interface MarkGridItemSpec extends MarkBaseLayoutSpec {\n gridRowStart?: number;\n gridRowEnd?: number;\n gridColumnStart?: number;\n gridColumnEnd?: number;\n}\n\nexport interface MarkBaseLayoutSpec {\n callback?: MarkLayoutCallback;\n skipBeforeLayouted?: boolean;\n updateViewSignals?: boolean;\n}\n\nexport interface MarkRelativeItemSpec extends MarkBaseLayoutSpec {\n position?: 'top' | 'bottom' | 'left' | 'right' | 'content' | 'auto' | string;\n padding?: CommonPaddingSpec;\n align?: 'left' | 'right' | 'center' | 'top' | 'bottom' | 'middle';\n order?: number;\n}\n\nexport interface MarkRelativeContainerSpec extends MarkBaseLayoutSpec {\n display: 'relative';\n maxChildWidth?: string | number;\n maxChildHeight?: string | number;\n}\n\nexport type MarkLayoutSpec =\n | MarkGridContainerSpec\n | MarkGridItemSpec\n | MarkRelativeContainerSpec\n | MarkRelativeItemSpec;\n\nexport type MarkLayoutCallback = (\n group: IGroupMark,\n children: IMark[],\n parentLayoutBounds: Bounds,\n options?: ILayoutOptions\n) => void;\n\nexport interface IMarkConfig {\n clip?: boolean;\n zIndex?: number;\n interactive?: boolean;\n context?: any;\n skipTheme?: boolean;\n /**\n * set customized shape\n */\n setCustomizedShape?: (datum: any[], attrs: any, path: ICustomPath2D) => ICustomPath2D;\n /** 是否开启大数据渲染模式 */\n large?: boolean;\n /** 开启大数据渲染优化的阀值,对应的是data的长度 */\n largeThreshold?: number;\n /** 分片长度 */\n progressiveStep?: number;\n /** 开启分片渲染的阀值,对应的是单系列data的长度 */\n progressiveThreshold?: number;\n /**\n * use 'sequential' for symbol chart\n * use 'mod' for bar/line chart\n */\n // largeChunkMode?: 'sequential' | 'mod';\n support3d?: boolean;\n /**\n * enable global morphing animation of the mark\n */\n morph?: boolean;\n /**\n * this key will be used to match the mark to morph\n */\n morphKey?: string;\n /**\n * this key will be used to match the element of two marks to morph\n * If not specified, we'll use the \"key\" of the mark by default\n */\n morphElementKey?: string;\n /** transforms of attributes */\n attributeTransforms?: AttributeTransform[];\n /**\n * only used in line/area mark\n * TODO\n */\n enableSegments?: boolean;\n}\n\n/**\n * Base mark specification type\n */\nexport interface GenerateMarkSpec<T extends MarkType = string, P = any> extends IMarkConfig, GrammarSpec {\n type: T;\n name?: string;\n group?: string | IGroupMark;\n // data attributes\n from?: MarkFromSpec;\n key?: MarkKeySpec;\n /**\n * sort all the elements in the mark\n */\n sort?: MarkSortSpec;\n /**\n * set the group key of the mark\n */\n groupBy?: MarkKeySpec;\n /**\n * sort the data of each group\n */\n groupSort?: MarkSortSpec;\n context?: any;\n // coordinate attributes\n coordinate?: string | ICoordinate;\n // encode attributes\n state?: MarkStateSpec;\n stateSort?: MarkStateSortSpec;\n encode?: GetEncoderSpecByType<T, P>;\n // animation attributes\n animationState?: MarkFunctionType<string>;\n animation?: MarkAnimationSpec;\n transform?: TransformSpec[];\n layout?: MarkLayoutSpec | MarkLayoutCallback;\n}\n\nexport type CircleMarkSpec = GenerateMarkSpec<'circle'>;\nexport type ArcMarkSpec = GenerateMarkSpec<'arc'>;\nexport type AreaMarkSpec = GenerateMarkSpec<'area'>;\nexport type LineMarkSpec = GenerateMarkSpec<'line'>;\nexport type RectMarkSpec = GenerateMarkSpec<'rect'>;\nexport type ImageMarkSpec = GenerateMarkSpec<'image'>;\nexport type PathMarkSpec = GenerateMarkSpec<'path'>;\nexport type RuleMarkSpec = GenerateMarkSpec<'rule'>;\nexport type ShapeMarkSpec = GenerateMarkSpec<'shape'>;\nexport type SymbolMarkSpec = GenerateMarkSpec<'symbol'>;\nexport type TextMarkSpec = GenerateMarkSpec<'text'>;\nexport type RichTextMarkSpec = GenerateMarkSpec<'richtext'>;\nexport type PolygonMarkSpec = GenerateMarkSpec<'polygon'>;\nexport type CellMarkSpec = GenerateMarkSpec<'cell'>;\nexport type IntervalMarkSpec = GenerateMarkSpec<'interval'>;\nexport type Arc3dMarkSpec = GenerateMarkSpec<'arc3d'>;\nexport type Pyramid3dMarkSpec = GenerateMarkSpec<'pyramid3d'>;\nexport type Rect3dMarkSpec = GenerateMarkSpec<'rect3d'>;\n\nexport type BasicGlyphEncoderSpec = BasicEncoderSpecMap['glyph'];\nexport type BasicGroupEncoderSpec = BasicEncoderSpecMap['group'];\nexport interface GroupMarkSpec extends GenerateMarkSpec<'group'> {\n marks?: MarkSpec[];\n}\n\nexport interface GlyphMarkSpec<CustomizedEncoderSpec = any> extends GenerateMarkSpec<'glyph', CustomizedEncoderSpec> {\n glyphType: string;\n glyphConfig?: any;\n}\n\nexport interface BoxPlotEncoderSpec extends BasicGlyphEncoderSpec {\n boxWidth?: number;\n boxHeight?: number;\n ruleWidth?: number;\n ruleHeight?: number;\n q1?: number;\n q3?: number;\n min?: number;\n max?: number;\n median?: number;\n angle?: number;\n anchor?: [number, number];\n}\n\nexport interface BarBoxPlotEncoderSpec extends BasicGlyphEncoderSpec {\n minMaxWidth?: number;\n q1q3Width?: number;\n minMaxHeight?: number;\n q1q3Height?: number;\n q1?: number;\n q3?: number;\n min?: number;\n max?: number;\n median?: number;\n angle?: number;\n lineWidth?: number;\n minMaxFillOpacity?: number;\n anchor?: [number, number];\n}\n\nexport interface LinkPathEncoderSpec extends BasicGlyphEncoderSpec {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n thickness: number;\n curvature?: number;\n /** round all the coordinates */\n round?: boolean;\n /** the ratio of normal style path */\n ratio?: number;\n align?: 'start' | 'end' | 'center';\n pathType?: 'line' | 'smooth' | 'polyline';\n endArrow?: boolean;\n startArrow?: boolean;\n backgroundStyle?: any;\n direction?: 'horizontal' | 'vertical' | 'LR' | 'RL' | 'TB' | 'BL' | 'radial';\n}\nexport interface TreePathEncoderSpec extends BasicGlyphEncoderSpec {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n curvature?: number;\n /** round all the coordinates */\n round?: boolean;\n /** the ratio of normal style path */\n align?: 'start' | 'end' | 'center';\n pathType?: 'line' | 'smooth' | 'polyline';\n startArrowStyle?: Partial<IGraphicAttribute>;\n endArrowStyle?: Partial<IGraphicAttribute>;\n endArrow?: boolean;\n startArrow?: boolean;\n arrowSize?: number;\n backgroundStyle?: any;\n direction?: 'horizontal' | 'vertical' | 'LR' | 'RL' | 'TB' | 'BL' | 'radial';\n}\n\nexport interface RipplePointEncoderSpec extends BasicGlyphEncoderSpec {\n ripple?: number;\n size?: number;\n}\n\nexport interface ViolinEncoderSpec extends BasicGlyphEncoderSpec {\n violinFill: string;\n violinStroke: string;\n medianFill?: string;\n density?: IPointLike[];\n boxWidth?: number;\n q1?: number;\n q3?: number;\n min?: number;\n max?: number;\n median?: number;\n angle?: number;\n anchor?: [number, number];\n}\n\nexport interface WaveEncoderSpec extends BasicGlyphEncoderSpec {\n wave?: number;\n}\nexport interface BoxPlotGlyphSpec extends GlyphMarkSpec<BoxPlotEncoderSpec> {\n glyphType: 'boxplot';\n}\nexport interface BarBoxPlotGlyphSpec extends GlyphMarkSpec<BarBoxPlotEncoderSpec> {\n glyphType: 'barBoxplot';\n}\nexport interface LinkPathGlyphSpec extends GlyphMarkSpec<LinkPathEncoderSpec> {\n glyphType: 'linkPath';\n}\nexport interface TreePathGlyphSpec extends GlyphMarkSpec<TreePathEncoderSpec> {\n glyphType: 'treePath';\n}\nexport interface RipplePointGlyphSpec extends GlyphMarkSpec<RipplePointEncoderSpec> {\n glyphType: 'ripplePoint';\n}\nexport interface ViolinGlyphSpec extends GlyphMarkSpec<ViolinEncoderSpec> {\n glyphType: 'violin';\n}\nexport interface WaveGlyphSpec extends GlyphMarkSpec<WaveEncoderSpec> {\n glyphType: 'wave';\n}\n\nexport interface ComponentSpec<\n BasicEncoderSpec extends GenerateBasicEncoderSpec<IGraphicAttribute> = GenerateBasicEncoderSpec<IGraphicAttribute>\n> extends GenerateMarkSpec<'component', BasicEncoderSpec> {\n componentType: string;\n componentConfig?: any;\n mode?: '2d' | '3d';\n}\n\nexport type BaseMarkSpec = GenerateMarkSpec<MarkType>;\nexport type MarkSpecMap = {\n circle: CircleMarkSpec;\n arc: ArcMarkSpec;\n area: AreaMarkSpec;\n image: ImageMarkSpec;\n line: LineMarkSpec;\n path: PathMarkSpec;\n rule: RuleMarkSpec;\n shape: ShapeMarkSpec;\n symbol: SymbolMarkSpec;\n text: TextMarkSpec;\n richtext: RichTextMarkSpec;\n polygon: PolygonMarkSpec;\n cell: CellMarkSpec;\n interval: IntervalMarkSpec;\n rect: RectMarkSpec;\n rect3d: Rect3dMarkSpec;\n arc3d: Arc3dMarkSpec;\n pyramid3d: Pyramid3dMarkSpec;\n group: GroupMarkSpec;\n glyph: GlyphMarkSpec;\n linkPath: LinkPathGlyphSpec;\n treePath: TreePathGlyphSpec;\n wave: WaveEncoderSpec;\n ripplePoint: RipplePointGlyphSpec;\n barBoxplot: BarBoxPlotGlyphSpec;\n boxPlot: BoxPlotGlyphSpec;\n component: ComponentSpec;\n axis: AxisSpec;\n legend: LegendSpec;\n slider: SliderSpec;\n datazoom: DatazoomSpec;\n label: LabelSpec;\n player: PlayerSpec;\n};\n\nexport type GetMarkSpecByType<T, P = any> = T extends keyof MarkSpecMap ? MarkSpecMap[T] : GenerateMarkSpec<string, P>;\nexport type GetBasicEncoderSpecByType<T, P = any> = T extends keyof BasicEncoderSpecMap\n ? BasicEncoderSpecMap[T]\n : GenerateBasicEncoderSpec<IGraphicAttribute & P>;\nexport type GetEncoderSpecByType<T, P = any> = T extends keyof BasicEncoderSpecMap\n ? StateEncodeSpec<BasicEncoderSpecMap[T]>\n : StateEncodeSpec<GenerateBasicEncoderSpec<IGraphicAttribute> & P>;\n\nexport type BaseEncodeSpec<P = any> = StateEncodeSpec<GenerateBasicEncoderSpec<IGraphicAttribute & P>>;\nexport type BaseSignleEncodeSpec<P = any> =\n | GenerateEncoderSpec<GenerateBasicEncoderSpec<IGraphicAttribute & P>>\n | StateProxyEncodeSpec<GenerateBasicEncoderSpec<IGraphicAttribute & P>>;\n\nexport type GetSignleEncodeSpecByType<T, P = any> = T extends keyof BasicEncoderSpecMap\n ? GenerateEncoderSpec<BasicEncoderSpecMap[T]> | StateProxyEncodeSpec<BasicEncoderSpecMap[T]>\n : BaseSignleEncodeSpec<P>;\n\nexport type MarkSpec =\n | GenerateMarkSpec<string, any>\n | CircleMarkSpec\n | ArcMarkSpec\n | AreaMarkSpec\n | ImageMarkSpec\n | LineMarkSpec\n | PathMarkSpec\n | RuleMarkSpec\n | ShapeMarkSpec\n | SymbolMarkSpec\n | TextMarkSpec\n | RichTextMarkSpec\n | PolygonMarkSpec\n | CellMarkSpec\n | IntervalMarkSpec\n | RectMarkSpec\n | Rect3dMarkSpec\n | Arc3dMarkSpec\n | Pyramid3dMarkSpec\n | GroupMarkSpec\n | GlyphMarkSpec\n | LinkPathGlyphSpec\n | TreePathGlyphSpec\n | WaveGlyphSpec\n | RipplePointGlyphSpec\n | BarBoxPlotGlyphSpec\n | BoxPlotGlyphSpec\n | ViolinGlyphSpec\n | ComponentSpec\n | BuiltInComponentSpec;\n\nexport interface AttributeTransform {\n channels: string[];\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => void;\n storedAttrs?: string;\n}\n\nexport interface IMarkConstructor {\n readonly markType: string;\n\n new (view: IView, markType: MarkType, group?: IGroupMark): IMark;\n}\n"]}
|
package/cjs/view/mark.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export declare class Mark extends GrammarBase implements IMark {
|
|
|
10
10
|
coord: ICoordinate;
|
|
11
11
|
disableCoordinateTransform: boolean;
|
|
12
12
|
markType: MarkType;
|
|
13
|
-
context: any;
|
|
14
13
|
group: IGroupMark | undefined;
|
|
15
14
|
graphicItem?: IGroup;
|
|
16
15
|
graphicIndex: number;
|
|
@@ -20,6 +19,7 @@ export declare class Mark extends GrammarBase implements IMark {
|
|
|
20
19
|
isUpdated: boolean;
|
|
21
20
|
private _groupKeys;
|
|
22
21
|
private _isReentered;
|
|
22
|
+
private _context;
|
|
23
23
|
private renderContext?;
|
|
24
24
|
animate: IAnimate;
|
|
25
25
|
protected differ: Differ<any>;
|
|
@@ -55,6 +55,7 @@ export declare class Mark extends GrammarBase implements IMark {
|
|
|
55
55
|
morph(enableMorph: boolean, morphKey?: string, morphElementKey?: string): this;
|
|
56
56
|
transform(transforms: TransformSpec[] | Nil): this;
|
|
57
57
|
configure(config: IMarkConfig | Nil): this;
|
|
58
|
+
context(context: any): this;
|
|
58
59
|
isCollectionMark(): boolean;
|
|
59
60
|
needAnimate(): boolean;
|
|
60
61
|
getAllElements(): IElement[];
|
|
@@ -103,6 +104,7 @@ export declare class Mark extends GrammarBase implements IMark {
|
|
|
103
104
|
morphElementKey: string;
|
|
104
105
|
};
|
|
105
106
|
getAttributeTransforms(): import("../types").AttributeTransform[];
|
|
107
|
+
getContext(): any;
|
|
106
108
|
protected needSkipBeforeLayout(): boolean;
|
|
107
109
|
private initEvent;
|
|
108
110
|
private releaseEvent;
|
package/cjs/view/mark.js
CHANGED
|
@@ -78,7 +78,7 @@ class Mark extends grammar_base_1.GrammarBase {
|
|
|
78
78
|
return this.markType = mark.markType, this.coord = mark.coord, this.elementMap = mark.elementMap,
|
|
79
79
|
this.elements = mark.elements, this.elementMap.forEach((element => element.mark = this)),
|
|
80
80
|
this.differ = mark.differ, this.animate = mark.animate, this.animate.mark = this,
|
|
81
|
-
this.
|
|
81
|
+
this._context = mark._context, this.graphicItem = mark.graphicItem, this.graphicIndex = mark.graphicIndex,
|
|
82
82
|
this.graphicParent = mark.graphicParent, this.needClear = mark.needClear, this.isUpdated = mark.isUpdated,
|
|
83
83
|
this;
|
|
84
84
|
}
|
|
@@ -194,13 +194,16 @@ class Mark extends grammar_base_1.GrammarBase {
|
|
|
194
194
|
this.spec.transform = transforms, this.commit(), this;
|
|
195
195
|
}
|
|
196
196
|
configure(config) {
|
|
197
|
-
const keys = [ "clip", "zIndex", "interactive", "context", "setCustomizedShape", "large", "largeThreshold", "progressiveStep", "progressiveThreshold", "support3d", "morph", "morphKey", "morphElementKey", "attributeTransforms", "skipTheme" ];
|
|
197
|
+
const keys = [ "clip", "zIndex", "interactive", "context", "setCustomizedShape", "large", "largeThreshold", "progressiveStep", "progressiveThreshold", "support3d", "morph", "morphKey", "morphElementKey", "attributeTransforms", "skipTheme", "enableSegments" ];
|
|
198
198
|
return null === config ? (keys.forEach((key => {
|
|
199
199
|
(0, vutils_1.isNil)(this.spec[key]) || (this.spec[key] = void 0);
|
|
200
200
|
})), this) : (keys.forEach((key => {
|
|
201
201
|
(0, vutils_1.isNil)(config[key]) || (this.spec[key] = config[key]);
|
|
202
202
|
})), this);
|
|
203
203
|
}
|
|
204
|
+
context(context) {
|
|
205
|
+
return this.spec.context = context, this._context = context, this;
|
|
206
|
+
}
|
|
204
207
|
isCollectionMark() {
|
|
205
208
|
return constants_1.CollectionMarkType.includes(this.markType);
|
|
206
209
|
}
|
|
@@ -274,7 +277,7 @@ class Mark extends grammar_base_1.GrammarBase {
|
|
|
274
277
|
this.graphicIndex = markIndex;
|
|
275
278
|
}
|
|
276
279
|
update(spec) {
|
|
277
|
-
this.
|
|
280
|
+
this._context = this.spec.context, this.isUpdated = !0, this.renderContext.progressive || (spec.animation && this.animate.updateConfig(spec.animation),
|
|
278
281
|
this.animate.updateState(spec.animationState)), this.markType !== enums_1.GrammarMarkType.group ? ((0,
|
|
279
282
|
vutils_1.isNil)(spec.zIndex) || this.graphicItem.setAttribute("zIndex", spec.zIndex),
|
|
280
283
|
(0, vutils_1.isNil)(spec.clip) || this.graphicItem.setAttribute("clip", spec.clip),
|
|
@@ -557,6 +560,9 @@ class Mark extends grammar_base_1.GrammarBase {
|
|
|
557
560
|
var _a;
|
|
558
561
|
return null !== (_a = this.spec.attributeTransforms) && void 0 !== _a ? _a : attributes_1.transformsByType[this.markType];
|
|
559
562
|
}
|
|
563
|
+
getContext() {
|
|
564
|
+
return this._context;
|
|
565
|
+
}
|
|
560
566
|
needSkipBeforeLayout() {
|
|
561
567
|
var _a, _b;
|
|
562
568
|
if (!0 === (null === (_a = this.spec.layout) || void 0 === _a ? void 0 : _a.skipBeforeLayouted)) return !0;
|