@visactor/vgrammar-core 0.8.1 → 0.8.2
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/axis.js +9 -9
- package/cjs/component/axis.js.map +1 -1
- package/cjs/component/datazoom.js +5 -5
- package/cjs/component/datazoom.js.map +1 -1
- package/cjs/component/grid.js +18 -18
- package/cjs/component/grid.js.map +1 -1
- package/cjs/component/label.js +16 -16
- package/cjs/component/label.js.map +1 -1
- package/cjs/component/legend.js +13 -13
- package/cjs/component/legend.js.map +1 -1
- package/cjs/component/scrollbar.js +7 -7
- package/cjs/component/scrollbar.js.map +1 -1
- package/cjs/component/slider.js +5 -5
- package/cjs/component/slider.js.map +1 -1
- package/cjs/component/title.js +5 -5
- package/cjs/component/title.js.map +1 -1
- package/cjs/core/factory.d.ts +5 -1
- package/cjs/core/factory.js +13 -3
- package/cjs/core/factory.js.map +1 -1
- package/cjs/graph/animation/animation/move.js +10 -8
- package/cjs/graph/animation/animation/move.js.map +1 -1
- package/cjs/graph/attributes/common.js +2 -10
- package/cjs/graph/attributes/common.js.map +1 -1
- package/cjs/graph/attributes/helpers.d.ts +2 -2
- package/cjs/graph/attributes/helpers.js +50 -17
- package/cjs/graph/attributes/helpers.js.map +1 -1
- package/cjs/graph/attributes/index.d.ts +4 -10
- package/cjs/graph/attributes/index.js +16 -251
- package/cjs/graph/attributes/index.js.map +1 -1
- package/cjs/graph/attributes/line.d.ts +3 -0
- package/cjs/graph/attributes/line.js +46 -0
- package/cjs/graph/attributes/line.js.map +1 -0
- package/cjs/graph/attributes/transform.d.ts +5 -0
- package/cjs/graph/attributes/transform.js +167 -0
- package/cjs/graph/attributes/transform.js.map +1 -0
- package/cjs/graph/canvas-renderer.js +1 -1
- package/cjs/graph/canvas-renderer.js.map +1 -1
- package/cjs/graph/constants.d.ts +0 -1
- package/cjs/graph/constants.js +2 -3
- package/cjs/graph/constants.js.map +1 -1
- package/cjs/graph/element.js +5 -5
- package/cjs/graph/element.js.map +1 -1
- package/cjs/graph/glyph-element.js +4 -4
- package/cjs/graph/glyph-element.js.map +1 -1
- package/cjs/graph/layout/relative.js.map +1 -1
- package/cjs/graph/mark/encode.js +4 -4
- package/cjs/graph/mark/encode.js.map +1 -1
- package/cjs/index.d.ts +3 -1
- package/cjs/index.js +3 -2
- package/cjs/index.js.map +1 -1
- package/cjs/interactions/base.js.map +1 -1
- package/cjs/interactions/brush-base.js +2 -2
- package/cjs/interactions/brush-base.js.map +1 -1
- package/cjs/interactions/brush-filter.js +2 -2
- package/cjs/interactions/brush-filter.js.map +1 -1
- package/cjs/interactions/crosshair.d.ts +1 -1
- package/cjs/interactions/crosshair.js +15 -15
- package/cjs/interactions/crosshair.js.map +1 -1
- package/cjs/interactions/datazoom-filter.js +3 -3
- package/cjs/interactions/datazoom-filter.js.map +1 -1
- package/cjs/interactions/drill-down.js +2 -2
- package/cjs/interactions/drill-down.js.map +1 -1
- package/cjs/interactions/legend-filter.js +3 -3
- package/cjs/interactions/legend-filter.js.map +1 -1
- package/cjs/interactions/player-filter.js +3 -3
- package/cjs/interactions/player-filter.js.map +1 -1
- package/cjs/interactions/roll-up.js +2 -2
- package/cjs/interactions/roll-up.js.map +1 -1
- package/cjs/interactions/scrollbar-filter.js +3 -3
- package/cjs/interactions/scrollbar-filter.js.map +1 -1
- package/cjs/interactions/slider-filter.js +3 -3
- package/cjs/interactions/slider-filter.js.map +1 -1
- package/cjs/parse/view.js +1 -1
- package/cjs/parse/view.js.map +1 -1
- package/cjs/semantic-marks/cell.d.ts +3 -1
- package/cjs/semantic-marks/cell.js +10 -4
- package/cjs/semantic-marks/cell.js.map +1 -1
- package/cjs/semantic-marks/interval.d.ts +2 -0
- package/cjs/semantic-marks/interval.js +10 -4
- package/cjs/semantic-marks/interval.js.map +1 -1
- package/cjs/semantic-marks/text.d.ts +1 -0
- package/cjs/semantic-marks/text.js +3 -3
- package/cjs/semantic-marks/text.js.map +1 -1
- package/cjs/types/animate.d.ts +5 -1
- package/cjs/types/animate.js.map +1 -1
- package/cjs/types/grammar.d.ts +1 -1
- package/cjs/types/grammar.js.map +1 -1
- package/cjs/types/mark.d.ts +5 -1
- package/cjs/types/mark.js.map +1 -1
- package/cjs/types/view.d.ts +1 -0
- package/cjs/types/view.js.map +1 -1
- package/cjs/view/View.d.ts +0 -1
- package/cjs/view/View.js +15 -25
- package/cjs/view/View.js.map +1 -1
- package/cjs/view/animate.d.ts +1 -0
- package/cjs/view/animate.js +12 -12
- package/cjs/view/animate.js.map +1 -1
- package/cjs/view/constants.d.ts +0 -3
- package/cjs/view/constants.js +2 -3
- package/cjs/view/constants.js.map +1 -1
- package/cjs/view/grammar-record.js +5 -5
- package/cjs/view/grammar-record.js.map +1 -1
- package/cjs/view/mark.js +1 -1
- package/cjs/view/mark.js.map +1 -1
- package/es/component/axis.js +1 -1
- package/es/component/axis.js.map +1 -1
- package/es/component/datazoom.js +1 -1
- package/es/component/datazoom.js.map +1 -1
- package/es/component/grid.js +1 -1
- package/es/component/grid.js.map +1 -1
- package/es/component/label.js +1 -1
- package/es/component/label.js.map +1 -1
- package/es/component/legend.js +1 -1
- package/es/component/legend.js.map +1 -1
- package/es/component/scrollbar.js +1 -1
- package/es/component/scrollbar.js.map +1 -1
- package/es/component/slider.js +1 -1
- package/es/component/slider.js.map +1 -1
- package/es/component/title.js +1 -1
- package/es/component/title.js.map +1 -1
- package/es/core/factory.d.ts +5 -1
- package/es/core/factory.js +11 -1
- package/es/core/factory.js.map +1 -1
- package/es/graph/animation/animation/move.js +5 -5
- package/es/graph/animation/animation/move.js.map +1 -1
- package/es/graph/attributes/common.js +2 -7
- package/es/graph/attributes/common.js.map +1 -1
- package/es/graph/attributes/helpers.d.ts +2 -2
- package/es/graph/attributes/helpers.js +46 -12
- package/es/graph/attributes/helpers.js.map +1 -1
- package/es/graph/attributes/index.d.ts +4 -10
- package/es/graph/attributes/index.js +4 -227
- package/es/graph/attributes/index.js.map +1 -1
- package/es/graph/attributes/line.d.ts +3 -0
- package/es/graph/attributes/line.js +42 -0
- package/es/graph/attributes/line.js.map +1 -0
- package/es/graph/attributes/transform.d.ts +5 -0
- package/es/graph/attributes/transform.js +153 -0
- package/es/graph/attributes/transform.js.map +1 -0
- package/es/graph/canvas-renderer.js +1 -1
- package/es/graph/canvas-renderer.js.map +1 -1
- package/es/graph/constants.d.ts +0 -1
- package/es/graph/constants.js +0 -2
- package/es/graph/constants.js.map +1 -1
- package/es/graph/element.js +4 -2
- package/es/graph/element.js.map +1 -1
- package/es/graph/glyph-element.js +1 -1
- package/es/graph/glyph-element.js.map +1 -1
- package/es/graph/layout/relative.js.map +1 -1
- package/es/graph/mark/encode.js +1 -1
- package/es/graph/mark/encode.js.map +1 -1
- package/es/index.d.ts +3 -1
- package/es/index.js +5 -1
- package/es/index.js.map +1 -1
- package/es/interactions/base.js.map +1 -1
- package/es/interactions/brush-base.js +1 -1
- package/es/interactions/brush-base.js.map +1 -1
- package/es/interactions/brush-filter.js +1 -1
- package/es/interactions/brush-filter.js.map +1 -1
- package/es/interactions/crosshair.d.ts +1 -1
- package/es/interactions/crosshair.js +1 -1
- package/es/interactions/crosshair.js.map +1 -1
- package/es/interactions/datazoom-filter.js +1 -1
- package/es/interactions/datazoom-filter.js.map +1 -1
- package/es/interactions/drill-down.js +1 -1
- package/es/interactions/drill-down.js.map +1 -1
- package/es/interactions/legend-filter.js +1 -1
- package/es/interactions/legend-filter.js.map +1 -1
- package/es/interactions/player-filter.js +1 -1
- package/es/interactions/player-filter.js.map +1 -1
- package/es/interactions/roll-up.js +1 -1
- package/es/interactions/roll-up.js.map +1 -1
- package/es/interactions/scrollbar-filter.js +1 -1
- package/es/interactions/scrollbar-filter.js.map +1 -1
- package/es/interactions/slider-filter.js +1 -1
- package/es/interactions/slider-filter.js.map +1 -1
- package/es/parse/view.js +1 -1
- package/es/parse/view.js.map +1 -1
- package/es/semantic-marks/cell.d.ts +3 -1
- package/es/semantic-marks/cell.js +11 -1
- package/es/semantic-marks/cell.js.map +1 -1
- package/es/semantic-marks/interval.d.ts +2 -0
- package/es/semantic-marks/interval.js +9 -1
- package/es/semantic-marks/interval.js.map +1 -1
- package/es/semantic-marks/text.d.ts +1 -0
- package/es/semantic-marks/text.js +3 -1
- package/es/semantic-marks/text.js.map +1 -1
- package/es/types/animate.d.ts +5 -1
- package/es/types/animate.js.map +1 -1
- package/es/types/grammar.d.ts +1 -1
- package/es/types/grammar.js.map +1 -1
- package/es/types/mark.d.ts +5 -1
- package/es/types/mark.js.map +1 -1
- package/es/types/view.d.ts +1 -0
- package/es/types/view.js.map +1 -1
- package/es/view/View.d.ts +0 -1
- package/es/view/View.js +13 -27
- package/es/view/View.js.map +1 -1
- package/es/view/animate.d.ts +1 -0
- package/es/view/animate.js +6 -6
- package/es/view/animate.js.map +1 -1
- package/es/view/constants.d.ts +0 -3
- package/es/view/constants.js +0 -6
- package/es/view/constants.js.map +1 -1
- package/es/view/grammar-record.js +1 -1
- package/es/view/grammar-record.js.map +1 -1
- package/es/view/mark.js +1 -1
- package/es/view/mark.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/player-filter.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"sources":["../src/interactions/player-filter.ts"],"names":[],"mappings":";;;AACA,0CAAiE;AACjE,6CAA4C;AAC5C,qCAAkC;AAClC,qEAA+D;AAE/D,MAAa,YAAa,SAAQ,eAAM;IAOtC,YAAY,IAAW,EAAE,OAA2B;QAClD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QANvB,SAAI,GAAW,YAAY,CAAC,IAAI,CAAC;QAO/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAEvE,IAAI,CAAC,MAAM,GAAG,IAAI;aACf,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,MA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AAE,cAAc,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;QAEtG,OAAO;YACL;gBACE,IAAI,EAAE,oCAAe,CAAC,QAAQ;gBAC9B,OAAO,EAAE,IAAI,CAAC,YAAY;aAC3B;SACF,CAAC;IACJ,CAAC;;AA7CH,oCA8CC;AA7CQ,iBAAI,GAAW,eAAe,CAAC;AAG/B,2BAAc,GAAsC,EAAE,CAAC","file":"player-filter.js","sourcesContent":["import type { DataFilterOptions, IComponent, IPlayer, IView, PlayerFilterValue } from '../types';\nimport { DataFilterRank, GrammarMarkType } from '../graph/enums';\nimport { isString } from '@visactor/vutils';\nimport { Filter } from './filter';\nimport { PlayerEventEnum } from '@visactor/vrender-components';\n\nexport class PlayerFilter extends Filter {\n static type: string = 'player-filter';\n type: string = PlayerFilter.type;\n\n static defaultOptions: Omit<DataFilterOptions, 'target'> = {};\n options: DataFilterOptions;\n\n constructor(view: IView, options?: DataFilterOptions) {\n super(view, options);\n this.options = Object.assign({}, PlayerFilter.defaultOptions, options);\n\n this._marks = view\n .getMarksBySelector(this.options.source)\n .filter(mark => mark.markType === GrammarMarkType.component && (mark as IComponent).componentType === 'player');\n this._data = isString(this.options.target.data)\n ? view.getDataById(this.options.target.data)\n : this.options.target.data;\n }\n\n protected getEvents() {\n if (!this._marks || this._marks.length === 0) {\n return [];\n }\n\n const player = this._marks[0] as IPlayer;\n\n if (!this._data || !player) {\n return [];\n }\n\n const transform = this.options.target.transform;\n\n const getFilterValue = (event: any) => ({ index: event.detail.index, value: event.detail.value });\n const dataTransform = (data: any[], filterValue: PlayerFilterValue) => {\n return transform ? transform(data, filterValue) : filterValue.value;\n };\n\n this._filterData(this._data, player, DataFilterRank.player, getFilterValue, undefined, dataTransform);\n\n return [\n {\n type: PlayerEventEnum.OnChange,\n handler: this.handleFilter\n }\n ];\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.RollUp = void 0;
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const enums_1 = require("../graph/enums"), vutils_1 = require("@visactor/vutils"), filter_1 = require("./filter");
|
|
8
8
|
|
|
9
9
|
class RollUp extends filter_1.Filter {
|
|
10
10
|
constructor(view, options) {
|
|
@@ -25,7 +25,7 @@ class RollUp extends filter_1.Filter {
|
|
|
25
25
|
if (!this._marks || 0 === this._marks.length) return [];
|
|
26
26
|
if (!this._data) return [];
|
|
27
27
|
const transform = this.options.target.transform;
|
|
28
|
-
this._filterData(this._data, null,
|
|
28
|
+
this._filterData(this._data, null, enums_1.DataFilterRank.rollUp, (event => {
|
|
29
29
|
var _a, _b;
|
|
30
30
|
return null === (_b = null === (_a = null == event ? void 0 : event.element) || void 0 === _a ? void 0 : _a.getDatum) || void 0 === _b ? void 0 : _b.call(_a);
|
|
31
31
|
}), void 0, ((data, filterValue) => transform(data, filterValue)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/roll-up.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"sources":["../src/interactions/roll-up.ts"],"names":[],"mappings":";;;AACA,0CAAgD;AAChD,6CAAqD;AACrD,qCAAkC;AAElC,MAAa,MAAO,SAAQ,eAAM;IAYhC,YAAY,IAAW,EAAE,OAAuB;QAC9C,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAXvB,SAAI,GAAW,MAAM,CAAC,IAAI,CAAC;QAQjB,cAAS,GAAY,KAAK,CAAC;QAyD3B,gBAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;;YAClD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;YAC9B,IAAI,OAAO,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAChE,MAAM,WAAW,GAAG,MAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,QAAQ,kDAAI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QAEhC,IAAI,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACtC,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,SAAsB;gBAC5B,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B,CAAC,CAAC;YACH,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;SACxB;aAAM;YACL,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;SACvB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;;AAjEH,wBAiGC;AAhGQ,WAAI,GAAW,SAAS,CAAC;AAGzB,qBAAc,GAAkC;IACrD,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,OAAO;CACtB,CAAC","file":"roll-up.js","sourcesContent":["import type { EventType, IView, InteractionEvent, RollUpOptions } from '../types';\nimport { DataFilterRank } from '../graph/enums';\nimport { isArray, isString } from '@visactor/vutils';\nimport { Filter } from './filter';\n\nexport class RollUp extends Filter {\n static type: string = 'roll-up';\n type: string = RollUp.type;\n\n static defaultOptions: Omit<RollUpOptions, 'target'> = {\n trigger: 'click',\n resetTrigger: 'empty'\n };\n options: RollUpOptions;\n\n protected _isToggle: boolean = false;\n\n constructor(view: IView, options?: RollUpOptions) {\n super(view, options);\n this.options = Object.assign({}, RollUp.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.source);\n this._data = isString(this.options.target.data)\n ? view.getDataById(this.options.target.data)\n : this.options.target.data;\n }\n\n protected getEvents() {\n if (!this._marks || this._marks.length === 0) {\n return [];\n }\n\n if (!this._data) {\n return [];\n }\n\n const transform = this.options.target.transform;\n\n const getFilterValue = (event: InteractionEvent) => event?.element?.getDatum?.();\n const dataTransform = (data: any[], filterValue: any) => {\n return transform(data, filterValue);\n };\n\n this._filterData(this._data, null, DataFilterRank.rollUp, getFilterValue, undefined, dataTransform);\n\n const events = [\n {\n type: this.options.trigger,\n handler: this.handleStart\n }\n ];\n\n const eventName =\n this.options.resetTrigger === 'empty'\n ? this.options.trigger\n : this.options.resetTrigger.includes('view:')\n ? this.options.resetTrigger.replace('view:', '')\n : this.options.resetTrigger;\n\n if (eventName !== this.options.trigger) {\n events.push({\n type: eventName as EventType,\n handler: this.handleReset\n });\n this._isToggle = false;\n } else {\n this._isToggle = true;\n }\n\n return events;\n }\n\n protected handleStart = (event: InteractionEvent) => {\n const element = event.element;\n if (element && this._marks && this._marks.includes(element.mark)) {\n const filterValue = event.element?.getDatum?.();\n\n const isEqualFilterValue =\n filterValue === this._filterData ||\n (isArray(filterValue) &&\n isArray(this._filterValue) &&\n filterValue.length === this._filterValue.length &&\n filterValue.every(datum => !this._filterValue.includes(datum)));\n\n if (isEqualFilterValue) {\n // reset filter value when toggle is enabled\n if (this._isToggle) {\n this._filterValue = null;\n this.handleFilter(event);\n }\n } else {\n this.handleFilter(event);\n }\n }\n };\n\n protected handleReset = (event: InteractionEvent) => {\n if (this._filterValue) {\n this._filterValue = null;\n this.handleFilter(event);\n }\n };\n}\n"]}
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.ScrollbarFilter = void 0;
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const enums_1 = require("../graph/enums"), vutils_1 = require("@visactor/vutils"), filter_1 = require("./filter");
|
|
8
8
|
|
|
9
9
|
class ScrollbarFilter extends filter_1.Filter {
|
|
10
10
|
constructor(view, options) {
|
|
11
11
|
super(view, options), this.type = ScrollbarFilter.type, this.options = Object.assign({}, ScrollbarFilter.defaultOptions, options),
|
|
12
|
-
this._marks = view.getMarksBySelector(this.options.source).filter((mark => mark.markType ===
|
|
12
|
+
this._marks = view.getMarksBySelector(this.options.source).filter((mark => mark.markType === enums_1.GrammarMarkType.component && "scrollbar" === mark.componentType)),
|
|
13
13
|
this._data = (0, vutils_1.isString)(this.options.target.data) ? view.getDataById(this.options.target.data) : this.options.target.data;
|
|
14
14
|
}
|
|
15
15
|
getEvents() {
|
|
@@ -21,7 +21,7 @@ class ScrollbarFilter extends filter_1.Filter {
|
|
|
21
21
|
const scale = scrollbar.getScale().getScale(), range = scale.range(), datumRatio = (scale.scale(datum[filter]) - range[0]) / (range[range.length - 1] - range[0]);
|
|
22
22
|
return filterValue.startRatio <= datumRatio && filterValue.endRatio >= datumRatio;
|
|
23
23
|
} : filter;
|
|
24
|
-
return this._filterData(this._data, scrollbar,
|
|
24
|
+
return this._filterData(this._data, scrollbar, enums_1.DataFilterRank.scrollbar, (event => {
|
|
25
25
|
if ((0, vutils_1.isString)(filter)) {
|
|
26
26
|
const range = event.detail.value, scaleGrammar = scrollbar.getScale();
|
|
27
27
|
if (scaleGrammar) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/scrollbar-filter.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"sources":["../src/interactions/scrollbar-filter.ts"],"names":[],"mappings":";;;AACA,0CAAiE;AACjE,6CAA4C;AAC5C,qCAAkC;AAElC,MAAa,eAAgB,SAAQ,eAAM;IAOzC,YAAY,IAAW,EAAE,OAA2B;QAClD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QANvB,SAAI,GAAW,eAAe,CAAC,IAAI,CAAC;QAOlC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAE1E,IAAI,CAAC,MAAM,GAAG,IAAI;aACf,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;aACvC,MAAM,CACL,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,uBAAe,CAAC,SAAS,IAAK,IAAmB,CAAC,aAAa,KAAK,WAAW,CAC1G,CAAC;QACJ,IAAI,CAAC,KAAK,GAAG,IAAA,iBAAQ,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;YAC7C,CAAC,CAAC,IAAI,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E,cAAc,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QAEzG,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,IAAI,CAAC,YAAY;aAC3B;SACF,CAAC;IACJ,CAAC;;AApEH,0CAqEC;AApEQ,oBAAI,GAAW,kBAAkB,CAAC;AAGlC,8BAAc,GAAsC,EAAE,CAAC","file":"scrollbar-filter.js","sourcesContent":["import type { DataFilterOptions, IComponent, IScrollbar, IView, ScrollbarFilterValue } from '../types';\nimport { DataFilterRank, GrammarMarkType } from '../graph/enums';\nimport { isString } from '@visactor/vutils';\nimport { Filter } from './filter';\n\nexport class ScrollbarFilter extends Filter {\n static type: string = 'scrollbar-filter';\n type: string = ScrollbarFilter.type;\n\n static defaultOptions: Omit<DataFilterOptions, 'target'> = {};\n options: DataFilterOptions;\n\n constructor(view: IView, options?: DataFilterOptions) {\n super(view, options);\n this.options = Object.assign({}, ScrollbarFilter.defaultOptions, options);\n\n this._marks = view\n .getMarksBySelector(this.options.source)\n .filter(\n mark => mark.markType === GrammarMarkType.component && (mark as IComponent).componentType === 'scrollbar'\n );\n this._data = isString(this.options.target.data)\n ? view.getDataById(this.options.target.data)\n : this.options.target.data;\n }\n\n protected getEvents() {\n if (!this._marks || this._marks.length === 0) {\n return [];\n }\n\n const scrollbar = this._marks[0] as IScrollbar;\n\n if (!this._data || !scrollbar) {\n return [];\n }\n\n const filter = this.options.target.filter;\n const transform = this.options.target.transform;\n\n const getFilterValue = (event: any) => {\n if (isString(filter)) {\n const range = event.detail.value;\n const scaleGrammar = scrollbar.getScale();\n if (scaleGrammar) {\n const scale = scaleGrammar.getScale();\n const scaleRange = scale.range();\n const start = scale.invert(range[0] * (scaleRange[1] - scaleRange[0]) + scaleRange[0]);\n const end = scale.invert(range[1] * (scaleRange[1] - scaleRange[0]) + scaleRange[0]);\n return { start, end, startRatio: range[0], endRatio: range[1] };\n }\n return { startRatio: range[0], endRatio: range[1] };\n }\n return { startRatio: event.detail.value[0], endRatio: event.detail.value[1] };\n };\n const dataFilter = isString(filter)\n ? (datum: any, filterValue: ScrollbarFilterValue) => {\n const scaleGrammar = scrollbar.getScale();\n const scale = scaleGrammar.getScale();\n const range = scale.range();\n const datumRatio = (scale.scale(datum[filter]) - range[0]) / (range[range.length - 1] - range[0]);\n return filterValue.startRatio <= datumRatio && filterValue.endRatio >= datumRatio;\n }\n : filter;\n\n this._filterData(this._data, scrollbar, DataFilterRank.scrollbar, getFilterValue, dataFilter, transform);\n\n return [\n {\n type: 'scroll',\n handler: this.handleFilter\n }\n ];\n }\n}\n"]}
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.SliderFilter = void 0;
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const enums_1 = require("../graph/enums"), vutils_1 = require("@visactor/vutils"), filter_1 = require("./filter");
|
|
8
8
|
|
|
9
9
|
class SliderFilter extends filter_1.Filter {
|
|
10
10
|
constructor(view, options) {
|
|
11
11
|
super(view, options), this.type = SliderFilter.type, this.options = Object.assign({}, SliderFilter.defaultOptions, options),
|
|
12
|
-
this._marks = view.getMarksBySelector(this.options.source).filter((mark => mark.markType ===
|
|
12
|
+
this._marks = view.getMarksBySelector(this.options.source).filter((mark => mark.markType === enums_1.GrammarMarkType.component && "slider" === mark.componentType)),
|
|
13
13
|
this._data = (0, vutils_1.isString)(this.options.target.data) ? view.getDataById(this.options.target.data) : this.options.target.data;
|
|
14
14
|
}
|
|
15
15
|
getEvents() {
|
|
@@ -18,7 +18,7 @@ class SliderFilter extends filter_1.Filter {
|
|
|
18
18
|
if (!this._data || !slider) return [];
|
|
19
19
|
const filter = this.options.target.filter, transform = this.options.target.transform, dataFilter = (0,
|
|
20
20
|
vutils_1.isString)(filter) ? (datum, filterValue) => datum[filter] >= filterValue.start && datum[filter] <= filterValue.end : filter;
|
|
21
|
-
return this._filterData(this._data, slider,
|
|
21
|
+
return this._filterData(this._data, slider, enums_1.DataFilterRank.slider, (event => ({
|
|
22
22
|
start: event.detail.value[0],
|
|
23
23
|
end: event.detail.value[1]
|
|
24
24
|
})), dataFilter, transform), [ {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/slider-filter.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"sources":["../src/interactions/slider-filter.ts"],"names":[],"mappings":";;;AACA,0CAAiE;AACjE,6CAA4C;AAC5C,qCAAkC;AAElC,MAAa,YAAa,SAAQ,eAAM;IAOtC,YAAY,IAAW,EAAE,OAA2B;QAClD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QANvB,SAAI,GAAW,YAAY,CAAC,IAAI,CAAC;QAO/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAEvE,IAAI,CAAC,MAAM,GAAG,IAAI;aACf,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;aACvC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,uBAAe,CAAC,SAAS,IAAK,IAAmB,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC;QAClH,IAAI,CAAC,KAAK,GAAG,IAAA,iBAAQ,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;YAC7C,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;YAC5C,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;IAC/B,CAAC;IAES,SAAS;QACjB,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5C,OAAO,EAAE,CAAC;SACX;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAY,CAAC;QAEzC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE;YAC1B,OAAO,EAAE,CAAC;SACX;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;QAEhD,MAAM,cAAc,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACtG,MAAM,UAAU,GAAG,IAAA,iBAAQ,EAAC,MAAM,CAAC;YACjC,CAAC,CAAC,CAAC,KAAU,EAAE,WAA8B,EAAE,EAAE,CAC7C,KAAK,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,GAAG;YAC1E,CAAC,CAAC,MAAM,CAAC;QAEX,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,sBAAc,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QAEnG,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,IAAI,CAAC,YAAY;aAC3B;SACF,CAAC;IACJ,CAAC;;AA/CH,oCAgDC;AA/CQ,iBAAI,GAAW,eAAe,CAAC;AAG/B,2BAAc,GAAsC,EAAE,CAAC","file":"slider-filter.js","sourcesContent":["import type { DataFilterOptions, IComponent, ISlider, IView, SliderFilterValue } from '../types';\nimport { DataFilterRank, GrammarMarkType } from '../graph/enums';\nimport { isString } from '@visactor/vutils';\nimport { Filter } from './filter';\n\nexport class SliderFilter extends Filter {\n static type: string = 'slider-filter';\n type: string = SliderFilter.type;\n\n static defaultOptions: Omit<DataFilterOptions, 'target'> = {};\n options: DataFilterOptions;\n\n constructor(view: IView, options?: DataFilterOptions) {\n super(view, options);\n this.options = Object.assign({}, SliderFilter.defaultOptions, options);\n\n this._marks = view\n .getMarksBySelector(this.options.source)\n .filter(mark => mark.markType === GrammarMarkType.component && (mark as IComponent).componentType === 'slider');\n this._data = isString(this.options.target.data)\n ? view.getDataById(this.options.target.data)\n : this.options.target.data;\n }\n\n protected getEvents() {\n if (!this._marks || this._marks.length === 0) {\n return [];\n }\n\n const slider = this._marks[0] as ISlider;\n\n if (!this._data || !slider) {\n return [];\n }\n\n const filter = this.options.target.filter;\n const transform = this.options.target.transform;\n\n const getFilterValue = (event: any) => ({ start: event.detail.value[0], end: event.detail.value[1] });\n const dataFilter = isString(filter)\n ? (datum: any, filterValue: SliderFilterValue) =>\n datum[filter] >= filterValue.start && datum[filter] <= filterValue.end\n : filter;\n\n this._filterData(this._data, slider, DataFilterRank.slider, getFilterValue, dataFilter, transform);\n\n return [\n {\n type: 'change',\n handler: this.handleFilter\n }\n ];\n }\n}\n"]}
|
package/cjs/parse/view.js
CHANGED
|
@@ -20,7 +20,7 @@ const builtInSignals = (option, config, theme) => {
|
|
|
20
20
|
value: null !== (_b = option[constants_2.SIGNAL_HEIGHT]) && void 0 !== _b ? _b : 0
|
|
21
21
|
}, {
|
|
22
22
|
id: constants_2.SIGNAL_PADDING,
|
|
23
|
-
value: (0, exports.normalizePadding)(null !== (_d = null !== (_c = option[constants_2.SIGNAL_PADDING]) && void 0 !== _c ? _c : config[constants_2.SIGNAL_PADDING]) && void 0 !== _d ? _d : theme.padding)
|
|
23
|
+
value: (0, exports.normalizePadding)(null !== (_d = null !== (_c = option[constants_2.SIGNAL_PADDING]) && void 0 !== _c ? _c : config[constants_2.SIGNAL_PADDING]) && void 0 !== _d ? _d : null == theme ? void 0 : theme.padding)
|
|
24
24
|
}, {
|
|
25
25
|
id: constants_2.SIGNAL_VIEW_WIDTH,
|
|
26
26
|
update: {
|
package/cjs/parse/view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parse/view.ts"],"names":[],"mappings":";;;AACA,6CAAoD;AACpD,kDAU4B;AAG5B,iDAQ2B;AAE3B,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;AAEP,QAAA,eAAe,GAAG;IAC7B,wBAAY;IACZ,yBAAa;IACb,0BAAc;IACd,6BAAiB;IACjB,8BAAkB;IAClB,2BAAe;IACf,0BAAc;CACf,CAAC;AAEK,MAAM,cAAc,GAAG,CAAC,MAAoB,EAAE,MAAwB,EAAE,KAAa,EAAqB,EAAE;;IACjH,OAAO;QACL,EAAE,EAAE,EAAE,wBAAY,EAAE,KAAK,EAAE,MAAA,MAAM,CAAC,wBAAY,CAAC,mCAAI,CAAC,EAAE;QACtD,EAAE,EAAE,EAAE,yBAAa,EAAE,KAAK,EAAE,MAAA,MAAM,CAAC,yBAAa,CAAC,mCAAI,CAAC,EAAE;QACxD,EAAE,EAAE,EAAE,0BAAc,EAAE,KAAK,EAAE,IAAA,wBAAgB,EAAC,MAAA,MAAA,MAAM,CAAC,0BAAc,CAAC,mCAAI,MAAM,CAAC,0BAAc,CAAC,mCAAI,KAAK,
|
|
1
|
+
{"version":3,"sources":["../src/parse/view.ts"],"names":[],"mappings":";;;AACA,6CAAoD;AACpD,kDAU4B;AAG5B,iDAQ2B;AAE3B,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;AAEP,QAAA,eAAe,GAAG;IAC7B,wBAAY;IACZ,yBAAa;IACb,0BAAc;IACd,6BAAiB;IACjB,8BAAkB;IAClB,2BAAe;IACf,0BAAc;CACf,CAAC;AAEK,MAAM,cAAc,GAAG,CAAC,MAAoB,EAAE,MAAwB,EAAE,KAAa,EAAqB,EAAE;;IACjH,OAAO;QACL,EAAE,EAAE,EAAE,wBAAY,EAAE,KAAK,EAAE,MAAA,MAAM,CAAC,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AAI,oCAAwB;YACxE,QAAQ,EAAE,MAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,0CAAE,QAAQ,mCAAI,oCAAwB;YACxE,SAAS,EAAE,MAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,0CAAE,SAAS,mCAAI,4BAAgB;SACnE;QACD,mBAAmB,EAAE,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,mBAAmB,mCAAI,sCAA0B;KACtF,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,sBAAsB,0BAcjC","file":"view.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport { isNumber, Bounds } from '@visactor/vutils';\nimport {\n DefaultAnimationDelay,\n DefaultAnimationDuration,\n DefaultAnimationEasing,\n DefaultAnimationOneByOne,\n DefaultEnableExitAnimation,\n DefaultMorph,\n DefaultMorphAll,\n DefaultReuse,\n DefaultSplitPath\n} from '../graph/constants';\nimport type { GroupMarkSpec, IRunningConfig, ITheme, MarkSpec, SignalSpec } from '../types';\nimport type { IViewOptions, IViewThemeConfig, ViewSpec } from '../types/view';\nimport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from '../view/constants';\n\nlet markBaseId = -1;\n\nexport const BuiltInSignalID = [\n SIGNAL_WIDTH,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_BOX,\n SIGNAL_AUTOFIT\n];\n\nexport const builtInSignals = (option: IViewOptions, config: IViewThemeConfig, theme: ITheme): SignalSpec<any>[] => {\n return [\n { id: SIGNAL_WIDTH, value: option[SIGNAL_WIDTH] ?? 0 },\n { id: SIGNAL_HEIGHT, value: option[SIGNAL_HEIGHT] ?? 0 },\n { id: SIGNAL_PADDING, value: normalizePadding(option[SIGNAL_PADDING] ?? config[SIGNAL_PADDING] ?? theme?.padding) },\n {\n id: SIGNAL_VIEW_WIDTH,\n update: {\n callback: (signal: number, params: any) => {\n const padding = normalizePadding(params[SIGNAL_PADDING]);\n return params[SIGNAL_WIDTH] - padding.left - padding.right;\n },\n dependency: [SIGNAL_WIDTH, SIGNAL_PADDING]\n }\n },\n {\n id: SIGNAL_VIEW_HEIGHT,\n update: {\n callback: (signal: number, params: any) => {\n const padding = normalizePadding(params[SIGNAL_PADDING]);\n return params[SIGNAL_HEIGHT] - padding.top - padding.bottom;\n },\n dependency: [SIGNAL_HEIGHT, SIGNAL_PADDING]\n }\n },\n {\n id: SIGNAL_VIEW_BOX,\n update: {\n callback: (signal: IBounds, params: any) => {\n const padding = normalizePadding(params[SIGNAL_PADDING]);\n return (signal ? signal : new Bounds()).setValue(\n padding.left,\n padding.top,\n padding.left + params[SIGNAL_VIEW_WIDTH],\n padding.top + params[SIGNAL_VIEW_HEIGHT]\n );\n },\n dependency: [SIGNAL_VIEW_WIDTH, SIGNAL_VIEW_HEIGHT, SIGNAL_PADDING]\n }\n },\n {\n id: SIGNAL_AUTOFIT,\n value: option[SIGNAL_AUTOFIT] ?? config[SIGNAL_AUTOFIT]\n }\n ];\n};\n\nexport const normalizePadding = (\n value: number | { top?: number; left?: number; right?: number; bottom?: number }\n): { top: number; left: number; right: number; bottom: number } => {\n if (isNumber(value)) {\n return { top: value, bottom: value, left: value, right: value };\n }\n return { top: value?.top ?? 0, bottom: value?.bottom ?? 0, left: value?.left ?? 0, right: value?.right ?? 0 };\n};\n\nexport const normalizeMarkTree = (spec: ViewSpec) => {\n const traverse = (spec: MarkSpec, group: string) => {\n spec.group = group;\n const id = spec.id ?? `VGRAMMAR_MARK_${++markBaseId}`;\n spec.id = id;\n ((spec as GroupMarkSpec).marks ?? []).forEach(child => traverse(child, id));\n };\n (spec.marks ?? []).forEach(mark => traverse(mark, 'root'));\n return spec;\n};\n\nexport const normalizeRunningConfig = (runningConfig: IRunningConfig): IRunningConfig => {\n return {\n reuse: runningConfig?.reuse ?? DefaultReuse,\n morph: runningConfig?.morph ?? DefaultMorph,\n morphAll: runningConfig?.morphAll ?? DefaultMorphAll,\n animation: {\n easing: runningConfig?.animation?.easing ?? DefaultAnimationEasing,\n delay: runningConfig?.animation?.delay ?? DefaultAnimationDelay,\n duration: runningConfig?.animation?.duration ?? DefaultAnimationDuration,\n oneByOne: runningConfig?.animation?.oneByOne ?? DefaultAnimationOneByOne,\n splitPath: runningConfig?.animation?.splitPath ?? DefaultSplitPath\n },\n enableExitAnimation: runningConfig?.enableExitAnimation ?? DefaultEnableExitAnimation\n };\n};\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GrammarMarkType } from '../graph/enums';
|
|
2
2
|
import type { StateEncodeSpec, MarkSpec, MarkFunctionType, AttributeTransform, BaseSignleEncodeSpec } from '../types';
|
|
3
3
|
import { Mark } from '../view/mark';
|
|
4
4
|
export declare class Cell extends Mark {
|
|
5
|
+
static markType: GrammarMarkType;
|
|
5
6
|
markType: GrammarMarkType.cell;
|
|
6
7
|
protected spec: MarkSpec;
|
|
7
8
|
protected _encoders: StateEncodeSpec | null;
|
|
@@ -11,3 +12,4 @@ export declare class Cell extends Mark {
|
|
|
11
12
|
getAttributeTransforms(): AttributeTransform[];
|
|
12
13
|
release(): void;
|
|
13
14
|
}
|
|
15
|
+
export declare const registerCellMark: () => void;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.Cell = void 0;
|
|
5
|
+
}), exports.registerCellMark = exports.Cell = void 0;
|
|
6
6
|
|
|
7
|
-
const encode_1 = require("../graph/mark/encode"), mark_1 = require("../parse/mark"), util_1 = require("../parse/util"), mark_2 = require("../view/mark"), vutils_1 = require("@visactor/vutils"),
|
|
7
|
+
const enums_1 = require("../graph/enums"), encode_1 = require("../graph/mark/encode"), mark_1 = require("../parse/mark"), util_1 = require("../parse/util"), mark_2 = require("../view/mark"), vutils_1 = require("@visactor/vutils"), transform_1 = require("../graph/attributes/transform"), scale_1 = require("../util/scale"), factory_1 = require("../core/factory");
|
|
8
8
|
|
|
9
9
|
class Cell extends mark_2.Mark {
|
|
10
10
|
encodeState(state, channel, value) {
|
|
@@ -50,12 +50,18 @@ class Cell extends mark_2.Mark {
|
|
|
50
50
|
} else graphicAttributes.size = storedAttrs.size;
|
|
51
51
|
},
|
|
52
52
|
storedAttrs: "paddingAttrs"
|
|
53
|
-
} ].concat(
|
|
53
|
+
} ].concat(transform_1.transformsByType.symbol);
|
|
54
54
|
}
|
|
55
55
|
release() {
|
|
56
56
|
super.release(), this._encoders = null;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
exports.Cell = Cell;
|
|
60
|
+
exports.Cell = Cell, Cell.markType = enums_1.GrammarMarkType.cell;
|
|
61
|
+
|
|
62
|
+
const registerCellMark = () => {
|
|
63
|
+
factory_1.Factory.registerMark(enums_1.GrammarMarkType.cell, Cell);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
exports.registerCellMark = registerCellMark;
|
|
61
67
|
//# sourceMappingURL=cell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/semantic-marks/cell.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/semantic-marks/cell.ts"],"names":[],"mappings":";;;AACA,0CAAiD;AACjD,iDAAqD;AACrD,wCAA8C;AAC9C,wCAAiE;AAUjE,uCAAoC;AACpC,6CAA4D;AAC5D,6DAAiE;AACjE,yCAAoD;AACpD,6CAA0C;AAE1C,MAAa,IAAK,SAAQ,WAAI;IAO5B,WAAW,CAAC,KAAa,EAAE,OAAsC,EAAE,KAA6B;QAC9F,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAA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AAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,iBAAO,CAAC,YAAY,CAAC,uBAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B","file":"cell.js","sourcesContent":["import type { IBaseScale } from '@visactor/vscale';\nimport { GrammarMarkType } from '../graph/enums';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { isScaleEncode } from '../parse/mark';\nimport { getGrammarOutput, isFunctionType } from '../parse/util';\nimport type {\n StateEncodeSpec,\n MarkSpec,\n IElement,\n MarkFunctionType,\n AttributeTransform,\n GetSignleEncodeSpecByType,\n BaseSignleEncodeSpec\n} from '../types';\nimport { Mark } from '../view/mark';\nimport { isArray, isNil, isNumber } from '@visactor/vutils';\nimport { transformsByType } from '../graph/attributes/transform';\nimport { getBandWidthOfScale } from '../util/scale';\nimport { Factory } from '../core/factory';\n\nexport class Cell extends Mark {\n static markType = GrammarMarkType.cell;\n declare markType: GrammarMarkType.cell;\n protected declare spec: MarkSpec;\n\n protected _encoders: StateEncodeSpec | null;\n\n encodeState(state: string, channel: string | BaseSignleEncodeSpec, value?: MarkFunctionType<any>) {\n super.encodeState(state, channel, value);\n\n this._updateComponentEncoders(state);\n\n return this;\n }\n\n protected _updateComponentEncoders(state: string) {\n if (!this._encoders) {\n this._encoders = {};\n }\n\n const userEncoder = this.spec.encode[state] as GetSignleEncodeSpecByType<'cell'>;\n\n if (userEncoder && state === 'update') {\n const params = this.parameters();\n const scales: Record<string, IBaseScale> = isFunctionType(userEncoder)\n ? null\n : Object.keys(userEncoder).reduce((res, channel) => {\n if (isScaleEncode(userEncoder[channel])) {\n res[channel] = getGrammarOutput(userEncoder[channel].scale, params);\n }\n return res;\n }, {});\n\n this._encoders[state] = {\n callback: (datum: any, element: IElement, parameters: any) => {\n const userEncodeRes = invokeEncoder(userEncoder, datum, element, parameters);\n\n if (isNil(userEncodeRes.size)) {\n const sizeX = scales.x ? getBandWidthOfScale(scales.x) : undefined;\n const sizeY = scales.y ? getBandWidthOfScale(scales.y) : undefined;\n\n if (isNil(sizeX) && isNil(sizeY)) {\n userEncodeRes.size = 10;\n } else if (isNil(sizeX)) {\n userEncodeRes.size = sizeY;\n } else if (isNil(sizeY)) {\n userEncodeRes.size = sizeX;\n }\n\n userEncodeRes.size = [sizeX, sizeY];\n }\n\n if (isNil(userEncodeRes.shape)) {\n userEncodeRes.shape = 'rect';\n }\n\n return userEncodeRes;\n }\n } as GetSignleEncodeSpecByType<'cell'>;\n } else {\n this._encoders[state] = userEncoder;\n }\n }\n\n protected _getEncoders() {\n return this._encoders ?? {};\n }\n\n getAttributeTransforms() {\n return (\n [\n {\n channels: ['size', 'padding'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n if (isNumber(storedAttrs.padding) && storedAttrs.padding > 0) {\n graphicAttributes.size = isArray(storedAttrs.size)\n ? storedAttrs.size.map((entry: number) => Math.max(entry - storedAttrs.padding, 1))\n : Math.max(storedAttrs.size - storedAttrs.padding, 1);\n } else if (isArray(storedAttrs.padding) && storedAttrs.padding.length === 2) {\n const arraySize = isArray(storedAttrs.size) ? storedAttrs.size : [storedAttrs.size, storedAttrs.size];\n\n graphicAttributes.size = [\n Math.max(arraySize[0] - storedAttrs.padding[0], 1),\n Math.max(arraySize[1] - storedAttrs.padding[1], 1)\n ];\n } else {\n graphicAttributes.size = storedAttrs.size;\n }\n },\n storedAttrs: 'paddingAttrs'\n }\n ] as AttributeTransform[]\n ).concat(transformsByType.symbol);\n }\n\n release(): void {\n super.release();\n this._encoders = null;\n }\n}\n\nexport const registerCellMark = () => {\n Factory.registerMark(GrammarMarkType.cell, Cell);\n};\n"]}
|
|
@@ -2,6 +2,7 @@ import { GrammarMarkType } from '../graph/enums';
|
|
|
2
2
|
import type { StateEncodeSpec, MarkSpec, MarkFunctionType, AttributeTransform, BaseSignleEncodeSpec } from '../types';
|
|
3
3
|
import { Mark } from '../view/mark';
|
|
4
4
|
export declare class Interval extends Mark {
|
|
5
|
+
static markType: GrammarMarkType;
|
|
5
6
|
markType: GrammarMarkType.interval;
|
|
6
7
|
protected spec: MarkSpec;
|
|
7
8
|
protected _encoders: StateEncodeSpec;
|
|
@@ -12,3 +13,4 @@ export declare class Interval extends Mark {
|
|
|
12
13
|
addGraphicItem(attrs: any, groupKey?: string): any;
|
|
13
14
|
release(): void;
|
|
14
15
|
}
|
|
16
|
+
export declare const registerIntervalMark: () => void;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.Interval = void 0;
|
|
5
|
+
}), exports.registerIntervalMark = exports.Interval = void 0;
|
|
6
6
|
|
|
7
|
-
const vscale_1 = require("@visactor/vscale"), enums_1 = require("../graph/enums"), encode_1 = require("../graph/mark/encode"), mark_1 = require("../parse/mark"), util_1 = require("../parse/util"), mark_2 = require("../view/mark"), vutils_1 = require("@visactor/vutils"), graphic_1 = require("../graph/util/graphic"),
|
|
7
|
+
const vscale_1 = require("@visactor/vscale"), enums_1 = require("../graph/enums"), encode_1 = require("../graph/mark/encode"), mark_1 = require("../parse/mark"), util_1 = require("../parse/util"), mark_2 = require("../view/mark"), vutils_1 = require("@visactor/vutils"), graphic_1 = require("../graph/util/graphic"), transform_1 = require("../graph/attributes/transform"), factory_1 = require("../core/factory");
|
|
8
8
|
|
|
9
9
|
class Interval extends mark_2.Mark {
|
|
10
10
|
encodeState(state, channel, value) {
|
|
@@ -65,7 +65,7 @@ class Interval extends mark_2.Mark {
|
|
|
65
65
|
graphicAttributes.outerRadius = storedAttrs.y1);
|
|
66
66
|
},
|
|
67
67
|
storedAttrs: "sizeAttrs"
|
|
68
|
-
} ] :
|
|
68
|
+
} ] : transform_1.transformsByType.rect;
|
|
69
69
|
}
|
|
70
70
|
addGraphicItem(attrs, groupKey) {
|
|
71
71
|
const graphicItem = (0, graphic_1.createGraphicItem)(this, this.coord && "polar" === this.coord.output().type ? enums_1.GrammarMarkType.arc : enums_1.GrammarMarkType.rect, attrs);
|
|
@@ -76,5 +76,11 @@ class Interval extends mark_2.Mark {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
exports.Interval = Interval;
|
|
79
|
+
exports.Interval = Interval, Interval.markType = enums_1.GrammarMarkType.interval;
|
|
80
|
+
|
|
81
|
+
const registerIntervalMark = () => {
|
|
82
|
+
factory_1.Factory.registerMark(enums_1.GrammarMarkType.interval, Interval);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.registerIntervalMark = registerIntervalMark;
|
|
80
86
|
//# sourceMappingURL=interval.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/semantic-marks/interval.ts"],"names":[],"mappings":";;;AAEA,6CAA6C;AAC7C,0CAAiD;AACjD,iDAAqD;AACrD,wCAA8C;AAC9C,wCAAiE;AAUjE,uCAAoC;AACpC,6CAAyC;AACzC,mDAA0D;AAE1D,oDAAuD;AAEvD,MAAa,QAAS,SAAQ,WAAI;IAMhC,WAAW,CAAC,KAAa,EAAE,OAAsC,EAAE,KAA6B;QAC9F,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEzC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;QAErC,OAAO,IAAI,CAAC;IACd,CAAC;IAES,wBAAwB,CAAC,KAAa;QAC9C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;SACrB;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAA0C,CAAC;QAErF,IAAI,WAAW,IAAI,KAAK,KAAK,QAAQ,EAAE;YACrC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YACjC,MAAM,MAAM,GAA+B,IAAA,qBAAc,EAAC,WAAW,C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\n// eslint-disable-next-line no-duplicate-imports\nimport { ScaleEnum } from '@visactor/vscale';\nimport { GrammarMarkType } from '../graph/enums';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { isScaleEncode } from '../parse/mark';\nimport { getGrammarOutput, isFunctionType } from '../parse/util';\nimport type {\n StateEncodeSpec,\n MarkSpec,\n IElement,\n MarkFunctionType,\n AttributeTransform,\n GetSignleEncodeSpecByType,\n BaseSignleEncodeSpec\n} from '../types';\nimport { Mark } from '../view/mark';\nimport { isNil } from '@visactor/vutils';\nimport { createGraphicItem } from '../graph/util/graphic';\nimport type { IPolarCoordinate } from '@visactor/vgrammar-coordinate';\nimport { transformsByType } from '../graph/attributes';\n\nexport class Interval extends Mark {\n declare markType: GrammarMarkType.interval;\n protected declare spec: MarkSpec;\n\n protected _encoders: StateEncodeSpec;\n\n encodeState(state: string, channel: string | BaseSignleEncodeSpec, value?: MarkFunctionType<any>) {\n super.encodeState(state, channel, value);\n\n this._updateComponentEncoders(state);\n\n return this;\n }\n\n protected _updateComponentEncoders(state: string) {\n if (!this._encoders) {\n this._encoders = {};\n }\n\n const userEncoder = this.spec.encode[state] as GetSignleEncodeSpecByType<'interval'>;\n\n if (userEncoder && state === 'update') {\n const params = this.parameters();\n const scales: Record<string, IBaseScale> = isFunctionType(userEncoder)\n ? null\n : Object.keys(userEncoder).reduce((res, channel) => {\n if (isScaleEncode(userEncoder[channel])) {\n res[channel] = getGrammarOutput(userEncoder[channel].scale, params);\n }\n return res;\n }, {});\n\n this._encoders[state] = {\n callback: (datum: any, element: IElement, parameters: any) => {\n const userEncodeRes = invokeEncoder(userEncoder, datum, element, parameters);\n\n this.disableCoordinateTransform = false;\n if (scales && scales.x && scales.x.type === ScaleEnum.Band) {\n if (!isNil(scales.y)) {\n const domain = scales.y.domain();\n const min = Math.min.apply(null, domain);\n const max = Math.max.apply(null, domain);\n const baseValue = min > 0 ? min : max < 0 ? max : 0;\n\n userEncodeRes.y1 = scales.y.scale(baseValue);\n }\n const bandWidth = (scales.x as IBandLikeScale).bandwidth();\n\n // TODO: handle bandWidth dynamically\n userEncodeRes.x = userEncodeRes.x + bandWidth / 4;\n userEncodeRes.x1 = userEncodeRes.x + bandWidth / 2;\n } else if (scales && scales.y && scales.y.type === ScaleEnum.Band) {\n if (!isNil(scales.x)) {\n const domain = scales.x.domain();\n const min = Math.min.apply(null, domain);\n const max = Math.max.apply(null, domain);\n const baseValue = min > 0 ? min : max < 0 ? max : 0;\n\n userEncodeRes.x1 = scales.x.scale(baseValue);\n }\n const bandWidth = (scales.y as IBandLikeScale).bandwidth();\n\n userEncodeRes.y = userEncodeRes.y + bandWidth / 4;\n userEncodeRes.y1 = userEncodeRes.y + bandWidth / 2;\n }\n\n if (scales) {\n const scaleGrammar =\n this.view.getScaleById((userEncoder as any).x?.scale) ??\n this.view.getScaleById((userEncoder as any).y?.scale);\n const coord = scaleGrammar.getCoordinate();\n\n if (coord && coord.type === 'polar') {\n this.disableCoordinateTransform = true;\n const origin = (coord as IPolarCoordinate).origin();\n userEncodeRes.cx = origin.x;\n userEncodeRes.cy = origin.y;\n }\n }\n\n return userEncodeRes;\n }\n } as GetSignleEncodeSpecByType<'interval'>;\n } else {\n this._encoders[state] = userEncoder;\n }\n }\n\n protected _getEncoders() {\n return this._encoders ?? {};\n }\n\n getAttributeTransforms() {\n if (this.coord && this.coord.output().type === 'polar') {\n return [\n {\n channels: ['x', 'y', 'x1', 'y1', 'cx', 'cy'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = storedAttrs.cx;\n graphicAttributes.y = storedAttrs.cy;\n if (this.coord.output().isTransposed()) {\n graphicAttributes.startAngle = storedAttrs.y;\n graphicAttributes.endAngle = storedAttrs.y1;\n graphicAttributes.innerRadius = storedAttrs.x;\n graphicAttributes.outerRadius = storedAttrs.x1;\n } else {\n //\n graphicAttributes.startAngle = storedAttrs.x;\n graphicAttributes.endAngle = storedAttrs.x1;\n graphicAttributes.innerRadius = storedAttrs.y;\n graphicAttributes.outerRadius = storedAttrs.y1;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ] as AttributeTransform[];\n }\n\n return transformsByType.rect;\n }\n\n addGraphicItem(attrs: any, groupKey?: string) {\n const graphicItem = createGraphicItem(\n this,\n this.coord && this.coord.output().type === 'polar' ? GrammarMarkType.arc : GrammarMarkType.rect,\n attrs\n );\n\n return super.addGraphicItem(attrs, groupKey, graphicItem);\n }\n\n release(): void {\n super.release();\n this._encoders = null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/semantic-marks/interval.ts"],"names":[],"mappings":";;;AAEA,6CAA6C;AAC7C,0CAAiD;AACjD,iDAAqD;AACrD,wCAA8C;AAC9C,wCAAiE;AAUjE,uCAAoC;AACpC,6CAAyC;AACzC,mDAA0D;AAE1D,6DAAiE;AACjE,6CAA0C;AAE1C,MAAa,QAAS,SAAQ,WAAI;IAOhC,WAAW,CAAC,KAAa,EAAE,OAAsC,EAAE,KAA6B;QAC9F,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEzC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;QAErC,OAAO,IAAI,CAAC;IACd,CAAC;IAES,wBAAwB,CAAC,KAAa;QAC9C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;SACrB;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAA0C,CAAC;QAErF,IAAI,WAAW,IAAI,KAAK,KAAK,QAAQ,EAAE;YACrC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YACjC,MAAM,MAAM,GAA+B,IAAA,qBAAc,EAAC,WAAW,CAAC;gBACpE,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,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AAC3D,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B","file":"interval.js","sourcesContent":["import type { IBandLikeScale, IBaseScale } from '@visactor/vscale';\n// eslint-disable-next-line no-duplicate-imports\nimport { ScaleEnum } from '@visactor/vscale';\nimport { GrammarMarkType } from '../graph/enums';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { isScaleEncode } from '../parse/mark';\nimport { getGrammarOutput, isFunctionType } from '../parse/util';\nimport type {\n StateEncodeSpec,\n MarkSpec,\n IElement,\n MarkFunctionType,\n AttributeTransform,\n GetSignleEncodeSpecByType,\n BaseSignleEncodeSpec\n} from '../types';\nimport { Mark } from '../view/mark';\nimport { isNil } from '@visactor/vutils';\nimport { createGraphicItem } from '../graph/util/graphic';\nimport type { IPolarCoordinate } from '@visactor/vgrammar-coordinate';\nimport { transformsByType } from '../graph/attributes/transform';\nimport { Factory } from '../core/factory';\n\nexport class Interval extends Mark {\n static markType = GrammarMarkType.interval;\n declare markType: GrammarMarkType.interval;\n protected declare spec: MarkSpec;\n\n protected _encoders: StateEncodeSpec;\n\n encodeState(state: string, channel: string | BaseSignleEncodeSpec, value?: MarkFunctionType<any>) {\n super.encodeState(state, channel, value);\n\n this._updateComponentEncoders(state);\n\n return this;\n }\n\n protected _updateComponentEncoders(state: string) {\n if (!this._encoders) {\n this._encoders = {};\n }\n\n const userEncoder = this.spec.encode[state] as GetSignleEncodeSpecByType<'interval'>;\n\n if (userEncoder && state === 'update') {\n const params = this.parameters();\n const scales: Record<string, IBaseScale> = isFunctionType(userEncoder)\n ? null\n : Object.keys(userEncoder).reduce((res, channel) => {\n if (isScaleEncode(userEncoder[channel])) {\n res[channel] = getGrammarOutput(userEncoder[channel].scale, params);\n }\n return res;\n }, {});\n\n this._encoders[state] = {\n callback: (datum: any, element: IElement, parameters: any) => {\n const userEncodeRes = invokeEncoder(userEncoder, datum, element, parameters);\n\n this.disableCoordinateTransform = false;\n if (scales && scales.x && scales.x.type === ScaleEnum.Band) {\n if (!isNil(scales.y)) {\n const domain = scales.y.domain();\n const min = Math.min.apply(null, domain);\n const max = Math.max.apply(null, domain);\n const baseValue = min > 0 ? min : max < 0 ? max : 0;\n\n userEncodeRes.y1 = scales.y.scale(baseValue);\n }\n const bandWidth = (scales.x as IBandLikeScale).bandwidth();\n\n // TODO: handle bandWidth dynamically\n userEncodeRes.x = userEncodeRes.x + bandWidth / 4;\n userEncodeRes.x1 = userEncodeRes.x + bandWidth / 2;\n } else if (scales && scales.y && scales.y.type === ScaleEnum.Band) {\n if (!isNil(scales.x)) {\n const domain = scales.x.domain();\n const min = Math.min.apply(null, domain);\n const max = Math.max.apply(null, domain);\n const baseValue = min > 0 ? min : max < 0 ? max : 0;\n\n userEncodeRes.x1 = scales.x.scale(baseValue);\n }\n const bandWidth = (scales.y as IBandLikeScale).bandwidth();\n\n userEncodeRes.y = userEncodeRes.y + bandWidth / 4;\n userEncodeRes.y1 = userEncodeRes.y + bandWidth / 2;\n }\n\n if (scales) {\n const scaleGrammar =\n this.view.getScaleById((userEncoder as any).x?.scale) ??\n this.view.getScaleById((userEncoder as any).y?.scale);\n const coord = scaleGrammar.getCoordinate();\n\n if (coord && coord.type === 'polar') {\n this.disableCoordinateTransform = true;\n const origin = (coord as IPolarCoordinate).origin();\n userEncodeRes.cx = origin.x;\n userEncodeRes.cy = origin.y;\n }\n }\n\n return userEncodeRes;\n }\n } as GetSignleEncodeSpecByType<'interval'>;\n } else {\n this._encoders[state] = userEncoder;\n }\n }\n\n protected _getEncoders() {\n return this._encoders ?? {};\n }\n\n getAttributeTransforms() {\n if (this.coord && this.coord.output().type === 'polar') {\n return [\n {\n channels: ['x', 'y', 'x1', 'y1', 'cx', 'cy'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = storedAttrs.cx;\n graphicAttributes.y = storedAttrs.cy;\n if (this.coord.output().isTransposed()) {\n graphicAttributes.startAngle = storedAttrs.y;\n graphicAttributes.endAngle = storedAttrs.y1;\n graphicAttributes.innerRadius = storedAttrs.x;\n graphicAttributes.outerRadius = storedAttrs.x1;\n } else {\n //\n graphicAttributes.startAngle = storedAttrs.x;\n graphicAttributes.endAngle = storedAttrs.x1;\n graphicAttributes.innerRadius = storedAttrs.y;\n graphicAttributes.outerRadius = storedAttrs.y1;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ] as AttributeTransform[];\n }\n\n return transformsByType.rect;\n }\n\n addGraphicItem(attrs: any, groupKey?: string) {\n const graphicItem = createGraphicItem(\n this,\n this.coord && this.coord.output().type === 'polar' ? GrammarMarkType.arc : GrammarMarkType.rect,\n attrs\n );\n\n return super.addGraphicItem(attrs, groupKey, graphicItem);\n }\n\n release(): void {\n super.release();\n this._encoders = null;\n }\n}\n\nexport const registerIntervalMark = () => {\n Factory.registerMark(GrammarMarkType.interval, Interval);\n};\n"]}
|
|
@@ -2,6 +2,7 @@ import { GrammarMarkType } from '../graph/enums';
|
|
|
2
2
|
import type { MarkSpec } from '../types';
|
|
3
3
|
import { Mark } from '../view/mark';
|
|
4
4
|
export declare class Text extends Mark {
|
|
5
|
+
static markType: GrammarMarkType;
|
|
5
6
|
markType: GrammarMarkType.text;
|
|
6
7
|
protected spec: MarkSpec;
|
|
7
8
|
addGraphicItem(initAttrs: any, groupKey?: string): any;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.Text = void 0;
|
|
6
6
|
|
|
7
|
-
const enums_1 = require("../graph/enums"), mark_1 = require("../view/mark"), graphic_1 = require("../graph/util/graphic"),
|
|
7
|
+
const enums_1 = require("../graph/enums"), mark_1 = require("../view/mark"), graphic_1 = require("../graph/util/graphic"), transform_1 = require("../graph/attributes/transform");
|
|
8
8
|
|
|
9
9
|
class Text extends mark_1.Mark {
|
|
10
10
|
addGraphicItem(initAttrs, groupKey) {
|
|
@@ -14,12 +14,12 @@ class Text extends mark_1.Mark {
|
|
|
14
14
|
}
|
|
15
15
|
getAttributeTransforms() {
|
|
16
16
|
var _a;
|
|
17
|
-
return "richtext" === (null === (_a = this.getGroupGraphicItem()) || void 0 === _a ? void 0 : _a.type) ?
|
|
17
|
+
return "richtext" === (null === (_a = this.getGroupGraphicItem()) || void 0 === _a ? void 0 : _a.type) ? transform_1.transformsByType.richtext : transform_1.transformsByType.text;
|
|
18
18
|
}
|
|
19
19
|
release() {
|
|
20
20
|
super.release();
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
exports.Text = Text;
|
|
24
|
+
exports.Text = Text, Text.markType = enums_1.GrammarMarkType.text;
|
|
25
25
|
//# sourceMappingURL=text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/semantic-marks/text.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AAEjD,uCAAoC;AACpC,mDAA0D;AAC1D,
|
|
1
|
+
{"version":3,"sources":["../src/semantic-marks/text.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AAEjD,uCAAoC;AACpC,mDAA0D;AAC1D,6DAAiE;AAEjE,MAAa,IAAK,SAAQ,WAAI;IAK5B,cAAc,CAAC,SAAc,EAAE,QAAiB;QAC9C,MAAM,UAAU,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,CAAC;QACnC,MAAM,MAAM,GAAG,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,MAAK,MAAM,CAAC;QAC3C,MAAM,WAAW,GAAG,IAAA,2BAAiB,EACnC,IAAa,EACb,MAAM,CAAC,CAAC,CAAC,uBAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,uBAAe,CAAC,IAAI,EACxD,SAAS,CACV,CAAC;QAEF,IAAI,MAAM,EAAE;YACV,SAAS,CAAC,UAAU,GAAG,EAAE,CAAC;SAC3B;QAED,OAAO,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAChE,CAAC;IAED,sBAAsB;;QACpB,OAAO,CAAA,MAAA,IAAI,CAAC,mBAAmB,EAAE,0CAAE,IAAI,MAAK,UAAU,CAAC,CAAC,CAAC,4BAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,4BAAgB,CAAC,IAAI,CAAC;IAC7G,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;;AA3BH,oBA4BC;AA3BQ,aAAQ,GAAG,uBAAe,CAAC,IAAI,CAAC","file":"text.js","sourcesContent":["import { GrammarMarkType } from '../graph/enums';\nimport type { IMark, MarkSpec } from '../types';\nimport { Mark } from '../view/mark';\nimport { createGraphicItem } from '../graph/util/graphic';\nimport { transformsByType } from '../graph/attributes/transform';\n\nexport class Text extends Mark {\n static markType = GrammarMarkType.text;\n declare markType: GrammarMarkType.text;\n protected declare spec: MarkSpec;\n\n addGraphicItem(initAttrs: any, groupKey?: string) {\n const textConfig = initAttrs?.text;\n const isRich = textConfig?.type === 'rich';\n const graphicItem = createGraphicItem(\n this as IMark,\n isRich ? GrammarMarkType.richtext : GrammarMarkType.text,\n initAttrs\n );\n\n if (isRich) {\n initAttrs.textConfig = [];\n }\n\n return super.addGraphicItem(initAttrs, groupKey, graphicItem);\n }\n\n getAttributeTransforms() {\n return this.getGroupGraphicItem()?.type === 'richtext' ? transformsByType.richtext : transformsByType.text;\n }\n\n release(): void {\n super.release();\n }\n}\n"]}
|
package/cjs/types/animate.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { IPointLike } from '@visactor/vutils';
|
|
|
3
3
|
import type { MarkFunctionCallback, MarkFunctionType } from './mark';
|
|
4
4
|
import type { IMark } from './grammar';
|
|
5
5
|
import type { IElement } from './element';
|
|
6
|
+
import type { FunctionCallback } from './signal';
|
|
6
7
|
export type TypeAnimation<T extends IElement> = (element: T, options: any, animationParameters: IAnimationParameters) => {
|
|
7
8
|
from?: {
|
|
8
9
|
[channel: string]: any;
|
|
@@ -43,7 +44,10 @@ export interface IMoveAnimationOptions {
|
|
|
43
44
|
point?: {
|
|
44
45
|
x?: number;
|
|
45
46
|
y?: number;
|
|
46
|
-
}
|
|
47
|
+
} | FunctionCallback<{
|
|
48
|
+
x?: number;
|
|
49
|
+
y?: number;
|
|
50
|
+
}>;
|
|
47
51
|
}
|
|
48
52
|
export interface IRotateAnimationOptions {
|
|
49
53
|
orient?: 'clockwise' | 'anticlockwise';
|
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';\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 }
|
|
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"]}
|
package/cjs/types/grammar.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ export interface IMark extends IGrammarBase, IProgressiveGrammar {
|
|
|
134
134
|
elementMap: Map<string, IElement>;
|
|
135
135
|
graphicIndex: number;
|
|
136
136
|
graphicItem?: IGroup;
|
|
137
|
-
animate
|
|
137
|
+
animate?: IAnimate;
|
|
138
138
|
join: (data: IData | string | Nil, key?: MarkKeySpec, sort?: MarkSortSpec, groupBy?: MarkKeySpec, groupSort?: MarkSortSpec) => this;
|
|
139
139
|
coordinate: (coordinate: ICoordinate | string | Nil) => this;
|
|
140
140
|
state: (state: MarkFunctionType<string | string[]> | Nil) => this;
|