What is the best way to showcase data in a linear HighChart format?

I've been attempting to generate a linear chart using highChart, but despite multiple attempts, the chart remains blank. Here's what I've tried so far:


<script>
$(document).ready(function() {

    var options={
         chart: {
                renderTo: 'container',
                type: 'line'
            },
        title : {
          text: 'Monthly Average Temperature'   
       },
       subtitle : {
          text: 'Source: WorldClimate.com'
       },
        xAxis : {
          categories: ['11','jj','jj','11']
       },
        yAxis :{
          title: {
             text: 'Temperature (\xB0C)'
          },
          plotLines: [{
             value: 0,
             width: 1,
             color: '#808080'
          }]
       },   

        tooltip : {
          valueSuffix: '\xB0C'
       },

        legend : {
          layout: 'vertical',
          align: 'right',
          verticalAlign: 'middle',
          borderWidth: 0
       },

        series : [{}]

    }
 $.ajax({
 type: 'GET',
 contentType : 'application/json',
 dataType: 'JSON',
 url: 'json',
 data: "",
 success: function(data){
     var array=[] ;
    $.each(data, function(i) {


        array.push(data[i].id); 

        })
          alert(array);
      options.series[0]= array;


    var chart = new Highcharts.Chart(options);

}
});

});
  </script>

After checking with alert(array);, it seems that an array of values is correctly returned from JSON, yet it is still not being recognized by the series. Any assistance would be greatly appreciated.

Answer №1

series[0] requires the data to be in a specific format.

Instead of using options.series[0]= array;

Use,

options.series[0]= {"data":array};

See it in action on this fiddle

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for concealing the check mark within a checkbox upon selection

I have checkboxes arranged in a table with 23 columns and 7 rows. My goal is to style the checkboxes in a way that hides the check mark when selected. I also want to change the background image of the checkbox to fill it with color when marked. Can someone ...

Is it possible to trigger an AJAX function automatically following the success of another AJAX function?

I am in the process of implementing a note system using procedural PHP and AJAX. This system should have the ability to display new notes without refreshing the page and load more notes dynamically without needing a full page refresh. Currently, each func ...

Using jQuery to fetch data asynchronously

I am currently dealing with a web application that needs to carry out the following task. It must send GET requests to a web service for each date within a selected date range, yet this process can be time-consuming. Since I plan to visualize the retrieved ...

D3-cloud creates a beautiful mesh of overlapping words

I am encountering an issue while trying to create a keyword cloud using d3 and d3-cloud. The problem I am facing is that the words in the cloud are overlapping, and I cannot figure out the exact reason behind it. I suspect it might be related to the fontSi ...

Deciphering JSON data in a textarea following a POST request

I am struggling with decoding a JSON string in PHP and I have identified the problem causing it. However, I am unsure of how to fix it. My approach involves putting an array that I convert to JSON into a hidden textarea, which I then post along with other ...

Error: JSONResponse is missing a semicolon before the statement in the syntax

I encountered the following error: SyntaxError: missing ; before statement Although I am unsure of what is causing this error, here is the code snippet that I am currently working with: (function pollschedule(){ $.ajax({type: "GET", dataType: "j ...

Using Ajax for submitting forms with jquery and html techniques

I am having an issue with my form submission page. I need to call a function at the time of form submission using AJAX. The form submission should occur or not based on certain conditions in the AJAX response. Below is the code I have, but it seems to be n ...

The child_process module has yet to be loaded

Exploring NodeJS to execute a PowerShell script from JavaScript. Found this code snippet online: var spawn = require("child_process").spawn, child; child = spawn("powershell.exe",["c:\\test\\mypstest.ps1 -arg1 1"]); child.stdout.on(" ...

retrieving request headers using XMLHttpRequest

Is there a way for me to access my requestHeaders within the onload function? Any guidance on how to achieve this would be greatly appreciated. Many thanks! ...

What does the use of square brackets signify in Vuex mutations?

I'm curious about the use of mutation values within brackets in Vuex. What does the code "" represent? export const SOME_MUTATION = 'SOME_MUTATION' Is this just a constant name for a function? If so, why is it enclosed in brackets "[]"? ...

What is the best way to update an object with a new object using JavaScript or lodash?

My data structure is as follows: const data = { getSomething: { id: '1', items: [ { id: '1', orders: [ { id: '1', ...

Wicked PDF - Pausing to Allow AJAX Request Completion

My challenge lies in creating a PDF using WickedPDF, where all my static HTML/CSS content loads perfectly. However, I am facing an issue with certain elements on the page which are populated through AJAX requests—they do not appear in the generated PDF. ...

jQuery Mishap - Creating an Unspecified Issue

At the moment, my website displays a list of registered users in one column and their email addresses with checkboxes next to them in another column. Users can check the boxes and then click a submit button to generate a list of the selected emails separat ...

Having some success with AngularJs autocomplete feature

Currently working on a small search application that utilizes Elasticsearch and AngularJS. I have made progress in implementing autocomplete functionality using the AngularJS Bootstrap typeahead feature. However, I am encountering difficulties in displayin ...

The text area is not increasing in size when using the " " for a new line

I have a code that enables Autocomplete input to add values chosen from the list to a textarea, with each value separated by a new line. While manually adding rows to the textarea by pressing Enter allows it to expand and fill in the new row and value, us ...

Panoramic viewer for Three.js with multi-resolution image support

Is there a way to incorporate a three.js panorama viewer with multi-resolution images similar to pannellum? Check out pannellum's example here: . You can find the current code using three.js here:(//codepen.io/w3core/pen/vEVWML). Starting from an e ...

How to locate the data-id of the next element in a jQuery list

Is it possible to retrieve the data-id of the following list element when clicking a button while on the current active list item? <div class="nbrs"> <ul> <li id="item1" data-id="1" class="active ...

The D3.js click event seems to be unresponsive

Currently, I am working with D3.js and backbone.js. My goal is to create a click event for each path element. Although I have provided an onclick event as shown below, the function does not seem to be triggered. createpath: function(nodes) { paths = ...

The parameters used in the json.parse function in javascript may be difficult to interpret

Currently, I am examining a JavaScript file on this website. It contains the following code: let source = fs.readFileSync("contracts.json"); let contracts = JSON.parse(source)["contracts"]; I'm curious about what exactly the JSON.parse function is d ...

Guide to implementing sliding effects with Jquery

I recently dived into the world of JavaScript and jQuery. I crafted a piece of JavaScript code for client-side validation. document.getElementById(spnError).style.display = 'block'; Currently, I am displaying a span element if any validation er ...