jQWidgets Forums

jQuery UI Widgets Forums Chart Page hangs when trying to load data

Tagged: 

This topic contains 5 replies, has 3 voices, and was last updated by  yoda 10 years, 4 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • Page hangs when trying to load data #66144

    realtek
    Participant

    Hi,

    I have the following source to get my data for a jqxChart.

        $(document).ready(function () {
            var source =
            {
                 datatype: "json",
                 datafields: [
                     { name: 'datetime', type: 'date'},
                     { name: 'temperature'},
                     { name: 'location'}
                ],
                url: './getdata.php'
            };
    

    However, I have an issue with the datetime datafield. Basically, the page just sits there trying to load when I have the datetime field specified.

    If I rename this to something that does not exist like datetimetest it loads ok without that data.

    My source is from a mySQL database and the JSON looks like this:

    [{"temperature":"20.69","datetime":"2015-01-28 15:17:21","location":"Hall"}] for example
    

    Any help would be great. Thanks

    Page hangs when trying to load data #66145

    realtek
    Participant

    hmm, seems to be caused by date being used for the Category Axis

    categoryAxis
    
      {
                        text: 'Category Axis',
                        textRotationAngle: 0,
                        dataField: 'datetime',
                        formatFunction: function (value) {
                            return $.jqx.dataFormat.formatdate(value, 'dd/MM/yyyy');
                        },
    Page hangs when trying to load data #66147

    Peter Stoev
    Keymaster

    Hi realtek,

    In your code you missed to set the “format’ property of your “datetime” field. I suppose your Date is not parsed to a JavaScript Date Object and in your formatFunction you actually try to format a String not JavaScript Date object which is the expected parameter.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Page hangs when trying to load data #66148

    realtek
    Participant

    Thanks Peter, I have tried { name: 'datetime', type: 'date', format:'dd/mm/yyyy'} but it still does not work.

    Des my date need to be converted to a Javascript date object first in the getdata.php ?

    Thanks

    Page hangs when trying to load data #66150

    realtek
    Participant

    Hi Peter,

    I now have this:

     datatype: "json",
                 datafields: [
                     { name: 'mydate', type: 'date', format:'yyyy-mm-dd hh:mi:ss'},
                     { name: 'temperature'},
                     { name: 'location'}
                ],
                url: './getdata.php'

    and

        {
                        text: 'Category Axis',
                        textRotationAngle: 0,
                        dataField: 'mydate',
                        formatFunction: function (value) {
                            return $.jqx.dataFormat.formatdate(value, 'yyyy-mm-dd hh:mi:ss');
                        },

    Here is the JSON:

    [{"temperature":"20.31","mydate":"2015-01-28T20:42:43+00:00","location":"Hall"}]
    

    But I still seem to get the same issue?

    Thanks

    Page hangs when trying to load data #66200

    yoda
    Participant

    I don’t see the axis type and unit in the the code.
    You should specify the type of the axis and set it to ‘date’ if you’re using dates. Also provide the unit (like ‘year’, ‘month’, ‘day’, ‘hour’, etc…):

    xAxis 
    {
      dataField: 'datetime',
      formatFunction: function (value) {
         return $.jqx.dataFormat.formatdate(value, 'dd/MM/yyyy');
      },
      type: 'date',
      baseUnit: 'day'
    }
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.