Jquery 在一个页面中使用多个Highcharts
我正在使用Highcharts,我想在一个页面中添加多个图表 下面是我的js代码Jquery 在一个页面中使用多个Highcharts,jquery,ajax,highcharts,Jquery,Ajax,Highcharts,我正在使用Highcharts,我想在一个页面中添加多个图表 下面是我的js代码 <script type="text/javascript"> $(function () { var chart; $(document).ready(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'container',
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Visual Data'
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Market Share',
data: [
['Plan 1', <?php echo $1; ?>],
['Plan 2', <?php echo $2; ?>],
['Plan 3', <?php echo $3; ?>]
]
}]
});
});
});
</script>
显示多个图表。目前,我想在一个页面中显示5个图表。您可以使用
Highcharts.setOptions
定义页面上所有图表的相同选项。下面是示例代码:
Highcharts.setOptions({
global: {
//Highchart uses UTC time by default
useUTC: false
},
legend: {
enabled: false
},
credits: {
enabled: false
},
xAxis: {
type: 'datetime',
tickColor: '#96AA8C',
labels: {
style: {
color: '#555F50'
}
},
tickPixelInterval: 70,
maxZoom: 20 * 1000
},
title: {
style: {
color: '#343434'
}
},
tooltip: {
xDateFormat: '%d/%m/%Y %H:%M:%S'
}
});
您可以用这种方式定义所有属性(不确定“全部”)
Highcharts.setOptions({
global: {
//Highchart uses UTC time by default
useUTC: false
},
legend: {
enabled: false
},
credits: {
enabled: false
},
xAxis: {
type: 'datetime',
tickColor: '#96AA8C',
labels: {
style: {
color: '#555F50'
}
},
tickPixelInterval: 70,
maxZoom: 20 * 1000
},
title: {
style: {
color: '#343434'
}
},
tooltip: {
xDateFormat: '%d/%m/%Y %H:%M:%S'
}
});