score:15

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.

score:1

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]*/) }]

score:6

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