Skip to content

Commit dfe5670

Browse files
committed
handle font styles in gl-scatter3d
1 parent 7aae57b commit dfe5670

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

src/traces/scatter3d/convert.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,11 @@ function convertPlotlyOptions(scene, data) {
296296
params.textOffset = calculateTextOffset(data.textposition);
297297
params.textColor = formatColor(data.textfont, 1, len);
298298
params.textSize = formatParam(data.textfont.size, len, Lib.identity, 12);
299-
params.textFont = data.textfont.family; // arrayOk === false
300-
params.textWeight = data.textfont.weight; // arrayOk === false
301-
params.textStyle = data.textfont.style; // arrayOk === false
302-
params.textStretch = data.textfont.stretch; // arrayOk === false
303-
params.textVariant = data.textfont.variant; // arrayOk === false
299+
params.textFontFamily = data.textfont.family; // arrayOk === false
300+
params.textFontWeight = data.textfont.weight; // arrayOk === false
301+
params.textFontStyle = data.textfont.style; // arrayOk === false
302+
params.textFontStretch = data.textfont.stretch; // arrayOk === false
303+
params.textFontVariant = data.textfont.variant; // arrayOk === false
304304
params.textAngle = 0;
305305
}
306306

@@ -449,7 +449,11 @@ proto.update = function(data) {
449449
size: options.textSize,
450450
angle: options.textAngle,
451451
alignment: options.textOffset,
452-
font: options.textFont,
452+
font: options.textFontFamily,
453+
fontWeight: options.textFontWeight,
454+
fontStyle: options.textFontStyle,
455+
fontStretch: options.textFontStretch,
456+
fontVariant: options.textFontVariant,
453457
orthographic: true,
454458
lineWidth: 0,
455459
project: false,

stackgl_modules/index.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21493,9 +21493,17 @@ module.exports = getGlyph
2149321493
var GLYPH_CACHE = {}
2149421494

2149521495
function getGlyph(symbol, font, pixelRatio) {
21496-
var fontCache = GLYPH_CACHE[font]
21496+
var fontKey = [
21497+
font.style,
21498+
font.weight,
21499+
font.stretch,
21500+
font.variant,
21501+
font.family
21502+
].join('_')
21503+
21504+
var fontCache = GLYPH_CACHE[fontKey]
2149721505
if(!fontCache) {
21498-
fontCache = GLYPH_CACHE[font] = {}
21506+
fontCache = GLYPH_CACHE[fontKey] = {}
2149921507
}
2150021508
if(symbol in fontCache) {
2150121509
return fontCache[symbol]
@@ -21505,7 +21513,11 @@ function getGlyph(symbol, font, pixelRatio) {
2150521513
textAlign: "center",
2150621514
textBaseline: "middle",
2150721515
lineHeight: 1.0,
21508-
font: font,
21516+
font: font.family,
21517+
fontStyle: font.style,
21518+
fontWeight: font.weight,
21519+
fontStretch: font.stretch,
21520+
fontVariant: font.variant,
2150921521
lineSpacing: 1.25,
2151021522
styletags: {
2151121523
breaklines:true,
@@ -22133,7 +22145,14 @@ proto.update = function(options) {
2213322145
var points = options.position
2213422146

2213522147
//Text font
22136-
var font = options.font || 'normal'
22148+
var font = {
22149+
family: options.font || 'normal',
22150+
style: options.fontStyle || 'normal',
22151+
weight: options.fontWeight || 'normal',
22152+
stretch: options.fontStretch || 'normal',
22153+
variant: options.fontVariant || 'normal'
22154+
}
22155+
2213722156
var alignment = options.alignment || [0,0]
2213822157

2213922158
var alignmentX;

stackgl_modules/package-lock.json

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stackgl_modules/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"gl-plot2d": "^1.4.5",
2323
"gl-plot3d": "^2.4.7",
2424
"gl-pointcloud2d": "^1.0.3",
25-
"gl-scatter3d": "^1.2.3",
25+
"gl-scatter3d": "github:gl-vis/gl-scatter3d#eeb947a712fc6a17fa0dc1775397976de926887a",
2626
"gl-select-box": "^1.0.4",
2727
"gl-shader": "4.3.1",
2828
"gl-spikes2d": "^1.0.2",

0 commit comments

Comments
 (0)