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
- Implementing Custom Temperature Gauge with Angular 4 and HighCharts
- high chart date format in x-axis
- adding series to highcharts from JSON
- Highcharts X axis categories name gets only shows 1 character
- Change data hover line color in Highcharts
- Events for HighCharts - MouseOver/MouseOut
- Highchart - xAxis values are to close
- Additional serires label in highcharts columnrange
- Highcharts Area graph, use 2 fill colors above / below X axis
- Highcharts Legend Custom HTML
- Highcharts: how to group data points and display the total accordingly?
- Highcharts customization PHP/MySQL
- Highcharts with live data: align chart on left side
- Highcharts x axis date full range even if there is not enough data
- Wrong x-axis position and formatting when only 1 data series sent to chart
- Highcharts histogram drilldown: set options for drilldown + first and last column cut-off
- Realtime backend platform for reporting / dashboards?
- Line Chart using array
- How to set 'lang' property in Highcharts using Angular JS?
- Extend Highcharts Export
- Create multiple vertical plotlines on click and drag each of the plotline. Developed in Angular 6 and Highcharts
- Making tooltip behave like in scatter
- Spline chart tooltip only snaps on x-axis
- Add plot line to heat map
- Highcharts donut hover all area
- How to add multiple axis without multiple series on highchart?
- Updating Series Color Appears to Break Navigator and Range Selector
- HighCharts.StockChart remove zoom feature
- data label is not shown Highcharts
- Reveal.js with highcharts