<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script type="text/javascript" src="https://raw.github.com/highslide-software/highcharts.com/v2.1.9/js/highcharts.src.js"></script> <script> var data0 = [10, 5, 95, 30, 4, 33, 90, 80, 42, 14, 17]; var data1 = ['02:59:27', '02:59:41', '02:59:49', '02:59:58', '03:00:06', '03:00:14', '03:00:23', '03:00:32', '03:00:39', '03:00:47']; setInterval(function (data1) { var cats = chart.xAxis[0].categories; cats.push(data1); chart.xAxis.setCategories(data1, false); chart.series[0].addPoint(Math.floor((Math.random() * 100) + 1), true, true); }, 2000); $(function () { //chart.xAxis[0].setCategories(['One', 'Two', 'Three', 'four', 'One', 'Two', 'Three', 'four', 'One', 'Two', 'Three']); chart = new Highcharts.Chart({ chart: { renderTo: 'chart', zoomType: 'x', defaultSeriesType: 'areaspline' }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', borderWidth: 0 }, title: { text: 'Online Users', x: -20 //center }, xAxis: { categories: cats, labels: { rotation: -45, style: { color: '#000' } }, tickInterval: 25 }, yAxis: { title: { text: 'Count' }, plotLines: [{ value: 0, width: 1, color: '#808080' }] }, series: [ { name: 'WLAN TX', data: data0 , lineWidth: 1 }, ] , plotOptions: { //series: { // stacking: null //}, areaspline: { marker: { enabled: false, symbol: 'circle' } } , spline: { marker: { enabled: false, symbol: 'circle' } } } }); }); </script></head><body> <div id="chart"></div></body></html>
I'm arrays Datta 1 in category chart view to dynamicallyvar data1 = ['02:59:27', '02:59:41', '02:59:49', '02:59:58', '03:00:06', '03:00:14', '03:00:23', '03:00:32', '03:00:39', '03:00:47']; As you can see in the above code I have written a piece of code to display the categories but displays an error.this code:
var cats = chart.xAxis[0].categories; cats.push(data1); chart.xAxis.setCategories(data1, false);
Firebug I debug my code and the error will appear.TypeError: chart.xAxis is undefined[break On This Error]var cats = chart.xAxis [0]. categories;