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 }); }