@visactor/vgrammar-plot 0.6.0

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.
Files changed (173) hide show
  1. package/README.md +3 -0
  2. package/README.zh-CN.md +0 -0
  3. package/cjs/area.d.ts +14 -0
  4. package/cjs/area.js +83 -0
  5. package/cjs/area.js.map +1 -0
  6. package/cjs/cell.d.ts +14 -0
  7. package/cjs/cell.js +51 -0
  8. package/cjs/cell.js.map +1 -0
  9. package/cjs/circle-packing.d.ts +17 -0
  10. package/cjs/circle-packing.js +76 -0
  11. package/cjs/circle-packing.js.map +1 -0
  12. package/cjs/enums.d.ts +24 -0
  13. package/cjs/enums.js +17 -0
  14. package/cjs/enums.js.map +1 -0
  15. package/cjs/image.d.ts +13 -0
  16. package/cjs/image.js +77 -0
  17. package/cjs/image.js.map +1 -0
  18. package/cjs/index.d.ts +1 -0
  19. package/cjs/index.js +15 -0
  20. package/cjs/index.js.map +1 -0
  21. package/cjs/interval.d.ts +19 -0
  22. package/cjs/interval.js +102 -0
  23. package/cjs/interval.js.map +1 -0
  24. package/cjs/line.d.ts +14 -0
  25. package/cjs/line.js +52 -0
  26. package/cjs/line.js.map +1 -0
  27. package/cjs/path.d.ts +11 -0
  28. package/cjs/path.js +25 -0
  29. package/cjs/path.js.map +1 -0
  30. package/cjs/plot-all.d.ts +2 -0
  31. package/cjs/plot-all.js +19 -0
  32. package/cjs/plot-all.js.map +1 -0
  33. package/cjs/plot.d.ts +46 -0
  34. package/cjs/plot.js +265 -0
  35. package/cjs/plot.js.map +1 -0
  36. package/cjs/polygon.d.ts +12 -0
  37. package/cjs/polygon.js +44 -0
  38. package/cjs/polygon.js.map +1 -0
  39. package/cjs/rect-x.d.ts +13 -0
  40. package/cjs/rect-x.js +67 -0
  41. package/cjs/rect-x.js.map +1 -0
  42. package/cjs/rect-y.d.ts +13 -0
  43. package/cjs/rect-y.js +67 -0
  44. package/cjs/rect-y.js.map +1 -0
  45. package/cjs/rect.d.ts +13 -0
  46. package/cjs/rect.js +82 -0
  47. package/cjs/rect.js.map +1 -0
  48. package/cjs/rule-x.d.ts +12 -0
  49. package/cjs/rule-x.js +37 -0
  50. package/cjs/rule-x.js.map +1 -0
  51. package/cjs/rule-y.d.ts +12 -0
  52. package/cjs/rule-y.js +36 -0
  53. package/cjs/rule-y.js.map +1 -0
  54. package/cjs/rule.d.ts +12 -0
  55. package/cjs/rule.js +45 -0
  56. package/cjs/rule.js.map +1 -0
  57. package/cjs/sankey.d.ts +46 -0
  58. package/cjs/sankey.js +139 -0
  59. package/cjs/sankey.js.map +1 -0
  60. package/cjs/semantic-mark.d.ts +88 -0
  61. package/cjs/semantic-mark.js +846 -0
  62. package/cjs/semantic-mark.js.map +1 -0
  63. package/cjs/sunburst.d.ts +45 -0
  64. package/cjs/sunburst.js +134 -0
  65. package/cjs/sunburst.js.map +1 -0
  66. package/cjs/symbol.d.ts +13 -0
  67. package/cjs/symbol.js +53 -0
  68. package/cjs/symbol.js.map +1 -0
  69. package/cjs/text.d.ts +12 -0
  70. package/cjs/text.js +32 -0
  71. package/cjs/text.js.map +1 -0
  72. package/cjs/tree.d.ts +20 -0
  73. package/cjs/tree.js +128 -0
  74. package/cjs/tree.js.map +1 -0
  75. package/cjs/treemap.d.ts +41 -0
  76. package/cjs/treemap.js +109 -0
  77. package/cjs/treemap.js.map +1 -0
  78. package/cjs/util.d.ts +3 -0
  79. package/cjs/util.js +11 -0
  80. package/cjs/util.js.map +1 -0
  81. package/cjs/wordcloud-shape.d.ts +13 -0
  82. package/cjs/wordcloud-shape.js +85 -0
  83. package/cjs/wordcloud-shape.js.map +1 -0
  84. package/cjs/wordcloud.d.ts +13 -0
  85. package/cjs/wordcloud.js +81 -0
  86. package/cjs/wordcloud.js.map +1 -0
  87. package/dist/index.js +3291 -0
  88. package/dist/index.min.js +1 -0
  89. package/es/area.d.ts +14 -0
  90. package/es/area.js +83 -0
  91. package/es/area.js.map +1 -0
  92. package/es/cell.d.ts +14 -0
  93. package/es/cell.js +49 -0
  94. package/es/cell.js.map +1 -0
  95. package/es/circle-packing.d.ts +17 -0
  96. package/es/circle-packing.js +75 -0
  97. package/es/circle-packing.js.map +1 -0
  98. package/es/enums.d.ts +24 -0
  99. package/es/enums.js +13 -0
  100. package/es/enums.js.map +1 -0
  101. package/es/image.d.ts +13 -0
  102. package/es/image.js +74 -0
  103. package/es/image.js.map +1 -0
  104. package/es/index.d.ts +1 -0
  105. package/es/index.js +2 -0
  106. package/es/index.js.map +1 -0
  107. package/es/interval.d.ts +19 -0
  108. package/es/interval.js +103 -0
  109. package/es/interval.js.map +1 -0
  110. package/es/line.d.ts +14 -0
  111. package/es/line.js +50 -0
  112. package/es/line.js.map +1 -0
  113. package/es/path.d.ts +11 -0
  114. package/es/path.js +23 -0
  115. package/es/path.js.map +1 -0
  116. package/es/plot-all.d.ts +2 -0
  117. package/es/plot-all.js +50 -0
  118. package/es/plot-all.js.map +1 -0
  119. package/es/plot.d.ts +46 -0
  120. package/es/plot.js +263 -0
  121. package/es/plot.js.map +1 -0
  122. package/es/polygon.d.ts +12 -0
  123. package/es/polygon.js +43 -0
  124. package/es/polygon.js.map +1 -0
  125. package/es/rect-x.d.ts +13 -0
  126. package/es/rect-x.js +69 -0
  127. package/es/rect-x.js.map +1 -0
  128. package/es/rect-y.d.ts +13 -0
  129. package/es/rect-y.js +69 -0
  130. package/es/rect-y.js.map +1 -0
  131. package/es/rect.d.ts +13 -0
  132. package/es/rect.js +84 -0
  133. package/es/rect.js.map +1 -0
  134. package/es/rule-x.d.ts +12 -0
  135. package/es/rule-x.js +35 -0
  136. package/es/rule-x.js.map +1 -0
  137. package/es/rule-y.d.ts +12 -0
  138. package/es/rule-y.js +34 -0
  139. package/es/rule-y.js.map +1 -0
  140. package/es/rule.d.ts +12 -0
  141. package/es/rule.js +45 -0
  142. package/es/rule.js.map +1 -0
  143. package/es/sankey.d.ts +46 -0
  144. package/es/sankey.js +137 -0
  145. package/es/sankey.js.map +1 -0
  146. package/es/semantic-mark.d.ts +88 -0
  147. package/es/semantic-mark.js +833 -0
  148. package/es/semantic-mark.js.map +1 -0
  149. package/es/sunburst.d.ts +45 -0
  150. package/es/sunburst.js +133 -0
  151. package/es/sunburst.js.map +1 -0
  152. package/es/symbol.d.ts +13 -0
  153. package/es/symbol.js +51 -0
  154. package/es/symbol.js.map +1 -0
  155. package/es/text.d.ts +12 -0
  156. package/es/text.js +30 -0
  157. package/es/text.js.map +1 -0
  158. package/es/tree.d.ts +20 -0
  159. package/es/tree.js +127 -0
  160. package/es/tree.js.map +1 -0
  161. package/es/treemap.d.ts +41 -0
  162. package/es/treemap.js +108 -0
  163. package/es/treemap.js.map +1 -0
  164. package/es/util.d.ts +3 -0
  165. package/es/util.js +3 -0
  166. package/es/util.js.map +1 -0
  167. package/es/wordcloud-shape.d.ts +13 -0
  168. package/es/wordcloud-shape.js +84 -0
  169. package/es/wordcloud-shape.js.map +1 -0
  170. package/es/wordcloud.d.ts +13 -0
  171. package/es/wordcloud.js +80 -0
  172. package/es/wordcloud.js.map +1 -0
  173. package/package.json +73 -0
