I have a device that hosts a simple web server and records data on a job site in .csv format. We would like to display this data in a simple line graph to make it easier to interpret when logged in remotely. The device currently records the data as follows:
YYYY/MM/DD,HH:MM:SS,Data1,Data2,Data3
When using Dygraph I know that the date and time need to be in the first column in order for it to parse the data correctly. There is no way to change the format that the device uses to save the data, but is there a way to make Dygraphs use both columns as date and time?
How about replacing the first comma on every line with a space?
data = data.split('\n').map(line => line.replace(',', ' ')).join('\n');
You'll have to either change the format coming from the .csv file, or issue the XHR yourself (jQuery and other libraries can help) and transform the data before handing it off to dygraphs.
Related
Picture for context
My Community Connector fetches these 2 fields (Subscription Date and Clicks).
I want to be able to filter by date so my table only shows, for example, data from the last 7 days. This works using the Date Filter that Data Studio provides, however, I notice that this date filter does another fetch request with the correct date I selected.
I don't want this to happen. I want to filter by date USING MY EXISTING DATA. Is there any way to do this? To filter only using my cached data, and not send a new GET request?
While this is not doable from Data Studio side, you can implement your own cache in Apps Script. You can evaluate each getData request and return data from the cache if needed. This will avoid sending new GET requests to your API endpoint.
While this may not be the best option to everyone, I found a quick temp solution by loading my own community connector USING google's community connector, Extract Data.
This way my data loads only 1 time, and I can filter it instantly the way I want.
If you want to refresh the data, you 'edit' the data source and save.
I'm looking to scrape a currency exchange for time-series data so I can do some analysis. I know I can use javascript libraries to scrape a website one time, but I want time series data. So would I essentially create a JSON Object that has the format :
{
ExchangeRateTimeseries:
[Timestamp: xxxxxx, Symbols: { symbol1: symbol1rate, symbol2: symbol2rate, symbol3: symbol3rate.....}]
}
?? So I can basically execute a scrape request every say 1 minute and then make a JSON object with the respective timestamps and the exchange rates? Does this make sense? I'm open for any input. Thank you.
I need to generate decision trees from a MYSQL v 5.6 table, queried with PHP PDO. I have a nice query which gives the data required, however I can't find the correct format to parse data to the Google API.
I searched and found a myriad of articles on how to format data to feed Google Charts. However the common denominator is the use of the infamous and deprecated mysql_query class to fetch data, and some addrow method which I found quite strange and UnClean.
I'm asking how should I format the json output in order to porperly feed the API. At the moment I query the data, json encode it using PHP's json_encode, and get the data properly via AJAX. Indeed my console shows that the data is properly read by the browser, however I know there is a format issue.
Unfortuantely tha google visualization API doesn't give me info on where the error could be. I just received this message:
Invalid format in explicit format: column #0 must be of type 'number'
Well this is a sample of data that the google javascript receives:
[{"id":"1","elemento":"CLIO","parent":"0","size":306}, {"id":"2","elemento":"LOGAN","parent":"0","size":431}, {"id":"3","elemento":"SANDERO","parent":"0","size":335},
On the other way, I'm following strictly the Google visualization guidelines to use data from external data sources:
Populating Data Using Server-Side Code
and specifically the chart that I need to render Wordtrees, which uses and arrayToDataTable method to format properly the data.
What should I correct in order to get and/or read the proper formatted json string of data? Please keep in mind the previous example of actual data which uses:
echo json_encode($data);
to JSON format the query output. Should I construct a table? How to do it in a proper, clean and modern way, not the mysql_query iteration.
Thanks for your time and collaboration.
I am doing a leapmotion webapp on PHP and javascript.it is based on gesture recognition. The values of the leapmotion must be stored into the database and when the corresponding gesture is matched the description of the gesture must be displayed. The values from the leapmotion is converted to JSON format. How can I store the JSON data to the mysql database 5.0.?
The JSON file content is:
{"name":"HA","pose":true,"data":[[{"x":0.16616291409773337,"y":-0.061424365133667,"z":-0.014198921561969446,"stroke":1},{"x":0.058005894163526694,"y":-0.05005164610312531,"z":0.029463953896938344,"stroke":1},{"x":-0.05015112577067998,"y":-0.03867892707258362,"z":0.07312682935584591,"stroke":1},{"x":-0.1583081457048866,"y":-0.02730620804204193,"z":0.1167897048147537,"stroke":1},{"x":-0.2664651656390933,"y":-0.01593348901150024,"z":0.16045258027366138,"stroke":1},{"x":-0.3746221855732999,"y":-0.00456076998095855,"z":0.20411545573256906,"stroke":1},{"x":0.6253778144267002,"y":0.19795540534387668,"z":-0.5697496025117985,"stroke":1}]]}
The error which i get is Syntax error. The work is based on Rob O'leary's leaptrainer.js which can be found on https://github.com/roboleary/LeapTrainer.js/tree/master.
In your situation I'd prefer to do next:
Create separate table for these data. Keys are dependable from your
purposes, but as quick solution just create table with the same
columns names as in your JSON.
Create some model, to communicate with DB. Make there some
methods(like saveMotion, getMotion etc.)
In your php code, use json_decode function, to convert JSON to std
object. Not sure here if you will be able to write std class to db,
but conversion it to array would give you a 100% possibility to do
that.
Our website provides various data services to our clients; one of which is gauge data. Some gauges log information every 15 minutes, some every minute. This data is sent to our SQL database.
All of this data is displayed via a graph (generated server side via PHP and JPGraphs) with each individual log entry being displayed as a row in a collapsible table (jquery 1.10.2).
When a client wants to view the data, they select a date range and which gauges they would like to view. If they want to view the last 3 days of a gauge that logs every minute then it loads pretty quickly. If they want to view 2 of those then it takes around 15-30 seconds to load. The real problem comes when they want to view a months worth of data; especially more than 1 gauge. This can take upwards of 15-20 minutes to load and the browser repeatedly asks if we want to stop the script from populating the collapsible table rows(jquery).
Obviously this is a problem since clients want a relatively fast response (1-5 min max). Ideally, we would also like to be able to pull gauge data from several months at a time. The only way we can do that now is to pull data 2 weeks at a time and compile the total manually.
For reference: If I wanted to pull a months data for 2 of our once-a-minute-logging gauges, then there would be 86,400 rows added via jQuery to a collapsible table. The page takes approx. 5 minutes to load and the browser is terribly slow during this time period.
My question is: What is the best way to pull/graph/populate data using a PHP based server (Symfony 1.4 framework) and javascript?
Should we look into upgrading our allotted processing power/RAM(we are hosted by GoDaddy)? Is there a faster way to populate collapsibles than with jquery? All of our calculatoins are done server side. Should we just pull the raw data and let the client side do the data processing? Should we split the data processing between client and server?
Here's a screen shot of the web page. Its cropped so that more client-sensitive information is not displayed:
In response to my comment.
Since you need the entire data-set only on the server side (you create your graph on the server), this means that you don't actually need to send the entire data-set to the client.
Instead send a small portion to the client. Let's say the first 200 results. Then you can go ahead and cache the rest of the result-set into a JSON file (lite database, whatever you want really). Then create an interface where the user can request for more data. Infinity scroll is nice but has its own problems. Maybe just a button that says load more data. As people have said anything more than a few hundred data points in a table at one time is crazy to have because people won't look at it anyways. Then when they hit the button to get more data, you send an AJAX request to the server with the correct parameters for what data you want.
For example the first time they click getMoreData() you want to get the next 200 data points. So you send getMoreData(start=200, length=200). Your server picks up the AJAX request and finds the correct data in the JSON file or the lite database, wherever you have cached the results. And the user can keep requesting more data (making sure you update your start parameter), and you only ever return a small subset. The user doesn't even realize that they don't have the whole data-set there in front of them because it looks like they do.
One that is complicated about this is sorting and searching. If you want to implement those then you need to make sure you go to the server side and sort/search through the cached results.
So basically you have a system where you can create the entire graph on the server side which shouldn't take long. What does take long is the loading of the entire data-set to the client side. So you break up that up into small chunks. You can even easily create pagination and the such with this method.