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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/treemap.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/treemap.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,MAAM,OAAO,mBAAoB,SAAQ,YAA0D;IAEjG,YAAY,EAAoB;QAC9B,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAE/B,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;YACpC,IAAI,CAAC,OAAO,CAAC,KAAK,CAChB;+DACuD,CACxD,CAAC;SACH;IACH,CAAC;IAED,WAAW;QACT,OAAO,eAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,uBAAuB;;QACrB,OAAO;YACL;gBACE,IAAI,EAAE,SAAS;gBACf,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;gBAC/B,OAAO,EAAE,IAAI;aACd;SACF,CAAC;IACJ,CAAC;IACD,kBAAkB,CAChB,OAA8B,EAC9B,MAAuG;QAEvG,IAAI,OAAO,KAAK,OAAO,EAAE;YACvB,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBAC5B,MAAM,E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D,OAAO;4BACL,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;4BAC9F,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;4BAC9F,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;yBACtD,CAAC;oBACJ,CAAC;iBACF;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;;AA9He,wBAAI,GAAG,WAAW,CAAC,OAAO,CAAC","file":"treemap.js","sourcesContent":["import type {\n TreemapEncodeChannels,\n WithDefaultEncode,\n PlotTreemapEncodeSpec,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n TransformSpec,\n IElement,\n LabelSpec\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType, Factory, SIGNAL_VIEW_BOX } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\nimport { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport type { BaseLabelAttrs } from '@visactor/vrender-components';\n\nexport class TreemapSemanticMark extends SemanticMark<PlotTreemapEncodeSpec, TreemapEncodeChannels> {\n static readonly type = PlotMakType.treemap;\n constructor(id?: string | number) {\n super(PlotMakType.treemap, id);\n\n if (!Factory.getTransform('treemap')) {\n this._logger.error(\n `Please add this line of code: import { registerTreemapTransforms } from 'vgrammar-hierarchy'; \n and run registerTreemapTransforms() before use treemap`\n );\n }\n }\n\n setMarkType() {\n return GrammarMarkType.rect;\n }\n\n setDefaultDataTransform(): TransformSpec[] {\n return [\n {\n type: 'treemap',\n width: { signal: 'viewWidth' },\n height: { signal: 'viewHeight' },\n nodeKey: this.spec.encode?.node,\n flatten: true\n }\n ];\n }\n parseScaleByEncode(\n channel: TreemapEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotTreemapEncodeSpec, TreemapEncodeChannels>, TreemapEncodeChannels>\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<PlotTreemapEncodeSpec, TreemapEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotTreemapEncodeSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res: GenerateEncoderSpec<PlotTreemapEncodeSpec> = {\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 datum?.datum ? scale.scale(colorAccessor(datum.datum[datum.datum.length - 1])) : undefined;\n };\n } else {\n res.fill = this.spec.style?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n\n setMainMarkSpec() {\n return { key: 'key' };\n }\n\n protected parseLabelSpec(): LabelSpec[] {\n // TODO use arc label in the future\n return [];\n }\n\n setMultiMarksSpec() {\n const label = this.spec.label;\n\n if (!label) {\n return null;\n }\n\n return Object.keys(label).map(key => {\n const textGetter = getFieldAccessor(key);\n return {\n id: `${this.getMarkId()}-text-${key}`,\n type: 'text',\n from: {\n data: this.getDataIdOfFiltered()\n },\n layout: {\n position: 'content',\n skipBeforeLayouted: true\n },\n key: 'flattenIndex',\n dependency: this.viewSpec.scales.map(scale => scale.id).concat(SIGNAL_VIEW_BOX),\n animation: this.convertMarkAnimation(),\n encode: {\n enter: Object.assign(\n {\n textAlign: 'center',\n textBaseline: 'middle'\n },\n (label[key] as Partial<BaseLabelAttrs>).textStyle\n ),\n update: (datum: any, el: IElement, params: any) => {\n return {\n x: datum.labelRect ? (datum.labelRect.x0 + datum.labelRect.x1) / 2 : (datum.x0 + datum.x1) / 2,\n y: datum.labelRect ? (datum.labelRect.y0 + datum.labelRect.y1) / 2 : (datum.y0 + datum.y1) / 2,\n text: textGetter(datum.datum[datum.datum.length - 1])\n };\n }\n }\n };\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/treemap.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,MAAM,OAAO,mBAAoB,SAAQ,YAA0D;IAEjG,YAAY,EAAoB;QAC9B,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAE/B,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;YAC5B,IAAI,CAAC,OAAO,CAAC,KAAK,CAChB;+DACuD,CACxD,CAAC;SACH;IACH,CAAC;IAED,WAAW;QACT,OAAO,eAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,uBAAuB;;QACrB,OAAO;YACL;gBACE,IAAI,EAAE,SAAS;gBACf,KAAK,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ueOf,\n TransformSpec,\n IElement,\n LabelSpec\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType, getTransform, SIGNAL_VIEW_BOX } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\nimport { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport type { BaseLabelAttrs } from '@visactor/vrender-components';\n\nexport class TreemapSemanticMark extends SemanticMark<PlotTreemapEncodeSpec, TreemapEncodeChannels> {\n static readonly type = PlotMakType.treemap;\n constructor(id?: string | number) {\n super(PlotMakType.treemap, id);\n\n if (!getTransform('treemap')) {\n this._logger.error(\n `Please add this line of code: import { registerTreemapTransforms } from 'vgrammar-hierarchy'; \n and run registerTreemapTransforms() before use treemap`\n );\n }\n }\n\n setMarkType() {\n return GrammarMarkType.rect;\n }\n\n setDefaultDataTransform(): TransformSpec[] {\n return [\n {\n type: 'treemap',\n width: { signal: 'viewWidth' },\n height: { signal: 'viewHeight' },\n nodeKey: this.spec.encode?.node,\n flatten: true\n }\n ];\n }\n parseScaleByEncode(\n channel: TreemapEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotTreemapEncodeSpec, TreemapEncodeChannels>, TreemapEncodeChannels>\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<PlotTreemapEncodeSpec, TreemapEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotTreemapEncodeSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res: GenerateEncoderSpec<PlotTreemapEncodeSpec> = {\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 datum?.datum ? scale.scale(colorAccessor(datum.datum[datum.datum.length - 1])) : undefined;\n };\n } else {\n res.fill = this.spec.style?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n\n setMainMarkSpec() {\n return { key: 'key' };\n }\n\n protected parseLabelSpec(): LabelSpec[] {\n // TODO use arc label in the future\n return [];\n }\n\n setMultiMarksSpec() {\n const label = this.spec.label;\n\n if (!label) {\n return null;\n }\n\n return Object.keys(label).map(key => {\n const textGetter = getFieldAccessor(key);\n return {\n id: `${this.getMarkId()}-text-${key}`,\n type: 'text',\n from: {\n data: this.getDataIdOfFiltered()\n },\n layout: {\n position: 'content',\n skipBeforeLayouted: true\n },\n key: 'flattenIndex',\n dependency: this.viewSpec.scales.map(scale => scale.id).concat(SIGNAL_VIEW_BOX),\n animation: this.convertMarkAnimation(),\n encode: {\n enter: Object.assign(\n {\n textAlign: 'center',\n textBaseline: 'middle'\n },\n (label[key] as Partial<BaseLabelAttrs>).textStyle\n ),\n update: (datum: any, el: IElement, params: any) => {\n return {\n x: datum.labelRect ? (datum.labelRect.x0 + datum.labelRect.x1) / 2 : (datum.x0 + datum.x1) / 2,\n y: datum.labelRect ? (datum.labelRect.y0 + datum.labelRect.y1) / 2 : (datum.y0 + datum.y1) / 2,\n text: textGetter(datum.datum[datum.datum.length - 1])\n };\n }\n }\n };\n });\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { SemanticMark } from "./semantic-mark";
2
2
 
3
- import { GrammarMarkType, Factory } from "@visactor/vgrammar";
3
+ import { GrammarMarkType, getTransform } from "@visactor/vgrammar";
4
4
 
5
5
  import { PlotMakType } from "./enums";
6
6
 
@@ -10,7 +10,7 @@ import { merge } from "@visactor/vutils";
10
10
 
11
11
  export class WordcloudShapeSemanticMark extends SemanticMark {
12
12
  constructor(id) {
13
- super(PlotMakType.wordcloudShape, id), Factory.getTransform(PlotMakType.wordcloudShape) || this._logger.error("Please add this line of code:\n import { registerWordCloudShapeTransforms } from '@visactor/vgrammar-wordcloud-shape'; \n and run registerWordCloudShapeTransforms() before use wordcloud-shape");
13
+ super(PlotMakType.wordcloudShape, id), getTransform(PlotMakType.wordcloudShape) || this._logger.error("Please add this line of code:\n import { registerWordCloudShapeTransforms } from '@visactor/vgrammar-wordcloud-shape'; \n and run registerWordCloudShapeTransforms() before use wordcloud-shape");
14
14
  }
15
15
  setMarkType() {
16
16
  return GrammarMarkType.text;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/wordcloud-shape.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,OAAO,0BAA2B,SAAQ,YAG/C;IAEC,YAAY,EAAoB;QAC9B,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAEtC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE;YACrD,IAAI,CAAC,OAAO,CAAC,KAAK,CAChB;;8EAEsE,CACvE,CAAC;SACH;IACH,CAAC;IAED,WAAW;QACT,OAAO,eAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,uBAAuB;;QACrB,OAAO;YACL;gBACE,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE;oBACJ,QAAQ,EAAE,CAAC,MAAW,EAAE,EAAE;wBACxB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,M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EAAE;YACnC,WAAW,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;YACjC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAA,IAAI,CAAC,IAAI,CAAC,MAAM,0CAAE,IAAI,EAAE;SACxC,CAAC;QAEF,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;SACjC;QAED,IAAI,WAAW,CAAC,KAAK,EAAE;YACrB,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,aAAa,GAAG,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAEhE,GAAG,CAAC,IAAI,GAAG,CAAC,KAAU,EAAE,EAAY,EAAE,MAAW,EAAE,EAAE;gBACnD,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;gBACnC,OAAO,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3C,CAAC,CAAC;SACH;aAAM;YACL,GAAG,CAAC,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,IAAI,mCAAI,MAAA,IAAI,CAAC,UAAU,EAAE,0CAAG,CAAC,CAAC,CAAC;SAC5D;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAES,cAAc;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;;AAvGe,+BAAI,GAAG,WAAW,CAAC,cAAc,CAAC","file":"wordcloud-shape.js","sourcesContent":["import type {\n WordcloudShapeEncodeChannels,\n WithDefaultEncode,\n PlotWordcloudShapeEncodeSpec,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n TransformSpec,\n IElement,\n LabelSpec\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType, Factory } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\nimport { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport { merge } from '@visactor/vutils';\n\nexport class WordcloudShapeSemanticMark extends SemanticMark<\n PlotWordcloudShapeEncodeSpec,\n WordcloudShapeEncodeChannels\n> {\n static readonly type = PlotMakType.wordcloudShape;\n constructor(id?: string | number) {\n super(PlotMakType.wordcloudShape, id);\n\n if (!Factory.getTransform(PlotMakType.wordcloudShape)) {\n this._logger.error(\n `Please add this line of code:\n import { registerWordCloudShapeTransforms } from '@visactor/vgrammar-wordcloud-shape'; \n and run registerWordCloudShapeTransforms() before use wordcloud-shape`\n );\n }\n }\n\n setMarkType() {\n return GrammarMarkType.text;\n }\n\n setDefaultDataTransform(): TransformSpec[] {\n return [\n {\n type: 'wordcloudShape',\n size: {\n callback: (params: any) => {\n return [params.viewBox.width(), params.viewBox.height()];\n },\n dependency: ['viewBox']\n },\n colorList: this.getPalette(),\n text: { field: this.spec.encode?.text }\n }\n ];\n }\n\n protected setMainMarkEnterEncode() {\n return merge(\n {\n textAlign: 'center',\n textBaseline: 'middle'\n },\n this.spec.style\n );\n }\n\n parseScaleByEncode(\n channel: WordcloudShapeEncodeChannels,\n option: ValueOf<\n WithDefaultEncode<PlotWordcloudShapeEncodeSpec, WordcloudShapeEncodeChannels>,\n WordcloudShapeEncodeChannels\n >\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<PlotWordcloudShapeEncodeSpec, WordcloudShapeEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotWordcloudShapeEncodeSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res: GenerateEncoderSpec<PlotWordcloudShapeEncodeSpec> = {\n x: { field: 'x' },\n y: { field: 'y' },\n angle: { field: 'angle' },\n fontSize: { field: 'fontSize' },\n fontStyle: { field: 'fontStyle' },\n fontFamily: { field: 'fontFamily' },\n fontWeight: { field: 'fontWeight' },\n fillOpacity: { field: 'opacity' },\n text: { field: this.spec.encode?.text }\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));\n };\n } else {\n res.fill = this.spec.style?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n\n protected parseLabelSpec(): LabelSpec[] {\n return [];\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/wordcloud-shape.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,OAAO,0BAA2B,SAAQ,YAG/C;IAEC,YAAY,EAAoB;QAC9B,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAEtC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE;YAC7C,IAAI,CAAC,OAAO,CAAC,KAAK,CAChB;;8EAEsE,CACvE,CAAC;SACH;IACH,CAAC;IAED,WAAW;QACT,OAAO,eAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,uBAAuB;;QACrB,OAAO;YACL;gBACE,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE;oBACJ,QAAQ,EAAE,CAAC,MAAW,EAAE,EAA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AAK,EAAE,YAAY,EAAE;YACnC,UAAU,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE;YACnC,WAAW,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;YACjC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAA,IAAI,CAAC,IAAI,CAAC,MAAM,0CAAE,IAAI,EAAE;SACxC,CAAC;QAEF,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;SACjC;QAED,IAAI,WAAW,CAAC,KAAK,EAAE;YACrB,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,aAAa,GAAG,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAEhE,GAAG,CAAC,IAAI,GAAG,CAAC,KAAU,EAAE,EAAY,EAAE,MAAW,EAAE,EAAE;gBACnD,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;gBACnC,OAAO,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3C,CAAC,CAAC;SACH;aAAM;YACL,GAAG,CAAC,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,IAAI,mCAAI,MAAA,IAAI,CAAC,UAAU,EAAE,0CAAG,CAAC,CAAC,CAAC;SAC5D;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAES,cAAc;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;;AAvGe,+BAAI,GAAG,WAAW,CAAC,cAAc,CAAC","file":"wordcloud-shape.js","sourcesContent":["import type {\n WordcloudShapeEncodeChannels,\n WithDefaultEncode,\n PlotWordcloudShapeEncodeSpec,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n TransformSpec,\n IElement,\n LabelSpec\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType, getTransform } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\nimport { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport { merge } from '@visactor/vutils';\n\nexport class WordcloudShapeSemanticMark extends SemanticMark<\n PlotWordcloudShapeEncodeSpec,\n WordcloudShapeEncodeChannels\n> {\n static readonly type = PlotMakType.wordcloudShape;\n constructor(id?: string | number) {\n super(PlotMakType.wordcloudShape, id);\n\n if (!getTransform(PlotMakType.wordcloudShape)) {\n this._logger.error(\n `Please add this line of code:\n import { registerWordCloudShapeTransforms } from '@visactor/vgrammar-wordcloud-shape'; \n and run registerWordCloudShapeTransforms() before use wordcloud-shape`\n );\n }\n }\n\n setMarkType() {\n return GrammarMarkType.text;\n }\n\n setDefaultDataTransform(): TransformSpec[] {\n return [\n {\n type: 'wordcloudShape',\n size: {\n callback: (params: any) => {\n return [params.viewBox.width(), params.viewBox.height()];\n },\n dependency: ['viewBox']\n },\n colorList: this.getPalette(),\n text: { field: this.spec.encode?.text }\n }\n ];\n }\n\n protected setMainMarkEnterEncode() {\n return merge(\n {\n textAlign: 'center',\n textBaseline: 'middle'\n },\n this.spec.style\n );\n }\n\n parseScaleByEncode(\n channel: WordcloudShapeEncodeChannels,\n option: ValueOf<\n WithDefaultEncode<PlotWordcloudShapeEncodeSpec, WordcloudShapeEncodeChannels>,\n WordcloudShapeEncodeChannels\n >\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<PlotWordcloudShapeEncodeSpec, WordcloudShapeEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotWordcloudShapeEncodeSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res: GenerateEncoderSpec<PlotWordcloudShapeEncodeSpec> = {\n x: { field: 'x' },\n y: { field: 'y' },\n angle: { field: 'angle' },\n fontSize: { field: 'fontSize' },\n fontStyle: { field: 'fontStyle' },\n fontFamily: { field: 'fontFamily' },\n fontWeight: { field: 'fontWeight' },\n fillOpacity: { field: 'opacity' },\n text: { field: this.spec.encode?.text }\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));\n };\n } else {\n res.fill = this.spec.style?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n\n protected parseLabelSpec(): LabelSpec[] {\n return [];\n }\n}\n"]}
package/es/wordcloud.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SemanticMark } from "./semantic-mark";
2
2
 
3
- import { GrammarMarkType, Factory } from "@visactor/vgrammar";
3
+ import { GrammarMarkType, getTransform } from "@visactor/vgrammar";
4
4
 
5
5
  import { PlotMakType } from "./enums";
6
6
 
@@ -8,7 +8,7 @@ import { field as getFieldAccessor } from "@visactor/vgrammar-util";
8
8
 
9
9
  export class WordcloudSemanticMark extends SemanticMark {
10
10
  constructor(id) {
11
- super(PlotMakType.wordcloud, id), Factory.getTransform(PlotMakType.wordcloud) || this._logger.error("Please add this line of code:\n 'import { registerWordCloudTransforms } from '@visactor/vgrammar-wordcloud'; \n and run registerWordCloudTransforms() before use wordcloud");
11
+ super(PlotMakType.wordcloud, id), getTransform(PlotMakType.wordcloud) || this._logger.error("Please add this line of code:\n 'import { registerWordCloudTransforms } from '@visactor/vgrammar-wordcloud'; \n and run registerWordCloudTransforms() before use wordcloud");
12
12
  }
13
13
  setMarkType() {
14
14
  return GrammarMarkType.text;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/wordcloud.ts"],"names":[],"mappings":"AAaA,OAA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AAC,KAAK,0CAAE,IAAI,mCAAI,MAAA,IAAI,CAAC,UAAU,EAAE,0CAAG,CAAC,CAAC,CAAC;SAC5D;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAES,cAAc;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;;AAvFe,0BAAI,GAAG,WAAW,CAAC,SAAS,CAAC","file":"wordcloud.js","sourcesContent":["import type {\n WordcloudEncodeChannels,\n WithDefaultEncode,\n PlotWordcloudEncodeSpec,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n TransformSpec,\n IElement,\n LabelSpec\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType, Factory } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\nimport { field as getFieldAccessor } from '@visactor/vgrammar-util';\n\nexport class WordcloudSemanticMark extends SemanticMark<PlotWordcloudEncodeSpec, WordcloudEncodeChannels> {\n static readonly type = PlotMakType.wordcloud;\n constructor(id?: string | number) {\n super(PlotMakType.wordcloud, id);\n\n if (!Factory.getTransform(PlotMakType.wordcloud)) {\n this._logger.error(\n `Please add this line of code:\n 'import { registerWordCloudTransforms } from '@visactor/vgrammar-wordcloud'; \n and run registerWordCloudTransforms() before use wordcloud`\n );\n }\n }\n\n setMarkType() {\n return GrammarMarkType.text;\n }\n\n setDefaultMarkTransform(): TransformSpec[] {\n return [\n {\n type: 'wordcloud',\n size: {\n callback: (params: any) => {\n return [params.viewBox.width(), params.viewBox.height()];\n },\n dependency: ['viewBox']\n },\n text: { field: this.spec.encode?.text }\n }\n ];\n }\n parseScaleByEncode(\n channel: WordcloudEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotWordcloudEncodeSpec, WordcloudEncodeChannels>, WordcloudEncodeChannels>\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<PlotWordcloudEncodeSpec, WordcloudEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotWordcloudEncodeSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res: GenerateEncoderSpec<PlotWordcloudEncodeSpec> = {\n x: { field: 'x' },\n y: { field: 'y' },\n angle: { field: 'angle' },\n fontSize: { field: 'fontSize' },\n fontStyle: { field: 'fontStyle' },\n fontFamily: { field: 'fontFamily' },\n fontWeight: { field: 'fontWeight' },\n text: { field: this.spec.encode?.text }\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));\n };\n } else {\n res.fill = this.spec.style?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n\n protected parseLabelSpec(): LabelSpec[] {\n return [];\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/wordcloud.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,MAAM,OAAO,qBAAsB,SAAQ,YAA8D;IAEvG,YAAY,EAAoB;QAC9B,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAEjC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE;YACxC,IAAI,CAAC,OAAO,CAAC,KAAK,CAChB;;mEAE2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,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE;YACnC,UAAU,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE;YACnC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAA,IAAI,CAAC,IAAI,CAAC,MAAM,0CAAE,IAAI,EAAE;SACxC,CAAC;QAEF,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;SACjC;QAED,IAAI,WAAW,CAAC,KAAK,EAAE;YACrB,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,aAAa,GAAG,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAEhE,GAAG,CAAC,IAAI,GAAG,CAAC,KAAU,EAAE,EAAY,EAAE,MAAW,EAAE,EAAE;gBACnD,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;gBACnC,OAAO,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3C,CAAC,CAAC;SACH;aAAM;YACL,GAAG,CAAC,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,IAAI,mCAAI,MAAA,IAAI,CAAC,UAAU,EAAE,0CAAG,CAAC,CAAC,CAAC;SAC5D;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAES,cAAc;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;;AAvFe,0BAAI,GAAG,WAAW,CAAC,SAAS,CAAC","file":"wordcloud.js","sourcesContent":["import type {\n WordcloudEncodeChannels,\n WithDefaultEncode,\n PlotWordcloudEncodeSpec,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n TransformSpec,\n IElement,\n LabelSpec\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType, getTransform } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\nimport { field as getFieldAccessor } from '@visactor/vgrammar-util';\n\nexport class WordcloudSemanticMark extends SemanticMark<PlotWordcloudEncodeSpec, WordcloudEncodeChannels> {\n static readonly type = PlotMakType.wordcloud;\n constructor(id?: string | number) {\n super(PlotMakType.wordcloud, id);\n\n if (!getTransform(PlotMakType.wordcloud)) {\n this._logger.error(\n `Please add this line of code:\n 'import { registerWordCloudTransforms } from '@visactor/vgrammar-wordcloud'; \n and run registerWordCloudTransforms() before use wordcloud`\n );\n }\n }\n\n setMarkType() {\n return GrammarMarkType.text;\n }\n\n setDefaultMarkTransform(): TransformSpec[] {\n return [\n {\n type: 'wordcloud',\n size: {\n callback: (params: any) => {\n return [params.viewBox.width(), params.viewBox.height()];\n },\n dependency: ['viewBox']\n },\n text: { field: this.spec.encode?.text }\n }\n ];\n }\n parseScaleByEncode(\n channel: WordcloudEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotWordcloudEncodeSpec, WordcloudEncodeChannels>, WordcloudEncodeChannels>\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<PlotWordcloudEncodeSpec, WordcloudEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotWordcloudEncodeSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res: GenerateEncoderSpec<PlotWordcloudEncodeSpec> = {\n x: { field: 'x' },\n y: { field: 'y' },\n angle: { field: 'angle' },\n fontSize: { field: 'fontSize' },\n fontStyle: { field: 'fontStyle' },\n fontFamily: { field: 'fontFamily' },\n fontWeight: { field: 'fontWeight' },\n text: { field: this.spec.encode?.text }\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));\n };\n } else {\n res.fill = this.spec.style?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n\n protected parseLabelSpec(): LabelSpec[] {\n return [];\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vgrammar-plot",
3
- "version": "0.7.0-alpha.1",
3
+ "version": "0.7.0-alpha.3",
4
4
  "description": "Plots of vgrammar.",
5
5
  "keywords": [
6
6
  "plot",
@@ -30,12 +30,12 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "@visactor/vgrammar-util": "0.7.0-alpha.1",
34
- "@visactor/vgrammar-coordinate": "0.7.0-alpha.1",
35
- "@visactor/vgrammar": "0.7.0-alpha.1",
33
+ "@visactor/vgrammar-util": "0.7.0-alpha.3",
34
+ "@visactor/vgrammar-coordinate": "0.7.0-alpha.3",
35
+ "@visactor/vgrammar": "0.7.0-alpha.3",
36
36
  "@visactor/vscale": "~0.15.9",
37
- "@visactor/vrender-components": "0.15.0-alpha.11",
38
- "@visactor/vrender": "0.15.0-alpha.11",
37
+ "@visactor/vrender-components": "0.15.0-alpha.14",
38
+ "@visactor/vrender": "0.15.0-alpha.14",
39
39
  "@visactor/vutils": "~0.15.9"
40
40
  },
41
41
  "devDependencies": {