At the beginning of updateChart, add:
alert(graphData)
See what you're actually getting back. There might be some formatting
characters that you won't see when you put the same thing into a DIV.
On Jul 10, 7:09 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hello everyone, I'm new here.
>
> I've been working with prototype and plotr for about a month now, off
> and on, and I have pretty much hit the wall on using the data returned
> by Ajax.Request.
>
> I'm using some php code to return a string:
>
> {'foo': [[0,0.0865334429075127], [1,0.0828179861705063],
> [2,0.0828173042602942], [3,0.0841707718624196]]}
>
> But I keep getting an error: "item.pluck is not a function" on line
> 857 of plotr_uncompressed.js
>
> Here is the code I'm using to grab the data into a javascript
> variable:
>
> var graphData = "";
> var url = "foobar.php";
>
> function generateGraphData(dataRange,dataUrl) {
> new Ajax.Request(url, {
> method: 'get',
> parameters: {dR:dataRange,dU:dataUrl},
> onLoading: function() {
> // change this to a loading image/html
> $(dataRange).innerHTML="loading...";
> },
> onComplete: function(request) {
> if(request.status != 200) {
> // change this to a pleasant error message
> $(dataRange).innerHTML="unavailable...";
> } else {
> graphData = request.responseText;
> $(dataRange).innerHTML = graphData;
> }
> },
> onFailure: function() {
> notice.update("hrm, something went wrong...");
> }
> });
> }
>
> And here is the code I'm using to try to load the data into the graph:
>
> function updateChart(chartName) {
>
> var newOptions = {
> padding: {left: 30, right: 0, top: 10, bottom: 30},
> backgroundColor: '#f2f2f2',
> shouldFill: false,
> colorScheme: 'blue',
> yNumberOfTicks: 2,
> xTicks: [
> {v:5, label:'jan'},
> ]
> };
>
> document.getElementById('weekdiv').innerHTML = '<div><canvas
> id="newchart"
> height="250" width="700"></canvas></div>';
>
> var weekLine = new Plotr.LineChart('newchart',newOptions);
> //weekLine.addDataset(dataset2);
> weekLine.addDataset(graphData);
> weekLine.render();
>
> }
>
> As you can see in the last bit of code, I've commented out the line:
> "weekLine.addDataset(dataset2)". dataset2 is an array defined in
> javascript on this page, that is identical to the string that is being
> passed to the page from the php script.
>
> Any help would be greatly appreciated!!
>
> Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---