score:2
You can set your points as follows:
genderChart.series[0].addPoint({
name: key_g,
y: val_g
});
score:0
I know this question has been solved. but the map function for array might be a good choice in these cases, I love map in functional language!
data = [{"y":"Mr","x":"145"},{"y":"Miss","x":"43"},
{"y":"Mrs","x":"18"},{"y":"Ms","x":"2"}];
var series = data.map(function(e){ return parseInt(e.x); });
.... hight chart ....
score:1
By rearranging my Json to have "name" and "y" as the keys i was able to make progress i.e:
[{"name":"Mr","y":"145"},{"name":"Miss","y":"43"},{"name":"Mrs","y":"18"},{"name":"Ms","y":"2"}]
Then by looping through the json data and parsing the "y" value as a int with the function parseInt() in the JS i was able to get my desired result...
function genderData() {
$.getJSON('/statsboard/gender', function(data_g) {
$.each(data_g, function(key_g, val_g) {
obj_g = val_g;
genderChart.series[0].addPoint({
name: obj_g.name,
y: parseInt(obj_g.y)
});
console.log(obj_g.y)
});
});
}
score:3
The forms:
[{"name": "Mr", "y": 145}, ...]
or
[["Mr", 145], ...]
will work. Notice the second form is an array of arrays not an array of objects (you were close).
See basic-pie demo (click view options and scroll down to data), series.data docs, and series.addPoint docs for more info.
If you make the server side return the data in one of the two above forms you can just do:
function genderData() {
$.getJSON('/statsboard/gender', function(data_g) {
genderChart.series[0].setData(data_g, true);
});
}
Source: stackoverflow.com
Related Query
- Parsing JSON data for Highcharts
- Parsing JSON Data for Lazy Highcharts
- Formatting JSON data monthwise for HighCharts using MySQL
- Formatting JSON Data with ColdFusion for HighCharts
- How to format my json data for stack column chart in HighCharts
- Formatting JSON from a Pandas data frame for Highcharts within a Django template
- How to create data in Json format for highcharts
- Retrieving JSON data for Highcharts with multiple series?
- Extracting data from a JSON call to a Postgres table for use in Highcharts (without PHP)
- JSON Data formatting for Highcharts
- Highcharts display label for pie chart using html table as data source
- Parsing json data to highcharts
- highcharts highmaps parsing json data to display world map with rich info
- Extract data series from a JSON array for a Highcharts chart with 2 y-axis
- JSON Result for Highcharts Data Object in C#
- HTML table as data source for highstock charts using highcharts
- Highcharts to populate data for pie chart using json object
- Data Conversion from SQL, C# with Linq to JSON for Highcharts Line chart
- Using a flask variable as data source for highcharts
- Error: Data source must be a URL for refresh | console error | javascript | Highcharts
- Parsing JSON for use with Highcharts using jquery .parseJSON or JSON.parse: how to remove quotes from function calls for formatters?
- HighCharts Bubble graph JSON as data source
- Use Node.js as data source for highcharts
- YQL finance data JSON format for use with highcharts
- Formatting PHP/MySQL data in correct JSON format for HighCharts
- Highcharts JSON formatting - splitting up and preprocessing data for charts?
- JSON Data for Highcharts in Symfony2 with ObHighchartsBundle
- Highcharts displays series names but missing data points from json source
- How to build a JSON data array for Highcharts display - switching values for xAxis/columns
- How to format Highcharts columnRange to get json data for temperature Min and Max
More Query from same tag
- Highchart Legend Alignment
- HIghcharts Legend Symbol Getting out of graph Canvas
- HIghcharts Scrollbar (w/ showFull false) displays after setExtremes called
- Additional Chart in Tooltip possible?
- HighCharts JS - Getting multiple linear underlays on a scatter plot
- High chart data downloads but does not display in browser using node
- Charts rendered using highcharts in angular2 do not take the height of the parent
- Set left and right border-like on highchart
- stacked bar chart with separate label
- How to de-couple and do dependency injection with highcharts-ng
- Creating a marimekko chart using Highcharts
- JavaScript highcharts: how to have two xAxis categories?
- React plot options onclick event
- Making tooltip behave like in scatter
- Make highcharts display the tooltip of the previous point
- parse file from input with papaparse
- highchart with a specific json format in django
- Highchart Export
- Highcharts : How to apply padding between each bar on Y-axis
- How do I scrape data from a highcharts graph in python?
- Building HighCharts-Export Server 2.1 Fails
- Highstock gapsize is causing line rendering issue
- Animation end callback after adding points
- highcharts - How do I show/hide secondary y axis based on optional parameter
- SyntaxError: JSON.parse: expected property name or '}' while using highcharts
- Highcharts more and highcharts guage issue
- Highstock Data Grouping to Use Last Data Time as Index
- Highcharts zIndex of Y-Axis title
- How to update just data attribute under series in highcharts with json?
- Highcharts not working on Heroku environment, works on local environment