score:5
The following is already an array -
["item1_10_20", "item2_2011_10_14", "item3_2011_10_07", "item3_2011_09_12"]
so, change the following
xAxis: {
categories: [items]
},
as follows -
xAxis: {
categories: items
},
Update:
xAxis: {
categories: eval('(' + items + ')')
},
Update2:
One thing you need to know here is that JSON is not Javascript. You get get JSON reponse from server which is nothing more than a string in Javascript. So, to use that JSON response in Javascript you have to parse the JSON to form a Javascript data structure like object, array, etc (Just like we do with XMl), which is called parsing.
There are a lot of JSON parsing libraries, but we can also use eval
JS function to do the job, as long as security is not a concern.
And in your case, the JSON response represents an array so you use eval
to turn that into a real Javascript array.
So, items
is JSON and you use eval
(eval('(' + items + ')')
) to parse which returns a Javascript array and then you assign the result to categories
.
score:1
I had the same problem with a c# array, I solve in this way with razor :
@{
string[] myIntArray = new string[5] {"Apples", "Oranges", "Pears", "Grapes", "Bananas" };
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
var jsVariable = serializer.Serialize(myIntArray);
}
xAxis: {
categories: @Html.Raw(jsVariable)
},
Source: stackoverflow.com
Related Query
- How to populate a Highcharts axis with string formatted data from a PHP array
- how to make chart real time with 2 line and get data from php with highcharts
- Passing data from PHP array to Highcharts chart with JSON
- How can I force ticks/grid lines on a Highcharts datetime X axis to arbitrarily line up with data points?
- How to make the Y Axis values not start from 0 in highcharts? How to display forcefully display the last category data on X axis in HighCharts ?
- Generating Highcharts from MySQL data with PHP does not work
- How to convert string array to ints to use with Highcharts
- HighCharts populate Pie Chart with data from SQL Database
- Yii2 How to pass php array data into highcharts
- How to use highcharts in reactjs with fetched data from API
- Extract data series from a JSON array for a Highcharts chart with 2 y-axis
- Set HighCharts data from JSON string with setData() function
- How to have multiple highcharts with different series data in vuejs without repeating code
- how do you create custom buttons with highcharts that each data buttons calls anather php script for its data
- How to replace x-axes with our own timestamp data from API in Highcharts using highstocks
- Highcharts data value from variable array string
- How to make multiple Y-axis with incoming series of data from database using Highcharts
- Highcharts : Display static Y axis labels from array when series data is null , else auto generated label
- Highcharts with data from table, how to add custom marker for specific value from specific series?
- Highcharts populate the categories with live data from MySQL
- How to draw a chart from one array of data and make labels on the chart from another array of data? Highcharts v.4.0.4
- Populate Highcharts series with data from AJAX/JSON
- Highcharts highstock plot with data from php
- How to prevent highcharts from shortening labels with ellipsis
- Highcharts data series issue with ajax/json and PHP
- Highcharts - How to start x axis from an arbitrary value
- How to display highchart y axis with constistant data
- Populate Highcharts X-Axis With Dates Given a From And To Date
- How to structure Angular with Highcharts and lots of dynamic data
- Add dynamic data to line chart from mysql database with highcharts
More Query from same tag
- json date format to Highcharts date format
- Highcharts chart moves up from x-axis on drill down
- How to tell Highcharts to set date on the x axis, and use a range of time (like 1 day)
- How To Get Multiple Areas From Dragging Selection Box in HighMaps
- Highcharts Gauge - start/endAngle and height
- Highcharts: Remove shadow from center of donut chart
- Highcharts thinks all dates are 1970-01-01, despite them being valid epoch times
- Highcharts Area chart gradient fill
- Get the end points of each bar in a highcharts column chart
- Highcharts crosshair with labels on axes
- highcharts round decimals for gauge labels
- Laravel Highcharts - Cant set value and labels from arrays
- highcharts strange area offset error when combined with xrange
- How to add data to a custom HighChart's HighMaps map? joinBy?
- Draw custom bars in a Highcharts bar chart
- Simple Highcharts chart not working in Firefox
- Can't see the labels on Pie HighCharts
- How to make 1st bar selected in column highchart on page load?
- Add additional data to a Highcharts series for use in formatters
- Crispy GridLineDashStyle
- Highcharts Yaxis scale not showing
- Emulating multiple click functions or have separate clicked values based on specific areas below or above dataMin and dataMax - highcharts
- Displaying yAxsis data for columnrange highchart
- How to set highchart boxplot size
- highchart set fill color
- Sunburst chart in angular
- Highstock chart doesn't show correct width in Phonegap app
- Represent extreme values on Doughnut chart in SSRS
- Highcharts - Highlight / Shade date range
- get data from the server using radio buttons, highcharts, vb.net