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
- Correct syntax for highchart API yAxis label style in coffeescript?
- Formatting Highcharts labels with a callback function (Formatter)
- How to have first level as column chart and second level as Fixed placement columns in drill down highcharts
- HighCharts: get Y and X value
- How to make a chart with highcharts, load data from API
- Highstock - change range input beyond the data max
- How to avoid X axis to display decimal values
- Add vertical(projection) line from point to categories, highcharts
- Get current date values to own hours
- Highcharts:Grouped and stacked legend
- Highcharts with decrease order in each interval
- Highcharts Drilldown upto n levels
- Highcharts - set column width dynamically
- how to take only categories for x-axis and remove unwanted scaling in Highstock chart
- Highcharts data loading from a JSON file error in setting up datetime
- High Charts Breaking jQuery Across Rails App
- highcharts stacked column overlaps when toggling the legends visibility
- Symbol-outline with pie chart -or- custom legend symbols
- highcharts changing dial value interactive with mouse events
- Draw multiple series upon mouse hover in Highstock
- how to extract data to array value
- Highcharts not rendering plotbands correctly on first load
- How can I pass this array to a javascript function in an html.erb file, without erb evaluating the Date.UTC?
- Tooltip text goes out of tooltip when zoom-in
- dynamically apply timezone offset to a highchart
- tool that shows javascript errors in code
- Dynamically update tooltip date format highchart
- highcharts javascript variables
- Can I use two different formatters for highchart tooltips?
- Group specific points to categories in Highchart