score:1
Accepted answer
I think you are trying to do something what you already have done.
You want to get display three series from your JSON, for respective categories, then let's to that:
Your code:
var categories = testDia['chartCategories'];
var series = testDia['chartSeries'];
Great! Now use that variables:
newChart = new Highcharts.Chart({
chart : {
renderTo : portletContainer,
type: 'column'
},
...
xAxis: {
categories: categories,
labels: {
rotation: -45,
align: 'right',
}
},
...
series: [{
name: 'Positive',
data: series.positive // testDia.chartSeries.positive is the same
}, {
name: 'Neutral',
data: series.neutral
}, {
name: 'Negative',
data: series.negative
}]
});
And working demo: http://jsfiddle.net/x8455/1/
score:1
Here's how you should do it.
var allPositiveData = []; // You want an array, so start off with an array.
for(var i=0; i < categories.length; i++) {
var diaPositive = series['positive'][i]['y'];
urlPositive = series['positive'][i]['url'];
allPositiveData.push({'y':diaPositive, 'url':urlPositive}); // Add the element to the array.
}
That's all there is to it. Your Highcharts-setup piece of code can remain the same.
To make the sample a little shorter, I only edited the code for the positive
data, the rest is the same, just a different name.
Source: stackoverflow.com
Related Query
- Setup of Highcharts and PhantomJS on Windows 7. JSON string parse error
- Highcharts phantomjs export server can't parse json string
- Use String as object in javascript?
- Parse json and give to category in Highcharts
- array and object handling in javascript for getting highchart json data
- Use different object property names for x and y axes
- Highcharts stacked column charts ( Parse json string for series)
- Get Key names and Values names from JSON and use in Highcharts
- Highcharts csv data loading and parse into separate array and json
- Accessing Value of JSON and use it in Highcharts
- Highchart - Unable to parse my JSON string as a variable in the series but hardcoded way seems to work fine
- how can I use rangeselector and navigation in highcharts in the given code
- How to parse and create JSON tuples with php
- Highcharts parse json string for x-axis grouped categories
- How to view and or read contents of a JSON object in C#?
- Use JSON with HighCharts and AJAX
- How to use the tooltip formatter and still display chart color (like it does by default)?
- use highchart and highstock on the same page
- python/flask/Jinja2 and Json
- Convert from string with milliseconds to date object Javascript
- Rails - convert date string into javascript date object for highcharts
- Possible to use xAxis with type "datetime" and yAxis with categories?
- Use non-emoji version of unicode character (highcharts and plain html)
- Highcharts with JSON data and multiple series
- Highcharts: How to load data from JSON to xAxis.categories and series.data?
- Query regarding why and how to use highcharts license
- how to parse json into highcharts
- AngularJS and angular-translate: Using the translate filter in an object literal
- Using PhantomJS to create HighCharts grahps server side for use in PDF creation (PHP) - results in exit code 11 from PHPs exec();
- How can i force Highcharts to use same symbols in Legend and Series?
More Query from same tag
- Is there a reliable way to have a 1 month auto generated tick interval with high charts?
- Highcharts numberFormat returns minus zero
- Synchronized HighCharts does not work when charts have different width
- How do I set the background color of a Highcharts HTML label?
- HighCharts donut chart drilldown
- Putting the Z-Coordinate in the Highcharts Tooltip
- How can i pass my data in sqlite database to templates? ( to make line chart using highcharts)
- In highcharts how can I provide data with values x, y, title so that I can put the title in the tooltip?
- HighCharts Line xas datetime
- JavaScript - Highcharts box plot not displaying
- Highchart bullet map plotBackground color always visible
- Highcharts - `lineColor` doesn't work with Zone
- Form data series for highcharts columns
- Series as columns in highcharts
- HighCharts column chart populated with series data from a function
- Plot one point on Highcharts JS graph according to x-axis?
- Highcharts treemap data labels overflow
- Alternatives to Highcharts for datasets with 10k data points?
- How to add HighCharts bundle to BundleConfig? MVC 3
- R HIGHCHARTER - How to display additional series values on a highchart hover?
- Plotbands in Highcharter - When x axis is date
- Show Gridline on Y axis for 0 point only
- Years-only display on xAxis with Highcharts
- Highcharts column percentage stacked chart worked in v 2.3.5 broken with v 3.0.2
- How to prevent highcharts from shortening labels with ellipsis
- Highmaps downloadXLS() issue with MacOS Safari
- Getting {% load chartit %} on my browser. Charts are not loading using chartit
- reuse of same object of chart in highcharts to minimize coding
- Grand Totals in HighCharts Pie Chart Legend
- How to draw an outer border for a donut chart - Highcharts