@visactor/vgrammar-plot 0.6.7-alpha.1 → 0.7.0-alpha.1

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 (109) hide show
  1. package/cjs/area.js +3 -3
  2. package/cjs/area.js.map +1 -1
  3. package/cjs/cell.js +3 -3
  4. package/cjs/cell.js.map +1 -1
  5. package/cjs/circle-packing.js +5 -6
  6. package/cjs/circle-packing.js.map +1 -1
  7. package/cjs/image.js +3 -3
  8. package/cjs/image.js.map +1 -1
  9. package/cjs/interval.js +3 -3
  10. package/cjs/interval.js.map +1 -1
  11. package/cjs/line.js +3 -3
  12. package/cjs/line.js.map +1 -1
  13. package/cjs/path.js +4 -1
  14. package/cjs/path.js.map +1 -1
  15. package/cjs/plot.d.ts +6 -4
  16. package/cjs/plot.js +24 -16
  17. package/cjs/plot.js.map +1 -1
  18. package/cjs/polygon.js +3 -3
  19. package/cjs/polygon.js.map +1 -1
  20. package/cjs/rect-x.js +3 -3
  21. package/cjs/rect-x.js.map +1 -1
  22. package/cjs/rect-y.js +3 -3
  23. package/cjs/rect-y.js.map +1 -1
  24. package/cjs/rect.js +3 -3
  25. package/cjs/rect.js.map +1 -1
  26. package/cjs/rule-x.js +3 -3
  27. package/cjs/rule-x.js.map +1 -1
  28. package/cjs/rule-y.d.ts +1 -1
  29. package/cjs/rule-y.js +14 -8
  30. package/cjs/rule-y.js.map +1 -1
  31. package/cjs/rule.js +3 -3
  32. package/cjs/rule.js.map +1 -1
  33. package/cjs/sankey.js +8 -10
  34. package/cjs/sankey.js.map +1 -1
  35. package/cjs/semantic-mark.d.ts +9 -4
  36. package/cjs/semantic-mark.js +113 -77
  37. package/cjs/semantic-mark.js.map +1 -1
  38. package/cjs/sunburst.js +5 -6
  39. package/cjs/sunburst.js.map +1 -1
  40. package/cjs/symbol.d.ts +3 -1
  41. package/cjs/symbol.js +25 -3
  42. package/cjs/symbol.js.map +1 -1
  43. package/cjs/text.js +5 -3
  44. package/cjs/text.js.map +1 -1
  45. package/cjs/tree.js +6 -7
  46. package/cjs/tree.js.map +1 -1
  47. package/cjs/treemap.js +5 -6
  48. package/cjs/treemap.js.map +1 -1
  49. package/cjs/wordcloud-shape.d.ts +1 -0
  50. package/cjs/wordcloud-shape.js +13 -8
  51. package/cjs/wordcloud-shape.js.map +1 -1
  52. package/cjs/wordcloud.js +5 -6
  53. package/cjs/wordcloud.js.map +1 -1
  54. package/dist/index.js +283 -126
  55. package/dist/index.min.js +1 -1
  56. package/es/area.js +3 -3
  57. package/es/area.js.map +1 -1
  58. package/es/cell.js +3 -3
  59. package/es/cell.js.map +1 -1
  60. package/es/circle-packing.js +6 -6
  61. package/es/circle-packing.js.map +1 -1
  62. package/es/image.js +3 -3
  63. package/es/image.js.map +1 -1
  64. package/es/interval.js +4 -4
  65. package/es/interval.js.map +1 -1
  66. package/es/line.js +3 -3
  67. package/es/line.js.map +1 -1
  68. package/es/path.js +4 -1
  69. package/es/path.js.map +1 -1
  70. package/es/plot.d.ts +6 -4
  71. package/es/plot.js +25 -17
  72. package/es/plot.js.map +1 -1
  73. package/es/polygon.js +3 -3
  74. package/es/polygon.js.map +1 -1
  75. package/es/rect-x.js +3 -3
  76. package/es/rect-x.js.map +1 -1
  77. package/es/rect-y.js +3 -3
  78. package/es/rect-y.js.map +1 -1
  79. package/es/rect.js +3 -3
  80. package/es/rect.js.map +1 -1
  81. package/es/rule-x.js +3 -3
  82. package/es/rule-x.js.map +1 -1
  83. package/es/rule-y.d.ts +1 -1
  84. package/es/rule-y.js +15 -7
  85. package/es/rule-y.js.map +1 -1
  86. package/es/rule.js +3 -3
  87. package/es/rule.js.map +1 -1
  88. package/es/sankey.js +9 -9
  89. package/es/sankey.js.map +1 -1
  90. package/es/semantic-mark.d.ts +9 -4
  91. package/es/semantic-mark.js +111 -77
  92. package/es/semantic-mark.js.map +1 -1
  93. package/es/sunburst.js +6 -6
  94. package/es/sunburst.js.map +1 -1
  95. package/es/symbol.d.ts +3 -1
  96. package/es/symbol.js +25 -3
  97. package/es/symbol.js.map +1 -1
  98. package/es/text.js +5 -3
  99. package/es/text.js.map +1 -1
  100. package/es/tree.js +7 -7
  101. package/es/tree.js.map +1 -1
  102. package/es/treemap.js +6 -6
  103. package/es/treemap.js.map +1 -1
  104. package/es/wordcloud-shape.d.ts +1 -0
  105. package/es/wordcloud-shape.js +15 -7
  106. package/es/wordcloud-shape.js.map +1 -1
  107. package/es/wordcloud.js +6 -6
  108. package/es/wordcloud.js.map +1 -1
  109. package/package.json +10 -10
