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
- canvg and highcharts how to include chart legend and keep the chart size?
- Highcharts: Ensure y-Axis 0 value is at chart bottom
- HTML displaying values in JavaScript "data"
- Highcharts - how to do a responsive pie chart when the texts of the labels are long
- Changing Color of Data Labels in HighCharts Bar Chart
- Highcharts add tooltip that has a small arrow pointing toward the series
- highcharts JSON google earth
- angular2-highcharts first point loses on xAxis
- Highcharts xAxi title how left-aligned?
- Highcharts Gauge: Labels radius styling
- Highchart tooltip issue
- position ticks in par with data - highcharts
- Highchart columnrange with scrollbar
- Highcharts - Issue with showing and hiding plot lines and bands on legendItemClick
- Highcharts - draw line chart with summed values but show breakup on hover
- Highcharts: Adding clickable image to every xAxis gridLine
- Highcharts pre-defined x-axis labels
- Highcharts click event should apply only on marker point
- Highchart: is it possible to change the font of the label in Highchart via a click of a button?
- Date formatting on x-axis highchart
- How to use array_merge to display non-quoted commands in PHP/Highcharts?
- Highcharts label format with tickPositioner in a datetime x Axis
- Coloring a country in lat-long highmap
- Highcharts: Disabling/Enabling enableMouseTracking after initial render
- What is the difference between angular-highcharts and highcharts-angular?
- How do I target a Highcharts path?
- Costumize indicators from stock tools
- Set Additional Data to highcharts series
- change data in highchart on changing selection from dropdown
- Highcharts - Display Stack Label