function createChart(data){ chart = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'line' }, title: { text: '用户一周PV线型图' }, subtitle: { text: '信息来源: www.weibo.com' }, xAxis: { categories: data.xAxis, max: data.xAxis.length > 10 ? 10 : null //设置x轴的宽度 }, yAxis: { title: { text: 'PV' } }, tooltip: { enabled: true, formatter: function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y +'pv'; } }, plotOptions: { line: { dataLabels: { enabled: true }, enableMouseTracking: true } }, scrollbar: { enabled: true //设置滚动bar }, legend: { layout: 'horizontal', align: 'top', verticalAlign: 'top', x: -10, y: 50, borderWidth: 0 }, series: data.series }); }