package/cjs/sankey.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sankey.ts"],"names":[],"mappings":";;;AAeA,mDAA+C;AAC/C,iDAA0G;AAC1G,mCAAsC;AACtC,2DAAoE;AAGpE,MAAa,kBAAmB,SAAQ,4BAAyD;IAE/F,YAAY,EAAoB;QAC9B,KAAK,CAAC,mBAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAE9B,IAAI,CAAC,IAAA,uBAAY,EAAC,mBAAW,CAAC,MAAM,CAAC,EAAE;YACrC,IAAI,CAAC,OAAO,CAAC,KAAK,CAChB;6DACqD,CACtD,CAAC;SACH;QAED,IAAI,CAAC,IAAA,mBAAQ,EAAC,UAAU,CAAC,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;;;OAGlB,CAAC,CAAC;SACJ;IACH,CAAC;IAED,WAAW;QACT,OAAO,0BAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,uBAAuB;;QACrB,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;gBAC9B,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE;gBAChC,OAAO,EAAE,MAAA,IAAI,CAAC,IAAI,CAAC,MAAM,0CAAE,IAAI;aAChC;SACF,CAAC;IACJ,CAAC;IAED,eAAe;;QACb,OAAO,GAAG,MAAA,MAAA,IAA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CAAC;iBACF,CAAC;aACH;SACF,CAAC;IACJ,CAAC;;AA1KH,gDA2KC;AA1KiB,uBAAI,GAAG,mBAAW,CAAC,MAAM,CAAC","file":"sankey.js","sourcesContent":["import type {\n SankeyEncodeChannels,\n WithDefaultEncode,\n PlotSankeyEncoderSpec,\n SemanticLabelOption,\n ChannelEncodeType,\n DataSpec,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n TransformSpec,\n IElement\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\nimport { getPalette, GrammarMarkType, SIGNAL_VIEW_BOX, getTransform, getGlyph } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\nimport { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport type { ITextAttribute } from '@visactor/vrender';\n\nexport class SankeySemanticMark extends SemanticMark<PlotSankeyEncoderSpec, SankeyEncodeChannels> {\n static readonly type = PlotMakType.sankey;\n constructor(id?: string | number) {\n super(PlotMakType.sankey, id);\n\n if (!getTransform(PlotMakType.sankey)) {\n this._logger.error(\n `Please add this line of code: import { registerSankeyTransforms } from '@visactor/vgrammar-sankey'; \n and run registerSankeyTransforms() before use sankey`\n );\n }\n\n if (!getGlyph('linkPath')) {\n this._logger.error(`\n Please add this line of code: import { registerLinkPathGlyph } from '@visactor/vgrammar';\n add run registerLinkPathGlyph() before use sankey\n `);\n }\n }\n\n setMarkType() {\n return GrammarMarkType.rect;\n }\n\n setDefaultDataTransform(): TransformSpec[] {\n return [\n {\n type: 'sankey',\n width: { signal: 'viewWidth' },\n height: { signal: 'viewHeight' },\n nodeKey: this.spec.encode?.node\n }\n ];\n }\n\n getDataIdOfLink() {\n return `${this.spec.data?.id ?? this.spec.id}-data-link`;\n }\n\n setMultipleData(): DataSpec[] {\n return [\n {\n id: this.getDataIdOfFiltered(),\n transform: [\n {\n type: 'map',\n all: true,\n callback: (datum: any) => {\n return datum[0].nodes;\n }\n }\n ]\n },\n {\n source: this.getDataIdOfMain(),\n id: this.getDataIdOfLink(),\n transform: [\n {\n type: 'map',\n all: true,\n callback: (datum: any) => {\n // return formatLinkPath(datum[0].links);\n return datum[0].links;\n }\n }\n ]\n }\n ];\n }\n\n parseScaleByEncode(\n channel: SankeyEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotSankeyEncoderSpec, SankeyEncodeChannels>, SankeyEncodeChannels>\n ): ScaleSpec | Nil {\n if (channel === 'color') {\n return {\n type: 'ordinal',\n id: this.getScaleId('color'),\n domain: {\n data: this.getDataIdOfFiltered(),\n field: option as string\n },\n range: getPalette()\n };\n }\n\n return null;\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<PlotSankeyEncoderSpec, SankeyEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotSankeyEncoderSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res: GenerateEncoderSpec<PlotSankeyEncoderSpec> = {\n x: { field: 'x0' },\n x1: { field: 'x1' },\n y: { field: 'y0' },\n y1: { field: 'y1' }\n };\n\n if (markEncoder.color) {\n const scaleColorId = this.getScaleId('color');\n const colorAccessor = getFieldAccessor(markEncoder.color.field);\n\n res.fill = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleColorId];\n return scale.scale(colorAccessor(datum?.datum));\n };\n } else {\n res.fill = this.spec.style?.nodeStyle?.fill ?? getPalette()[0];\n }\n\n return res;\n }\n\n setMainMarkSpec() {\n return { key: 'key' };\n }\n\n protected setLabelTextGetter(\n channel: string,\n option: SemanticLabelOption | boolean\n ): ChannelEncodeType<ITextAttribute['text']> {\n const textGetter = getFieldAccessor(channel);\n return (datum: any, el: IElement, params: any) => {\n return textGetter(datum.datum);\n };\n }\n\n setMultiMarksSpec() {\n // TODO: optimize the default style\n return [\n {\n id: `${this.getMarkId()}-link`,\n type: 'glyph',\n glyphType: 'linkPath',\n from: {\n data: this.getDataIdOfLink()\n },\n layout: {\n position: 'content',\n skipBeforeLayouted: true\n },\n key: 'index',\n dependency: this.viewSpec.scales.map(scale => scale.id).concat(SIGNAL_VIEW_BOX),\n animation: this.convertMarkAnimation(),\n encode: Object.assign({}, this.spec.state, {\n enter: Object.assign(\n {\n backgroundStyle: { fillColor: '#ccc', fillOpacity: 0.2 },\n fillOpacity: 0.8,\n round: true\n },\n this.spec.style?.linkStyle\n ),\n update: (datum: any, el: IElement, params: any) => {\n return {\n direction: datum.vertical ? 'vertical' : 'horizontal',\n x0: datum.x0,\n x1: datum.x1,\n y0: datum.y0,\n y1: datum.y1,\n thickness: datum.thickness,\n fill: this.spec.style?.linkStyle?.fill ?? getPalette()[0]\n };\n }\n })\n }\n ];\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/sankey.ts"],"names":[],"mappings":";;;AAeA,mDAA+C;AAE/C,iDAA+E;AAC/E,mCAAsC;AACtC,2DAAoE;AAGpE,MAAa,kBAAmB,SAAQ,4BAAyD;IAE/F,YAAY,EAAoB;QAC9B,KAAK,CAAC,mBAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAE9B,IAAI,CAAC,kBAAO,CAAC,YAAY,CAAC,mBAAW,CAAC,MAAM,CAAC,EAAE;YAC7C,IAAI,CAAC,OAAO,CAAC,KAAK,CAChB;6DACqD,CACtD,CAAC;SACH;QAED,IAAI,CAAC,kBAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YACjC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;;;OAGlB,CAAC,CAAC;SACJ;IACH,CAAC;IAED,WAAW;QACT,OAAO,0BAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,uBAAuB;;QACrB,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;gBAC9B,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE;gBAChC,OAAO,EAAE,MAAA,IAAI,CAAC,IAAI,CAAC,MAAM,0CAAE,IAAI;aAChC;SACF,CAAC;IACJ,CAAC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C1B,IAAI,EAAE,MAAA,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,SAAS,0CAAE,IAAI,mCAAI,MAAA,IAAI,CAAC,UAAU,EAAE,0CAAG,CAAC,CAAC;yBACjE,CAAC;oBACJ,CAAC;iBACF,CAAC;aACH;SACF,CAAC;IACJ,CAAC;;AA9KH,gDA+KC;AA9KiB,uBAAI,GAAG,mBAAW,CAAC,MAAM,CAAC","file":"sankey.js","sourcesContent":["import type {\n SankeyEncodeChannels,\n WithDefaultEncode,\n PlotSankeyEncoderSpec,\n SemanticLabelOption,\n ChannelEncodeType,\n DataSpec,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n TransformSpec,\n IElement\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType, SIGNAL_VIEW_BOX, Factory } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\nimport { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport type { ITextAttribute } from '@visactor/vrender';\n\nexport class SankeySemanticMark extends SemanticMark<PlotSankeyEncoderSpec, SankeyEncodeChannels> {\n static readonly type = PlotMakType.sankey;\n constructor(id?: string | number) {\n super(PlotMakType.sankey, id);\n\n if (!Factory.getTransform(PlotMakType.sankey)) {\n this._logger.error(\n `Please add this line of code: import { registerSankeyTransforms } from '@visactor/vgrammar-sankey'; \n and run registerSankeyTransforms() before use sankey`\n );\n }\n\n if (!Factory.getGlyph('linkPath')) {\n this._logger.error(`\n Please add this line of code: import { registerLinkPathGlyph } from '@visactor/vgrammar';\n add run registerLinkPathGlyph() before use sankey\n `);\n }\n }\n\n setMarkType() {\n return GrammarMarkType.rect;\n }\n\n setDefaultDataTransform(): TransformSpec[] {\n return [\n {\n type: 'sankey',\n width: { signal: 'viewWidth' },\n height: { signal: 'viewHeight' },\n nodeKey: this.spec.encode?.node\n }\n ];\n }\n\n getDataIdOfLink() {\n return `${this.spec.data?.id ?? this.spec.id}-data-link`;\n }\n\n setMultipleData(): DataSpec[] {\n return [\n {\n id: this.getDataIdOfFiltered(),\n transform: [\n {\n type: 'map',\n all: true,\n callback: (datum: any) => {\n return datum[0].nodes;\n }\n }\n ]\n },\n {\n source: this.getDataIdOfMain(),\n id: this.getDataIdOfLink(),\n transform: [\n {\n type: 'map',\n all: true,\n callback: (datum: any) => {\n // return formatLinkPath(datum[0].links);\n return datum[0].links;\n }\n }\n ]\n }\n ];\n }\n\n parseScaleByEncode(\n channel: SankeyEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotSankeyEncoderSpec, SankeyEncodeChannels>, SankeyEncodeChannels>\n ): ScaleSpec | Nil {\n if (channel === 'color') {\n return {\n type: 'ordinal',\n id: this.getScaleId('color'),\n domain: {\n data: this.getDataIdOfFiltered(),\n field: option as string\n },\n range: this.getPalette()\n };\n }\n\n return null;\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<PlotSankeyEncoderSpec, SankeyEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotSankeyEncoderSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res: GenerateEncoderSpec<PlotSankeyEncoderSpec> = {\n x: { field: 'x0' },\n x1: { field: 'x1' },\n y: { field: 'y0' },\n y1: { field: 'y1' }\n };\n\n if (markEncoder.stroke) {\n res.stroke = markEncoder.stroke;\n }\n\n if (markEncoder.color) {\n const scaleColorId = this.getScaleId('color');\n const colorAccessor = getFieldAccessor(markEncoder.color.field);\n\n res.fill = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleColorId];\n return scale.scale(colorAccessor(datum?.datum));\n };\n } else {\n res.fill = this.spec.style?.nodeStyle?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n\n setMainMarkSpec() {\n return { key: 'key' };\n }\n\n protected setLabelTextGetter(\n channel: string,\n option: SemanticLabelOption | boolean\n ): ChannelEncodeType<ITextAttribute['text']> {\n const textGetter = getFieldAccessor(channel);\n return (datum: any, el: IElement, params: any) => {\n return textGetter(datum.datum);\n };\n }\n\n setMultiMarksSpec() {\n // TODO: optimize the default style\n return [\n {\n id: `${this.getMarkId()}-link`,\n type: 'glyph',\n glyphType: 'linkPath',\n from: {\n data: this.getDataIdOfLink()\n },\n layout: {\n position: 'content',\n skipBeforeLayouted: true\n },\n key: 'index',\n dependency: this.viewSpec.scales.map(scale => scale.id).concat(SIGNAL_VIEW_BOX),\n animation: this.convertMarkAnimation(),\n encode: Object.assign({}, this.spec.state, {\n enter: Object.assign(\n {\n backgroundStyle: { fillColor: '#ccc', fillOpacity: 0.2 },\n fillOpacity: 0.8,\n round: true\n },\n this.spec.style?.linkStyle\n ),\n update: (datum: any, el: IElement, params: any) => {\n return {\n direction: datum.vertical ? 'vertical' : 'horizontal',\n x0: datum.x0,\n x1: datum.x1,\n y0: datum.y0,\n y1: datum.y1,\n thickness: datum.thickness,\n fill: this.spec.style?.linkStyle?.fill ?? this.getPalette()?.[0]\n };\n }\n })\n }\n ];\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { ILogger } from '@visactor/vutils';
2
- import type { ISemanticMark, ISemanticMarkSpec, ParsedSimpleEncode, WithDefaultEncode, SemanticTooltipOption, SemanticAxisOption, SemanticPlayerOption, SemanticLabelOption, SemanticDataZoomOption, SemanticSliderOption, SemanticLegendOption, SemanticCrosshairOption, CoordinateOption, AxisSpec, CrosshairSpec, DatazoomSpec, DimensionTooltipSpec, LabelSpec, LegendSpec, PlayerSpec, SliderSpec, TooltipSpec, CoordinateSpec, DataSpec, ChannelEncodeType, ScaleSpec, TransformSpec, MarkAnimationSpec, ViewSpec, MarkType, Nil, ValueOf, GenerateBaseEncodeSpec, IAnimationConfig, MarkSpec, MarkRelativeItemSpec } from '@visactor/vgrammar';
2
+ import type { ISemanticMark, ISemanticMarkSpec, ParsedSimpleEncode, WithDefaultEncode, SemanticTooltipOption, SemanticAxisOption, SemanticPlayerOption, SemanticLabelOption, SemanticDataZoomOption, SemanticSliderOption, SemanticLegendOption, SemanticCrosshairOption, CoordinateOption, AxisSpec, CrosshairSpec, DatazoomSpec, DimensionTooltipSpec, LabelSpec, LegendSpec, PlayerSpec, SliderSpec, TooltipSpec, CoordinateSpec, DataSpec, ChannelEncodeType, ScaleSpec, TransformSpec, MarkAnimationSpec, ViewSpec, MarkType, Nil, ValueOf, GenerateBaseEncodeSpec, IAnimationConfig, MarkSpec, MarkRelativeItemSpec, IPlot } from '@visactor/vgrammar';
3
3
  import type { ITextAttribute } from '@visactor/vrender';
4
4
  export declare abstract class SemanticMark<EncodeSpec, K extends string> implements ISemanticMark<EncodeSpec, K> {
5
5
  spec: ISemanticMarkSpec<EncodeSpec, K>;
@@ -8,7 +8,8 @@ export declare abstract class SemanticMark<EncodeSpec, K extends string> impleme
8
8
  protected _logger: ILogger;
9
9
  protected _coordinate: CoordinateOption;
10
10
  readonly type: string;
11
- constructor(type: string, id?: string | number);
11
+ readonly plot: IPlot;
12
+ constructor(type: string, id?: string | number, plot?: IPlot);
12
13
  parseSpec(spec: Partial<ISemanticMarkSpec<EncodeSpec, K>>): this;
13
14
  coordinate(option: CoordinateOption): this;
14
15
  data(values: any, transform?: TransformSpec[], id?: string): this;
@@ -26,13 +27,14 @@ export declare abstract class SemanticMark<EncodeSpec, K extends string> impleme
26
27
  datazoom(channel: string, option?: SemanticDataZoomOption | boolean, layout?: MarkRelativeItemSpec): this;
27
28
  label(channel: string, option?: SemanticLabelOption | boolean): this;
28
29
  player(data?: any[], option?: SemanticPlayerOption | boolean, layout?: MarkRelativeItemSpec): this;
30
+ protected getPalette(): import("@visactor/vrender").IColor[];
29
31
  abstract setMarkType(): MarkType;
30
32
  abstract parseScaleByEncode(channel: K, option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
31
33
  abstract convertMarkEncode(encode: WithDefaultEncode<EncodeSpec, K>): GenerateBaseEncodeSpec<EncodeSpec>;
32
34
  protected setDefaultDataTransform(): TransformSpec[];
33
35
  protected setMultipleData(): DataSpec[];
34
36
  protected setDefaultMarkTransform(): TransformSpec[];
35
- protected convertMarkTransform(userTransform: TransformSpec[], defaultTransform?: TransformSpec[]): TransformSpec[];
37
+ protected convertMarkTransform(userTransform: TransformSpec[], defaultTransform?: TransformSpec[]): any[];
36
38
  protected convertMarkAnimation(): MarkAnimationSpec;
37
39
  protected convertSimpleMarkEncode(encode: WithDefaultEncode<EncodeSpec, K>): ParsedSimpleEncode<EncodeSpec, K>;
38
40
  protected getDataIdOfFiltered(): string;
@@ -48,6 +50,7 @@ export declare abstract class SemanticMark<EncodeSpec, K extends string> impleme
48
50
  protected parseScaleOfEncodeX(option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
49
51
  protected parseScaleOfEncodeY(option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
50
52
  protected parseScaleOfEncodeColor(option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
53
+ protected parseScaleOfEncodeStroke(option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
51
54
  protected parseScaleOfEncodeGroup(option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
52
55
  protected parseScaleOfCommonEncode(channel: K, option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
53
56
  protected setDefaultAxis(): Record<string, Partial<AxisSpec>>;
@@ -78,7 +81,9 @@ export declare abstract class SemanticMark<EncodeSpec, K extends string> impleme
78
81
  protected setDefaultPlayer(): Record<string, Partial<PlayerSpec>>;
79
82
  protected parsePlayerSpec(): PlayerSpec[];
80
83
  protected parseDataSpec(): DataSpec[];
81
- protected parseScaleSpec(): ScaleSpec[];
84
+ protected parseScaleSpec(): (ScaleSpec & {
85
+ userScale?: ScaleSpec;
86
+ })[];
82
87
  protected parseCoordinateSpec(): CoordinateSpec[];
83
88
  protected setMainMarkEnterEncode(): Partial<any>;
84
89
  protected setMainMarkSpec(): {};
@@ -4,15 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.SemanticMark = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), vscale_1 = require("@visactor/vscale"), vgrammar_1 = require("@visactor/vgrammar"), vgrammar_util_1 = require("@visactor/vgrammar-util"), defaultTheme = (0,
8
- vgrammar_1.getTheme)("default");
7
+ const vutils_1 = require("@visactor/vutils"), vscale_1 = require("@visactor/vscale"), vgrammar_1 = require("@visactor/vgrammar"), vgrammar_util_1 = require("@visactor/vgrammar-util");
9
8
 
10
9
  let semanticMarkId = -1;
11
10
 
12
11
  class SemanticMark {
13
- constructor(type, id) {
12
+ constructor(type, id, plot) {
14
13
  this.type = type, this.uid = ++semanticMarkId, this._logger = vutils_1.Logger.getInstance(),
15
- this.spec = {
14
+ this.plot = plot, this.spec = {
16
15
  id: null != id ? id : `${this.type}-${this.uid}`
17
16
  };
18
17
  }
@@ -96,6 +95,10 @@ class SemanticMark {
96
95
  layout: layout
97
96
  }, this;
98
97
  }
98
+ getPalette() {
99
+ var _a;
100
+ return null === (_a = (this.plot ? this.plot.view.getCurrentTheme() : vgrammar_1.ThemeManager.getDefaultTheme()).palette) || void 0 === _a ? void 0 : _a.default;
101
+ }
99
102
  setDefaultDataTransform() {
100
103
  return [];
101
104
  }
@@ -112,7 +115,7 @@ class SemanticMark {
112
115
  const excludeIndex = [];
113
116
  for (let i = 0, len = userTransform.length; i < len; i++) {
114
117
  const customizedSpec = userTransform[i], index = defaultTransform.findIndex((entry => entry.type === customizedSpec.type));
115
- index >= 0 ? (transforms.push(Object.assign({}, defaultTransform[index], customizedSpec)),
118
+ index >= 0 ? (transforms.push((0, vutils_1.merge)({}, defaultTransform[index], customizedSpec)),
116
119
  excludeIndex.push(index)) : transforms.push(customizedSpec);
117
120
  }
118
121
  for (let j = 0, dlen = defaultTransform.length; j < dlen; j++) excludeIndex.includes(j) || (transforms = [ defaultTransform[j] ].concat(transforms));
@@ -131,7 +134,8 @@ class SemanticMark {
131
134
  return Object.keys(encode).map((channel => {
132
135
  markEncoder[channel] = {
133
136
  field: encode[channel],
134
- scale: this.getScaleId(channel)
137
+ scale: this.getScaleId(channel),
138
+ band: .5
135
139
  };
136
140
  })), markEncoder;
137
141
  }
@@ -202,7 +206,18 @@ class SemanticMark {
202
206
  data: this.getDataIdOfMain(),
203
207
  field: option
204
208
  },
205
- range: (0, vgrammar_1.getPalette)()
209
+ range: this.getPalette()
210
+ };
211
+ }
212
+ parseScaleOfEncodeStroke(option) {
213
+ return {
214
+ type: "ordinal",
215
+ id: this.getScaleId("stroke"),
216
+ domain: {
217
+ data: this.getDataIdOfMain(),
218
+ field: option
219
+ },
220
+ range: this.getPalette()
206
221
  };
207
222
  }
208
223
  parseScaleOfEncodeGroup(option) {
@@ -213,11 +228,11 @@ class SemanticMark {
213
228
  data: this.getDataIdOfMain(),
214
229
  field: option
215
230
  },
216
- range: (0, vgrammar_1.getPalette)()
231
+ range: this.getPalette()
217
232
  };
218
233
  }
219
234
  parseScaleOfCommonEncode(channel, option) {
220
- return "x" === channel ? this.parseScaleOfEncodeX(option) : "y" === channel ? this.parseScaleOfEncodeY(option) : "color" === channel ? this.parseScaleOfEncodeColor(option) : "group" === channel ? this.parseScaleOfEncodeGroup(option) : null;
235
+ return "x" === channel ? this.parseScaleOfEncodeX(option) : "y" === channel ? this.parseScaleOfEncodeY(option) : "color" === channel ? this.parseScaleOfEncodeColor(option) : "group" === channel ? this.parseScaleOfEncodeGroup(option) : "stroke" === channel ? this.parseScaleOfEncodeStroke(option) : null;
221
236
  }
222
237
  setDefaultAxis() {
223
238
  return {};
@@ -259,7 +274,7 @@ class SemanticMark {
259
274
  y: -params.viewBox.height()
260
275
  }
261
276
  };
262
- return (0, vutils_1.isPlainObject)(option) ? Object.assign(positionAttrs, option) : positionAttrs;
277
+ return (0, vutils_1.isPlainObject)(option) ? (0, vutils_1.merge)(positionAttrs, option) : positionAttrs;
263
278
  }
264
279
  }
265
280
  };
@@ -304,6 +319,7 @@ class SemanticMark {
304
319
  type: "component",
305
320
  componentType: vgrammar_1.ComponentEnum.legend,
306
321
  scale: this.getScaleId(channel),
322
+ shapeScale: this.getScaleId("shape"),
307
323
  dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
308
324
  target: {
309
325
  data: this.getDataIdOfFiltered(),
@@ -329,7 +345,7 @@ class SemanticMark {
329
345
  x: null !== (_w = null === (_v = null === (_u = element.mark) || void 0 === _u ? void 0 : _u.relativePosition) || void 0 === _v ? void 0 : _v.left) && void 0 !== _w ? _w : 0,
330
346
  y: null !== (_z = null === (_y = null === (_x = element.mark) || void 0 === _x ? void 0 : _x.relativePosition) || void 0 === _y ? void 0 : _y.top) && void 0 !== _z ? _z : 0
331
347
  };
332
- return (0, vutils_1.isPlainObject)(option) ? Object.assign({}, calculatedAttrs, option) : calculatedAttrs;
348
+ return (0, vutils_1.isPlainObject)(option) ? (0, vutils_1.merge)({}, calculatedAttrs, option) : calculatedAttrs;
333
349
  }
334
350
  }
335
351
  };
@@ -385,19 +401,21 @@ class SemanticMark {
385
401
  return null;
386
402
  }
387
403
  parseTooltipSpec() {
388
- var _a;
404
+ var _a, _b;
389
405
  const defaultTooltipSpec = this.setDefaultTooltip(), userTooltipSpec = this.spec.tooltip;
390
406
  if (!1 !== userTooltipSpec && null !== userTooltipSpec && null !== defaultTooltipSpec) {
391
- const res = [], tooltipSpec = Object.assign({}, defaultTooltipSpec, !0 === userTooltipSpec ? {} : userTooltipSpec), colorChannel = (0,
392
- vutils_1.isNil)(this.spec.encode.color) ? "group" : "color", colorEncode = this.spec.encode[colorChannel], dependency = colorEncode ? [ this.getScaleId(colorChannel) ] : [], colorAccessor = colorEncode ? (0,
407
+ const res = [], tooltipSpec = (0, vutils_1.merge)({}, defaultTooltipSpec, !0 === userTooltipSpec ? {} : userTooltipSpec), colorChannel = (0,
408
+ vutils_1.isNil)(this.spec.encode.color) ? (0, vutils_1.isNil)(this.spec.encode.group) ? "stroke" : "group" : "color", colorEncode = this.spec.encode[colorChannel], dependency = colorEncode ? [ this.getScaleId(colorChannel) ] : [], colorAccessor = colorEncode ? (0,
393
409
  vgrammar_util_1.field)(colorEncode) : null, title = {
394
410
  visible: !!tooltipSpec.title || !!tooltipSpec.staticTitle,
395
411
  key: "title",
396
412
  value: (0, vutils_1.isNil)(tooltipSpec.staticTitle) ? {
397
- field: (datum, el, params) => tooltipSpec.title && (null == datum ? void 0 : datum.length) ? (0,
398
- vgrammar_util_1.field)(tooltipSpec.title)(datum[0]) : void 0
413
+ field: (datum, el, params) => tooltipSpec.title ? (0, vgrammar_util_1.field)(tooltipSpec.title)((0,
414
+ vutils_1.isArray)(datum) ? datum[0] : datum) : void 0
399
415
  } : tooltipSpec.staticTitle
400
- }, content = (0, vutils_1.isArray)(tooltipSpec.content) && tooltipSpec.content.length ? tooltipSpec.content.map(((entry, index) => ({
416
+ };
417
+ this.spec.encode.shape && dependency.push(this.getScaleId("shape"));
418
+ const content = (0, vutils_1.isArray)(tooltipSpec.content) && tooltipSpec.content.length ? tooltipSpec.content.map(((entry, index) => ({
401
419
  key: entry.key ? {
402
420
  field: entry.key
403
421
  } : (0, vutils_1.isNil)(tooltipSpec.staticContentKey) ? (datum, el, params) => colorAccessor ? colorAccessor(datum) : void 0 : (0,
@@ -407,14 +425,16 @@ class SemanticMark {
407
425
  },
408
426
  symbol: (datum, el, params) => {
409
427
  var _a;
410
- const scale = params[this.getScaleId(colorChannel)];
411
- return {
412
- symbolType: entry.symbol && null !== (_a = (0, vgrammar_util_1.field)(entry.symbol)(datum)) && void 0 !== _a ? _a : "circle",
413
- fill: scale && colorAccessor ? scale.scale(colorAccessor(datum)) : (0, vgrammar_1.getPalette)()[0]
428
+ const scale = params[this.getScaleId(colorChannel)], shapeScale = params[this.getScaleId("shape")];
429
+ let symbolType = "circle";
430
+ return shapeScale && entry.symbol ? symbolType = shapeScale.scale((0, vgrammar_util_1.field)(entry.symbol)(datum)) : entry.symbol && (symbolType = (0,
431
+ vgrammar_util_1.field)(entry.symbol)(datum)), {
432
+ fill: scale && colorAccessor ? scale.scale(colorAccessor(datum)) : null === (_a = this.getPalette()) || void 0 === _a ? void 0 : _a[0],
433
+ symbolType: symbolType
414
434
  };
415
435
  }
416
436
  }))) : null;
417
- return !0 !== tooltipSpec.disableGraphicTooltip && res.push({
437
+ if (!0 !== tooltipSpec.disableGraphicTooltip && res.push({
418
438
  type: "component",
419
439
  componentType: vgrammar_1.ComponentEnum.tooltip,
420
440
  target: this.getMarkId(),
@@ -422,21 +442,25 @@ class SemanticMark {
422
442
  title: title,
423
443
  content: content,
424
444
  zIndex: 1e3
425
- }), !0 !== tooltipSpec.disableDimensionTooltip && res.push({
426
- type: "component",
427
- componentType: vgrammar_1.ComponentEnum.dimensionTooltip,
428
- tooltipType: this.getVisualChannel("x"),
429
- scale: this.getScaleId("x"),
430
- dependency: dependency,
431
- target: {
432
- data: this.getDataIdOfFiltered(),
433
- filter: null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a.x
434
- },
435
- title: title,
436
- content: content,
437
- avoidMark: tooltipSpec.disableGraphicTooltip ? [] : [ this.getMarkId() ],
438
- zIndex: 1e3
439
- }), res;
445
+ }), !0 !== tooltipSpec.disableDimensionTooltip) {
446
+ const channel = null !== (_a = tooltipSpec.dimensionTooltipChannel) && void 0 !== _a ? _a : "x";
447
+ res.push({
448
+ type: "component",
449
+ componentType: vgrammar_1.ComponentEnum.dimensionTooltip,
450
+ tooltipType: this.getVisualChannel(channel),
451
+ scale: this.getScaleId(channel),
452
+ dependency: dependency,
453
+ target: {
454
+ data: this.getDataIdOfFiltered(),
455
+ filter: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b[channel]
456
+ },
457
+ title: title,
458
+ content: content,
459
+ avoidMark: tooltipSpec.disableGraphicTooltip ? [] : [ this.getMarkId() ],
460
+ zIndex: 1e3
461
+ });
462
+ }
463
+ return res;
440
464
  }
441
465
  return [];
442
466
  }
@@ -451,7 +475,8 @@ class SemanticMark {
451
475
  if (option) {
452
476
  const scaleId = this.getScaleId(channel), scaleSpec = this.getScaleSpec(scaleId), dataId = this.getDataIdOfMain();
453
477
  if (!scaleSpec || !(0, vscale_1.isContinuous)(scaleSpec.type)) return void this._logger.warn(`[VGrammar]: Don't use slider in a channel which has scale type = ${null == scaleSpec ? void 0 : scaleSpec.type}`);
454
- const getter = (0, vgrammar_util_1.field)(null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]), markLayout = null != layout ? layout : (0,
478
+ const theme = this.plot ? this.plot.view.getCurrentTheme() : vgrammar_1.ThemeManager.getDefaultTheme(), getter = (0,
479
+ vgrammar_util_1.field)(null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]), markLayout = null != layout ? layout : (0,
455
480
  vutils_1.isPlainObject)(option) && !(0, vutils_1.isNil)(option.layout) ? "horizontal" === option.layout ? {
456
481
  position: "top",
457
482
  align: "center"
@@ -487,28 +512,28 @@ class SemanticMark {
487
512
  layout: "vertical",
488
513
  x: null !== (_c = null === (_b = null === (_a = elment.mark) || void 0 === _a ? void 0 : _a.relativePosition) || void 0 === _b ? void 0 : _b.left) && void 0 !== _c ? _c : 0,
489
514
  y: null !== (_f = null === (_e = null === (_d = elment.mark) || void 0 === _d ? void 0 : _d.relativePosition) || void 0 === _e ? void 0 : _e.top) && void 0 !== _f ? _f : 0,
490
- railWidth: defaultTheme.slider.railHeight,
515
+ railWidth: theme.components.slider.railHeight,
491
516
  railHeight: params.viewBox.height()
492
517
  } : "right" === markLayout.position ? {
493
518
  layout: "vertical",
494
519
  x: null !== (_j = null === (_h = null === (_g = elment.mark) || void 0 === _g ? void 0 : _g.relativePosition) || void 0 === _h ? void 0 : _h.left) && void 0 !== _j ? _j : params.viewBox.width(),
495
520
  y: null !== (_m = null === (_l = null === (_k = elment.mark) || void 0 === _k ? void 0 : _k.relativePosition) || void 0 === _l ? void 0 : _l.top) && void 0 !== _m ? _m : 0,
496
- railWidth: defaultTheme.slider.railHeight,
521
+ railWidth: theme.components.slider.railHeight,
497
522
  railHeight: params.viewBox.height()
498
523
  } : "bottom" === markLayout.position ? {
499
524
  layout: "horizontal",
500
525
  x: null !== (_q = null === (_p = null === (_o = elment.mark) || void 0 === _o ? void 0 : _o.relativePosition) || void 0 === _p ? void 0 : _p.left) && void 0 !== _q ? _q : 0,
501
526
  y: null !== (_t = null === (_s = null === (_r = elment.mark) || void 0 === _r ? void 0 : _r.relativePosition) || void 0 === _s ? void 0 : _s.top) && void 0 !== _t ? _t : params.viewBox.height(),
502
- railHeight: defaultTheme.slider.railHeight,
527
+ railHeight: theme.components.slider.railHeight,
503
528
  railWidth: params.viewBox.width()
504
529
  } : {
505
530
  layout: "horizontal",
506
531
  x: null !== (_w = null === (_v = null === (_u = elment.mark) || void 0 === _u ? void 0 : _u.relativePosition) || void 0 === _v ? void 0 : _v.left) && void 0 !== _w ? _w : 0,
507
532
  y: null !== (_z = null === (_y = null === (_x = elment.mark) || void 0 === _x ? void 0 : _x.relativePosition) || void 0 === _y ? void 0 : _y.top) && void 0 !== _z ? _z : 0,
508
- railHeight: defaultTheme.slider.railHeight,
533
+ railHeight: theme.components.slider.railHeight,
509
534
  railWidth: params.viewBox.width()
510
535
  };
511
- return (0, vutils_1.isPlainObject)(option) ? Object.assign({}, calculatedAttrs, option) : calculatedAttrs;
536
+ return (0, vutils_1.isPlainObject)(option) ? (0, vutils_1.merge)({}, calculatedAttrs, option) : calculatedAttrs;
512
537
  }
513
538
  }
514
539
  };
@@ -546,7 +571,7 @@ class SemanticMark {
546
571
  scale: x,
547
572
  field: null !== (_d = null === (_c = this.spec.encode) || void 0 === _c ? void 0 : _c[channel]) && void 0 !== _d ? _d : channel
548
573
  };
549
- const markSpec = {
574
+ const theme = this.plot ? this.plot.view.getCurrentTheme() : vgrammar_1.ThemeManager.getDefaultTheme(), markSpec = {
550
575
  type: "component",
551
576
  componentType: vgrammar_1.ComponentEnum.datazoom,
552
577
  dependency: [ vgrammar_1.SIGNAL_VIEW_BOX, dataId ],
@@ -564,7 +589,7 @@ class SemanticMark {
564
589
  y: null !== (_f = null === (_e = null === (_d = elment.mark) || void 0 === _d ? void 0 : _d.relativePosition) || void 0 === _e ? void 0 : _e.top) && void 0 !== _f ? _f : 0,
565
590
  size: {
566
591
  height: params.viewBox.height(),
567
- width: defaultTheme.datazoom.size.height
592
+ width: theme.components.datazoom.size.height
568
593
  }
569
594
  } : "right" === markLayout.position ? {
570
595
  orient: markLayout.position,
@@ -572,7 +597,7 @@ class SemanticMark {
572
597
  y: null !== (_m = null === (_l = null === (_k = elment.mark) || void 0 === _k ? void 0 : _k.relativePosition) || void 0 === _l ? void 0 : _l.top) && void 0 !== _m ? _m : 0,
573
598
  size: {
574
599
  height: params.viewBox.height(),
575
- width: defaultTheme.datazoom.size.height
600
+ width: theme.components.datazoom.size.height
576
601
  }
577
602
  } : "bottom" === markLayout.position ? {
578
603
  orient: markLayout.position,
@@ -580,7 +605,7 @@ class SemanticMark {
580
605
  y: null !== (_t = null === (_s = null === (_r = elment.mark) || void 0 === _r ? void 0 : _r.relativePosition) || void 0 === _s ? void 0 : _s.top) && void 0 !== _t ? _t : params.viewBox.height(),
581
606
  size: {
582
607
  width: params.viewBox.width(),
583
- height: defaultTheme.datazoom.size.height
608
+ height: theme.components.datazoom.size.height
584
609
  }
585
610
  } : {
586
611
  orient: markLayout.position,
@@ -588,10 +613,10 @@ class SemanticMark {
588
613
  y: null !== (_z = null === (_y = null === (_x = elment.mark) || void 0 === _x ? void 0 : _x.relativePosition) || void 0 === _y ? void 0 : _y.top) && void 0 !== _z ? _z : 0,
589
614
  size: {
590
615
  width: params.viewBox.width(),
591
- height: defaultTheme.datazoom.size.height
616
+ height: theme.components.datazoom.size.height
592
617
  }
593
618
  };
594
- return (0, vutils_1.isPlainObject)(option) ? Object.assign({}, calculatedAttrs, option) : calculatedAttrs;
619
+ return (0, vutils_1.isPlainObject)(option) ? (0, vutils_1.merge)({}, calculatedAttrs, option) : calculatedAttrs;
595
620
  }
596
621
  }
597
622
  };
@@ -607,7 +632,9 @@ class SemanticMark {
607
632
  return "polar" === (null === (_a = this._coordinate) || void 0 === _a ? void 0 : _a.type) ? this._coordinate.transpose ? "endAngle" : "outer" : (null === (_b = this._coordinate) || void 0 === _b ? void 0 : _b.transpose) ? "right" : "top";
608
633
  }
609
634
  setLabelTextGetter(channel, option) {
610
- return null;
635
+ return {
636
+ field: channel
637
+ };
611
638
  }
612
639
  parseLabelSpec() {
613
640
  const label = this.spec.label, res = [];
@@ -622,7 +649,7 @@ class SemanticMark {
622
649
  position: "content",
623
650
  skipBeforeLayouted: !0
624
651
  },
625
- labelStyle: (0, vutils_1.isPlainObject)(option) ? Object.assign({
652
+ labelStyle: (0, vutils_1.isPlainObject)(option) ? (0, vutils_1.merge)({
626
653
  position: this.getLabelPosition()
627
654
  }, option) : {
628
655
  position: this.getLabelPosition()
@@ -694,7 +721,7 @@ class SemanticMark {
694
721
  height: 20
695
722
  }
696
723
  };
697
- return (0, vutils_1.isPlainObject)(option) ? Object.assign({}, calculatedAttrs, option) : calculatedAttrs;
724
+ return (0, vutils_1.isPlainObject)(option) ? (0, vutils_1.merge)({}, calculatedAttrs, option) : calculatedAttrs;
698
725
  }
699
726
  }
700
727
  };
@@ -735,38 +762,47 @@ class SemanticMark {
735
762
  const {encode: encode, scale: scale, datazoom: datazoom} = this.spec, scales = {};
736
763
  return encode && Object.keys(encode).forEach((k => {
737
764
  var _a;
738
- const encodeOption = encode[k], scaleId = this.getScaleId(k);
739
- scales[scaleId] = Object.assign({
765
+ const encodeOption = encode[k], scaleId = this.getScaleId(k), userScale = null === (_a = this.spec.scale) || void 0 === _a ? void 0 : _a[k];
766
+ scales[scaleId] = userScale ? Object.assign({
740
767
  id: scaleId
741
- }, this.parseScaleByEncode(k, encodeOption), null === (_a = this.spec.scale) || void 0 === _a ? void 0 : _a[k]);
768
+ }, this.parseScaleByEncode(k, encodeOption), userScale, {
769
+ userScale: userScale
770
+ }) : Object.assign({
771
+ id: scaleId
772
+ }, this.parseScaleByEncode(k, encodeOption));
742
773
  })), scale && Object.keys(scale).forEach((k => {
743
774
  const scaleId = this.getScaleId(k);
744
- scales[scaleId] || (scales[scaleId] = scale[k]);
775
+ scales[scaleId] || (scales[scaleId] = scale[k], scales[scaleId].userScale = scale[k]);
745
776
  })), datazoom && Object.keys(datazoom).forEach((k => {
746
777
  var _a, _b, _c, _d;
747
778
  const scaleId = this.getScaleId(k), {x: xScaleId, y: yScaleId} = this.getDataZoomScaleId(k);
748
- "x" === k && encode[k] ? (scales[xScaleId] = {
749
- type: scales[scaleId].type,
750
- id: xScaleId,
751
- domain: {
752
- data: this.getDataIdOfMain(),
753
- field: encode[k]
754
- },
755
- dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
756
- range: (scale, params) => [ 0, params.viewBox.width() ]
757
- }, encode.y && (scales[yScaleId] = {
758
- type: null !== (_b = null === (_a = scales[this.getScaleId("y")]) || void 0 === _a ? void 0 : _a.type) && void 0 !== _b ? _b : "linear",
759
- id: yScaleId,
760
- domain: {
761
- data: this.getDataIdOfMain(),
762
- field: null == encode ? void 0 : encode.y
763
- },
764
- range: (scale, params) => {
765
- var _a, _b;
766
- const option = this.parseOption(datazoom[k]).option;
767
- return [ 0, (0, vutils_1.isPlainObject)(option) && null !== (_b = null === (_a = option.size) || void 0 === _a ? void 0 : _a.height) && void 0 !== _b ? _b : defaultTheme.datazoom.size.height ];
779
+ if ("x" === k && encode[k]) {
780
+ if (scales[xScaleId] = {
781
+ type: scales[scaleId].type,
782
+ id: xScaleId,
783
+ domain: {
784
+ data: this.getDataIdOfMain(),
785
+ field: encode[k]
786
+ },
787
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
788
+ range: (scale, params) => [ 0, params.viewBox.width() ]
789
+ }, encode.y) {
790
+ const theme = this.plot ? this.plot.view.getCurrentTheme() : vgrammar_1.ThemeManager.getDefaultTheme();
791
+ scales[yScaleId] = {
792
+ type: null !== (_b = null === (_a = scales[this.getScaleId("y")]) || void 0 === _a ? void 0 : _a.type) && void 0 !== _b ? _b : "linear",
793
+ id: yScaleId,
794
+ domain: {
795
+ data: this.getDataIdOfMain(),
796
+ field: null == encode ? void 0 : encode.y
797
+ },
798
+ range: (scale, params) => {
799
+ var _a, _b;
800
+ const option = this.parseOption(datazoom[k]).option;
801
+ return [ 0, (0, vutils_1.isPlainObject)(option) && null !== (_b = null === (_a = option.size) || void 0 === _a ? void 0 : _a.height) && void 0 !== _b ? _b : theme.components.datazoom.size.height ];
802
+ }
803
+ };
768
804
  }
769
- })) : scales[xScaleId] = {
805
+ } else scales[xScaleId] = {
770
806
  type: null !== (_c = scales[scaleId].type) && void 0 !== _c ? _c : "band",
771
807
  id: xScaleId,
772
808
  domain: {