Giter VIP home page Giter VIP logo

Comments (11)

pushpinderbagga avatar pushpinderbagga commented on August 24, 2024

Below is the Ajax request I am making. Any clues where it goes wrong?

    $.ajax({
        type: "POST",
        url: "MY-SERVER",        
        datatype: 'json',
        complete: function(data){                          

            totaldata = JSON.parse(data.responseText);
            appointmentsdata = totaldata.appointments;
            droppedappointmentsdata = totaldata.droppedappointments;

            $.each(appointmentsdata, function() {
                this.date = new Date(this.date.toString());
                this.value = parseInt(this.value);
            });

            $.each(droppedappointmentsdata, function() {
                this.date = new Date(this.date.toString());
                this.value = parseInt(this.value);
            });

            options = {                
                'width':  '100%', 
                'height': '250px'
            };

            totalappointments = {
            'label': 'Appointments',
            'data': appointmentsdata
            };
            totaldroppedappointments = {
              'label': 'Dropped Appointments',
              'data': droppedappointmentsdata
            };

            graph = new links.Graph(document.getElementById('mygraph'));
            graph.draw([totalappointments, totaldroppedappointments], options);

        },
        error: function(){
            return false;
        }
    });

from chap-links-library.

pushpinderbagga avatar pushpinderbagga commented on August 24, 2024

The tooltips being shown show a value of 3 as 3.000

from chap-links-library.

josdejong avatar josdejong commented on August 24, 2024

The separate datasets may have differing time series, though each dataset is supposed to be ordered in time.

Can you give a (small) example of the data that you retrieve from your server?

from chap-links-library.

pushpinderbagga avatar pushpinderbagga commented on August 24, 2024

Hello, thanks for the reply.

Here is the data being retreived.

{"appointments":[{"date":"2012 11 29","value":1},{"date":"2012 11 27","value":1},{"date":"2012 11 25","value":5},{"date":"2012 11 23","value":2},{"date":"2012 11 22","value":1},{"date":"2012 11 21","value":2},{"date":"2012 11 20","value":3},{"date":"2012 11 19","value":4},{"date":"2012 11 18","value":1},{"date":"2012 11 15","value":5},{"date":"2012 11 14","value":1},{"date":"2012 11 05","value":7},{"date":"2012 11 04","value":1},{"date":"2012 10 30","value":4},{"date":"2012 10 29","value":3},{"date":"2012 10 28","value":1},{"date":"2012 10 27","value":1},{"date":"2012 10 22","value":4},{"date":"2012 10 16","value":2},{"date":"2012 10 15","value":1},{"date":"2012 10 14","value":1},{"date":"2012 10 12","value":9},{"date":"2012 10 10","value":2},{"date":"2012 10 09","value":1},{"date":"2012 10 08","value":2},{"date":"2012 10 07","value":1},{"date":"2012 10 06","value":2},{"date":"2012 10 05","value":1},{"date":"2012 10 03","value":1},{"date":"2012 10 02","value":1},{"date":"2012 10 01","value":2},{"date":"2012 10 01","value":1},{"date":"2012 09 30","value":2},{"date":"2012 09 27","value":1},{"date":"2012 09 26","value":1},{"date":"2012 09 25","value":1},{"date":"2012 09 24","value":2},{"date":"2012 09 23","value":2},{"date":"2012 09 22","value":1},{"date":"2012 09 20","value":4},{"date":"2012 09 19","value":2},{"date":"2012 09 18","value":1},{"date":"2012 09 17","value":3},{"date":"2012 09 16","value":5},{"date":"2012 09 15","value":13},{"date":"2012 09 13","value":10}],"droppedappointments":[{"date":"2012 11 21","value":"3"},{"date":"2012 11 19","value":"8"},{"date":"2012 11 18","value":"1"},{"date":"2012 11 15","value":"3"},{"date":"2012 11 04","value":"1"},{"date":"2012 10 28","value":"1"},{"date":"2012 10 22","value":"10"},{"date":"2012 10 16","value":"2"},{"date":"2012 10 15","value":"16"},{"date":"2012 10 07","value":"3"},{"date":"2012 10 03","value":"2"},{"date":"2012 10 02","value":"2"},{"date":"2012 09 27","value":"1"},{"date":"2012 09 26","value":"6"},{"date":"2012 09 25","value":"4"}]}

Basically 2 arrays in JSON namely appointments and droppedappointments

{"appointments":[{"date":"2012 11 29","value":1}],"droppedappointments":[{"date":"2012 11 21","value":"3"}]}

Any tips? Thanks in advance!

from chap-links-library.

pushpinderbagga avatar pushpinderbagga commented on August 24, 2024

I see that in one array the value is in quotes and in the other it isn't although it isn't the reason. I rectified and tested it with both types equal. With and without parseInt().

It seems like a Date related error. It's even happening in the Timeline - it simply does not run in IE8.

Just want to let you know that your help is greatly appreciated!

from chap-links-library.

josdejong avatar josdejong commented on August 24, 2024

Can IE handle a date like "2012 11 29"? I have never seen/used this date format before (A date is typically "2012-11-29").

The dates in your data seem to be in descending order, while the Graph expects dates in ascending (chronological) order. Maybe that is causing the problem?

from chap-links-library.

pushpinderbagga avatar pushpinderbagga commented on August 24, 2024

Oh is it - I will check try the suggestion and get back very soon.

Thanks a lot again!

On 28-Dec-2012, at 12:30 AM, Jos de Jong [email protected] wrote:

Can IE handle a date like "2012 11 29"? I have never seen/used this date format before (A date is typically "2012-11-29").

The dates in your data seem to be in descending order, while the Graph expects dates in ascending (chronological) order. Maybe that is causing the problem?


Reply to this email directly or view it on GitHub.

from chap-links-library.

pushpinderbagga avatar pushpinderbagga commented on August 24, 2024

Tooltips now work. Your suggestion of ASC dates and format was perfect!

The table tag needs to be closed in line 2028

            label.innerHTML = '<table>' +
                '<tr><td>Date:</td><td>' + dataPoint.date + '</td></tr>' +
                '<tr><td>Value:</td><td>' + dataPoint.value + '</td></tr>';

Also while passing values as {"date":"2012-09-13","value":"10"}

toPrecision() throws an error - so I removed it from the table data and from the function links.Graph.StepNumber.prototype.getCurrent

Sad though no error is shown in IE - neither is the graph.

from chap-links-library.

pushpinderbagga avatar pushpinderbagga commented on August 24, 2024

There is a JSON.parse error on IE. The error is resolved using json.js or json2.js - the graph shows up - but the data is not drawn

I have even tried this script - http://code.google.com/p/json-sans-eval/

Same - graph is there - data not drawn. I bet there is some encoding problem.

Found out - IE cannot parse date

this.date = new Date(this.date.toString());

from chap-links-library.

pushpinderbagga avatar pushpinderbagga commented on August 24, 2024

SOLVED.

I am using the script mentioned above (http://code.google.com/p/json-sans-eval/) and after it doing this.

Parsing the JSON as

totaldata = jsonParse(data.responseText);            
            $.each(appointmentsdata, function() {                
                this.date = Date.parse(this.date.toString());
                this.value = parseInt(this.value);                
            });

Works seamlessly till IE7

from chap-links-library.

josdejong avatar josdejong commented on August 24, 2024

Glad it is working now. I have fixed the unclosed table element, thanks.

from chap-links-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.