score:1
move the print after the for loop, and don't reinitialize $result
to an empty array inside of the loop.
also...
$cc = array();
$cc = count($cb);
one of those lines is redundant (probably the first).
score:0
move $result = array();
to occur before the loop, perhaps even before the if-block. you can probably handle the code from there.
score:0
highcharts use number data, but your data is a array of strings. so you need to parse it by parsefloat() or use json_encode() with json_numeric_check which allows to return correct json values.
score:1
there are two things wrong with your code:
- you're re-inializing the array on each iteration
- you're printing the json string on each iteration
what you're seeing as the output is three json strings combined. as there are no line breaks in your code, it'll appear as one big json string.
your code should look like:
$result = array(); // initialize the array
while($ba = mysql_fetch_array($b))
{
$rows['name'] = $ba[0];
$rows['data'][] = $ba['jumlah'];
array_push($result,$rows);
}
print json_encode($result);
Source: stackoverflow.com
Related Query
- adding element with array_push() with looping to create json data
- Create Density Heatmap Chart using Jquery with array of data
- Adding data to a highchart chart using an array with IDs
- Trying to push data to a JSON array
- Extract data series from a JSON array for a Highcharts chart with 2 y-axis
- set series driildown data with looping from array
- Highcharts: create a simple line graph with json data
- make highcharts graph with data in json format, with 4-element array
- Passing data from PHP array to Highcharts chart with JSON
- create custom objects array from json data
- Reload chart data via JSON with Highcharts
- creating highchart with ajax json data
- Plot Highchart Gauge with JSON Data
- HighChart Heatmap with JSON data
- Highcharts with JSON data and multiple series
- Highcharts - Global configuration with common code and unique data & Headings
- How to populate a Highcharts axis with string formatted data from a PHP array
- Formatting JSON Data with ColdFusion for HighCharts
- Highcharts with ajax and json data what am i doing wrong?
- Create six chart with the same rendering,different data (highchart )
- How can i get the json data with the specific between Year?
- JSON data with angular2-highcharts
- Plotting JSON data with angular2-highchart
- dynamic highcharts with json data
- Line not rendered with data in variable but rendering with array data
- How to create data in Json format for highcharts
- Retrieving JSON data for Highcharts with multiple series?
- passing formatting JavaScript code to HighCharts with JSON
- how to create highcharts formatted json structure with python
- JSON Data Map Issue with HighCharts + Ajax
More Query from same tag
- Clickable Bars in js Highcharts?
- How to make the regression line through the origin in highcharts
- How to add a line at the bottom of a column chart in highcharts
- Highcharts bubbles incorrect initial size, changes on resize
- Adding data points in Highcharts
- Prevent xAxis of column highchart taking negative labels on hiding one of other series(on legendItemClick event)
- How can I disable the value tooltip on a Vaadin-Charts/Highcharts SolidGauge chart?
- How can I embed the AJAX output of JS in Javascript function
- Parsing JSON for use with Highcharts using jquery .parseJSON or JSON.parse: how to remove quotes from function calls for formatters?
- HighCharts: How to read the JSON data
- Highcharts pie wrong legend colors
- unable to Add display data values on top of bar high chart
- highcharts, Set minimum height for stacked column chart?
- Disable hover on HighCharts
- Highcharts version 7.1.1 how to offline-exporting PDF with amd modules
- Parse data from specified columns highcharts.js
- Updating highcharts gauge with JSON
- Series for tooltip only in highcharts
- how to add values from my object to Highchart using Jquery
- populating highchart series by looping my query every month
- How to map values within a data series to different y-axes?
- HighCharts SyntaxError: missing ] after element list
- How to make histogram from already aggregated data?
- Line to the Y axis on hover
- Highcharts- this.category returns undefined
- High Charts Can't hide Pie Chart data labels
- How to modify the code so that Highcharts graph does not cover fixed navigation bar at the top of the page?
- Dynamic updates with highcharts
- Why does highchart not recognize my dates?
- Highcharts - Data won't get loaded into chart on Android WebView