Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

graph a pie chart using variable names (jqplot)

hello Appery team,
I ́m using this example to graph a pie using jqplot:
(if I use numbers for aa, bb, cc the graph is draw. but if I use the variables names, it fails.
I have take a look into stackoverflow questions, and also here in the question about ride trip, but I couldn ́t get it work.

____________

var aa = localStorage.getItem("aa");
var bb = localStorage.getItem("bb");
var cc = localStorage.getItem("cc");
$(document).ready(function(){
var data = [
['sales', aa],['service', bb], ['maintenance', cc]
];
var plot1 = jQuery.jqplot ('chart1', [data],
{
seriesDefaults: {
// Make this a pie chart.
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
// Put data labels on the pie slices.
// By default, labels show the percentage of the slice.
showDataLabels: true
}
},
legend: { show:true, location: 'e' }
}
);
});

_________

the problem is that I get the aa,bb,cc, and d values from REST.
No errors in console.

could you help me with this? Thanks

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

graph a pie chart using variable names (jqplot)

A couple of things you should try:

  • Check to make sure you are getting the right values for aa, bb, cc.
  • Test this to make sure it works in a plain HTML page (outside of Appery.io)
Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

graph a pie chart using variable names (jqplot)

I use labels, and alert(), and I get the right value from rest, when testing.

________

in this question on other post (Journey Recording using GPS Tracking )
they are able to use variables in the array...

___________

points.push([(coordsArray.time - startTime) / 1000 / 60, avrSpeed/j]);
avrSpeed = 0;
j = 0;
}
}
var plot1 = $.jqplot('plot1', [points], {

______
Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

graph a pie chart using variable names (jqplot)

Hi Alex,

Please try this on an empty page with static data.

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

graph a pie chart using variable names (jqplot)

hello KAtya, I have already tried with static data, and works OK.
but when change to variable names it fails. Image

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

graph a pie chart using variable names (jqplot)

Alex,

Please try the following to get variables:prevar aa = parseInt(localStorage.getItem("aa"));
var bb = parseInt(localStorage.getItem("bb"));
var cc = parseInt(localStorage.getItem("cc"));/pre

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

graph a pie chart using variable names (jqplot)

wonderful! I works now. Thanks

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

graph a pie chart using variable names (jqplot)

Alex,

Glad it's working!

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

graph a pie chart using variable names (jqplot)

Hello KAtya, I have another question. I ́ve been strugling to add the values return on REST service.
This APP is to graph the income of a bussiness per week or month. So when the user sells something he enters the price, and click save. I ́ve a service to crate and update the DB. So, at any time, when the user wants to see the graph, he click "show results" and I call service with "where" to pick different categories (as in the last question aa, bb, cc).
I have look at other post like this https://getsatisfaction.com/apperyio/..., but could no get it works..
this is my db: Image
one service uses : return '{"servicio":"bb"}'; and if I map on a label I get the two values(600 and 400),, so what I need to do to add those, and get the result (1000), to pass to the pie chart?? In the above example there are only two values, but could be much more. So I was thinking to create and array, and push the values, then use "for" to sum all values.

could you give a hint,,,thankss!!!!

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

graph a pie chart using variable names (jqplot)

Hello,

You can save array to localStorage variable https://getsatisfaction.com/apperyio/... and calculate the sum of values in an array http://stackoverflow.com/questions/16...

Return to “Issues”