Javascript examples for highcharts:Chart Point
animation when using addPoint()
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript"> $(function () {//from w w w . j av a2 s . c om var categories = ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']; $('#container').highcharts({ chart: {}, title: { text: 'Combination chart' }, xAxis: { categories: categories, max: 4 }, tooltip: { formatter: function () { var s; if (this.point.name) { // the pie chart s = '' + this.point.name + ': ' + this.y + ' fruits'; } else { s = '' + this.x + ': ' + this.y; } return s; } }, labels: { items: [{ html: 'Total fruit consumption', style: { left: '40px', top: '8px', color: 'black' } }] }, series: [{ type: 'column', name: 'Jane', data: [3, 2, 1, 3, 4, 0, 0, 0, 0, 0] }, { type: 'column', name: 'John', data: [2, 3, 5, 7, 6, 0, 0, 0, 0, 0] }, { type: 'column', name: 'Joe', data: [4, 3, 3, 9, 0] }, { type: 'pie', name: 'Total consumption', data: [{ name: 'Jane', y: 13, color: Highcharts.getOptions().colors[0] // Jane's color }, { name: 'John', y: 23, color: Highcharts.getOptions().colors[1] // John's color }, { name: 'Joe', y: 19, color: Highcharts.getOptions().colors[2] // Joe's color }], center: [100, 80], size: 100, showInLegend: false, dataLabels: { enabled: false } }] }); $btn = $('#button'); var pointIndex = 5; $btn.click(function () { var chart = $("#container").highcharts(); categories.push("My new category"); chart.xAxis[0].setCategories(categories, false); chart.series[0].data[pointIndex].update(['My new category', Math.random() * 10], false); chart.series[1].data[pointIndex].update(['My new category', Math.random() * 10], false); chart.xAxis[0].setExtremes(0, pointIndex); pointIndex = pointIndex == 9 ? 0 : pointIndex + 1; }); }); </script> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div> <button id="button">Click</button> </body> </html>