Javascript examples for highcharts:Chart Text
Add text to chart
<html> <head> <title>Highcharts Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(function () {/*from www .j ava 2s . co m*/ $('#container').highcharts({ xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, yAxis: { max: 300 }, series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] }] }, function (chart) { text = chart.renderer.text("My Text<br>Second Line").add(); textBBox = text.getBBox(); x = chart.plotLeft + (chart.plotWidth * 0.5) - (textBBox.width * 0.5); y = chart.plotTop + (chart.plotHeight * 0.5) - (textBBox.height * 0.25); text.attr({x: x, y: y, zIndex: 10}); rect = chart.renderer.rect(x, y, textBBox.width, textBBox.height, 2) .attr({ fill: '#FFFFEF', stroke: 'gray', 'stroke-width': 1, zIndex: 9 }) .add(); rectBBox = rect.getBBox(); rect.attr({y: y - rectBBox.height*0.5 - textBBox.height*0.25}); }); }); </script> </head> <body> <script src="https://code.highcharts.com/4.1.1/highcharts.js"></script> <div id="container" style="height: 300px; width: 400px"></div> </body> </html>