1Chart.pluginService.register({ 2 beforeDraw: function (chart) { 3 if (chart.config.options.elements.center) { 4 //Get ctx from string 5 var ctx = chart.chart.ctx; 6 7 //Get options from the center object in options 8 var centerConfig = chart.config.options.elements.center; 9 var fontStyle = centerConfig.fontStyle || 'Arial'; 10 var txt = centerConfig.text; 11 var color = centerConfig.color || '#000'; 12 var sidePadding = centerConfig.sidePadding || 20; 13 var sidePaddingCalculated = (sidePadding/100) * (chart.innerRadius * 2) 14 //Start with a base font of 30px 15 ctx.font = "30px " + fontStyle; 16 17 //Get the width of the string and also the width of the element minus 10 to give it 5px side padding 18 var stringWidth = ctx.measureText(txt).width; 19 var elementWidth = (chart.innerRadius * 2) - sidePaddingCalculated; 20 21 // Find out how much the font can grow in width. 22 var widthRatio = elementWidth / stringWidth; 23 var newFontSize = Math.floor(30 * widthRatio); 24 var elementHeight = (chart.innerRadius * 2); 25 26 // Pick a new font size so it will not be larger than the height of label. 27 var fontSizeToUse = Math.min(newFontSize, elementHeight); 28 29 //Set font settings to draw it correctly. 30 ctx.textAlign = 'center'; 31 ctx.textBaseline = 'middle'; 32 var centerX = ((chart.chartArea.left + chart.chartArea.right) / 2); 33 var centerY = ((chart.chartArea.top + chart.chartArea.bottom) / 2); 34 ctx.font = fontSizeToUse+"px " + fontStyle; 35 ctx.fillStyle = color; 36 37 //Draw text in center 38 ctx.fillText(txt, centerX, centerY); 39 } 40 } 41});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.