jQWidgets Forums

jQuery UI Widgets Forums General Discussions Charting data from sql server

Tagged: ,

This topic contains 11 replies, has 2 voices, and was last updated by  Peter Stoev 10 years ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
  • Charting data from sql server #70402

    scada
    Participant

    hi
    i want to use of jqxChart method for Charting data from sql server and use web service for this issue ,i want to prepare user interface , user can select time period and that values drawn to form graph ,i prepare this method for month but It has problems,
    i get data The following format for many month :
    sbData "{\"value\":\"\", \"Date\":\"2015/2/8\"},{\"value\":\"\", \"Date\":\"2015/2/8\"},{\"value\":\"112.666666666667\", \"Date\”:\”2015/2/8\”},{\”value\”:\”59.5\”, \”Date\”:\”2015/2/8\”},{\”value\”:\”55.5757575757576\”, \”Date\”:\”2015/2/9\”},{\”value\”:\”203.966666666667\”, \”Date\”:\”2015/2/9\”},” …………etc`
    This period can be changed ,
    after this i use below code :

    
          var source =
                 {
                     datatype: "json",
                     type: "GET",
                     data: data,
                     datafields: datafieldss,
                     url: "../WebService.asmx/GetOfSql"
                 };
                 var dataAdapter = new $.jqx.dataAdapter(source, {
                     contentType: 'application/json; charset=utf-8',
                     async: false,
                     autoBind: true,
                     loadError: function (xhr, status, error) {
                         alert('loading "' + source.url + '" : ' + error);
                     }
                 });
    
                 // prepare jqxChart settings
                 var settings = {
                     title: 'title', 
                     description: "description",
                     enableAnimations: true,
                     animationDuration: 3600,
                     enableCrosshairs: true,
                   
                     padding: { left: 20, top: 20, right: 20, bottom: 20},
                   
                     colorScheme: 'scheme06',
                     source: dataAdapter,
                     xAxis:
                     {
                         dataField: 'Date',
                         type: 'date',
                         baseUnit: 'month',
                         textRotationAngle: 360,
                         formatFunction: function (value) {
                           return value.getFullYear().toString() + '/' + (value.getMonth()+1) + '/' + value.getDate();
                         },
                     seriesGroups:
                     [
                         {
                             type: 'spline',
                             valueAxis:
                             {
                                 unitInterval: difrential / 10,
                                 description: 'description ',
                                 showGridLines: true
                              },
                             series: stack
                         },
                                         ]
                 };
                 // setup the chart
                 $('#jqxMain').jqxChart(settings);
             }
    

    but this method give me different figure for any period time of month ! Is this method suitable? What other methods are recommended?
    What should I do When the period is hours or a few day?

    Charting data from sql server #70404

    Peter Stoev
    Keymaster

    Hi scada,

    baseUnit – the base unit when used with ‘date’ axis. Values can be ‘year’, ‘month’, ‘day’, ‘hour’, ‘minute’, ‘second’ or ‘millisecond’.

    If it’s hours or day, set it to ‘day’ or ‘hour’. Also, please post your future questions about jqxChart in the Chart’s Forum.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Charting data from sql server #70407

    scada
    Participant

    excuse me Keymaster for post in this topic
    i test baseUnit for day and hour but dont work ,i have problem in a few period, perhaps my code is wrong , do you can show me a sample for get records of sql server and place it in jqxchart ?

    Charting data from sql server #70414

    Peter Stoev
    Keymaster

    Hi scada,

    Sample with Chart bound to Sql DB – http://mvcexamples.jqwidgets.com/widgets/chart/arctic

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Charting data from sql server #70456

    scada
    Participant

    ok , thank you sir ,
    i have other question : why do not exist getHour or getminute in format function(see below image) ?
    why do not exist getHour or getminute in format function

    Charting data from sql server #70470

    Peter Stoev
    Keymaster

    Hi scada,

    We are not aware why your IDE’s Intellisense does not display options.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Charting data from sql server #70472

    scada
    Participant

    thanks Peter Stoev ,
    my IDE is visual stdio 2012 , do my country is problem? see below figure for value :
    why
    i want to show hour and minute on graph .What should I do ?

    Charting data from sql server #70477

    Peter Stoev
    Keymaster

    Hi scada,

    I do not think that your country is a problem. However, don’t expect that your Visual Studio’s intellisense will display all the available options. About JavaScript Date object, I suggest you to read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Charting data from sql server #70480

    scada
    Participant

    thanks Peter Stoev,
    i use this and other method but all method return 0 for time ! why?
    only below method return time but that is wrong
    return $.jqx.dataFormat.formatdate(value, “hh:mm”, ‘en-us’);

    Charting data from sql server #70482

    Peter Stoev
    Keymaster

    Hi scara,

    Your hour in your Date object is 0 so the result for formatting Date to Hour is 0, too.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Charting data from sql server #70486

    scada
    Participant

    ok,i correct code ,now return data of web service is following :

    "{\"val\":\"5.3\", \"Date\":\"8:38\"},{\"val\":\"55.3\", \"Date\":\"8:52\"},......................."

    and formatFunction in xAxis:
    ` formatFunction: function (value) {
    return value.getHours() + ‘:’ + value.getMinutes();
    },`
    now i get a new error , do not show graph and xAxis ! only show yAxis and that value on graph!

    Charting data from sql server #70493

    Peter Stoev
    Keymaster

    Hi scada,

    I would suggest you to look at the jqxChart’s demos and read the documentation help topics in order to learn how to use the component. In addition, your Date in the JSON is not actually a Date, it’s a number with : delimiter.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.