pietro117
Posts: 0
Joined: Fri Mar 16, 2012 12:09 am

Is it possible to get data from the Tiggzi database in a format that could be used by rGraph (or any other chartiing api

I have data in a TIggzi database that has three columns. when I get the data from the rest service, it comes through as JSON objects e.g.
{
"id":"516ea545e4b055aafd1f6355",
"Hour":"08:00",
"LY":".05",
"TY":"0.2"
},
{
"id":"516ea545e4b055aafd1f6356",
"Hour":"09:00",
"LY":"1",
"TY":"2"
}
I need to extact one of the JSON elements (e.g. TY) and convert it into an array (e.g. [0.2,2] so i can feed it into the chart api. Is there a way to do this?
Thanks
Peter

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

Is it possible to get data from the Tiggzi database in a format that could be used by rGraph (or any other chartiing api

The data is only returned in JSON format. Once you have the data, you can convert it to any format.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Is it possible to get data from the Tiggzi database in a format that could be used by rGraph (or any other chartiing api

To add to what Max said - you can use the following JS (for example on service Success event):
codevar arrayTY = [];
try {
for(var i = 0, len = data&#46;length; i < len; i++) {
arrayTY&#46;push(data["TY"]);
}
} catch( e ) {
}
localStorage&#46;setItem('TY', JSON&#46;stringify(arrayTY));/code

After successful invoking the service and running the code above in localStorage TY will be an array in json format ["0.2","2"]

To make it JS array use code:
codevar arrayTY = JSON&#46;parse(localStorage&#46;getItem("TY"));/code

laura6372139
Posts: 0
Joined: Wed Oct 30, 2013 11:54 am

Is it possible to get data from the Tiggzi database in a format that could be used by rGraph (or any other chartiing api

Hi:

I followed this tutorial.

https://getsatisfaction.com/apperyio/...

It's perfect.

But I need these values ​​to connect to the database with the chart

Image

The service that I have to create is list_service?

Can I help me?

Thanks

laura6372139
Posts: 0
Joined: Wed Oct 30, 2013 11:54 am

Is it possible to get data from the Tiggzi database in a format that could be used by rGraph (or any other chartiing api

Hi Maryna!

I adapted my code.
Image

I click invoke service (button)

And then I load this code:

var arraypesos = JSON.parse(localStorage.getItem("pesos"));

$(document).ready(function(){
var plot2 = $.jqplot ('chart', [arraypesos], {
// Give the plot a title.
title: 'Plot With Options',
// You can specify options for all axes on the plot at once with
// the axesDefaults object. Here, we're using a canvas renderer
// to draw the axis label which allows rotated text.
axesDefaults: {
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
},
// An axes object holds options for all axes.
// Allowable axes are xaxis, x2axis, yaxis, y2axis, y3axis, ...
// Up to 9 y axes are supported.
axes: {
// options for each axis are specified in seperate option objects.
xaxis: {
label: "X Axis",
// Turn off "padding". This will allow data point to lie on the
// edges of the grid. Default padding is 1.2 and will keep all
// points inside the bounds of the grid.
pad: 0
},
yaxis: {
label: "Y Axis"
}
}
});
});

But doens't work!

Image

Return to “Issues”