@@ -0,0 +1,13 @@
1
+ import type { RectXEncodeChannels, PlotRectXEncoderSpec, SemanticTooltipOption, WithDefaultEncode, GenerateBaseEncodeSpec, CrosshairSpec, Nil, ScaleSpec, ValueOf } from '@visactor/vgrammar';
2
+ import { SemanticMark } from './semantic-mark';
3
+ import { PlotMakType } from './enums';
4
+ import { GrammarMarkType } from '@visactor/vgrammar';
5
+ export declare class RectXSemanticMark extends SemanticMark<PlotRectXEncoderSpec, RectXEncodeChannels> {
6
+ static readonly type = PlotMakType.rectX;
7
+ constructor(id?: string | number);
8
+ setMarkType(): GrammarMarkType;
9
+ parseScaleByEncode(channel: RectXEncodeChannels, option: ValueOf<WithDefaultEncode<PlotRectXEncoderSpec, RectXEncodeChannels>, RectXEncodeChannels>): ScaleSpec | Nil;
10
+ setDefaultCrosshair(): Record<string, Pick<CrosshairSpec, 'crosshairShape' | 'crosshairType'>>;
11
+ setDefaultTooltip(): SemanticTooltipOption | Nil;
12
+ convertMarkEncode(encode: WithDefaultEncode<PlotRectXEncoderSpec, RectXEncodeChannels>): GenerateBaseEncodeSpec<PlotRectXEncoderSpec>;
13
+ }
package/cjs/rect-x.js ADDED
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.RectXSemanticMark = void 0;
6
+
7
+ const vgrammar_util_1 = require("@visactor/vgrammar-util"), semantic_mark_1 = require("./semantic-mark"), vutils_1 = require("@visactor/vutils"), enums_1 = require("./enums"), vgrammar_1 = require("@visactor/vgrammar");
8
+
9
+ class RectXSemanticMark extends semantic_mark_1.SemanticMark {
10
+ constructor(id) {
11
+ super(enums_1.PlotMakType.rectX, id);
12
+ }
13
+ setMarkType() {
14
+ return vgrammar_1.GrammarMarkType.rect;
15
+ }
16
+ parseScaleByEncode(channel, option) {
17
+ return this.parseScaleOfCommonEncode(channel, option);
18
+ }
19
+ setDefaultCrosshair() {
20
+ return {
21
+ x: {
22
+ crosshairShape: "rect"
23
+ }
24
+ };
25
+ }
26
+ setDefaultTooltip() {
27
+ var _a;
28
+ const encodeX = null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a.x;
29
+ return {
30
+ content: (0, vutils_1.isArray)(encodeX) ? encodeX.map((entry => ({
31
+ value: entry
32
+ }))) : [ {
33
+ value: encodeX
34
+ } ]
35
+ };
36
+ }
37
+ convertMarkEncode(encode) {
38
+ var _a, _b, _c, _d;
39
+ const markEncoder = this.convertSimpleMarkEncode(encode), scaleXId = this.getScaleId("x"), res = {
40
+ y: (datum, el, params) => 0,
41
+ y1: (datum, el, params) => params.viewBox.height()
42
+ };
43
+ if ((0, vutils_1.isArray)(null === (_a = markEncoder.x) || void 0 === _a ? void 0 : _a.field)) res.x = {
44
+ field: markEncoder.x.field[0],
45
+ scale: markEncoder.x.scale
46
+ }, res.x1 = {
47
+ field: markEncoder.x.field[1],
48
+ scale: markEncoder.x.scale
49
+ }; else {
50
+ const xAccessor = (0, vgrammar_util_1.field)(markEncoder.x.field);
51
+ res.x = (datum, el, params) => {
52
+ const xVals = xAccessor(datum), scale = params[scaleXId];
53
+ return (0, vutils_1.isArray)(xVals) ? scale.scale(xVals[0]) : scale.scale(xVals);
54
+ }, res.x1 = (datum, el, params) => {
55
+ const scale = params[scaleXId], xVals = xAccessor(datum);
56
+ if ((0, vutils_1.isArray)(xVals) && xVals.length > 1) return scale.scale(xVals[1]);
57
+ const domain = scale.domain(), min = Math.min.apply(null, domain), max = Math.max.apply(null, domain), baseValue = min > 0 ? min : max < 0 ? max : 0;
58
+ return scale.scale(baseValue);
59
+ };
60
+ }
61
+ return markEncoder.color || markEncoder.group ? res.fill = null !== (_b = markEncoder.color) && void 0 !== _b ? _b : markEncoder.group : res.fill = null !== (_d = null === (_c = this.spec.style) || void 0 === _c ? void 0 : _c.fill) && void 0 !== _d ? _d : (0,
62
+ vgrammar_1.getPalette)()[0], res;
63
+ }
64
+ }
65
+
66
+ exports.RectXSemanticMark = RectXSemanticMark, RectXSemanticMark.type = enums_1.PlotMakType.rectX;
67
+ //# sourceMappingURL=rect-x.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rect-x.ts"],"names":[],"mappings":";;;AAAA,2DAAoE;AAapE,mDAA+C;AAC/C,6CAA2C;AAC3C,mCAAsC;AACtC,iDAAiE;AAEjE,MAAa,iBAAkB,SAAQ,4BAAuD;IAE5F,YAAY,EAAoB;QAC9B,KAAK,CAAC,mBAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED,WAAW;QACT,OAAO,0BAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,kBAAkB,CAChB,OAA4B,EAC5B,MAAkG;QAElG,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,mBAAmB;QACjB,OAAO;YACL,CAAC,EAAE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CAAC,CAAC,CAAC,CAAC,CAAC;gBAEpD,OAAO,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAChC,CAAC,CAAC;SACH;QACD,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE;YAC1C,GAAG,CAAC,IAAI,GAAG,MAAA,WAAW,CAAC,KAAK,mCAAI,WAAW,CAAC,KAAK,CAAC;SACnD;aAAM;YACL,GAAG,CAAC,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,IAAI,mCAAI,IAAA,qBAAU,GAAE,CAAC,CAAC,CAAC,CAAC;SACrD;QAED,OAAO,GAAG,CAAC;IACb,CAAC;;AAvFH,8CAwFC;AAvFiB,sBAAI,GAAG,mBAAW,CAAC,KAAK,CAAC","file":"rect-x.js","sourcesContent":["import { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport type {\n RectXEncodeChannels,\n PlotRectXEncoderSpec,\n SemanticTooltipOption,\n WithDefaultEncode,\n GenerateBaseEncodeSpec,\n CrosshairSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n IElement\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\nimport { isArray } from '@visactor/vutils';\nimport { PlotMakType } from './enums';\nimport { getPalette, GrammarMarkType } from '@visactor/vgrammar';\n\nexport class RectXSemanticMark extends SemanticMark<PlotRectXEncoderSpec, RectXEncodeChannels> {\n static readonly type = PlotMakType.rectX;\n constructor(id?: string | number) {\n super(PlotMakType.rectX, id);\n }\n\n setMarkType() {\n return GrammarMarkType.rect;\n }\n\n parseScaleByEncode(\n channel: RectXEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotRectXEncoderSpec, RectXEncodeChannels>, RectXEncodeChannels>\n ): ScaleSpec | Nil {\n return this.parseScaleOfCommonEncode(channel, option);\n }\n\n setDefaultCrosshair(): Record<string, Pick<CrosshairSpec, 'crosshairShape' | 'crosshairType'>> {\n return {\n x: { crosshairShape: 'rect' }\n };\n }\n\n setDefaultTooltip(): SemanticTooltipOption | Nil {\n const encodeX = this.spec.encode?.x;\n return {\n content: isArray(encodeX)\n ? encodeX.map(entry => {\n return {\n value: entry\n };\n })\n : [\n {\n value: encodeX\n }\n ]\n };\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<PlotRectXEncoderSpec, RectXEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotRectXEncoderSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n const scaleXId = this.getScaleId('x');\n const res: GenerateBaseEncodeSpec<PlotRectXEncoderSpec> = {\n y: (datum: any, el: IElement, params: any) => {\n return 0;\n },\n y1: (datum: any, el: IElement, params: any) => {\n return params.viewBox.height();\n }\n };\n\n if (isArray(markEncoder.x?.field)) {\n res.x = { field: markEncoder.x.field[0], scale: markEncoder.x.scale };\n res.x1 = { field: markEncoder.x.field[1], scale: markEncoder.x.scale };\n } else {\n const xAccessor = getFieldAccessor(markEncoder.x.field);\n res.x = (datum: any, el: IElement, params: any) => {\n const xVals = xAccessor(datum);\n const scale = params[scaleXId];\n\n return isArray(xVals) ? scale.scale(xVals[0]) : scale.scale(xVals);\n };\n res.x1 = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleXId];\n const xVals = xAccessor(datum);\n\n if (isArray(xVals) && xVals.length > 1) {\n return scale.scale(xVals[1]);\n }\n const domain = scale.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 return scale.scale(baseValue);\n };\n }\n if (markEncoder.color || markEncoder.group) {\n res.fill = markEncoder.color ?? markEncoder.group;\n } else {\n res.fill = this.spec.style?.fill ?? getPalette()[0];\n }\n\n return res;\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { RectYEncodeChannels, PlotRectYEncoderSpec, SemanticTooltipOption, WithDefaultEncode, GenerateBaseEncodeSpec, CrosshairSpec, Nil, ScaleSpec, ValueOf } from '@visactor/vgrammar';
2
+ import { SemanticMark } from './semantic-mark';
3
+ import { GrammarMarkType } from '@visactor/vgrammar';
4
+ import { PlotMakType } from './enums';
5
+ export declare class RectYSemanticMark extends SemanticMark<PlotRectYEncoderSpec, RectYEncodeChannels> {
6
+ static readonly type = PlotMakType.rectY;
7
+ constructor(id?: string | number);
8
+ setMarkType(): GrammarMarkType;
9
+ parseScaleByEncode(channel: RectYEncodeChannels, option: ValueOf<WithDefaultEncode<PlotRectYEncoderSpec, RectYEncodeChannels>, RectYEncodeChannels>): ScaleSpec | Nil;
10
+ setDefaultCrosshair(): Record<string, Pick<CrosshairSpec, 'crosshairShape' | 'crosshairType'>>;
11
+ setDefaultTooltip(): SemanticTooltipOption | Nil;
12
+ convertMarkEncode(encode: WithDefaultEncode<PlotRectYEncoderSpec, RectYEncodeChannels>): GenerateBaseEncodeSpec<PlotRectYEncoderSpec>;
13
+ }
package/cjs/rect-y.js ADDED
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.RectYSemanticMark = void 0;
6
+
7
+ const vgrammar_util_1 = require("@visactor/vgrammar-util"), semantic_mark_1 = require("./semantic-mark"), vutils_1 = require("@visactor/vutils"), vgrammar_1 = require("@visactor/vgrammar"), enums_1 = require("./enums");
8
+
9
+ class RectYSemanticMark extends semantic_mark_1.SemanticMark {
10
+ constructor(id) {
11
+ super(enums_1.PlotMakType.rectY, id);
12
+ }
13
+ setMarkType() {
14
+ return vgrammar_1.GrammarMarkType.rect;
15
+ }
16
+ parseScaleByEncode(channel, option) {
17
+ return this.parseScaleOfCommonEncode(channel, option);
18
+ }
19
+ setDefaultCrosshair() {
20
+ return {
21
+ x: {
22
+ crosshairShape: "rect"
23
+ }
24
+ };
25
+ }
26
+ setDefaultTooltip() {
27
+ var _a;
28
+ const encodeY = null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a.y;
29
+ return {
30
+ content: (0, vutils_1.isArray)(encodeY) ? encodeY.map((entry => ({
31
+ value: entry
32
+ }))) : [ {
33
+ value: encodeY
34
+ } ]
35
+ };
36
+ }
37
+ convertMarkEncode(encode) {
38
+ var _a, _b, _c, _d;
39
+ const markEncoder = this.convertSimpleMarkEncode(encode), scaleYId = this.getScaleId("y"), res = {
40
+ x: (datum, el, params) => 0,
41
+ x1: (datum, el, params) => params.viewBox.width()
42
+ };
43
+ if ((0, vutils_1.isArray)(null === (_a = markEncoder.y) || void 0 === _a ? void 0 : _a.field)) res.y = {
44
+ field: markEncoder.y.field[0],
45
+ scale: markEncoder.y.scale
46
+ }, res.y1 = {
47
+ field: markEncoder.y.field[1],
48
+ scale: markEncoder.y.scale
49
+ }; else {
50
+ const yAccessor = (0, vgrammar_util_1.field)(markEncoder.y.field);
51
+ res.y = (datum, el, params) => {
52
+ const yVals = yAccessor(datum), scale = params[scaleYId];
53
+ return (0, vutils_1.isArray)(yVals) ? scale.scale(yVals[0]) : scale.scale(yVals);
54
+ }, res.y1 = (datum, el, params) => {
55
+ const scale = params[scaleYId], yVals = yAccessor(datum);
56
+ if ((0, vutils_1.isArray)(yVals) && yVals.length > 1) return scale.scale(yVals[1]);
57
+ const domain = scale.domain(), min = Math.min.apply(null, domain), max = Math.max.apply(null, domain), baseValue = min > 0 ? min : max < 0 ? max : 0;
58
+ return scale.scale(baseValue);
59
+ };
60
+ }
61
+ return markEncoder.color || markEncoder.group ? res.fill = null !== (_b = markEncoder.color) && void 0 !== _b ? _b : markEncoder.group : res.fill = null !== (_d = null === (_c = this.spec.style) || void 0 === _c ? void 0 : _c.fill) && void 0 !== _d ? _d : (0,
62
+ vgrammar_1.getPalette)()[0], res;
63
+ }
64
+ }
65
+
66
+ exports.RectYSemanticMark = RectYSemanticMark, RectYSemanticMark.type = enums_1.PlotMakType.rectY;
67
+ //# sourceMappingURL=rect-y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rect-y.ts"],"names":[],"mappings":";;;AAAA,2DAAoE;AAapE,mDAA+C;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AC,CAAC,CAAC,CAAC,CAAC;iBAC9B;gBACD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBACzC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBACzC,MAAM,SAAS,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAEpD,OAAO,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAChC,CAAC,CAAC;SACH;QAED,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE;YAC1C,GAAG,CAAC,IAAI,GAAG,MAAA,WAAW,CAAC,KAAK,mCAAI,WAAW,CAAC,KAAK,CAAC;SACnD;aAAM;YACL,GAAG,CAAC,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,IAAI,mCAAI,IAAA,qBAAU,GAAE,CAAC,CAAC,CAAC,CAAC;SACrD;QAED,OAAO,GAAG,CAAC;IACb,CAAC;;AAxFH,8CAyFC;AAxFiB,sBAAI,GAAG,mBAAW,CAAC,KAAK,CAAC","file":"rect-y.js","sourcesContent":["import { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport type {\n RectYEncodeChannels,\n PlotRectYEncoderSpec,\n SemanticTooltipOption,\n WithDefaultEncode,\n GenerateBaseEncodeSpec,\n CrosshairSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n IElement\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\nimport { isArray } from '@visactor/vutils';\nimport { getPalette, GrammarMarkType } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\n\nexport class RectYSemanticMark extends SemanticMark<PlotRectYEncoderSpec, RectYEncodeChannels> {\n static readonly type = PlotMakType.rectY;\n constructor(id?: string | number) {\n super(PlotMakType.rectY, id);\n }\n\n setMarkType() {\n return GrammarMarkType.rect;\n }\n\n parseScaleByEncode(\n channel: RectYEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotRectYEncoderSpec, RectYEncodeChannels>, RectYEncodeChannels>\n ): ScaleSpec | Nil {\n return this.parseScaleOfCommonEncode(channel, option);\n }\n\n setDefaultCrosshair(): Record<string, Pick<CrosshairSpec, 'crosshairShape' | 'crosshairType'>> {\n return {\n x: { crosshairShape: 'rect' }\n };\n }\n\n setDefaultTooltip(): SemanticTooltipOption | Nil {\n const encodeY = this.spec.encode?.y;\n return {\n content: isArray(encodeY)\n ? encodeY.map(entry => {\n return {\n value: entry\n };\n })\n : [\n {\n value: encodeY\n }\n ]\n };\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<PlotRectYEncoderSpec, RectYEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotRectYEncoderSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n const scaleYId = this.getScaleId('y');\n const res: GenerateBaseEncodeSpec<PlotRectYEncoderSpec> = {\n x: (datum: any, el: IElement, params: any) => {\n return 0;\n },\n x1: (datum: any, el: IElement, params: any) => {\n return params.viewBox.width();\n }\n };\n\n if (isArray(markEncoder.y?.field)) {\n res.y = { field: markEncoder.y.field[0], scale: markEncoder.y.scale };\n res.y1 = { field: markEncoder.y.field[1], scale: markEncoder.y.scale };\n } else {\n const yAccessor = getFieldAccessor(markEncoder.y.field);\n res.y = (datum: any, el: IElement, params: any) => {\n const yVals = yAccessor(datum);\n const scale = params[scaleYId];\n\n return isArray(yVals) ? scale.scale(yVals[0]) : scale.scale(yVals);\n };\n res.y1 = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleYId];\n const yVals = yAccessor(datum);\n\n if (isArray(yVals) && yVals.length > 1) {\n return scale.scale(yVals[1]);\n }\n const domain = scale.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 return scale.scale(baseValue);\n };\n }\n\n if (markEncoder.color || markEncoder.group) {\n res.fill = markEncoder.color ?? markEncoder.group;\n } else {\n res.fill = this.spec.style?.fill ?? getPalette()[0];\n }\n\n return res;\n }\n}\n"]}
package/cjs/rect.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { RectEncodeChannels, PlotRectEncoderSpec, SemanticTooltipOption, WithDefaultEncode, GenerateBaseEncodeSpec, CrosshairSpec, Nil, ScaleSpec, ValueOf } from '@visactor/vgrammar';
2
+ import { SemanticMark } from './semantic-mark';
3
+ import { GrammarMarkType } from '@visactor/vgrammar';
4
+ import { PlotMakType } from './enums';
5
+ export declare class RectSemanticMark extends SemanticMark<PlotRectEncoderSpec, RectEncodeChannels> {
6
+ static readonly type = PlotMakType.rect;
7
+ constructor(id?: string | number);
8
+ setMarkType(): GrammarMarkType;
9
+ parseScaleByEncode(channel: RectEncodeChannels, option: ValueOf<WithDefaultEncode<PlotRectEncoderSpec, RectEncodeChannels>, RectEncodeChannels>): ScaleSpec | Nil;
10
+ setDefaultCrosshair(): Record<string, Pick<CrosshairSpec, 'crosshairShape' | 'crosshairType'>>;
11
+ setDefaultTooltip(): SemanticTooltipOption | Nil;
12
+ convertMarkEncode(encode: WithDefaultEncode<PlotRectEncoderSpec, RectEncodeChannels>): GenerateBaseEncodeSpec<PlotRectEncoderSpec>;
13
+ }
package/cjs/rect.js ADDED
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.RectSemanticMark = void 0;
6
+
7
+ const vgrammar_util_1 = require("@visactor/vgrammar-util"), semantic_mark_1 = require("./semantic-mark"), vgrammar_1 = require("@visactor/vgrammar"), vutils_1 = require("@visactor/vutils"), enums_1 = require("./enums");
8
+
9
+ class RectSemanticMark extends semantic_mark_1.SemanticMark {
10
+ constructor(id) {
11
+ super(enums_1.PlotMakType.rect, id);
12
+ }
13
+ setMarkType() {
14
+ return vgrammar_1.GrammarMarkType.rect;
15
+ }
16
+ parseScaleByEncode(channel, option) {
17
+ return this.parseScaleOfCommonEncode(channel, option);
18
+ }
19
+ setDefaultCrosshair() {
20
+ return {
21
+ x: {
22
+ crosshairShape: "rect"
23
+ }
24
+ };
25
+ }
26
+ setDefaultTooltip() {
27
+ var _a;
28
+ const encodeY = null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a.y;
29
+ return {
30
+ content: (0, vutils_1.isArray)(encodeY) ? encodeY.map((entry => ({
31
+ value: entry
32
+ }))) : [ {
33
+ value: encodeY
34
+ } ]
35
+ };
36
+ }
37
+ convertMarkEncode(encode) {
38
+ var _a, _b, _c, _d, _e;
39
+ const markEncoder = this.convertSimpleMarkEncode(encode), scaleXId = this.getScaleId("x"), scaleYId = this.getScaleId("y"), res = {};
40
+ if ((0, vutils_1.isArray)(null === (_a = markEncoder.x) || void 0 === _a ? void 0 : _a.field)) res.x = {
41
+ field: markEncoder.x.field[0],
42
+ scale: markEncoder.x.scale
43
+ }, res.x1 = {
44
+ field: markEncoder.x.field[1],
45
+ scale: markEncoder.x.scale
46
+ }; else {
47
+ const xAccessor = (0, vgrammar_util_1.field)(markEncoder.x.field);
48
+ res.x = (datum, el, params) => {
49
+ const xVals = xAccessor(datum), scale = params[scaleXId];
50
+ return (0, vutils_1.isArray)(xVals) ? scale.scale(xVals[0]) : scale.scale(xVals);
51
+ }, res.x1 = (datum, el, params) => {
52
+ const scale = params[scaleXId], xVals = xAccessor(datum);
53
+ if ((0, vutils_1.isArray)(xVals) && xVals.length > 1) return scale.scale(xVals[1]);
54
+ const domain = scale.domain(), min = Math.min.apply(null, domain), max = Math.max.apply(null, domain), baseValue = min > 0 ? min : max < 0 ? max : 0;
55
+ return scale.scale(baseValue);
56
+ };
57
+ }
58
+ if ((0, vutils_1.isArray)(null === (_b = markEncoder.y) || void 0 === _b ? void 0 : _b.field)) res.y = {
59
+ field: markEncoder.y.field[0],
60
+ scale: markEncoder.y.scale
61
+ }, res.y1 = {
62
+ field: markEncoder.y.field[1],
63
+ scale: markEncoder.y.scale
64
+ }; else {
65
+ const yAccessor = (0, vgrammar_util_1.field)(markEncoder.y.field);
66
+ res.y = (datum, el, params) => {
67
+ const yVals = yAccessor(datum), scale = params[scaleYId];
68
+ return (0, vutils_1.isArray)(yVals) ? scale.scale(yVals[0]) : scale.scale(yVals);
69
+ }, res.y1 = (datum, el, params) => {
70
+ const scale = params[scaleYId], yVals = yAccessor(datum);
71
+ if ((0, vutils_1.isArray)(yVals) && yVals.length > 1) return scale.scale(yVals[1]);
72
+ const domain = scale.domain(), min = Math.min.apply(null, domain), max = Math.max.apply(null, domain), baseValue = min > 0 ? min : max < 0 ? max : 0;
73
+ return scale.scale(baseValue);
74
+ };
75
+ }
76
+ return markEncoder.color || markEncoder.group ? res.fill = null !== (_c = markEncoder.color) && void 0 !== _c ? _c : markEncoder.group : res.fill = null !== (_e = null === (_d = this.spec.style) || void 0 === _d ? void 0 : _d.fill) && void 0 !== _e ? _e : (0,
77
+ vgrammar_1.getPalette)()[0], res;
78
+ }
79
+ }
80
+
81
+ exports.RectSemanticMark = RectSemanticMark, RectSemanticMark.type = enums_1.PlotMakType.rect;
82
+ //# sourceMappingURL=rect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rect.ts"],"names":[],"mappings":";;;AAAA,2DAAoE;AAapE,mDAA+C;AAC/C,iDAAiE;AACjE,6CAA2C;AAC3C,mCAAsC;AAEtC,MAAa,gBAAiB,SAAQ,4BAAqD;IAEzF,YAAY,EAAoB;QAC9B,KAAK,CAAC,mBAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,WAAW;QACT,OAAO,0BAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,kBAAkB,CAChB,OAA2B,EAC3B,M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OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC9B;gBACD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBACzC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBACzC,MAAM,SAAS,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAEpD,OAAO,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAChC,CAAC,CAAC;SACH;QAED,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE;YAC1C,GAAG,CAAC,IAAI,GAAG,MAAA,WAAW,CAAC,KAAK,mCAAI,WAAW,CAAC,KAAK,CAAC;SACnD;aAAM;YACL,GAAG,CAAC,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,IAAI,mCAAI,IAAA,qBAAU,GAAE,CAAC,CAAC,CAAC,CAAC;SACrD;QAED,OAAO,GAAG,CAAC;IACb,CAAC;;AA7GH,4CA8GC;AA7GiB,qBAAI,GAAG,mBAAW,CAAC,IAAI,CAAC","file":"rect.js","sourcesContent":["import { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport type {\n RectEncodeChannels,\n PlotRectEncoderSpec,\n SemanticTooltipOption,\n WithDefaultEncode,\n GenerateBaseEncodeSpec,\n CrosshairSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n IElement\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\nimport { getPalette, GrammarMarkType } from '@visactor/vgrammar';\nimport { isArray } from '@visactor/vutils';\nimport { PlotMakType } from './enums';\n\nexport class RectSemanticMark extends SemanticMark<PlotRectEncoderSpec, RectEncodeChannels> {\n static readonly type = PlotMakType.rect;\n constructor(id?: string | number) {\n super(PlotMakType.rect, id);\n }\n\n setMarkType() {\n return GrammarMarkType.rect;\n }\n\n parseScaleByEncode(\n channel: RectEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotRectEncoderSpec, RectEncodeChannels>, RectEncodeChannels>\n ): ScaleSpec | Nil {\n return this.parseScaleOfCommonEncode(channel, option);\n }\n\n setDefaultCrosshair(): Record<string, Pick<CrosshairSpec, 'crosshairShape' | 'crosshairType'>> {\n return {\n x: { crosshairShape: 'rect' }\n };\n }\n\n setDefaultTooltip(): SemanticTooltipOption | Nil {\n const encodeY = this.spec.encode?.y;\n return {\n content: isArray(encodeY)\n ? encodeY.map(entry => {\n return {\n value: entry\n };\n })\n : [\n {\n value: encodeY\n }\n ]\n };\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<PlotRectEncoderSpec, RectEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotRectEncoderSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n const scaleXId = this.getScaleId('x');\n const scaleYId = this.getScaleId('y');\n const res: GenerateBaseEncodeSpec<PlotRectEncoderSpec> = {};\n\n if (isArray(markEncoder.x?.field)) {\n res.x = { field: markEncoder.x.field[0], scale: markEncoder.x.scale };\n res.x1 = { field: markEncoder.x.field[1], scale: markEncoder.x.scale };\n } else {\n const xAccessor = getFieldAccessor(markEncoder.x.field);\n res.x = (datum: any, el: IElement, params: any) => {\n const xVals = xAccessor(datum);\n const scale = params[scaleXId];\n\n return isArray(xVals) ? scale.scale(xVals[0]) : scale.scale(xVals);\n };\n res.x1 = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleXId];\n const xVals = xAccessor(datum);\n\n if (isArray(xVals) && xVals.length > 1) {\n return scale.scale(xVals[1]);\n }\n const domain = scale.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 return scale.scale(baseValue);\n };\n }\n\n if (isArray(markEncoder.y?.field)) {\n res.y = { field: markEncoder.y.field[0], scale: markEncoder.y.scale };\n res.y1 = { field: markEncoder.y.field[1], scale: markEncoder.y.scale };\n } else {\n const yAccessor = getFieldAccessor(markEncoder.y.field);\n res.y = (datum: any, el: IElement, params: any) => {\n const yVals = yAccessor(datum);\n const scale = params[scaleYId];\n\n return isArray(yVals) ? scale.scale(yVals[0]) : scale.scale(yVals);\n };\n res.y1 = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleYId];\n const yVals = yAccessor(datum);\n\n if (isArray(yVals) && yVals.length > 1) {\n return scale.scale(yVals[1]);\n }\n const domain = scale.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 return scale.scale(baseValue);\n };\n }\n\n if (markEncoder.color || markEncoder.group) {\n res.fill = markEncoder.color ?? markEncoder.group;\n } else {\n res.fill = this.spec.style?.fill ?? getPalette()[0];\n }\n\n return res;\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import type { RuleXEncodeChannels, WithDefaultEncode, BasicEncoderSpecMap, GenerateBaseEncodeSpec, Nil, ScaleSpec, ValueOf } from '@visactor/vgrammar';
2
+ import { SemanticMark } from './semantic-mark';
3
+ import { GrammarMarkType } from '@visactor/vgrammar';
4
+ import { PlotMakType } from './enums';
5
+ export declare class RuleX extends SemanticMark<BasicEncoderSpecMap['rule'], RuleXEncodeChannels> {
6
+ static readonly type = PlotMakType.ruleX;
7
+ constructor(id?: string | number);
8
+ setMarkType(): GrammarMarkType;
9
+ protected parseScaleOfEncodeX(option: ValueOf<WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleXEncodeChannels>, RuleXEncodeChannels>): ScaleSpec | Nil;
10
+ parseScaleByEncode(channel: RuleXEncodeChannels, option: ValueOf<WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleXEncodeChannels>, RuleXEncodeChannels>): ScaleSpec | Nil;
11
+ convertMarkEncode(encode: WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleXEncodeChannels>): GenerateBaseEncodeSpec<BasicEncoderSpecMap['rule']>;
12
+ }
package/cjs/rule-x.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.RuleX = void 0;
6
+
7
+ const semantic_mark_1 = require("./semantic-mark"), vgrammar_1 = require("@visactor/vgrammar"), enums_1 = require("./enums");
8
+
9
+ class RuleX extends semantic_mark_1.SemanticMark {
10
+ constructor(id) {
11
+ super(enums_1.PlotMakType.ruleX, id);
12
+ }
13
+ setMarkType() {
14
+ return vgrammar_1.GrammarMarkType.rule;
15
+ }
16
+ parseScaleOfEncodeX(option) {
17
+ const res = super.parseScaleOfEncodeX(option);
18
+ return res.type = "point", res;
19
+ }
20
+ parseScaleByEncode(channel, option) {
21
+ return this.parseScaleOfCommonEncode(channel, option);
22
+ }
23
+ convertMarkEncode(encode) {
24
+ var _a, _b, _c;
25
+ const markEncoder = this.convertSimpleMarkEncode(encode), res = {
26
+ x: markEncoder.x,
27
+ x1: markEncoder.x,
28
+ y: (datum, el, params) => 0,
29
+ y1: (datum, el, params) => params.viewBox.height()
30
+ };
31
+ return markEncoder.color || markEncoder.group ? res.stroke = null !== (_a = markEncoder.color) && void 0 !== _a ? _a : markEncoder.group : res.stroke = null !== (_c = null === (_b = this.spec.style) || void 0 === _b ? void 0 : _b.stroke) && void 0 !== _c ? _c : (0,
32
+ vgrammar_1.getPalette)()[0], res;
33
+ }
34
+ }
35
+
36
+ exports.RuleX = RuleX, RuleX.type = enums_1.PlotMakType.ruleX;
37
+ //# sourceMappingURL=rule-x.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rule-x.ts"],"names":[],"mappings":";;;AAWA,mDAA+C;AAC/C,iDAAiE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AC,CAAC;SACzD;QAED,OAAO,GAAG,CAAC;IACb,CAAC;;AAjDH,sBAkDC;AAjDiB,UAAI,GAAG,mBAAW,CAAC,KAAK,CAAC","file":"rule-x.js","sourcesContent":["import type {\n RuleXEncodeChannels,\n WithDefaultEncode,\n BasicEncoderSpecMap,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n IElement,\n Nil,\n ScaleSpec,\n ValueOf\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\nimport { getPalette, GrammarMarkType } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\n\nexport class RuleX extends SemanticMark<BasicEncoderSpecMap['rule'], RuleXEncodeChannels> {\n static readonly type = PlotMakType.ruleX;\n constructor(id?: string | number) {\n super(PlotMakType.ruleX, id);\n }\n\n setMarkType() {\n return GrammarMarkType.rule;\n }\n\n protected parseScaleOfEncodeX(\n option: ValueOf<WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleXEncodeChannels>, RuleXEncodeChannels>\n ): ScaleSpec | Nil {\n const res = super.parseScaleOfEncodeX(option);\n\n res.type = 'point';\n return res;\n }\n\n parseScaleByEncode(\n channel: RuleXEncodeChannels,\n option: ValueOf<WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleXEncodeChannels>, RuleXEncodeChannels>\n ): ScaleSpec | Nil {\n return this.parseScaleOfCommonEncode(channel, option);\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleXEncodeChannels>\n ): GenerateBaseEncodeSpec<BasicEncoderSpecMap['rule']> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res = {\n x: markEncoder.x,\n x1: markEncoder.x,\n y: (datum: any, el: IElement, params: any) => {\n return 0;\n },\n y1: (datum: any, el: IElement, params: any) => {\n return params.viewBox.height();\n }\n } as GenerateEncoderSpec<BasicEncoderSpecMap['rule']>;\n\n if (markEncoder.color || markEncoder.group) {\n res.stroke = markEncoder.color ?? markEncoder.group;\n } else {\n res.stroke = this.spec.style?.stroke ?? getPalette()[0];\n }\n\n return res;\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import type { RuleYEncodeChannels, WithDefaultEncode, BasicEncoderSpecMap, GenerateBaseEncodeSpec, Nil, ScaleSpec, ValueOf } from '@visactor/vgrammar';
2
+ import { SemanticMark } from './semantic-mark';
3
+ import { GrammarMarkType } from '@visactor/vgrammar';
4
+ import { PlotMakType } from './enums';
5
+ export declare class RuleY extends SemanticMark<BasicEncoderSpecMap['rule'], RuleYEncodeChannels> {
6
+ static readonly type = PlotMakType.ruleX;
7
+ constructor(id?: string | number);
8
+ setMarkType(): GrammarMarkType;
9
+ protected parseScaleOfEncodeX(option: ValueOf<WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleYEncodeChannels>, RuleYEncodeChannels>): ScaleSpec | Nil;
10
+ parseScaleByEncode(channel: RuleYEncodeChannels, option: ValueOf<WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleYEncodeChannels>, RuleYEncodeChannels>): ScaleSpec | Nil;
11
+ convertMarkEncode(encode: WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleYEncodeChannels>): GenerateBaseEncodeSpec<BasicEncoderSpecMap['rule']>;
12
+ }
package/cjs/rule-y.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.RuleY = void 0;
6
+
7
+ const semantic_mark_1 = require("./semantic-mark"), vgrammar_1 = require("@visactor/vgrammar"), enums_1 = require("./enums");
8
+
9
+ class RuleY extends semantic_mark_1.SemanticMark {
10
+ constructor(id) {
11
+ super(enums_1.PlotMakType.ruleX, id);
12
+ }
13
+ setMarkType() {
14
+ return vgrammar_1.GrammarMarkType.rule;
15
+ }
16
+ parseScaleOfEncodeX(option) {
17
+ const res = super.parseScaleOfEncodeX(option);
18
+ return res.type = "point", res;
19
+ }
20
+ parseScaleByEncode(channel, option) {
21
+ return this.parseScaleOfCommonEncode(channel, option);
22
+ }
23
+ convertMarkEncode(encode) {
24
+ var _a, _b, _c;
25
+ const markEncoder = this.convertSimpleMarkEncode(encode), res = {
26
+ y: markEncoder.y,
27
+ y1: markEncoder.y,
28
+ x: (datum, el, params) => 0,
29
+ x1: (datum, el, params) => params.viewBox.width()
30
+ };
31
+ return markEncoder.color || markEncoder.group ? res.stroke = null !== (_a = markEncoder.color) && void 0 !== _a ? _a : markEncoder.group : res.stroke = null !== (_c = null === (_b = this.spec.style) || void 0 === _b ? void 0 : _b.stroke) && void 0 !== _c ? _c : (0,
32
+ vgrammar_1.getPalette)()[0], res;
33
+ }
34
+ }
35
+
36
+ exports.RuleY = RuleY, RuleY.type = enums_1.PlotMakType.ruleX;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rule-y.ts"],"names":[],"mappings":";;;AAWA,mDAA+C;AAC/C,iDAAiE;AACjE,mCAAsC;AAEtC,MAAa,KAAM,SAAQ,4BAA8D;IAEvF,YAAY,EAAoB;QAC9B,KAAK,CAAC,mBAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED,WAAW;QACT,OAAO,0BAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAES,mBAAmB,CAC3B,MAAyG;QAEzG,MAAM,GAAG,GAAG,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAE9C,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC;QACnB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,kBAAkB,CAChB,OAA4B,EAC5B,MAAyG;QAEzG,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,iBAAiB,CACf,MAA2E;;QAE3E,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEzD,MAAM,GAAG,GAAG;YACV,CAAC,EAAE,WAAW,CAAC,CAAC;YAChB,EAAE,EAAE,WAAW,CAAC,CAAC;YACjB,CAAC,EAAE,CAAC,KAAU,EAAE,EAAY,EAAE,MAAW,EAAE,EAAE;gBAC3C,OAAO,CAAC,CAAC;YACX,CAAC;YACD,EAAE,EAAE,CAAC,KAAU,EAAE,EAAY,EAAE,MAAW,EAAE,EAAE;gBAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAChC,CAAC;SACkD,CAAC;QAEtD,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE;YAC1C,GAAG,CAAC,MAAM,GAAG,MAAA,WAAW,CAAC,KAAK,mCAAI,WAAW,CAAC,KAAK,CAAC;SACrD;aAAM;YACL,GAAG,CAAC,MAAM,GAAG,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,MAAM,mCAAI,IAAA,qBAAU,GAAE,CAAC,CAAC,CAAC,CAAC;SACzD;QAED,OAAO,GAAG,CAAC;IACb,CAAC;;AAjDH,sBAkDC;AAjDiB,UAAI,GAAG,mBAAW,CAAC,KAAK,CAAC","file":"rule-y.js","sourcesContent":["import type {\n RuleYEncodeChannels,\n WithDefaultEncode,\n BasicEncoderSpecMap,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n IElement,\n Nil,\n ScaleSpec,\n ValueOf\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\nimport { getPalette, GrammarMarkType } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\n\nexport class RuleY extends SemanticMark<BasicEncoderSpecMap['rule'], RuleYEncodeChannels> {\n static readonly type = PlotMakType.ruleX;\n constructor(id?: string | number) {\n super(PlotMakType.ruleX, id);\n }\n\n setMarkType() {\n return GrammarMarkType.rule;\n }\n\n protected parseScaleOfEncodeX(\n option: ValueOf<WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleYEncodeChannels>, RuleYEncodeChannels>\n ): ScaleSpec | Nil {\n const res = super.parseScaleOfEncodeX(option);\n\n res.type = 'point';\n return res;\n }\n\n parseScaleByEncode(\n channel: RuleYEncodeChannels,\n option: ValueOf<WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleYEncodeChannels>, RuleYEncodeChannels>\n ): ScaleSpec | Nil {\n return this.parseScaleOfCommonEncode(channel, option);\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<BasicEncoderSpecMap['rule'], RuleYEncodeChannels>\n ): GenerateBaseEncodeSpec<BasicEncoderSpecMap['rule']> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res = {\n y: markEncoder.y,\n y1: markEncoder.y,\n x: (datum: any, el: IElement, params: any) => {\n return 0;\n },\n x1: (datum: any, el: IElement, params: any) => {\n return params.viewBox.width();\n }\n } as GenerateEncoderSpec<BasicEncoderSpecMap['rule']>;\n\n if (markEncoder.color || markEncoder.group) {\n res.stroke = markEncoder.color ?? markEncoder.group;\n } else {\n res.stroke = this.spec.style?.stroke ?? getPalette()[0];\n }\n\n return res;\n }\n}\n"]}
package/cjs/rule.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { RuleEncodeChannels, WithDefaultEncode, PlotRuleEncoderSpec, GenerateBaseEncodeSpec, Nil, ScaleSpec, ValueOf } from '@visactor/vgrammar';
2
+ import { SemanticMark } from './semantic-mark';
3
+ import { GrammarMarkType } from '@visactor/vgrammar';
4
+ import { PlotMakType } from './enums';
5
+ export declare class Rule extends SemanticMark<PlotRuleEncoderSpec, RuleEncodeChannels> {
6
+ static readonly type = PlotMakType.rule;
7
+ constructor(id?: string | number);
8
+ setMarkType(): GrammarMarkType;
9
+ protected parseScaleOfEncodeX(option: ValueOf<WithDefaultEncode<PlotRuleEncoderSpec, RuleEncodeChannels>, RuleEncodeChannels>): ScaleSpec | Nil;
10
+ parseScaleByEncode(channel: RuleEncodeChannels, option: ValueOf<WithDefaultEncode<PlotRuleEncoderSpec, RuleEncodeChannels>, RuleEncodeChannels>): ScaleSpec | Nil;
11
+ convertMarkEncode(encode: WithDefaultEncode<PlotRuleEncoderSpec, RuleEncodeChannels>): GenerateBaseEncodeSpec<PlotRuleEncoderSpec>;
12
+ }
package/cjs/rule.js ADDED
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.Rule = void 0;
6
+
7
+ const semantic_mark_1 = require("./semantic-mark"), vgrammar_1 = require("@visactor/vgrammar"), vutils_1 = require("@visactor/vutils"), enums_1 = require("./enums");
8
+
9
+ class Rule extends semantic_mark_1.SemanticMark {
10
+ constructor(id) {
11
+ super(enums_1.PlotMakType.rule, id);
12
+ }
13
+ setMarkType() {
14
+ return vgrammar_1.GrammarMarkType.rule;
15
+ }
16
+ parseScaleOfEncodeX(option) {
17
+ const res = super.parseScaleOfEncodeX(option);
18
+ return res.type = "point", res;
19
+ }
20
+ parseScaleByEncode(channel, option) {
21
+ return this.parseScaleOfCommonEncode(channel, option);
22
+ }
23
+ convertMarkEncode(encode) {
24
+ var _a, _b, _c, _d, _e;
25
+ const markEncoder = this.convertSimpleMarkEncode(encode);
26
+ let res;
27
+ return (0, vutils_1.isArray)(null === (_a = markEncoder.x) || void 0 === _a ? void 0 : _a.field) ? (res.x = {
28
+ field: markEncoder.x.field[0],
29
+ scale: markEncoder.x.scale
30
+ }, res.x1 = {
31
+ field: markEncoder.x.field[1],
32
+ scale: markEncoder.x.scale
33
+ }) : res.x = res.x1 = markEncoder.x, (0, vutils_1.isArray)(null === (_b = markEncoder.y) || void 0 === _b ? void 0 : _b.field) ? (res.y = {
34
+ field: markEncoder.y.field[0],
35
+ scale: markEncoder.y.scale
36
+ }, res.y1 = {
37
+ field: markEncoder.y.field[1],
38
+ scale: markEncoder.y.scale
39
+ }) : res.y = res.y1 = markEncoder.y, markEncoder.color || markEncoder.group ? res.stroke = null !== (_c = markEncoder.color) && void 0 !== _c ? _c : markEncoder.group : res.stroke = null !== (_e = null === (_d = this.spec.style) || void 0 === _d ? void 0 : _d.stroke) && void 0 !== _e ? _e : (0,
40
+ vgrammar_1.getPalette)()[0], res;
41
+ }
42
+ }
43
+
44
+ exports.Rule = Rule, Rule.type = enums_1.PlotMakType.rule;
45
+ //# sourceMappingURL=rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rule.ts"],"names":[],"mappings":";;;AAUA,mDAA+C;AAC/C,iDAAiE;AACjE,6CAA2C;AAC3C,mCAAsC;AAEtC,MAAa,IAAK,SAAQ,4BAAqD;IAE7E,YAAY,EAAoB;QAC9B,KAAK,CAAC,mBAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,WAAW;QACT,OAAO,0BAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAES,mBAAmB,CAC3B,MAA+F;QAE/F,MAAM,GAAG,GAAG,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAE9C,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC;QACnB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,kBAAkB,CAChB,OAA2B,EAC3B,MAA+F;QAE/F,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,iBAAiB,CACf,MAAkE;;QAElE,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEzD,IAAI,GAA6C,CAAC;QAElD,IAAI,IAAA,gBAAO,EAAC,MAAA,WAAW,CAAC,CAAC,0CAAE,KAAK,CAAC,EAAE;YACjC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YACtE,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;SACxE;aAAM;YACL,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;SAChC;QAED,IAAI,IAAA,gBAAO,EAAC,MAAA,WAAW,CAAC,CAAC,0CAAE,KAAK,CAAC,EAAE;YACjC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YACtE,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;SACxE;aAAM;YACL,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;SAChC;QAED,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE;YAC1C,GAAG,CAAC,MAAM,GAAG,MAAA,WAAW,CAAC,KAAK,mCAAI,WAAW,CAAC,KAAK,CAAC;SACrD;aAAM;YACL,GAAG,CAAC,MAAM,GAAG,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,MAAM,mCAAI,IAAA,qBAAU,GAAE,CAAC,CAAC,CAAC,CAAC;SACzD;QAED,OAAO,GAAG,CAAC;IACb,CAAC;;AAtDH,oBAuDC;AAtDiB,SAAI,GAAG,mBAAW,CAAC,IAAI,CAAC","file":"rule.js","sourcesContent":["import type {\n RuleEncodeChannels,\n WithDefaultEncode,\n PlotRuleEncoderSpec,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\nimport { getPalette, GrammarMarkType } from '@visactor/vgrammar';\nimport { isArray } from '@visactor/vutils';\nimport { PlotMakType } from './enums';\n\nexport class Rule extends SemanticMark<PlotRuleEncoderSpec, RuleEncodeChannels> {\n static readonly type = PlotMakType.rule;\n constructor(id?: string | number) {\n super(PlotMakType.rule, id);\n }\n\n setMarkType() {\n return GrammarMarkType.rule;\n }\n\n protected parseScaleOfEncodeX(\n option: ValueOf<WithDefaultEncode<PlotRuleEncoderSpec, RuleEncodeChannels>, RuleEncodeChannels>\n ): ScaleSpec | Nil {\n const res = super.parseScaleOfEncodeX(option);\n\n res.type = 'point';\n return res;\n }\n\n parseScaleByEncode(\n channel: RuleEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotRuleEncoderSpec, RuleEncodeChannels>, RuleEncodeChannels>\n ): ScaleSpec | Nil {\n return this.parseScaleOfCommonEncode(channel, option);\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<PlotRuleEncoderSpec, RuleEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotRuleEncoderSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n let res: GenerateEncoderSpec<PlotRuleEncoderSpec>;\n\n if (isArray(markEncoder.x?.field)) {\n res.x = { field: markEncoder.x.field[0], scale: markEncoder.x.scale };\n res.x1 = { field: markEncoder.x.field[1], scale: markEncoder.x.scale };\n } else {\n res.x = res.x1 = markEncoder.x;\n }\n\n if (isArray(markEncoder.y?.field)) {\n res.y = { field: markEncoder.y.field[0], scale: markEncoder.y.scale };\n res.y1 = { field: markEncoder.y.field[1], scale: markEncoder.y.scale };\n } else {\n res.y = res.y1 = markEncoder.y;\n }\n\n if (markEncoder.color || markEncoder.group) {\n res.stroke = markEncoder.color ?? markEncoder.group;\n } else {\n res.stroke = this.spec.style?.stroke ?? getPalette()[0];\n }\n\n return res;\n }\n}\n"]}
@@ -0,0 +1,46 @@
1
+ import type { SankeyEncodeChannels, WithDefaultEncode, PlotSankeyEncoderSpec, SemanticLabelOption, ChannelEncodeType, DataSpec, GenerateBaseEncodeSpec, Nil, ScaleSpec, ValueOf, TransformSpec, IElement } from '@visactor/vgrammar';
2
+ import { SemanticMark } from './semantic-mark';
3
+ import { GrammarMarkType } from '@visactor/vgrammar';
4
+ import { PlotMakType } from './enums';
5
+ import type { ITextAttribute } from '@visactor/vrender';
6
+ export declare class SankeySemanticMark extends SemanticMark<PlotSankeyEncoderSpec, SankeyEncodeChannels> {
7
+ static readonly type = PlotMakType.sankey;
8
+ constructor(id?: string | number);
9
+ setMarkType(): GrammarMarkType;
10
+ setDefaultDataTransform(): TransformSpec[];
11
+ getDataIdOfLink(): string;
12
+ setMultipleData(): DataSpec[];
13
+ parseScaleByEncode(channel: SankeyEncodeChannels, option: ValueOf<WithDefaultEncode<PlotSankeyEncoderSpec, SankeyEncodeChannels>, SankeyEncodeChannels>): ScaleSpec | Nil;
14
+ convertMarkEncode(encode: WithDefaultEncode<PlotSankeyEncoderSpec, SankeyEncodeChannels>): GenerateBaseEncodeSpec<PlotSankeyEncoderSpec>;
15
+ setMainMarkSpec(): {
16
+ key: string;
17
+ };
18
+ protected setLabelTextGetter(channel: string, option: SemanticLabelOption | boolean): ChannelEncodeType<ITextAttribute['text']>;
19
+ setMultiMarksSpec(): {
20
+ id: string;
21
+ type: string;
22
+ glyphType: string;
23
+ from: {
24
+ data: string;
25
+ };
26
+ layout: {
27
+ position: string;
28
+ skipBeforeLayouted: boolean;
29
+ };
30
+ key: string;
31
+ dependency: string[];
32
+ animation: import("@visactor/vgrammar").MarkAnimationSpec;
33
+ encode: Record<string, Partial<Partial<import("@visactor/vgrammar").LinkPathEncoderSpec>>> & {
34
+ enter: any;
35
+ update: (datum: any, el: IElement, params: any) => {
36
+ direction: string;
37
+ x0: any;
38
+ x1: any;
39
+ y0: any;
40
+ y1: any;
41
+ thickness: any;
42
+ fill: any;
43
+ };
44
+ };
45
+ }[];
46
+ }