score:0
Simplest way is to query data from mySql and then sort it same as
[
['Firefox.com', 45.0],
['Default.com', 26.8],
['MSN', 12.8],
['Google.com', 8.5],
['Yahoo.com', 6.2],
['Others', 0.7]
]
Requires if you want to show chart just on page loading. You can also use JSON.
score:2
series: [{
type: 'pie',
name: 'Browser share',
data: [
<?php
$sql = 'select sum(hits) from tracks';
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
$totalHits = $row[0];
$sql = 'select name, hits from tracks order by hits desc';
$result = mysql_query($sql);
$i = 0;
$totalOther = 0;
$maxSlices = 5;
$minPercent = 10;
while ($row = mysql_fetch_row($result))
{
$percent = row[1] / $totalHits * 100;
if (++$i <= $maxSlices && $percent >= $minPercent)
{
echo json_encode($row);
}
else
{
$totalOther += $row[1];
}
}
if ( $totalOther > 0 ) echo json_encode(array('Other', $totalOther));
?>
]
}]
if you want to refresh it thourgh ajax...
...
series: [{
type: 'pie',
name: 'Browser share',
data: getData(function(result) {return result;}),
...
and
function getData(setDataCallback)
{
$.getJSON('file.php', args, function(result) { // use of jquery for clarity.
setDataCallback(result);
});
}
in php you have to do a new file ('file.php') with the code shown in the first code block;
Source: stackoverflow.com
Related Query
- Get stats and show it in chart - PHP/HighCharts
- how to make chart real time with 2 line and get data from php with highcharts
- Show tootip and select pie slice on legend click of pie chart in HighCharts
- Highcharts series doesnt show data and render the chart
- Yii - Highcharts - Cannot get chart to show
- HighCharts and PHP json_encode. Data from MySQL. No data on chart
- Converted PHP code that built an array to JS and now highcharts doesn't work - what did I do wrong?
- Highcharts column chart extends off container and doesn't properly show X axis
- HighCharts pie chart X-axies values are not displayed while trying to get data from MySQL database using PHP
- I want to add a loading spinner or add some dialog until highcharts get loaded and should close after chart is loaded in react typescript?
- using a few data columns to plot chart and some to show on tooltip highcharts
- Displaying highchart and using php to get data for the chart from mysql database
- Show Column and line chart together in drill down using highcharts
- PHP and MySQL, get JSON data to feed HighCharts
- How to create a column range chart in Highcharts using range and navigator functions?
- How can I get access to a Highcharts chart through a DOM-Container?
- Hiding _groups_ of series in Highcharts and jQuery: how to get acceptable performance?
- Highcharts data series issue with ajax/json and PHP
- Highcharts - labels inside and outside a pie chart
- Highcharts / jQuery - destroy and rebuild chart with original options
- How do you increase the performance of highcharts chart creation and rendering
- Highcharts Pie Chart ignores percentageDecimals tooltip setting and has floating point inaccuracy issue
- Using html2canvas to render a highcharts chart to pdf doesn't work on IE and Firefox
- Can highcharts crosshairs show on top of area chart fill?
- Highcharts - best way to handle and display zero (or negative) values in a line chart series with logarithmic Y axis
- Using Highcharts and displaying a message over or on the chart when there is no data
- Highcharts : Venn Diagram how to show total and union numbers?
- How to add space between chart and axis in highcharts
- how to get chart object inside a point event function in Highcharts
- Highcharts - How can I remove starting and ending padding from area chart
More Query from same tag
- Load HighCharts Chart/Data on Form Submit with jQuery
- series is truncated after click on the series in the legend
- How to access different contexts of 'this' in HighCharts callback (Angular / Typescript)
- How to update option of specific point?
- Adjust X Scale in highchart to display proper ratio
- Set datetime measure unit in Highcharts
- Highcharts with external CSV $.get - No xAxis date
- DotNet HighChart not populating
- how to adjust distance between to bars in bar chart highchart
- Style specific data element in highchart
- How do you change plotBackGroundColor dynamically if value exceeds a maxium value in Highcharts?
- HighStock chart.rangeSelector after loading
- how to create a responsive custom label in highchart
- How to display non-graphed data from CSV file in Highcharts' tooltip?
- Highcharts: make the X and Y axes intersect at 0
- Behavior of log axis
- Summing graph data in highcharts
- How to use Highcharts React to create chart with multiple lines for same XAxis?
- Highcharts doesn't work
- How to set minutes as units in Highstock chart using data from CSV
- Get images from Highcharts PHP Laravel
- Highcharts Gauge not showing in Angular
- HighCharts - HighStock - Show Date for Candlestick & Volume
- React Highchart: Synchronized chart and tooltip is not highlighting the points
- Formatter in 'Bar with negative stack': this.point.stackTotal has the wrong value (bug?)
- Highcharts: How to change the border color of RangeSelector Input Boxes in StockCharts?
- Highcharts line chart tooltips not showing correctly?
- Export Highcharts polar chart csv with categories in place of polar coordinates
- Highcharts pie chart slice colour intensity using colorValue
- unexpected token { in javascript