jQWidgets Forums
jQuery UI Widgets › Forums › General Discussions › Charting data from sql server
This topic contains 11 replies, has 2 voices, and was last updated by Peter Stoev 10 years ago.
-
Author
-
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?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 StoevjQWidgets Team
http://www.jqwidgets.comexcuse 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 ?Hi scada,
Sample with Chart bound to Sql DB – http://mvcexamples.jqwidgets.com/widgets/chart/arctic
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comok , thank you sir ,
i have other question : why do not exist getHour or getminute in format function(see below image) ?
Hi scada,
We are not aware why your IDE’s Intellisense does not display options.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comthanks Peter Stoev ,
my IDE is visual stdio 2012 , do my country is problem? see below figure for value :
i want to show hour and minute on graph .What should I do ?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 StoevjQWidgets Team
http://www.jqwidgets.comthanks 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’);Hi scara,
Your hour in your Date object is 0 so the result for formatting Date to Hour is 0, too.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comok,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!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 StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.