Accepted answer

try this:

data: json.parse("[" + myjstring + "]")

basically this formats the string's contents as a json array. the parse function then de-serializes the string into a javascript array.


another easy approach is using the javascript string.split() function, thus.

series: [{ name: 'series1', data: myjstring.split(', ') }]

if you're not sure whether you'll have a space after the comma or not, use regex.

series: [{ name: 'series1', data: myjstring.split(/,[\d]*/) }]


since data is a array type, you can use arrays for the values like

mydata = [4.5, 3.1, 6.5, 7.0, -1.3];

Related Query

More Query from same tag