(options: MarkStagerOptions, stage: Stage, scene: Scene, x: number, y: number, groupType: GroupType)
| 25 | } |
| 26 | |
| 27 | const markStager: MarkStager = (options: MarkStagerOptions, stage: Stage, scene: Scene, x: number, y: number, groupType: GroupType) => { |
| 28 | |
| 29 | //scale Deck.Gl text to Vega size |
| 30 | const fontScale = 1; |
| 31 | |
| 32 | //change direction of y from SVG to GL |
| 33 | const ty = -1; |
| 34 | |
| 35 | base.vega.sceneVisit(scene, function (item: SceneText2) { |
| 36 | if (!item.text) return; |
| 37 | const size = item.fontSize * fontScale; |
| 38 | const alignmentBaseline = convertBaseline(item.baseline); |
| 39 | const yOffset = alignmentBaseline === 'top' ? item.fontSize / 2 : 0; //fixup to get tick text correct |
| 40 | const textItem: VegaTextLayerDatum = { |
| 41 | color: colorFromString(item.fill), |
| 42 | text: item.limit === undefined ? item.text : base.vega.truncate(item.text, item.limit, 'right', item.ellipsis || '...'), //use dots instead of unicode ellipsis for deck.gl's default font atlas |
| 43 | position: [x + (item.x || 0), ty * (y + (item.y || 0) + yOffset), 0], |
| 44 | size, |
| 45 | angle: convertAngle(item.angle), |
| 46 | textAnchor: convertAlignment(item.align), |
| 47 | alignmentBaseline, |
| 48 | metaData: item.metaData, |
| 49 | }; |
| 50 | if (item.mark.role === 'axis-label') { |
| 51 | const tickText = textItem as TickText; |
| 52 | tickText.value = (item.datum as LabelDatum).value; |
| 53 | if (options.currAxis.role === 'z') { |
| 54 | zSwap(tickText.position); |
| 55 | } |
| 56 | options.currAxis.tickText.push(tickText); |
| 57 | } else if (item.mark.role === 'axis-title') { |
| 58 | if (options.currAxis.role === 'z') { |
| 59 | zSwap(textItem.position); |
| 60 | } |
| 61 | options.currAxis.title = textItem; |
| 62 | } else { |
| 63 | stage.textData.push(textItem); |
| 64 | } |
| 65 | }); |
| 66 | }; |
| 67 | |
| 68 | function convertAngle(vegaTextAngle: number) { |
| 69 | if (vegaTextAngle && !isNaN(vegaTextAngle)) { |
no test coverage detected