MCPcopy Index your code
hub / github.com/plotly/plotly.js / addItem

Function addItem

stackgl_modules/index.js:13000–13036  ·  view source on GitHub ↗
(t, text, font, size, lineSpacing, styletags)

Source from the content-addressed store, hash-verified

12998 var data = []
12999
13000 function addItem(t, text, font, size, lineSpacing, styletags) {
13001 var fontKey = [
13002 font.style,
13003 font.weight,
13004 font.variant,
13005 font.family
13006 ].join('_')
13007
13008 var fontcache = __TEXT_CACHE[fontKey]
13009 if(!fontcache) {
13010 fontcache = __TEXT_CACHE[fontKey] = {}
13011 }
13012 var mesh = fontcache[text]
13013 if(!mesh) {
13014 mesh = fontcache[text] = tryVectorizeText(text, {
13015 triangles: true,
13016 font: font.family,
13017 fontStyle: font.style,
13018 fontWeight: font.weight,
13019 fontVariant: font.variant,
13020 textAlign: 'center',
13021 textBaseline: 'middle',
13022 lineSpacing: lineSpacing,
13023 styletags: styletags
13024 })
13025 }
13026 var scale = (size || 12) / 12
13027 var positions = mesh.positions
13028 var cells = mesh.cells
13029 for(var i=0, nc=cells.length; i<nc; ++i) {
13030 var c = cells[i]
13031 for(var j=2; j>=0; --j) {
13032 var p = positions[c[j]]
13033 data.push(scale*p[0], -scale*p[1], t)
13034 }
13035 }
13036 }
13037
13038 //Generate sprites for all 3 axes, store data in texture atlases
13039 var tickOffset = [0,0,0]

Callers 1

index.jsFile · 0.70

Calls 1

tryVectorizeTextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…