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
- Recover page content when visiting back
- Adding highcharts to mapbox popup from CSV?
- Highcharts: To achieve exploded sections behaviour in Sunburst chart similar to pie charts
- Can't access custom point variable inside Highcharts tooltip.headerFormat
- How to display the collection in the library dynamically Highcharts - Bind collection with Highcharts in MVC
- How can I apply different background color to entire tooltip for different series in highcharts
- Put my labels in front of the graph without obscuring the points
- Highcharts - additional data with Json
- Plot time on Y-axis and users on X-axis Highcharts
- Highcharts Ganttchart (or XRange) group y-Axis elements
- Highcharts - Export with background color
- Show x-Axis line but hide all data points
- HighCharts areaspline multicolor gradient opacity fade
- Highstock : Yaxis last horizontal label value not showing
- Highcharts and JSON data from PHP
- Highcharts pie chart slice colour intensity using colorValue
- Is there a rangeselector event to get dates outside the data range?
- Pass vales from Javascript back to C# function
- Highcharts error 19 issue when adjusting container width that chart displays in
- Highcharts not showing value when two stacked columns have value = 1
- Locate a dot with the same xpath in a highchart
- HighCharts plugin JQuery
- Month wise category separation in Highcharts
- How to Control Highchart.js Dom Elements Through CSS Rules
- hide a particular column on xAxis highchart Column Chart
- Highstock Stockchart with custom color for single grouped column
- How do I hide specific legend items?
- Converting this highcharts to my data
- Highchart - Use a formatter on PlotLine labels
- Highcharts: how to change "overscroll" parameter on "afterSetExtremes" even?