I'm using Highcharts to make a couple of charts for a project. I've created two of them in a charts.php file. It needs to php because I plan on adding information from a pgsql database to update the chart dynamically. Right now I was just wondering how to print them in other files. Here's one of the charts:
<div class = "genres-container">
<div id="genres" style="width:75%; height:400px;"></div>
<script>
$(function drawChart () {
// Radialize the colors
Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function (color) {
return {
radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
stops: [
[0, color],
[1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
]
};
});
// Build the chart
$('#genres').highcharts({
chart: {
plotBackgroundColor: null,
plotShadow: false
},
title: {
text: 'Genres'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
}
}
},
series: [{
type: 'pie',
name: 'Genre Percentage',
data: [
['Comedy', 1884],
['Drama', 1862],
['Action', 1079],
['Adventure', 830],
['Crime', 826],
['Romance', 764],
['Thriller', 694],
['Family', 411],
['Horror', 384],
['Fantasy', 375],
['Mystery', 341],
['Sci-Fi', 336],
['Animation', 236],
['Biography', 175],
['Sport', 154],
['Music', 135],
['History', 86],
['War', 59],
['Documentary', 55],
['Musical', 45],
['Western', 31],
['Film-Noir', 2]
]
}]
});
});
</script>
If I wanted to print this chart in a different file, say index.php (the front page of our project) How would I do this?
Aucun commentaire:
Enregistrer un commentaire