2

I am converting json to string and saving the content in an arrays. from the array am directly sending the values to charts js and its working fine.

But its not working in highcharts. What could be the issue?

I have also tried passing variables with data directly to high charts but it isn't working

//converting from json to string and saving in array

var retrievedData = localStorage.getItem("items");
var amnts = JSON.parse(retrievedData); 

//how i have passed data to charts js & its working correctly

data: {
      labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 
              'Sartuday', 'Sunday'],
      datasets: [{
          label: 'Week 1 Income',
          backgroundColor: 'rgb(255, 99, 132)',
          borderColor: 'rgb(255, 99, 132)',
          data: [amnts[0], amnts[1], amnts[2], amnts[3], amnts[4], 
          amnts[5], amnts[6]]
      }

//passing data to highcharts & NOT WORKING & not displaying data in chart

series: [{name: 'Week 1 Income',
         data: [amnts[0],amnts[1],amnts[2], amnts[3], amnts[4], amnts[5], 
                amnts[6]]
}

I expected the array data or a variable passed to show the value in the chart

9
  • You mean when you pass the data object to highchart it is working correctly and for series array it is not? Commented Apr 2, 2019 at 5:30
  • @randomSoul Sorry, Its working correctly in charts js data object but not working in high chart series Commented Apr 2, 2019 at 5:33
  • You are missing ending brackets ] in series array for highCharts Commented Apr 2, 2019 at 5:36
  • @JoharZaman its in my code but its still not working, I just copied a small part of the code Commented Apr 2, 2019 at 5:38
  • 1
    What is inside the amnts did you check that? Commented Apr 2, 2019 at 5:41

1 Answer 1

1

Use like this I think it works.

series: [{name: 'Week 1 Income',
         data: [parseInt(amnts[0]),parseInt(amnts[1]),parseInt(amnts[2]), parseInt(amnts[3]), parseInt(amnts[4]), parseInt(amnts[5]),parseInt(amnts[6])]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.