I have a Json format like:
var d = "1,3,2,4"
How do I convert it into
var d = [3,5,3,6]
I tried this:
success: function (Response) {
debugger;
var du = (Response.d);
var final_string = '[' + du + ']'
// final_string = [1, 3, 2, 4];
console.log(final_string);
But this is not working, I want to final_string
value as final_string = [1, 3, 2, 4];
actually i am trying to making a graph by this data
JvaScript
<script>
$(document).ready(function(){
debugger;
$.ajax({
type: "Post",
url: "Default.aspx/getdata",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (Response) {
debugger;
var d = Response.d.toString();
var final_string = '[' + d + ']'
console.log(final_string);
//final_string = [1,3,2,4];
var options = {
chart: {
height: 250,
width:500,
type: 'line',
},
series: [{
name: ' ',
type: 'column',
data: final_string
}, {
name: '',
type: 'line',
data: final_string
}],
stroke: {
width: [0, 4]
},
title: {
text: 'Total Count'
},
labels: ['Birthady', 'Anniversary', 'Special', 'Total'],
xaxis: {
type: 'text'
},
yaxis: [{
title: {
text: 'Count Blog',
},
}, {
opposite: true,
title: {
text: ''
}
}]
}
debugger;
var chart = new ApexCharts(
document.querySelector("#chart"),
options
);
chart.render();
},
error: function (result) {
}
});
});
</script>
here the series data format is [1,3,2,4]
and when i am passing data = [1,3,2,4]
in series data graph is display in correct format and when i am passing final_string
in series data graph is not display in correct format what is the main issue in this format final_string
can any one help me
?